Skip to content

Commit

Permalink
[change] [filter] admin notices
Browse files Browse the repository at this point in the history
  • Loading branch information
osmansufy committed Nov 22, 2024
1 parent 22d192e commit c446b6b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion includes/Admin/Notices/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] );
Expand Down
6 changes: 3 additions & 3 deletions includes/REST/AdminNoticeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function register_routes() {
'args' => [
'type' => [
'description' => __( 'Type of notices', 'dokan-lite' ),
'scope' => 'string',
'context' => 'string',
'required' => false,
],
],
Expand All @@ -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 );
}
Expand Down
4 changes: 2 additions & 2 deletions src/admin/components/AdminNotice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {
type: Number,
default: 5000
},
scope: {
context: {
type: String,
default: 'all'
}
Expand 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 );
Expand Down
2 changes: 1 addition & 1 deletion src/admin/notice/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AdminNotice from "admin/components/AdminNotice.vue";
</script>

<template>
<AdminNotice interval="10000" endpoint="admin"></AdminNotice>
<AdminNotice context="global" interval="10000" endpoint="admin"></AdminNotice>

</template>

Expand Down

0 comments on commit c446b6b

Please sign in to comment.