Skip to content

Commit

Permalink
fix: global admin notice is not working
Browse files Browse the repository at this point in the history
  • Loading branch information
mralaminahamed committed Nov 25, 2024
1 parent d1e755b commit bde68e9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions includes/REST/AdminNoticeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function ( $notice ) {
);

// Filter notices by scope
$filtered_notices = self::filter_notices_by_scope( $notices, $notice_scope );
$filtered_notices = $this->filter_notices_by_scope( $notices, $notice_scope );

return rest_ensure_response( $filtered_notices );
}
Expand All @@ -99,12 +99,14 @@ public function get_promo_notices() {
/**
* Filter notices by allowed types
*
* @since DOKAN_SINCE
*
* @param array $notices
* @param string $allowed_scope
*
* @return array
*/
private static function filter_notices_by_scope( array $notices, string $allowed_scope = '' ): array {
private function filter_notices_by_scope( array $notices, string $allowed_scope = '' ): array {
if ( empty( $allowed_scope ) ) {
return $notices;
}
Expand Down
1 change: 1 addition & 0 deletions includes/Upgrade/AdminNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static function show_notice( $notices ) {
'title' => __( 'Dokan Data Update Required', 'dokan-lite' ),
'description' => __( 'We need to update your install to the latest version', 'dokan-lite' ),
'priority' => 1,
'scope' => 'global',
'actions' => [
[
'type' => 'primary',
Expand Down
3 changes: 3 additions & 0 deletions src/admin/components/AdminNotice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export default {
xhr.setRequestHeader( 'X-WP-Nonce', dokan_promo.rest.nonce );
},
} ).done( response => {
if ( ! Array.isArray( response ) ){
response = Object.entries( response ).map( ( [ id, data ] ) => ( { id, ...data } ) );
}
this.notices = response.filter( notice => notice.description || notice.title );
this.startAutoSlide();
});
Expand Down

0 comments on commit bde68e9

Please sign in to comment.