Skip to content

Commit

Permalink
= 4.2.7.4 =
Browse files Browse the repository at this point in the history
~ Format code.
  • Loading branch information
tungnxt89 committed Nov 19, 2024
1 parent 27ae168 commit eb404fc
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 74 deletions.
10 changes: 3 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"issues": "https://github.com/LearnPress/learnpress/issues"
},
"require-dev": {
"squizlabs/php_codesniffer": "3.10.2",
"wp-coding-standards/wpcs": "3.0.1"
"squizlabs/php_codesniffer": "3.11.1",
"wp-coding-standards/wpcs": "3.1.0",
"phpcompatibility/php-compatibility": "9.3.5"
},
"scripts": {
"format": "phpcbf --standard=phpcs.xml --report-summary --report-source",
Expand All @@ -29,10 +30,5 @@
"psr-4": {
"LearnPress\\": "inc/"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
1 change: 0 additions & 1 deletion inc/Databases/class-lp-section-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,3 @@ public function get_last_number_order( int $course_id = 0 ): int {
return $number_order;
}
}

8 changes: 4 additions & 4 deletions inc/Models/Courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ public static function handle_params_for_query_courses( LP_Course_Filter &$filte
// Get Columns
$fields_str = LP_Helper::sanitize_params_submitted( urldecode( $param['c_fields'] ?? '' ) );
if ( ! empty( $fields_str ) ) {
$fields = explode( ',', $fields_str );
$fields = explode( ',', $fields_str );
foreach ( $fields as $key => $field ) {
$fields[ $key ] = LP_Database::getInstance()->wpdb->prepare( '%i', $field );;
$fields[ $key ] = LP_Database::getInstance()->wpdb->prepare( '%i', $field );
}
$filter->fields = $fields;
}

// Get only columns
$fields_only_str = LP_Helper::sanitize_params_submitted( urldecode( $param['c_only_fields'] ?? '' ) );
if ( ! empty( $fields_only_str ) ) {
$fields_only = explode( ',', $fields_only_str );
$fields_only = explode( ',', $fields_only_str );
foreach ( $fields_only as $key => $field ) {
$fields_only[ $key ] = LP_Database::getInstance()->wpdb->prepare( '%i', $field );;
$fields_only[ $key ] = LP_Database::getInstance()->wpdb->prepare( '%i', $field );
}
$filter->only_fields = $fields_only;
}
Expand Down
22 changes: 11 additions & 11 deletions inc/TemplateHooks/Course/FilterCourseTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,19 @@ public function html_search( array $data = [] ): string {
);

$this->check_param_url_has_lang( $data );
$value = LP_Request::get_param( 'c_search' );
$value = isset( $data['params_url'] ) ? ( $data['params_url']['c_search'] ?? $value ) : $value;
$content = sprintf(
$value = LP_Request::get_param( 'c_search' );
$value = isset( $data['params_url'] ) ? ( $data['params_url']['c_search'] ?? $value ) : $value;
$content = sprintf(
'<input type="text" name="c_search" placeholder="%s" value="%s" class="%s" data-search-suggest="%d">',
__( 'Search Course', 'learnpress' ),
$value,
'lp-course-filter-search',
$data['search_suggestion'] ?? 1
);
$content .= '<span class="lp-loading-circle lp-loading-no-css hide"></span>';
$content = Template::instance()->nest_elements( $html_wrapper, $content );
$content = Template::instance()->nest_elements( $html_wrapper, $content );
$content .= '<div class="lp-course-filter-search-result"></div>';
$content = $this->html_item( esc_html__( 'Search', 'learnpress' ), $content );
$content = $this->html_item( esc_html__( 'Search', 'learnpress' ), $content );
} catch ( Throwable $e ) {
error_log( __METHOD__ . ': ' . $e->getMessage() );
}
Expand Down Expand Up @@ -300,7 +300,7 @@ public function html_category( array $data = [] ): string {

if ( ! empty( $category_current ) ) {
$parent_cat_id = $category_current_id;
$content .= $this->html_field_category( $category_current->term_id, $category_current->name, $data );
$content .= $this->html_field_category( $category_current->term_id, $category_current->name, $data );
}
}

Expand Down Expand Up @@ -393,7 +393,8 @@ public function html_field_category( int $category_id, string $category_name, ar
$checked = in_array( $category_id, $args['data_selected'] ?? [] ) && empty( $disabled ) ? 'checked' : '';
$input = sprintf(
'<input name="term_id" type="checkbox" value="%s" %s %s>',
esc_attr( $category_id ), esc_attr( $checked ),
esc_attr( $category_id ),
esc_attr( $checked ),
$disabled
);
$label = sprintf( '<label for="">%s</label>', wp_kses_post( $category_name ) );
Expand Down Expand Up @@ -692,11 +693,10 @@ public function handle_filter_params_before_query( LP_Course_Filter &$filter, ar

// Check has in category page.
if ( isset( $params_url['page_term_id_current'] ) &&
empty( $params_url['term_id'] ) ) {
empty( $params_url['term_id'] ) ) {
$filter->term_ids[] = $params_url['page_term_id_current'];
} // Check has in tag page.
elseif ( isset( $params_url['page_tag_id_current'] ) &&
empty( $params_url['tag_id'] ) ) {
} elseif ( isset( $params_url['page_tag_id_current'] )
&& empty( $params_url['tag_id'] ) ) {
$filter->tag_ids[] = $params_url['page_tag_id_current'];
}
}
Expand Down
11 changes: 6 additions & 5 deletions inc/TemplateHooks/Course/ListCoursesRelatedTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function layout_courses( CourseModel $course, $limit ) {

$args = [
'course_id' => $course->get_id(),
'limit' => $limit
'limit' => $limit,
];

$content = TemplateAJAX::load_content_via_ajax( $args, $callback );
Expand Down Expand Up @@ -126,7 +126,9 @@ public static function render_courses( array $settings = [] ): stdClass {
'header' => sprintf( '<h3 class="section-title">%s</h3>', __( 'You might be interested in', 'learnpress' ) ),
'courses' => $html_courses,
],
$course, $courses, $settings
$course,
$courses,
$settings
);
$content->content = Template::combine_components( $sections );

Expand All @@ -136,7 +138,7 @@ public static function render_courses( array $settings = [] ): stdClass {
/**
* Render single item course
*
* @param LP_Course $course
* @param CourseModel $course
* @param array $settings
*
* @return string
Expand All @@ -154,7 +156,6 @@ public static function render_course( CourseModel $course, array $settings = []
$img = sprintf( '<a href="%s">%s</a>', $course->get_permalink(), $singleCourseTemplate->html_image( $course ) );
$html_top = Template::instance()->nest_elements( $top_wrapper, $img );


// Section main top
$section_main_top = [
'wrapper_start' => '<div class="course-content-top">',
Expand Down Expand Up @@ -197,7 +198,7 @@ public static function render_course( CourseModel $course, array $settings = []
'wrapper_start' => sprintf( '<li class="course-item" data-id="%s">', esc_attr( $course->get_id() ) ),
'top' => $html_top,
'bottom' => $html_section_main,
'wrapper_end' => '</li>'
'wrapper_end' => '</li>',
],
$course,
$settings
Expand Down
10 changes: 5 additions & 5 deletions inc/TemplateHooks/Course/ListCoursesTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static function render_courses( array $settings = [] ): stdClass {
// HTML section courses.
ob_start();
if ( empty( $courses ) ) {
echo sprintf( '<p class="learn-press-message success">%s!</p>', __( 'No courses found', 'learnpress' ) );
Template::print_message( __( 'No courses found', 'learnpress' ), 'info' );
} else {
foreach ( $courses as $courseObj ) {
$course = CourseModel::find( $courseObj->ID, true );
Expand Down Expand Up @@ -507,13 +507,13 @@ public function html_layout_type( array $data = [] ): string {
/**
* Order by
*
* @param string $default
* @param string $default_value
*
* @return string
* @since 4.2.3.2
* @version 1.0.1
*/
public function html_order_by( string $default = 'post_date' ): string {
public function html_order_by( string $default_value = 'post_date' ): string {
$html_wrapper = [
'<div class="courses-order-by-wrapper">' => '</div>',
];
Expand All @@ -532,7 +532,7 @@ public function html_order_by( string $default = 'post_date' ): string {

$content = '<select name="order_by" class="courses-order-by">';
foreach ( $values as $k => $v ) {
$content .= '<option value="' . $k . '" ' . selected( $default, $k, false ) . '>' . $v . '</option>';
$content .= '<option value="' . $k . '" ' . selected( $default_value, $k, false ) . '>' . $v . '</option>';
}
$content .= '</select>';

Expand All @@ -544,7 +544,7 @@ public function html_search_form( array $data = [] ) {
ob_start();
?>
<form class="search-courses" method="get"
action="<?php echo esc_url_raw( learn_press_get_page_link( 'courses' ) ); ?>">
action="<?php echo esc_url_raw( learn_press_get_page_link( 'courses' ) ); ?>">
<input type="search" placeholder="<?php esc_attr_e( 'Search courses...', 'learnpress' ); ?>"
name="c_search"
value="<?php echo esc_attr( $s ); ?>">
Expand Down
10 changes: 5 additions & 5 deletions inc/cache/class-lp-courses-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class LP_Courses_Cache extends LP_Cache {
/**
* @var string Save list keys cached to clear
*/
public static $keys = 'keys';
const KEYS_QUERY_COURSES = 'keys/query_courses';
const KEYS_QUERY_COURSES_APP = 'keys/query_courses/app';
const KEYS_QUERY_TOTAL_COURSES = 'keys/query_courses/total';
const KEYS_COUNT_COURSES_FREE = 'keys/count_courses_free';
public static $keys = 'keys';
const KEYS_QUERY_COURSES = 'keys/query_courses';
const KEYS_QUERY_COURSES_APP = 'keys/query_courses/app';
const KEYS_QUERY_TOTAL_COURSES = 'keys/query_courses/total';
const KEYS_COUNT_COURSES_FREE = 'keys/count_courses_free';
const KEYS_COUNT_STUDENT_COURSES = 'keys/count_student_courses';

/**
Expand Down
2 changes: 0 additions & 2 deletions inc/class-lp-multi-language.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public static function load_plugin_text_domain( $path, $text_domain = '', $langu
$mo = WP_CONTENT_DIR . "/plugins/{$plugin_folder}/languages/{$plugin_folder}-{$locale}.mo";
load_textdomain( $text_domain, $mo );
load_plugin_textdomain( $text_domain, false, plugin_basename( $path ) . '/' . $language_folder );

}
}
}
Expand All @@ -65,6 +64,5 @@ public static function load_plugin_text_domain( $path, $text_domain = '', $langu
function learn_press_load_plugin_text_domain( $path, $text_domain = '', $language_folder = '' ) {

LP_Multi_Language::load_plugin_text_domain( $path, $text_domain, $language_folder );

}
}
1 change: 1 addition & 0 deletions inc/lp-deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ function learn_press_single_quiz_sidebar_buttons() {

// Show filters for students list
// Wait addon student list v4.0.3 update will remove it
// @deprecated 4.2.7.4
function learn_press_get_students_list_filter() {
$filter = array(
'all' => esc_html__( 'All', 'learnpress' ),
Expand Down
21 changes: 11 additions & 10 deletions inc/rest-api/v1/frontend/class-lp-rest-material-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function register_routes() {
* @since 4.2.2
*/
public function save_post_materials( WP_REST_Request $request ) {
$response = new LP_REST_Response();
$response = new LP_REST_Response();
$response->data = [];

try {
Expand Down Expand Up @@ -169,8 +169,8 @@ public function save_post_materials( WP_REST_Request $request ) {
$file_info = wp_check_filetype( $file_name );
$file_type = $file_info['ext'] ?? '';
if ( empty( $file_info['ext'] )
|| false === $this->material_check_file_extention( $file_info['ext'] )
|| ! in_array( $file_info['type'], get_allowed_mime_types() ) ) {
|| false === $this->material_check_file_extention( $file_info['ext'] )
|| ! in_array( $file_info['type'], get_allowed_mime_types() ) ) {
$error_messages .= sprintf( esc_html__( 'File %s type is invalid!', 'learnpress' ), $label );
continue;
}
Expand Down Expand Up @@ -233,7 +233,7 @@ public function save_post_materials( WP_REST_Request $request ) {
}

$success_messages .= __( 'Other files is upload successfully.', 'learnpress' );
$response->data[] = [
$response->data[] = [
'file_name' => $label,
'method' => ucfirst( $method ),
'file_id' => $insert,
Expand All @@ -248,7 +248,7 @@ public function save_post_materials( WP_REST_Request $request ) {
if ( ! empty( $success_messages ) ) {
$response->status = 'success';
if ( empty( $error_messages ) ) {
$success_messages = __( 'Files upload successfully.', 'learnpress' );;
$success_messages = __( 'Files upload successfully.', 'learnpress' );
}
$response->message .= $success_messages;
}
Expand Down Expand Up @@ -380,11 +380,12 @@ public function material_check_file_extention( $ext ) {
}

/**
* @param [type] $request [description]
*
* @return [type] [description]
* @version 1.0.0
* @since 4.2.2
* [get_material description]
* @param [type] $request [description]
* @return [type] [description]
*/
public function get_material( $request ) {
$response = new LP_REST_Response();
Expand Down Expand Up @@ -439,11 +440,12 @@ public function update_material_orders( $request ) {
}

/**
* @param [type] $request [description]
*
* @return [json] [return message]
* @version 1.0.0
* @since 4.2.2
* [delete_material delete a material when a delete request is send]
* @param [type] $request [description]
* @return [json] [return message]
*/
public function delete_material( $request ) {
$response = new LP_REST_Response();
Expand Down Expand Up @@ -494,5 +496,4 @@ public function check_user_permission( $request ): bool {

return $permission;
}

}
49 changes: 26 additions & 23 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
<?xml version="1.0"?>
<ruleset name="LearnPress ruleset">
<description>LearnPress rules for PHP_CodeSniffer</description>

<!-- <config name="installed_paths" value="vendor/wp-coding-standards/wpcs,vendor/phpcsstandards/phpcsutils"/>-->
<arg value="ps"/>
<arg name="extensions" value="php"/>

<file>./inc/</file>
<file>./templates/</file>
<file>./inc</file>
<file>./templates</file>
<file>./config</file>
<file>learnpress.php</file>

<exclude-pattern>./inc/admin/includes/class-markdown-parse.php</exclude-pattern>
<exclude-pattern>*/inc/libraries/*</exclude-pattern>
<exclude-pattern type="relative">vendor</exclude-pattern>
<exclude-pattern type="relative">node_modules</exclude-pattern>
<exclude-pattern type="relative">tests</exclude-pattern>
<exclude-pattern type="relative">assets</exclude-pattern>
<exclude-pattern>*/inc/libraries/*</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>package.json</exclude-pattern>
<exclude-pattern>assets/*</exclude-pattern>
<exclude-pattern>languages/*</exclude-pattern>
<exclude-pattern>release/*</exclude-pattern>

<rule ref="WordPress-Core">
<exclude name="WordPress.PHP.YodaConditions.NotYoda"/>
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar"/>
<exclude name="WordPress.NamingConventions.ValidHookName.UseUnderscores"/>
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/>
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.PHP.StrictComparisons.LooseComparison"/>
<exclude name="WordPress.PHP.StrictInArray.MissingTrueStrict"/>
<exclude name="WordPress.PHP.RestrictedPHPFunctions.date_date"/>
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
<exclude name="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase"/>
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
<exclude name="Universal.Arrays.DisallowShortArraySyntax" />
<exclude name="Universal.Operators.StrictComparisons.LooseNotEqual" />
<exclude name="Universal.Operators.StrictComparisons.LooseEqual" />
<exclude name="WordPress.NamingConventions.ValidHookName.UseUnderscores" />
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment" />
<exclude name="WordPress.PHP.YodaConditions.NotYoda" />
<exclude name="WordPress.PHP.StrictInArray.MissingTrueStrict" />
<exclude name="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase" />
<exclude name="WordPress.NamingConventions.ValidHookName.NotLowercase" />
<!-- When need check security query mysql use default of WordPress, need open -->
<exclude name="WordPress.DB.PreparedSQL.NotPrepared" />
<exclude name="WordPress.DB.PreparedSQL.InterpolatedNotPrepared" />
<exclude name="Generic.WhiteSpace.IncrementDecrementSpacing.SpaceAfterIncrement" />
<exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase" />
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: thimpress, tungnx89, nhamdv, nguyenlammanh, tunnhn, phonglq.foobla
Donate link:
Tags: elearning, education, course, lms, learning management system
Requires at least: 6.0
Tested up to: 6.6.2
Tested up to: 6.7
Requires PHP: 7.0
Stable tag: 4.2.7.3
License: GPLv3
Expand Down

0 comments on commit eb404fc

Please sign in to comment.