Skip to content

Commit

Permalink
= 4.2.6.5 =
Browse files Browse the repository at this point in the history
~ Tweak: FilterCourseTemplate class, add for call custom field filter
~ Tweak: list_instructors method, add option accept hide admin
  • Loading branch information
tungnxt89 committed Apr 6, 2024
1 parent d051d2b commit d3caeac
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion assets/src/js/admin/course-material.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ document.addEventListener( 'DOMContentLoaded', function() {
return;
}

if ( data && data.items.length > 0 ) {
if ( data && data.items && data.items.length > 0 ) {
const materials = data.items;
if ( ele.querySelector( '.lp-skeleton-animation' ) ) {
ele.querySelector( '.lp-skeleton-animation' ).remove();
Expand Down
1 change: 1 addition & 0 deletions assets/src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @param data
* @param functions
* @since 4.2.5.1
* @version 1.0.1
*/
const lpFetchAPI = ( url, data = {}, functions = {} ) => {
if ( 'function' === typeof functions.before ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected function selected_style_list() {

if ( ! empty( $_GET['c_level'] ) ) {
if ( $_GET['c_level'] === 'all' ) {
echo '<span class="' . $classListItem . '" data-name="c_level" data-value="' . $_GET['c_level'] . '">' . __( 'All Levels', 'learnpress' ). $icon_move . '</span>';
echo '<span class="' . $classListItem . '" data-name="c_level" data-value="' . $_GET['c_level'] . '">' . __( 'All Levels', 'learnpress' ) . $icon_move . '</span>';
} else {
echo '<span class="' . $classListItem . '" data-name="c_level" data-value="' . $_GET['c_level'] . '">' . $_GET['c_level'] . $icon_move . '</span>';
}
Expand Down
8 changes: 7 additions & 1 deletion inc/TemplateHooks/Course/FilterCourseTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Template hooks Archive Package.
*
* @since 4.2.3.2
* @version 1.0.3
* @version 1.0.4
*/

namespace LearnPress\TemplateHooks\Course;
Expand Down Expand Up @@ -31,6 +31,8 @@ public function init() {
* @param array $data
*
* @return void
* @since 4.2.3.2
* @version 1.0.1
*/
public function sections( array $data = [] ) {
wp_enqueue_script( 'lp-course-filter' );
Expand Down Expand Up @@ -72,6 +74,10 @@ public function sections( array $data = [] ) {
foreach ( $data['fields'] as $field ) {
if ( is_callable( [ $this, 'html_' . $field ] ) ) {
$sections[ $field ] = [ 'text_html' => $this->{'html_' . $field}( $data ) ];
} elseif ( isset( $field['class'] ) && isset( $field['method'] ) ) { // For custom field.
if ( is_callable( [ $field['class']::instance(), $field['method'] ] ) ) {
$sections[ $field ] = [ 'text_html' => $field['class']::instance()->{$field['method']}( $data ) ];
}
}
}

Expand Down
35 changes: 18 additions & 17 deletions inc/admin/class-lp-admin-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@ public function load_scripts_styles_on_head() {
*
* @return array
* @since 4.2.5.6
* @version 1.0.0
* @version 1.0.1
*/
public function localize_data_global(): array {
return apply_filters(
'learn-press/admin/localize-data-global',
[
'site_url' => site_url(),
'user_id' => get_current_user_id(),
'is_admin' => current_user_can( ADMIN_ROLE ),
'theme' => get_stylesheet(),
'lp_version' => LP()->version,
'lp_rest_url' => get_rest_url(),
'nonce' => wp_create_nonce( 'wp_rest' ),
'courses_url' => learn_press_get_page_link( 'courses' ),
'urlParams' => lp_archive_skeleton_get_args(),
'site_url' => site_url(),
'user_id' => get_current_user_id(),
'is_admin' => current_user_can( ADMIN_ROLE ),
'theme' => get_stylesheet(),
'lp_version' => LP()->version,
'lp_rest_url' => get_rest_url(),
'lp_rest_load_ajax' => get_rest_url( null, 'lp/v1/load_content_via_ajax/' ),
'nonce' => wp_create_nonce( 'wp_rest' ),
'courses_url' => learn_press_get_page_link( 'courses' ),
'urlParams' => lp_archive_skeleton_get_args(),
]
);
}
Expand Down Expand Up @@ -352,7 +353,7 @@ protected function _get_scripts(): array {
'',
[ 'strategy' => 'defer' ]
),
'lp-load-ajax' => new LP_Asset_Key(
'lp-load-ajax' => new LP_Asset_Key(
self::url( 'js/dist/loadAJAX' . self::$_min_assets . '.js' ),
[],
[],
Expand Down Expand Up @@ -463,12 +464,12 @@ public function get_course_data_for_editor_vue() {
global $post, $pagenow;

if ( empty( $post ) || ( get_post_type() !== LP_COURSE_CPT ) || ! in_array(
$pagenow,
array(
'post.php',
'post-new.php',
)
) ) {
$pagenow,
array(
'post.php',
'post-new.php',
)
) ) {
return [];
}

Expand Down
10 changes: 7 additions & 3 deletions inc/rest-api/v1/frontend/class-lp-rest-instructor-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ public function list_instructors( WP_REST_Request $request ): LP_REST_Response {
$response = new LP_REST_Response();

try {
$params = $request->get_params();
$args = apply_filters(
$params = $request->get_params();
$roles_query = [ LP_TEACHER_ROLE ];
if ( 'yes' === LP_Settings::get_option( 'show_admin_on_list_instructors', 'yes' ) ) {
$roles_query[] = ADMIN_ROLE;
}
$args = apply_filters(
'learnpress/instructor-list/args',
array(
'fields' => [ 'ID' ],
'number' => LP_Settings::get_option( 'instructor_per_page', 12 ),
'paged' => $params['paged'] ?? 1,
'orderby' => $params['orderby'] ?? 'display_name',
'order' => $params['order'] ?? 'asc',
'role__in' => [ LP_TEACHER_ROLE, ADMIN_ROLE ],
'role__in' => $roles_query,
)
);

Expand Down
4 changes: 2 additions & 2 deletions learnpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: http://thimpress.com/learnpress
* Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
* Author: ThimPress
* Version: 4.2.6.4
* Version: 4.2.6.5-beta.1
* Author URI: http://thimpress.com
* Requires at least: 6.3
* Requires PHP: 7.0
Expand Down Expand Up @@ -146,7 +146,7 @@ class LearnPress {
/**
* LearnPress constructor.
*/
protected function __construct() {
public function __construct() {
/*if ( isset( $_POST['action'] ) && 'heartbeat' === $_POST['action'] ) {
return;
}*/
Expand Down

0 comments on commit d3caeac

Please sign in to comment.