PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 2.33
Strong Testimonials v2.33
3.3.3 3.3.2 3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / admin / admin-notices.php
strong-testimonials / admin Last commit date
about 7 years ago css 7 years ago img 8 years ago js 7 years ago menu 8 years ago partials 7 years ago scss 7 years ago settings 7 years ago admin-notices.php 8 years ago admin.php 7 years ago class-strong-testimonials-admin-category-list.php 8 years ago class-strong-testimonials-admin-list.php 7 years ago class-strong-testimonials-admin-scripts.php 8 years ago class-strong-testimonials-defaults.php 7 years ago class-strong-testimonials-help.php 8 years ago class-strong-testimonials-list-table.php 7 years ago class-strong-testimonials-page-shortcodes.php 7 years ago class-strong-testimonials-post-editor.php 7 years ago class-strong-testimonials-updater.php 7 years ago class-strong-views-list-table.php 8 years ago class-walker-strong-category-checklist.php 7 years ago class-walker-strong-form-category-checklist.php 7 years ago compat.php 8 years ago custom-fields-ajax.php 8 years ago custom-fields.php 7 years ago form-preview.php 8 years ago view-list-order.php 8 years ago views-ajax.php 7 years ago views-validate.php 7 years ago views.php 7 years ago
admin-notices.php
178 lines
1 <?php
2 /**
3 * Admin notices
4 */
5
6
7 /**
8 * Dismiss persistent notices.
9 *
10 * @since 2.29.0
11 */
12 function wpmtst_dismiss_notice_ajax() {
13 if ( ! isset( $_POST['key'] ) || ! $_POST['key'] ) {
14 echo 0;
15 wp_die();
16 }
17
18 check_ajax_referer( 'wpmtst-admin', 'nonce' );
19 wpmtst_delete_admin_notice( $_POST['key'] );
20 wp_die();
21 }
22
23 add_action( 'wp_ajax_wpmtst_dismiss_notice', 'wpmtst_dismiss_notice_ajax' );
24
25 /**
26 * Print admin notices.
27 *
28 * @since 2.24.0
29 */
30 function wpmtst_admin_notices() {
31 $notices = get_option( 'wpmtst_admin_notices' );
32 if ( ! $notices ) {
33 return;
34 }
35
36 foreach ( $notices as $key => $notice ) {
37 $message = apply_filters( 'wpmtst_admin_notice', '', $key );
38 if ( $message ) {
39 echo $message;
40 }
41 if ( ! $notice['persist'] ) {
42 wpmtst_delete_admin_notice( $key );
43 }
44 }
45 }
46 add_action( 'admin_notices', 'wpmtst_admin_notices' );
47
48
49 /**
50 * Return specific admin notice text.
51 *
52 * @since 2.28.5
53 * @param string $html
54 * @param $key
55 *
56 * @return string
57 */
58 function wpmtst_admin_notice_text( $html = '', $key, $persist = false ) {
59
60 switch ( $key ) {
61 case 'defaults-restored' :
62 ob_start();
63 ?>
64 <div class="wpmtst notice notice-success is-dismissible" data-key="<?php esc_attr_e( $key ); ?>">
65 <p>
66 <?php _e( 'Defaults restored.', 'strong-testimonials' ); ?>
67 </p>
68 </div>
69 <?php
70 $html = ob_get_clean();
71 break;
72
73 case 'fields-saved' :
74 ob_start();
75 ?>
76 <div class="wpmtst notice notice-success is-dismissible" data-key="<?php esc_attr_e( $key ); ?>">
77 <p>
78 <?php _e( 'Fields saved.', 'strong-testimonials' ); ?>
79 </p>
80 </div>
81 <?php
82 $html = ob_get_clean();
83 break;
84
85 case 'changes-cancelled' :
86 ob_start();
87 ?>
88 <div class="wpmtst notice notice-success is-dismissible" data-key="<?php esc_attr_e( $key ); ?>">
89 <p>
90 <?php _e( 'Changes cancelled.', 'strong-testimonials' ); ?>
91 </p>
92 </div>
93 <?php
94 $html = ob_get_clean();
95 break;
96
97 case 'captcha-options-changed' :
98 $tags = array( 'a' => array( 'class' => array(), 'href' => array() ) );
99 //$settings_url = admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' );
100 $settings_url = admin_url( '?action=captcha-options-changed' );
101 $settings_link = sprintf( wp_kses( __( 'Please check your <a href="%s">%s</a>.', 'strong-testimonials' ), $tags ), esc_url( $settings_url ), __( 'settings', 'strong-testimonials' ) );
102
103 ob_start();
104 ?>
105 <div class="wpmtst notice notice-warning is-dismissible" data-key="<?php esc_attr_e( $key ); ?>">
106 <p>
107 <?php _e( 'Captcha options have changed in <strong>Strong Testimonials</strong>.', 'strong-testimonials' ); ?>
108 <?php echo $settings_link; ?>
109 </p>
110 </div>
111 <?php
112 $html = ob_get_clean();
113 break;
114
115 default :
116 // nothing
117 }
118
119 return $html;
120 }
121 add_filter( 'wpmtst_admin_notice', 'wpmtst_admin_notice_text', 10, 2 );
122
123
124 /**
125 * Add admin notice to queue.
126 *
127 * @since 2.24.0
128 *
129 * @param $key
130 * @param $persist
131 */
132 function wpmtst_add_admin_notice( $key, $persist = false ) {
133 $notices = get_option( 'wpmtst_admin_notices', array() );
134 $notices[ $key ] = array( 'persist' => $persist );
135 update_option( 'wpmtst_admin_notices', $notices );
136 }
137
138
139 /**
140 * Delete admin notice from queue.
141 *
142 * @since 2.24.0
143 *
144 * @param $key
145 */
146 function wpmtst_delete_admin_notice( $key ) {
147 $notices = get_option( 'wpmtst_admin_notices', array() );
148 unset( $notices[ $key ] );
149 update_option( 'wpmtst_admin_notices', $notices );
150 }
151
152
153 /**
154 * Automatically dismiss specific notices when settings are saved.
155 *
156 * @since 2.29.0
157 * @param $option
158 * @param $old_value
159 * @param $value
160 */
161 function wpmtst_auto_dismiss_notices( $option, $old_value, $value ) {
162 if ( ! function_exists( 'get_current_screen' ) ) {
163 return;
164 }
165
166 $screen = get_current_screen();
167 if ( $screen && 'options' == $screen->base ) {
168 if ( 'wpmtst_form_options' == $option ) {
169 $notices = get_option( 'wpmtst_admin_notices', array() );
170 if ( isset( $notices['captcha-options-changed'] ) ) {
171 unset( $notices['captcha-options-changed'] );
172 update_option( 'wpmtst_admin_notices', $notices );
173 }
174 }
175 }
176 }
177 add_action( 'update_option', 'wpmtst_auto_dismiss_notices', 10, 3 );
178