class-activation.php
2 years ago
class-admin-columns-manager.php
2 years ago
class-admin-menu-organizer.php
2 years ago
class-auto-publish-posts-with-missed-schedule.php
2 years ago
class-avif-upload.php
2 years ago
class-change-login-url.php
2 years ago
class-cleanup-admin-bar.php
2 years ago
class-code-snippets-manager.php
2 years ago
class-common-methods.php
2 years ago
class-content-duplication.php
2 years ago
class-content-order.php
2 years ago
class-custom-admin-footer-text.php
2 years ago
class-custom-body-class.php
2 years ago
class-custom-content-types.php
2 years ago
class-custom-css.php
2 years ago
class-custom-nav-menu-items-in-new-tab.php
2 years ago
class-deactivation.php
2 years ago
class-disable-comments.php
2 years ago
class-disable-dashboard-widgets.php
2 years ago
class-disable-feeds.php
2 years ago
class-disable-gutenberg.php
2 years ago
class-disable-rest-api.php
2 years ago
class-disable-smaller-components.php
2 years ago
class-disable-updates.php
2 years ago
class-disable-xml-rpc.php
2 years ago
class-display-system-summary.php
2 years ago
class-email-address-obfuscator.php
2 years ago
class-email-delivery.php
2 years ago
class-enhance-list-tables.php
2 years ago
class-external-permalinks.php
2 years ago
class-heartbeat-control.php
2 years ago
class-hide-admin-bar.php
2 years ago
class-hide-admin-notices.php
2 years ago
class-image-sizes-panel.php
2 years ago
class-image-upload-control.php
2 years ago
class-insert-head-body-footer-code.php
2 years ago
class-last-login-column.php
2 years ago
class-limit-login-attempts.php
2 years ago
class-login-id-type.php
2 years ago
class-login-logout-menu.php
2 years ago
class-maintenance-mode.php
2 years ago
class-manage-ads-appads-txt.php
2 years ago
class-manage-robots-txt.php
2 years ago
class-media-replacement.php
2 years ago
class-multiple-user-roles.php
2 years ago
class-obfuscate-author-slugs.php
2 years ago
class-open-external-links-in-new-tab.php
2 years ago
class-password-protection.php
2 years ago
class-redirect-after-login.php
2 years ago
class-redirect-after-logout.php
2 years ago
class-redirect-fourofour.php
2 years ago
class-revisions-control.php
2 years ago
class-search-engines-visibility.php
2 years ago
class-settings-fields-render.php
2 years ago
class-settings-sanitization.php
2 years ago
class-settings-sections-fields.php
2 years ago
class-show-custom-taxonomy-filters.php
2 years ago
class-site-identity-on-login-page.php
2 years ago
class-svg-upload.php
2 years ago
class-various-admin-ui-enhancements.php
2 years ago
class-view-admin-as-role.php
2 years ago
class-wider-admin-menu.php
2 years ago
class-hide-admin-notices.php
232 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ASENHA\Classes; |
| 4 | |
| 5 | use WP_Admin_Bar; |
| 6 | |
| 7 | /** |
| 8 | * Class for Hide Admin Notices module |
| 9 | * |
| 10 | * @since 6.9.5 |
| 11 | */ |
| 12 | class Hide_Admin_Notices { |
| 13 | |
| 14 | /** |
| 15 | * Wrapper for admin notices being output on admin screens |
| 16 | * |
| 17 | * @since 1.2.0 |
| 18 | */ |
| 19 | public function admin_notices_wrapper() { |
| 20 | $options = get_option( ASENHA_SLUG_U, array() ); |
| 21 | $hide_for_nonadmins = isset( $options['hide_admin_notices_for_nonadmins'] ) ? $options['hide_admin_notices_for_nonadmins'] : false; |
| 22 | |
| 23 | $minimum_capability = 'manage_options'; |
| 24 | |
| 25 | if ( function_exists( 'bwasenha_fs' ) ) { |
| 26 | if ( $hide_for_nonadmins && bwasenha_fs()->can_use_premium_code__premium_only() ) { |
| 27 | $minimum_capability = 'read'; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | if ( current_user_can( $minimum_capability ) ) { |
| 32 | echo '<div class="asenha-admin-notices-drawer" style="display:none;"><h2>' . __( 'Admin Notices', 'admin-site-enhancements' ) . '</h2></div>'; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Admin bar menu item for the hidden admin notices |
| 38 | * |
| 39 | * @link https://developer.wordpress.org/reference/classes/wp_admin_bar/add_menu/ |
| 40 | * @link https://developer.wordpress.org/reference/classes/wp_admin_bar/add_node/ |
| 41 | * @since 1.2.0 |
| 42 | */ |
| 43 | public function admin_notices_menu( WP_Admin_Bar $wp_admin_bar ) { |
| 44 | |
| 45 | // Only show Notices menu in wp-admin but when not in Customizer preview |
| 46 | if ( is_admin() && ! is_customize_preview() ) { |
| 47 | $options = get_option( ASENHA_SLUG_U, array() ); |
| 48 | $hide_for_nonadmins = isset( $options['hide_admin_notices_for_nonadmins'] ) ? $options['hide_admin_notices_for_nonadmins'] : false; |
| 49 | |
| 50 | $minimum_capability = 'manage_options'; |
| 51 | |
| 52 | if ( function_exists( 'bwasenha_fs' ) ) { |
| 53 | if ( $hide_for_nonadmins && bwasenha_fs()->can_use_premium_code__premium_only() ) { |
| 54 | $minimum_capability = 'read'; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | if ( current_user_can( $minimum_capability ) ) { |
| 59 | |
| 60 | $wp_admin_bar->add_menu( array( |
| 61 | 'id' => 'asenha-hide-admin-notices', |
| 62 | 'parent' => 'top-secondary', |
| 63 | 'group' => null, |
| 64 | 'title' => __( 'Notices', 'admin-site-enhancements' ) . '<span class="asenha-admin-notices-counter" style="opacity:0;">0</span>', |
| 65 | // 'href' => '', |
| 66 | 'meta' => array( |
| 67 | 'class' => 'asenha-admin-notices-menu hidden', |
| 68 | 'title' => __( 'Click to view hidden admin notices', 'admin-site-enhancements' ), |
| 69 | ), |
| 70 | ) ); |
| 71 | |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Inline CSS for the hiding notices on page load in wp admin pages |
| 79 | * |
| 80 | * @since 1.2.0 |
| 81 | */ |
| 82 | public function admin_notices_menu_inline_css() { |
| 83 | |
| 84 | $options = get_option( ASENHA_SLUG_U, array() ); |
| 85 | $hide_for_nonadmins = isset( $options['hide_admin_notices_for_nonadmins'] ) ? $options['hide_admin_notices_for_nonadmins'] : false; |
| 86 | |
| 87 | $minimum_capability = 'manage_options'; |
| 88 | |
| 89 | if ( function_exists( 'bwasenha_fs' ) ) { |
| 90 | if ( $hide_for_nonadmins && bwasenha_fs()->can_use_premium_code__premium_only() ) { |
| 91 | $minimum_capability = 'read'; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | if ( is_admin() && ! is_customize_preview() && current_user_can( $minimum_capability ) ) { |
| 96 | |
| 97 | // Below we pre-emptively hide notices to avoid having them shown briefly before being moved into the notices panel via JS |
| 98 | ?> |
| 99 | <style type="text/css"> |
| 100 | #wpadminbar .asenha-admin-notices-menu .ab-empty-item { |
| 101 | cursor: pointer; |
| 102 | } |
| 103 | |
| 104 | #wpadminbar .asenha-admin-notices-counter { |
| 105 | box-sizing: border-box; |
| 106 | margin: 1px 0 -1px 6px ; |
| 107 | padding: 2px 6px 3px 5px; |
| 108 | min-width: 18px; |
| 109 | height: 18px; |
| 110 | border-radius: 50%; |
| 111 | background-color: #ca4a1f; |
| 112 | color: #fff; |
| 113 | font-size: 11px; |
| 114 | line-height: 1.6; |
| 115 | text-align: center; |
| 116 | } |
| 117 | |
| 118 | /* #wpbody-content .notice:not(.system-notice,.update-message), |
| 119 | #wpbody-content .notice-error, |
| 120 | #wpbody-content .error, |
| 121 | #wpbody-content .notice-info, |
| 122 | #wpbody-content .notice-information, |
| 123 | #wpbody-content #message, |
| 124 | #wpbody-content .notice-warning:not(.update-message), |
| 125 | #wpbody-content .notice-success:not(.update-message), |
| 126 | #wpbody-content .notice-updated, |
| 127 | #wpbody-content .updated:not(.active, .inactive, .plugin-update-tr), |
| 128 | #wpbody-content .update-nag, */ |
| 129 | #wpbody-content > .wrap > .notice:not(#plugin-activated-successfully,.system-notice,.hidden), |
| 130 | #wpbody-content > .wrap > .notice-error, |
| 131 | #wpbody-content > .wrap > .error:not(.hidden), |
| 132 | #wpbody-content > .wrap > .notice-info, |
| 133 | #wpbody-content > .wrap > .notice-information, |
| 134 | #wpbody-content > .wrap > #message, |
| 135 | #wpbody-content > .wrap > .notice-warning:not(.hidden), |
| 136 | #wpbody-content > .wrap > .notice-success:not(#plugin-activated-successfully), |
| 137 | #wpbody-content > .wrap > .notice-updated, |
| 138 | #wpbody-content > .wrap > .updated:not(.inline), |
| 139 | #wpbody-content > .wrap > .update-nag, |
| 140 | #wpbody-content > .wrap > div:not(#loco-notices,#loco-content) > .notice:not(.system-notice,.hidden), |
| 141 | #wpbody-content > .wrap > div:not(#loco-notices,#loco-content) > .notice-error, |
| 142 | #wpbody-content > .wrap > div:not(#loco-notices,#loco-content) > .error:not(.hidden), |
| 143 | #wpbody-content > .wrap > div:not(#loco-notices,#loco-content) > .notice-info, |
| 144 | #wpbody-content > .wrap > div:not(#loco-notices,#loco-content) > .notice-information, |
| 145 | #wpbody-content > .wrap > div > #message, |
| 146 | #wpbody-content > .wrap > div:not(#loco-notices,#loco-content) > .notice-warning:not(.hidden), |
| 147 | #wpbody-content > .wrap > div:not(#loco-notices,#loco-content) > .notice-success, |
| 148 | #wpbody-content > .wrap > div:not(#loco-notices,#loco-content) > .notice-updated, |
| 149 | #wpbody-content > .wrap > div:not(#loco-notices,#loco-content) > .updated, |
| 150 | #wpbody-content > .wrap > div > .update-nag, |
| 151 | #wpbody-content > div > .wrap > .notice:not(.system-notice,.hidden), |
| 152 | #wpbody-content > div > .wrap > .notice-error, |
| 153 | #wpbody-content > div > .wrap > .error:not(.hidden), |
| 154 | #wpbody-content > div > .wrap > .notice-info, |
| 155 | #wpbody-content > div > .wrap > .notice-information, |
| 156 | #wpbody-content > div > .wrap > #message, |
| 157 | #wpbody-content > div > .wrap > .notice-warning:not(.hidden), |
| 158 | #wpbody-content > div > .wrap > .notice-success, |
| 159 | #wpbody-content > div > .wrap > .notice-updated, |
| 160 | #wpbody-content > div > .wrap > .updated:not(.inline), |
| 161 | #wpbody-content > div > .wrap > .update-nag, |
| 162 | #wpbody-content > .wrap.woocommerce > form > .notice:not(.system-notice,.hidden), |
| 163 | #wpbody-content > .wrap.woocommerce > form > .notice-error, |
| 164 | #wpbody-content > .wrap.woocommerce > form > .error:not(.hidden), |
| 165 | #wpbody-content > .wrap.woocommerce > form > .notice-info, |
| 166 | #wpbody-content > .wrap.woocommerce > form > .notice-information, |
| 167 | #wpbody-content > .wrap.woocommerce > form > #message, |
| 168 | #wpbody-content > .wrap.woocommerce > form > .notice-warning:not(.hidden), |
| 169 | #wpbody-content > .wrap.woocommerce > form > .notice-success, |
| 170 | #wpbody-content > .wrap.woocommerce > form > .notice-updated, |
| 171 | #wpbody-content > .wrap.woocommerce > form > .updated:not(.inline), |
| 172 | #wpbody-content > .wrap.woocommerce > form > .update-nag, |
| 173 | /* TranslatePress */ |
| 174 | #wpbody-content > #trp-main-settings > form > .notice:not(.system-notice,.hidden), |
| 175 | #wpbody-content > #trp-main-settings > form > .notice-error, |
| 176 | #wpbody-content > #trp-main-settings > form > .error:not(.hidden), |
| 177 | #wpbody-content > #trp-main-settings > form > .notice-info, |
| 178 | #wpbody-content > #trp-main-settings > form > .notice-information, |
| 179 | #wpbody-content > #trp-main-settings > form > #message, |
| 180 | #wpbody-content > #trp-main-settings > form > .notice-warning:not(.hidden), |
| 181 | #wpbody-content > #trp-main-settings > form > .notice-success, |
| 182 | #wpbody-content > #trp-main-settings > form > .notice-updated, |
| 183 | #wpbody-content > #trp-main-settings > form > .updated:not(.inline), |
| 184 | #wpbody-content > #trp-main-settings > form > .update-nag, |
| 185 | /* Funnel Builder for WordPress by FunnelKit */ |
| 186 | #wpbody-content > .bwfan_header > .notice:not(.system-notice,.hidden), |
| 187 | #wpbody-content > .bwfan_header > .notice-error, |
| 188 | #wpbody-content > .bwfan_header > .error:not(.hidden), |
| 189 | #wpbody-content > .bwfan_header > .notice-info, |
| 190 | #wpbody-content > .bwfan_header > .notice-information, |
| 191 | #wpbody-content > .bwfan_header > #message, |
| 192 | #wpbody-content > .bwfan_header > .notice-warning:not(.hidden), |
| 193 | #wpbody-content > .bwfan_header > .notice-success, |
| 194 | #wpbody-content > .bwfan_header > .notice-updated, |
| 195 | #wpbody-content > .bwfan_header > .updated:not(.inline), |
| 196 | #wpbody-content > .bwfan_header > .update-nag, |
| 197 | #wpbody-content > .notice:not(.otgs-notice,.wcml-notice), |
| 198 | #wpbody-content > .error, |
| 199 | #wpbody-content > .updated:not(.inline), |
| 200 | #wpbody-content > .update-nag, |
| 201 | #wpbody-content > .jp-connection-banner, |
| 202 | #wpbody-content > .jitm-banner, |
| 203 | #wpbody-content > .jetpack-jitm-message, |
| 204 | #wpbody-content > .ngg_admin_notice, |
| 205 | #wpbody-content > .imagify-welcome, |
| 206 | #wpbody-content #wordfenceAutoUpdateChoice, |
| 207 | #wpbody-content #easy-updates-manager-dashnotice, |
| 208 | #wpbody-content > .wrap.gblocks-dashboard-wrap .notice:not(.system-notice,.hidden), |
| 209 | #wpbody-content > .wrap.gblocks-dashboard-wrap .notice-error, |
| 210 | #wpbody-content > .wrap.gblocks-dashboard-wrap .error:not(.hidden), |
| 211 | #wpbody-content > .wrap.gblocks-dashboard-wrap .notice-info, |
| 212 | #wpbody-content > .wrap.gblocks-dashboard-wrap .notice-information, |
| 213 | #wpbody-content > .wrap.gblocks-dashboard-wrap #message, |
| 214 | #wpbody-content > .wrap.gblocks-dashboard-wrap .notice-warning:not(.hidden), |
| 215 | #wpbody-content > .wrap.gblocks-dashboard-wrap .notice-success, |
| 216 | #wpbody-content > .wrap.gblocks-dashboard-wrap .notice-updated, |
| 217 | #wpbody-content > .wrap.gblocks-dashboard-wrap .updated:not(.inline), |
| 218 | #wpbody-content > .wrap.gblocks-dashboard-wrap .update-nag, |
| 219 | /* WooCommerce Stock Sync */ |
| 220 | #wpbody-content > .wrap > .ssgs-influencer-banner, |
| 221 | #wpbody-content > .wrap > .ssgs-upgrade-banner, |
| 222 | #wpbody-content > .wrap > .ssgs-rating-banner { |
| 223 | position: absolute !important; |
| 224 | visibility: hidden !important; |
| 225 | } |
| 226 | </style> |
| 227 | <?php |
| 228 | |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | } |