PluginProbe
Disable Admin Notices – Hide Dashboard Notifications / 1.2.2
Disable Admin Notices – Hide Dashboard Notifications v1.2.2
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 All 30 releases
disable-admin-notices / admin / options.php
options.php
258 lines 11.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Регистрируем поля Html формы в Clearfy на странице "Подолнительно". Если этот плагин загружен, как отдельный плагин
4 * то поля будет зарегистрированы для страницы общи�
5 настроек этого плагина.
6 *
7 * Github: https://github.com/alexkovalevv
8 *
9 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
10 * @copyright (c) 2018 Webraftic Ltd
11 * @version 1.0
12 */
13
14 // Exit if accessed directly
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Регистрируем поля Html формы с настройками плагина.
21 *
22 * Эта функция используется для общей страницы настроек текущего плагина,
23 * а также для раширения настроек в плагине Clearfy.
24 *
25 * @return array Возвращает группу зарегистрируемы�
26 опций
27 * @since 1.0
28 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
29 */
30 function wbcr_dan_get_plugin_options() {
31 $options = [];
32
33 $options[] = [
34 'type' => 'html',
35 'html' => '<div class="wbcr-factory-page-group-header">' . '<strong>' . __( 'Admin notifications, Update nags', 'disable-admin-notices' ) . '</strong>' . '<p>' . __( 'Do you know the situation, when some plugin offers you to update to premium, to collect technical data and shows many annoying notices? You are close these notices every now and again but they newly appears and interfere your work with WordPress. Even worse, some plugin’s authors delete “close” button from notices and they shows in your admin panel forever.', 'disable-admin-notices' ) . '</p>' . '</div>'
36 ];
37
38 $hide_admin_notices_data = [
39 [
40 'not_hide',
41 __( "Don't hide", 'disable-admin-notices' ),
42 __( 'Do not hide notices and do not show “Hide notification forever” link for admin.', 'disable-admin-notices' )
43 ],
44 [
45 'all',
46 __( 'All notices', 'disable-admin-notices' ),
47 __( 'Hide all notices globally.', 'disable-admin-notices' ) . sprintf( __( 'Watch the <a href="%s" target="_blank">video</a> to find out how it works .', 'disable-admin-notices' ), 'https://youtu.be/_Lv5i4P3Gqs' )
48 ],
49 [
50 'only_selected',
51 __( 'Only selected', 'disable-admin-notices' ),
52 __( 'Hide selected notices only. You will see the link "Hide notification forever" in each notice. Push it and they will not bother you anymore.', 'disable-admin-notices' ) . sprintf( __( 'Watch the <a href="%s" target="_blank">video</a> to find out how it works .', 'disable-admin-notices' ), 'https://youtu.be/HazI81AsHuY' )
53 ]
54 ];
55
56 if ( ! defined( 'WCL_PLUGIN_ACTIVE' ) ) {
57 $hide_admin_notices_data[] = [
58 'compact_panel',
59 __( 'Compact panel', 'disable-admin-notices' ),
60 __( 'Collapse all notifications in one line (panel with notification counters), to see the notifications, you will need to click this panel.', 'disable-admin-notices' ) . sprintf( __( 'Watch the <a href="%s" target="_blank">video</a> to find out how it works .', 'disable-admin-notices' ), 'https://youtu.be/437u1Js2o2M' )
61 ];
62 }
63
64 $options[] = [
65 'type' => 'dropdown',
66 'name' => 'hide_admin_notices',
67 'way' => 'buttons',
68 'title' => __( 'Hide admin notices', 'disable-admin-notices' ),
69 'data' => $hide_admin_notices_data,
70 'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'green' ],
71 'hint' => __( 'Some plugins shows notifications about premium version, data collecting or promote their services. Even if you push close button (that sometimes are impossible), notices are shows again in some time. This option allows you to control notices. Hide them all or each individually. Some plugins shows notifications about premium version, data collecting or promote their services. Even if you push close button (that sometimes are impossible), notices are shows again in some time. This option allows you to control notices. Hide them all or each individually.', 'disable-admin-notices' ),
72 'default' => 'only_selected',
73 'cssClass' => ! ( WDN_Plugin::app()->premium->is_activate() && WDN_Plugin::app()->premium->is_install_package() ) ? [ 'wdanpro-radio-premium-label' ] : [],
74 'events' => [
75 'all' => [
76 'show' => '.factory-control-hide_admin_notices_user_roles',
77 'hide' => '.factory-control-reset_notices_button'
78 ],
79 'only_selected' => [
80 'hide' => '.factory-control-hide_admin_notices_user_roles',
81 'show' => '.factory-control-reset_notices_button'
82 ],
83 'not_hide' => [
84 'hide' => '.factory-control-hide_admin_notices_user_roles, .factory-control-reset_notices_button'
85 ]
86 ]
87 ];
88
89 if ( ! defined( 'WCL_PLUGIN_ACTIVE' ) ) {
90 $options[] = [
91 'type' => 'checkbox',
92 'way' => 'buttons',
93 'name' => 'disable_updates_nags_for_plugins',
94 'title' => __( 'Disable plugins updates nags', 'disable-admin-notices' ),
95 'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
96 'hint' => __( 'Disable plugins updates nags', 'disable-admin-notices' ),
97 'cssClass' => ! ( WDN_Plugin::app()->premium->is_activate() && WDN_Plugin::app()->premium->is_install_package() ) ? [ 'factory-checkbox-disabled wdanpro-checkbox-premium-label' ] : [],
98 'default' => false
99 ];
100
101 $options[] = [
102 'type' => 'checkbox',
103 'way' => 'buttons',
104 'name' => 'disable_updates_nags_for_core',
105 'title' => __( 'Disable core updates nags', 'disable-admin-notices' ),
106 'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ],
107 'hint' => __( 'Disable core updates nags', 'disable-admin-notices' ),
108 'cssClass' => ! ( WDN_Plugin::app()->premium->is_activate() && WDN_Plugin::app()->premium->is_install_package() ) ? [ 'factory-checkbox-disabled wdanpro-checkbox-premium-label' ] : [],
109 'default' => false
110 ];
111 }
112
113 /*$options[] = array(
114 'type' => 'dropdown',
115 'name' => 'hide_admin_notices_for',
116 'way' => 'buttons',
117 'title' => __('Hide admin notices only for', 'disable-admin-notices'),
118 'data' => array(
119 array(
120 'user',
121 __('Current user', 'disable-admin-notices')
122 ),
123 array(
124 'all_users',
125 __('All users', 'disable-admin-notices')
126 )
127 ),
128 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'green'),
129 'hint' => __('Choose who to hide notifications for?', 'disable-admin-notices'),
130 'default' => 'user',
131 'events' => array(
132 'all' => array(
133 'show' => '.factory-control-hide_admin_notices_user_roles',
134 'hide' => '.factory-control-reset_notices_button'
135 ),
136 'only_selected' => array(
137 'hide' => '.factory-control-hide_admin_notices_user_roles',
138 'show' => '.factory-control-reset_notices_button'
139 ),
140 'not_hide' => array(
141 'hide' => '.factory-control-hide_admin_notices_user_roles, .factory-control-reset_notices_button'
142 )
143 )
144 );*/
145
146 $options[] = [
147 'type' => 'checkbox',
148 'way' => 'buttons',
149 'name' => 'show_notices_in_adminbar',
150 'title' => __( 'Enable hidden notices in adminbar', 'disable-admin-notices' ),
151 'layout' => [ 'hint-type' => 'icon', 'hint-icon-color' => 'green' ],
152 'hint' => __( 'By default, the plugin hides all notices, which you specified. If you enable this option, the plugin will collect all hidden notices and show them into the top admin toolbar. It will not disturb you but will allow to look notices at your convenience.', 'disable-admin-notices' ),
153 'default' => false
154 ];
155
156 $options[] = [
157 'type' => 'html',
158 'html' => 'wbcr_dan_reset_notices_button'
159 ];
160
161 return $options;
162 }
163
164 /**
165 * Расширяем опции html формы страницы "Дополнительно" в плагине Clearfy
166 *
167 * Это необ�
168 одимо для того, чтобы не создавать отдельную страницу в плагине Clearfy, \
169 * с настройками этого плагина, потому что это у�
170 удшает юзабилити.
171 *
172 * @param array $form Массив с группой настроек, страницы "Дополнительно" в плагине Clearfy
173 * @param Wbcr_FactoryPages431_ImpressiveThemplate $page Экземпляр страницы
174 *
175 * @return mixed Отсортированный массив с группой опций
176 */
177 function wbcr_dan_additionally_form_options( $form, $page ) {
178 if ( empty( $form ) ) {
179 return $form;
180 }
181
182 $options = wbcr_dan_get_plugin_options();
183
184 foreach ( array_reverse( $options ) as $option ) {
185 array_unshift( $form[0]['items'], $option );
186 }
187
188 return $form;
189 }
190
191 add_filter( 'wbcr_clr_additionally_form_options', 'wbcr_dan_additionally_form_options', 10, 2 );
192
193 /**
194 * Реализует кнопку сброса скрыты�
195 уведомлений.
196 *
197 * Вы можете выбрать для какой группы пользователей сбросить уведомления.
198 * Эта модикация является не стандартной, поэтому мы не можете реалировать ее
199 * через фреймворк.
200 *
201 * @param @param $html_builder Wbcr_FactoryForms429_Html
202 *
203 * @since 1.0
204 *
205 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
206 */
207 function wbcr_dan_reset_notices_button( $html_builder ) {
208 global $wpdb;
209
210 $form_name = $html_builder->getFormName();
211 $reseted = false;
212
213 if ( isset( $_POST['wbcr_dan_reset_action'] ) ) {
214 check_admin_referer( $form_name, 'wbcr_dan_reset_nonce' );
215 $reset_for_users = WDN_Plugin::app()->request->post( 'wbcr_dan_reset_for_users', 'current_user', true );
216
217 if ( $reset_for_users == 'current_user' ) {
218 delete_user_meta( get_current_user_id(), WDN_Plugin::app()->getOptionName( 'hidden_notices' ) );
219 } else {
220 $meta_key = sanitize_key( WDN_Plugin::app()->getOptionName( 'hidden_notices' ) );
221 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$meta_key}'" );
222 }
223
224 $reseted = true;
225 }
226
227 ?>
228 <div class="form-group form-group-checkbox factory-control-reset_notices_button">
229 <label for="wbcr_clearfy_reset_notices_button" class="col-sm-4 control-label">
230 <?= __( 'Reset hidden notices for', 'disable-admin-notices' ); ?>
231 <span class="factory-hint-icon factory-hint-icon-grey" data-toggle="factory-tooltip" data-placement="right" title="" data-original-title="<?php _e( 'Push reset hidden notices if you need to show hidden notices again.', 'disable-admin-notices' ) ?>">
232 <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt="">
233 </span>
234 </label>
235 <div class="control-group col-sm-8">
236 <div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group">
237 <form method="post">
238 <?php wp_nonce_field( $form_name, 'wbcr_dan_reset_nonce' ); ?>
239 <p>
240 <input type="radio" name="wbcr_dan_reset_for_users" value="current_user" checked/> <?= __( 'current user', 'disable-admin-notices' ); ?>
241 </p>
242 <p>
243 <input type="radio" name="wbcr_dan_reset_for_users" value="all"/> <?= __( 'all users', 'disable-admin-notices' ); ?>
244 </p>
245 <p>
246 <input type="submit" name="wbcr_dan_reset_action" value="<?= __( 'Reset notices', 'disable-admin-notices' ); ?>" class="button button-default"/>
247 </p>
248 <?php if ( $reseted ): ?>
249 <div style="color:green;margin-top:5px;"><?php _e( 'Hidden notices are successfully reset, now you can see them again!', 'disable-admin-notices' ) ?></div>
250 <?php endif; ?>
251 </form>
252 </div>
253 </div>
254 </div>
255 <?php
256 }
257
258