From c446b6b2f87d069fdaa521cc12f625825ef9e2ed Mon Sep 17 00:00:00 2001 From: osman sufy Date: Fri, 22 Nov 2024 12:28:35 +0600 Subject: [PATCH] [change] [filter] admin notices --- includes/Admin/Notices/Helper.php | 2 +- includes/REST/AdminNoticeController.php | 6 +++--- src/admin/components/AdminNotice.vue | 4 ++-- src/admin/notice/App.vue | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/Admin/Notices/Helper.php b/includes/Admin/Notices/Helper.php index 63dd2ca234..07354af4bd 100644 --- a/includes/Admin/Notices/Helper.php +++ b/includes/Admin/Notices/Helper.php @@ -30,7 +30,7 @@ public static function dokan_get_admin_notices( $notice_scope = 'all' ) { if ( empty( $notices ) ) { return $notices; } - $allowed_types = self::$scope_type_mapping[ $notice_scope ] ?? []; + $allowed_types = apply_filters( 'dokan_admin_notices_scope', self::$scope_type_mapping[ $notice_scope ] ) ?? []; $notices = self::filter_notices_by_type( $notices, $allowed_types ); uasort( $notices, [ self::class, 'dokan_sort_notices_by_priority' ] ); diff --git a/includes/REST/AdminNoticeController.php b/includes/REST/AdminNoticeController.php index a5c94f503e..5308591480 100644 --- a/includes/REST/AdminNoticeController.php +++ b/includes/REST/AdminNoticeController.php @@ -40,7 +40,7 @@ public function register_routes() { 'args' => [ 'type' => [ 'description' => __( 'Type of notices', 'dokan-lite' ), - 'scope' => 'string', + 'context' => 'string', 'required' => false, ], ], @@ -66,8 +66,8 @@ public function register_routes() { * @return WP_REST_Response */ public function dokan_get_admin_notices( WP_REST_Request $request ) { - $notices = Helper::dokan_get_admin_notices(); - $notice_scope = $request->get_param( 'scope' ); + $notice_scope = $request->get_param( 'context' ); + $notices = Helper::dokan_get_admin_notices( $notice_scope ); return rest_ensure_response( $notices ); } diff --git a/src/admin/components/AdminNotice.vue b/src/admin/components/AdminNotice.vue index 37ba63858d..d522005348 100644 --- a/src/admin/components/AdminNotice.vue +++ b/src/admin/components/AdminNotice.vue @@ -62,7 +62,7 @@ export default { type: Number, default: 5000 }, - scope: { + context: { type: String, default: 'all' } @@ -87,7 +87,7 @@ export default { methods: { fetch() { $.ajax( { - url: `${dokan_promo.rest.root}${dokan_promo.rest.version}/admin/notices/${this.endpoint}?scope=${this.scope}`, + url: `${dokan_promo.rest.root}${dokan_promo.rest.version}/admin/notices/${this.endpoint}?context=${this.context}`, method: 'get', beforeSend: function ( xhr ) { xhr.setRequestHeader( 'X-WP-Nonce', dokan_promo.rest.nonce ); diff --git a/src/admin/notice/App.vue b/src/admin/notice/App.vue index de247084e5..4201c441de 100644 --- a/src/admin/notice/App.vue +++ b/src/admin/notice/App.vue @@ -4,7 +4,7 @@ import AdminNotice from "admin/components/AdminNotice.vue";