PluginProbe ʕ •ᴥ•ʔ
Disable Admin Notices – Hide Dashboard Notifications / 1.4.7
Disable Admin Notices – Hide Dashboard Notifications v1.4.7
1.4.7 1.4.6 1.4.5 trunk 1.0.0 1.0.2 1.0.3 1.0.5 1.0.6 1.1.1 1.1.3 1.1.4 1.2.0 1.2.2 1.2.3 1.2.4 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4
disable-admin-notices / admin / ajax / restore-notice.php
disable-admin-notices / admin / ajax Last commit date
disable-adminbar-menus.php 7 months ago hide-notice.php 7 months ago index.php 8 years ago restore-notice.php 7 months ago
restore-notice.php
50 lines
1 <?php
2 /**
3 * Restore notice
4 *
5 * Github: https://github.com/alexkovalevv
6 *
7 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
8 * @copyright (c) 2018 Webraftic Ltd
9 * @version 1.0
10 */
11
12 // Exit if accessed directly
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 function wbcr_dan_ajax_restore_notice() {
18 check_ajax_referer( WDN_Plugin::app()->getPluginName() . '_ajax_restore_notice_nonce', 'security' );
19
20 if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_network' ) ) {
21 $notice_id = WDN_Plugin::app()->request->post( 'notice_id', null, true );
22
23 if ( empty( $notice_id ) ) {
24 wp_send_json_error( [ 'error_message' => __( 'Unable to process request: notice ID is missing. Please try again.', 'disable-admin-notices' ) ] );
25 }
26
27 //Users notices
28 $current_user_id = get_current_user_id();
29 $get_hidden_notices = get_user_meta( $current_user_id, WDN_Plugin::app()->getOptionName( 'hidden_notices' ), true );
30 if ( ! empty( $get_hidden_notices ) && isset( $get_hidden_notices[ $notice_id ] ) ) {
31 unset( $get_hidden_notices[ $notice_id ] );
32 update_user_meta( $current_user_id, WDN_Plugin::app()->getOptionName( 'hidden_notices' ), $get_hidden_notices );
33 }
34
35 //All notices
36 $get_hidden_notices_all = WDN_Plugin::app()->getPopulateOption( 'hidden_notices', [] );
37 if ( ! empty( $get_hidden_notices_all ) && isset( $get_hidden_notices_all[ $notice_id ] ) ) {
38 unset( $get_hidden_notices_all[ $notice_id ] );
39 WDN_Plugin::app()->updatePopulateOption( 'hidden_notices', $get_hidden_notices_all );
40 }
41
42
43 wp_send_json_success();
44 } else {
45 wp_send_json_error( [ 'error_message' => __( 'You don\'t have permission to perform this action. Please contact your administrator.', 'disable-admin-notices' ) ] );
46 }
47 }
48
49 add_action( 'wp_ajax_wbcr-dan-restore-notice', 'wbcr_dan_ajax_restore_notice' );
50