diff --git a/composer.json b/composer.json index 82db627d3..e6ade859d 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -29,10 +30,5 @@ "psr-4": { "LearnPress\\": "inc/" } - }, - "config": { - "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true - } } } diff --git a/inc/Databases/class-lp-section-db.php b/inc/Databases/class-lp-section-db.php index 6d3e22c28..6e184bea9 100644 --- a/inc/Databases/class-lp-section-db.php +++ b/inc/Databases/class-lp-section-db.php @@ -395,4 +395,3 @@ public function get_last_number_order( int $course_id = 0 ): int { return $number_order; } } - diff --git a/inc/Models/Courses.php b/inc/Models/Courses.php index 60af590ba..5e32c81e1 100644 --- a/inc/Models/Courses.php +++ b/inc/Models/Courses.php @@ -78,9 +78,9 @@ 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; } @@ -88,9 +88,9 @@ public static function handle_params_for_query_courses( LP_Course_Filter &$filte // 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; } diff --git a/inc/TemplateHooks/Course/FilterCourseTemplate.php b/inc/TemplateHooks/Course/FilterCourseTemplate.php index df8893a37..945965e1c 100644 --- a/inc/TemplateHooks/Course/FilterCourseTemplate.php +++ b/inc/TemplateHooks/Course/FilterCourseTemplate.php @@ -162,9 +162,9 @@ 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( '', __( 'Search Course', 'learnpress' ), $value, @@ -172,9 +172,9 @@ public function html_search( array $data = [] ): string { $data['search_suggestion'] ?? 1 ); $content .= ''; - $content = Template::instance()->nest_elements( $html_wrapper, $content ); + $content = Template::instance()->nest_elements( $html_wrapper, $content ); $content .= '
'; - $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() ); } @@ -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 ); } } @@ -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( '', - esc_attr( $category_id ), esc_attr( $checked ), + esc_attr( $category_id ), + esc_attr( $checked ), $disabled ); $label = sprintf( '', wp_kses_post( $category_name ) ); @@ -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']; } } diff --git a/inc/TemplateHooks/Course/ListCoursesRelatedTemplate.php b/inc/TemplateHooks/Course/ListCoursesRelatedTemplate.php index f81440bff..b5934932d 100644 --- a/inc/TemplateHooks/Course/ListCoursesRelatedTemplate.php +++ b/inc/TemplateHooks/Course/ListCoursesRelatedTemplate.php @@ -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 ); @@ -126,7 +126,9 @@ public static function render_courses( array $settings = [] ): stdClass { 'header' => sprintf( '

%s

', __( 'You might be interested in', 'learnpress' ) ), 'courses' => $html_courses, ], - $course, $courses, $settings + $course, + $courses, + $settings ); $content->content = Template::combine_components( $sections ); @@ -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 @@ -154,7 +156,6 @@ public static function render_course( CourseModel $course, array $settings = [] $img = sprintf( '%s', $course->get_permalink(), $singleCourseTemplate->html_image( $course ) ); $html_top = Template::instance()->nest_elements( $top_wrapper, $img ); - // Section main top $section_main_top = [ 'wrapper_start' => '
', @@ -197,7 +198,7 @@ public static function render_course( CourseModel $course, array $settings = [] 'wrapper_start' => sprintf( '
  • ', esc_attr( $course->get_id() ) ), 'top' => $html_top, 'bottom' => $html_section_main, - 'wrapper_end' => '
  • ' + 'wrapper_end' => '', ], $course, $settings diff --git a/inc/TemplateHooks/Course/ListCoursesTemplate.php b/inc/TemplateHooks/Course/ListCoursesTemplate.php index 9e7997cd0..1a8acd1e4 100644 --- a/inc/TemplateHooks/Course/ListCoursesTemplate.php +++ b/inc/TemplateHooks/Course/ListCoursesTemplate.php @@ -103,7 +103,7 @@ public static function render_courses( array $settings = [] ): stdClass { // HTML section courses. ob_start(); if ( empty( $courses ) ) { - echo sprintf( '

    %s!

    ', __( 'No courses found', 'learnpress' ) ); + Template::print_message( __( 'No courses found', 'learnpress' ), 'info' ); } else { foreach ( $courses as $courseObj ) { $course = CourseModel::find( $courseObj->ID, true ); @@ -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 = [ '
    ' => '
    ', ]; @@ -532,7 +532,7 @@ public function html_order_by( string $default = 'post_date' ): string { $content = ''; @@ -544,7 +544,7 @@ public function html_search_form( array $data = [] ) { ob_start(); ?>
    + action=""> diff --git a/inc/cache/class-lp-courses-cache.php b/inc/cache/class-lp-courses-cache.php index a6e50f03b..7f7ca73c0 100644 --- a/inc/cache/class-lp-courses-cache.php +++ b/inc/cache/class-lp-courses-cache.php @@ -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'; /** diff --git a/inc/class-lp-multi-language.php b/inc/class-lp-multi-language.php index 22e730883..c56a28558 100644 --- a/inc/class-lp-multi-language.php +++ b/inc/class-lp-multi-language.php @@ -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 ); - } } } @@ -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 ); - } } diff --git a/inc/lp-deprecated.php b/inc/lp-deprecated.php index c274eb594..f2bf70362 100644 --- a/inc/lp-deprecated.php +++ b/inc/lp-deprecated.php @@ -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' ), diff --git a/inc/rest-api/v1/frontend/class-lp-rest-material-controller.php b/inc/rest-api/v1/frontend/class-lp-rest-material-controller.php index a4cb4e493..e78215970 100644 --- a/inc/rest-api/v1/frontend/class-lp-rest-material-controller.php +++ b/inc/rest-api/v1/frontend/class-lp-rest-material-controller.php @@ -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 { @@ -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; } @@ -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, @@ -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; } @@ -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(); @@ -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(); @@ -494,5 +496,4 @@ public function check_user_permission( $request ): bool { return $permission; } - } diff --git a/phpcs.xml b/phpcs.xml index 309a3cc83..2ef68bc68 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,35 +1,38 @@ LearnPress rules for PHP_CodeSniffer - + - ./inc/ - ./templates/ + ./inc + ./templates + ./config learnpress.php - ./inc/admin/includes/class-markdown-parse.php - */inc/libraries/* - vendor - node_modules - tests - assets + */inc/libraries/* + vendor/* + node_modules/* + tests/* + package.json + assets/* + languages/* + release/* - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/readme.txt b/readme.txt index 386037e9a..19ed1187e 100644 --- a/readme.txt +++ b/readme.txt @@ -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