__('Invalid nonce', 'acadlix-addon-for-elementor'), 'error_code' => 'invalid_nonce' ], 403); wp_die(); } $aelms_categories = isset($_POST['categories']) ? json_decode(wp_unslash($_POST['categories']), true) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized : []; $aelms_query_config = isset($_POST['query']) ? json_decode(wp_unslash($_POST['query']), true) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized : []; $aelms_display_config = isset($_POST['display']) ? json_decode(wp_unslash($_POST['display']), true) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized : []; $acadlix_settings = isset($_POST['settings']) ? json_decode(wp_unslash($_POST['settings']), true) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized : []; $aelms_query_config['search'] = isset($_POST['search']) ? sanitize_text_field(wp_unslash($_POST['search'])) : ''; $aelms_paged = isset($_POST['page']) ? max(1, intval($_POST['page'])) : 1; $coursesPerPage = isset($aelms_query_config['posts_per_page']) ? intval($aelms_query_config['posts_per_page']) : 6; if(!empty($aelms_categories)) { $aelms_query_config['include_categories'] = array_map('intval', $aelms_categories); } $aelms_the_query = acadlix_get_courses_query([ 'paged' => $aelms_paged, ] + $aelms_query_config); // If requested page is out of range for the filtered result, clamp to last valid page. $aelms_max_pages = max(1, (int) ($aelms_the_query['course_count'] > 0 ? ceil($aelms_the_query['course_count'] / $coursesPerPage) : 1)); if ($aelms_paged > $aelms_max_pages) { $aelms_paged = $aelms_max_pages; $aelms_the_query = acadlix_get_courses_query([ 'paged' => $aelms_paged, ] + $aelms_query_config); } ob_start(); include AELMS_PLUGIN_DIR . 'templates/list/course-list.php'; $html = ob_get_clean(); wp_send_json_success(array('html' => $html)); wp_die(); } }