Skip to content

Commit

Permalink
= 4.2.2.4 =
Browse files Browse the repository at this point in the history
~ Fixed: send X-WP-Nonce when fetch apiAdminNotice.
~ Modified: call template API admin_notices.
  • Loading branch information
tungnxt89 committed Mar 24, 2023
1 parent 6ca8f37 commit 3fc155c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions assets/src/apps/js/admin/admin-notices.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const callAdminNotices = ( set = '' ) => {
const params = tab ? `?tab=${ tab }` : `?${ set }`;
fetch( adminAPI.apiAdminNotice + params, {
method: 'GET',
headers: {
'X-WP-Nonce': lpGlobalSettings.nonce,
},
} ).then( ( res ) =>
res.json()
).then( ( res ) => {
Expand Down
11 changes: 9 additions & 2 deletions inc/rest-api/v1/admin/class-lp-admin-rest-tools-controller.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use LearnPress\Helpers\Template;

/**
* Class LP_REST_Admin_Tools_Controller
*
Expand Down Expand Up @@ -264,14 +266,19 @@ public function admin_notices( WP_REST_Request $request ) {
]
);

ob_start();
foreach ( $rules as $template_data ) {
$content .= learn_press_admin_view( $template_data['template'] ?? '', [ 'data' => $template_data ], true, true );
Template::instance()->get_admin_template(
$template_data['template'] ?? '',
[ 'data' => $template_data ]
);
}
}

$response->status = 'success';
$response->data->content = $content;
$response->data->content = ob_get_clean();
} catch ( Exception $e ) {
ob_end_clean();
$response->message = $e->getMessage();
}

Expand Down
2 changes: 1 addition & 1 deletion 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.2.3
* Version: 4.2.2.4-beta-1
* Author URI: http://thimpress.com
* Requires at least: 5.8
* Tested up to: 6.1.1
Expand Down

0 comments on commit 3fc155c

Please sign in to comment.