helper
3 weeks ago
importers
1 month ago
list-tables
1 month ago
marketplace-suggestions
1 year ago
meta-boxes
1 month ago
notes
4 months ago
plugin-updates
2 years ago
reports
1 month ago
settings
1 month ago
views
1 month ago
class-wc-admin-addons.php
11 months ago
class-wc-admin-api-keys-table-list.php
3 years ago
class-wc-admin-api-keys.php
1 month ago
class-wc-admin-assets.php
1 month ago
class-wc-admin-attributes.php
1 month ago
class-wc-admin-brands.php
1 month ago
class-wc-admin-customize.php
6 years ago
class-wc-admin-dashboard-setup.php
1 month ago
class-wc-admin-dashboard.php
1 month ago
class-wc-admin-duplicate-product.php
1 month ago
class-wc-admin-exporters.php
1 year ago
class-wc-admin-help.php
2 years ago
class-wc-admin-importers.php
1 year ago
class-wc-admin-log-table-list.php
6 months ago
class-wc-admin-marketplace-promotions.php
1 month ago
class-wc-admin-menus.php
1 month ago
class-wc-admin-meta-boxes.php
2 months ago
class-wc-admin-notices.php
1 month ago
class-wc-admin-permalink-settings.php
5 years ago
class-wc-admin-pointers.php
3 years ago
class-wc-admin-post-types.php
1 month ago
class-wc-admin-profile.php
1 year ago
class-wc-admin-reports.php
6 months ago
class-wc-admin-settings.php
1 month ago
class-wc-admin-setup-wizard.php
2 months ago
class-wc-admin-status.php
1 year ago
class-wc-admin-taxonomies.php
2 months ago
class-wc-admin-upload-downloadable-product.php
2 years ago
class-wc-admin-webhooks-table-list.php
2 months ago
class-wc-admin-webhooks.php
1 month ago
class-wc-admin.php
5 months ago
wc-admin-functions.php
1 month ago
wc-meta-box-functions.php
1 year ago
woocommerce-legacy-reports.php
1 year ago
class-wc-admin-notices.php
621 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Display notices in admin |
| 4 | * |
| 5 | * @package WooCommerce\Admin |
| 6 | * @version 3.4.0 |
| 7 | */ |
| 8 | |
| 9 | use Automattic\Jetpack\Constants; |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | /** |
| 14 | * WC_Admin_Notices Class. |
| 15 | */ |
| 16 | class WC_Admin_Notices { |
| 17 | |
| 18 | /** |
| 19 | * Local notices cache. |
| 20 | * |
| 21 | * DON'T manipulate this field directly! |
| 22 | * Always use get_notices and set_notices instead. |
| 23 | * |
| 24 | * @var array |
| 25 | */ |
| 26 | private static $notices = array(); |
| 27 | |
| 28 | /** |
| 29 | * Array of notices - name => callback. |
| 30 | * |
| 31 | * @var array |
| 32 | */ |
| 33 | private static $core_notices = array( |
| 34 | 'update' => 'update_notice', |
| 35 | 'template_files' => 'template_file_check_notice', |
| 36 | 'legacy_shipping' => 'legacy_shipping_notice', |
| 37 | 'no_shipping_methods' => 'no_shipping_methods_notice', |
| 38 | 'regenerating_thumbnails' => 'regenerating_thumbnails_notice', |
| 39 | 'regenerating_lookup_table' => 'regenerating_lookup_table_notice', |
| 40 | 'no_secure_connection' => 'secure_connection_notice', |
| 41 | 'maxmind_license_key' => 'maxmind_missing_license_key_notice', |
| 42 | 'redirect_download_method' => 'redirect_download_method_notice', |
| 43 | 'uploads_directory_is_unprotected' => 'uploads_directory_is_unprotected_notice', |
| 44 | 'base_tables_missing' => 'base_tables_missing_notice', |
| 45 | 'download_directories_sync_complete' => 'download_directories_sync_complete', |
| 46 | 'hpos_sync_on_read_disabled' => 'sync_on_read_disabled_notice', |
| 47 | ); |
| 48 | |
| 49 | /** |
| 50 | * Stores a flag indicating if the code is running in a multisite setup. |
| 51 | * |
| 52 | * @var bool |
| 53 | */ |
| 54 | private static bool $is_multisite; |
| 55 | |
| 56 | /** |
| 57 | * Initializes the class. |
| 58 | * |
| 59 | * @return void |
| 60 | */ |
| 61 | public static function init() { |
| 62 | self::$is_multisite = is_multisite(); |
| 63 | self::set_notices( get_option( 'woocommerce_admin_notices', array() ) ); |
| 64 | if ( defined( 'WC_PHP_MIN_REQUIREMENTS_NOTICE' ) ) { |
| 65 | self::remove_notice( WC_PHP_MIN_REQUIREMENTS_NOTICE ); |
| 66 | } |
| 67 | |
| 68 | add_action( 'switch_theme', array( __CLASS__, 'reset_admin_notices' ) ); |
| 69 | add_action( 'woocommerce_installed', array( __CLASS__, 'reset_admin_notices' ) ); |
| 70 | add_action( 'admin_init', array( __CLASS__, 'hide_notices' ), 20 ); |
| 71 | |
| 72 | // @TODO: This prevents Action Scheduler async jobs from storing empty list of notices during WC installation. |
| 73 | // That could lead to OBW not starting and 'Run setup wizard' notice not appearing in WP admin, which we want |
| 74 | // to avoid. |
| 75 | if ( ! WC_Install::is_new_install() || ! wc_is_running_from_async_action_scheduler() ) { |
| 76 | add_action( 'shutdown', array( __CLASS__, 'store_notices' ) ); |
| 77 | } |
| 78 | |
| 79 | if ( current_user_can( 'manage_woocommerce' ) ) { |
| 80 | add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) ); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Parses query to create nonces when available. |
| 86 | * |
| 87 | * @deprecated 5.4.0 |
| 88 | * @param object $response The WP_REST_Response we're working with. |
| 89 | * @return object $response The prepared WP_REST_Response object. |
| 90 | */ |
| 91 | public static function prepare_note_with_nonce( $response ) { |
| 92 | wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '5.4.0' ); |
| 93 | |
| 94 | return $response; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Store the locally cached notices to DB. |
| 99 | * |
| 100 | * @return void |
| 101 | */ |
| 102 | public static function store_notices() { |
| 103 | $current_notices = self::get_notices(); |
| 104 | $prev_notices = get_option( 'woocommerce_admin_notices', array() ); |
| 105 | |
| 106 | // Store notices. |
| 107 | update_option( 'woocommerce_admin_notices', $current_notices ); |
| 108 | |
| 109 | // Clean up removed notices. |
| 110 | foreach ( array_diff( $prev_notices, $current_notices ) as $notice ) { |
| 111 | if ( isset( self::$core_notices[ $notice ] ) ) { |
| 112 | continue; |
| 113 | } |
| 114 | |
| 115 | delete_option( 'woocommerce_admin_notice_' . $notice ); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Get the value of the locally cached notices array for the current site. |
| 121 | * |
| 122 | * @return array |
| 123 | */ |
| 124 | public static function get_notices() { |
| 125 | if ( ! self::$is_multisite ) { |
| 126 | return self::$notices; |
| 127 | } |
| 128 | |
| 129 | $blog_id = get_current_blog_id(); |
| 130 | $notices = self::$notices[ $blog_id ] ?? null; |
| 131 | if ( ! is_null( $notices ) ) { |
| 132 | return $notices; |
| 133 | } |
| 134 | |
| 135 | self::$notices[ $blog_id ] = get_option( 'woocommerce_admin_notices', array() ); |
| 136 | return self::$notices[ $blog_id ]; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Set the locally cached notices array for the current site. |
| 141 | * |
| 142 | * @param array $notices New value for the locally cached notices array. |
| 143 | * @return void |
| 144 | */ |
| 145 | private static function set_notices( array $notices ) { |
| 146 | if ( self::$is_multisite ) { |
| 147 | self::$notices[ get_current_blog_id() ] = $notices; |
| 148 | } else { |
| 149 | self::$notices = $notices; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Remove all notices from the locally cached notices array. |
| 155 | * |
| 156 | * @return void |
| 157 | */ |
| 158 | public static function remove_all_notices() { |
| 159 | self::set_notices( array() ); |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Reset notices for themes when switched or a new version of WC is installed. |
| 164 | * |
| 165 | * @return void |
| 166 | */ |
| 167 | public static function reset_admin_notices() { |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Show a notice. |
| 172 | * |
| 173 | * @param string $name Notice name. |
| 174 | * @param bool $force_save Force saving inside this method instead of at the 'shutdown'. |
| 175 | * @return void |
| 176 | */ |
| 177 | public static function add_notice( $name, $force_save = false ) { |
| 178 | self::set_notices( array_unique( array_merge( self::get_notices(), array( $name ) ) ) ); |
| 179 | |
| 180 | if ( $force_save ) { |
| 181 | // Adding early save to prevent more race conditions with notices. |
| 182 | self::store_notices(); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Remove a notice from being displayed. |
| 188 | * |
| 189 | * @param string $name Notice name. |
| 190 | * @param bool $force_save Force saving inside this method instead of at the 'shutdown'. |
| 191 | * @return void |
| 192 | */ |
| 193 | public static function remove_notice( $name, $force_save = false ) { |
| 194 | if ( self::has_notice( $name ) ) { |
| 195 | self::set_notices( array_diff( self::get_notices(), array( $name ) ) ); |
| 196 | } |
| 197 | |
| 198 | if ( $force_save ) { |
| 199 | // Adding early save to prevent more race conditions with notices. |
| 200 | self::store_notices(); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Remove a given set of notices. |
| 206 | * |
| 207 | * An array of notice names or a regular expression string can be passed, in the later case |
| 208 | * all the notices whose name matches the regular expression will be removed. |
| 209 | * |
| 210 | * @param array|string $names_array_or_regex An array of notice names, or a string representing a regular expression. |
| 211 | * @param bool $force_save Force saving inside this method instead of at the 'shutdown'. |
| 212 | * @return void |
| 213 | */ |
| 214 | public static function remove_notices( $names_array_or_regex, $force_save = false ) { |
| 215 | if ( ! is_array( $names_array_or_regex ) ) { |
| 216 | $names_array_or_regex = array_filter( self::get_notices(), fn( $notice_name ) => 1 === preg_match( $names_array_or_regex, $notice_name ) ); |
| 217 | } |
| 218 | self::set_notices( array_diff( self::get_notices(), $names_array_or_regex ) ); |
| 219 | |
| 220 | if ( $force_save ) { |
| 221 | // Adding early save to prevent more race conditions with notices. |
| 222 | self::store_notices(); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * See if a notice is being shown. |
| 228 | * |
| 229 | * @param string $name Notice name. |
| 230 | * |
| 231 | * @return boolean |
| 232 | */ |
| 233 | public static function has_notice( $name ) { |
| 234 | return in_array( $name, self::get_notices(), true ); |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Hide a notice if the GET variable is set. |
| 239 | * |
| 240 | * @return void |
| 241 | */ |
| 242 | public static function hide_notices() { |
| 243 | if ( isset( $_GET['wc-hide-notice'] ) && isset( $_GET['_wc_notice_nonce'] ) ) { |
| 244 | if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_wc_notice_nonce'] ) ), 'woocommerce_hide_notices_nonce' ) ) { |
| 245 | wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) ); |
| 246 | } |
| 247 | |
| 248 | $notice_name = sanitize_text_field( wp_unslash( $_GET['wc-hide-notice'] ) ); |
| 249 | |
| 250 | /** |
| 251 | * Filter the capability required to dismiss a given notice. |
| 252 | * |
| 253 | * @since 6.7.0 |
| 254 | * |
| 255 | * @param string $default_capability The default required capability. |
| 256 | * @param string $notice_name The notice name. |
| 257 | */ |
| 258 | $required_capability = apply_filters( 'woocommerce_dismiss_admin_notice_capability', 'manage_woocommerce', $notice_name ); |
| 259 | |
| 260 | if ( ! current_user_can( $required_capability ) ) { |
| 261 | wp_die( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) ); |
| 262 | } |
| 263 | |
| 264 | self::hide_notice( $notice_name ); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Hide a single notice. |
| 270 | * |
| 271 | * @param string $name Notice name. |
| 272 | * @return void |
| 273 | */ |
| 274 | private static function hide_notice( $name ) { |
| 275 | self::remove_notice( $name ); |
| 276 | |
| 277 | update_user_meta( get_current_user_id(), 'dismissed_' . $name . '_notice', true ); |
| 278 | |
| 279 | do_action( 'woocommerce_hide_' . $name . '_notice' ); |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Check if a given user has dismissed a given admin notice. |
| 284 | * |
| 285 | * @since 8.5.0 |
| 286 | * |
| 287 | * @param string $name The name of the admin notice to check. |
| 288 | * @param int|null $user_id User id, or null for the current user. |
| 289 | * @return bool True if the user has dismissed the notice. |
| 290 | */ |
| 291 | public static function user_has_dismissed_notice( string $name, ?int $user_id = null ): bool { |
| 292 | return (bool) get_user_meta( $user_id ?? get_current_user_id(), "dismissed_{$name}_notice", true ); |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Add notices + styles if needed. |
| 297 | * |
| 298 | * @return void |
| 299 | */ |
| 300 | public static function add_notices() { |
| 301 | $notices = self::get_notices(); |
| 302 | |
| 303 | if ( empty( $notices ) ) { |
| 304 | return; |
| 305 | } |
| 306 | |
| 307 | require_once WC_ABSPATH . 'includes/admin/wc-admin-functions.php'; |
| 308 | |
| 309 | $screen = get_current_screen(); |
| 310 | $screen_id = $screen ? $screen->id : ''; |
| 311 | $show_on_screens = array( |
| 312 | 'dashboard', |
| 313 | 'plugins', |
| 314 | ); |
| 315 | |
| 316 | // Notices should only show on WooCommerce screens, the main dashboard, and on the plugins screen. |
| 317 | if ( ! in_array( $screen_id, wc_get_screen_ids(), true ) && ! in_array( $screen_id, $show_on_screens, true ) ) { |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', WC_PLUGIN_FILE ), array(), Constants::get_constant( 'WC_VERSION' ) ); |
| 322 | |
| 323 | // Add RTL support. |
| 324 | wp_style_add_data( 'woocommerce-activation', 'rtl', 'replace' ); |
| 325 | |
| 326 | foreach ( $notices as $notice ) { |
| 327 | if ( ! empty( self::$core_notices[ $notice ] ) && apply_filters( 'woocommerce_show_admin_notice', true, $notice ) ) { |
| 328 | add_action( 'admin_notices', array( __CLASS__, self::$core_notices[ $notice ] ) ); |
| 329 | } else { |
| 330 | add_action( 'admin_notices', array( __CLASS__, 'output_custom_notices' ) ); |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Add a custom notice. |
| 337 | * |
| 338 | * @param string $name Notice name. |
| 339 | * @param string $notice_html Notice HTML. |
| 340 | * @return void |
| 341 | */ |
| 342 | public static function add_custom_notice( $name, $notice_html ) { |
| 343 | self::add_notice( $name ); |
| 344 | update_option( 'woocommerce_admin_notice_' . $name, wp_kses_post( $notice_html ) ); |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * Output any stored custom notices. |
| 349 | * |
| 350 | * @return void |
| 351 | */ |
| 352 | public static function output_custom_notices() { |
| 353 | $notices = self::get_notices(); |
| 354 | |
| 355 | if ( ! empty( $notices ) ) { |
| 356 | foreach ( $notices as $notice ) { |
| 357 | if ( empty( self::$core_notices[ $notice ] ) ) { |
| 358 | $notice_html = get_option( 'woocommerce_admin_notice_' . $notice ); |
| 359 | |
| 360 | if ( $notice_html ) { |
| 361 | include __DIR__ . '/views/html-notice-custom.php'; |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * If we need to update the database, include a message with the DB update button. |
| 370 | * |
| 371 | * @return void |
| 372 | */ |
| 373 | public static function update_notice() { |
| 374 | $screen = get_current_screen(); |
| 375 | $screen_id = $screen ? $screen->id : ''; |
| 376 | if ( WC()->is_wc_admin_active() && in_array( $screen_id, wc_get_screen_ids(), true ) ) { |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | if ( WC_Install::needs_db_update() ) { |
| 381 | $next_scheduled_date = WC()->queue()->get_next( 'woocommerce_run_update_callback', null, 'woocommerce-db-updates' ); |
| 382 | |
| 383 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 384 | if ( $next_scheduled_date || ! empty( $_GET['do_update_woocommerce'] ) ) { |
| 385 | include __DIR__ . '/views/html-notice-updating.php'; |
| 386 | } else { |
| 387 | include __DIR__ . '/views/html-notice-update.php'; |
| 388 | } |
| 389 | } else { |
| 390 | include __DIR__ . '/views/html-notice-updated.php'; |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | /** |
| 395 | * If we have just installed, show a message with the install pages button. |
| 396 | * |
| 397 | * @deprecated 4.6.0 |
| 398 | * @return void |
| 399 | */ |
| 400 | public static function install_notice() { |
| 401 | _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', esc_html__( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Previously showed a notice highlighting bad template files. |
| 406 | * |
| 407 | * Template override status is now shown in Site Health. |
| 408 | * |
| 409 | * @return void |
| 410 | */ |
| 411 | public static function template_file_check_notice() { |
| 412 | self::remove_notice( 'template_files' ); |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Previously showed a notice asking users to convert to shipping zones. |
| 417 | * |
| 418 | * Legacy shipping status is now shown in Site Health. |
| 419 | * |
| 420 | * @return void |
| 421 | */ |
| 422 | public static function legacy_shipping_notice() { |
| 423 | self::remove_notice( 'legacy_shipping' ); |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * Previously showed a notice when no shipping methods were configured. |
| 428 | * |
| 429 | * Shipping method status is now shown in Site Health. |
| 430 | * |
| 431 | * @return void |
| 432 | */ |
| 433 | public static function no_shipping_methods_notice() { |
| 434 | self::remove_notice( 'no_shipping_methods' ); |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * Previously showed a notice about secure connections. |
| 439 | * |
| 440 | * Secure connection status is now shown in Site Health. |
| 441 | * |
| 442 | * @return void |
| 443 | */ |
| 444 | public static function secure_connection_notice() { |
| 445 | self::remove_notice( 'no_secure_connection' ); |
| 446 | } |
| 447 | |
| 448 | /** |
| 449 | * Previously showed a notice while thumbnails regenerated in the background. |
| 450 | * |
| 451 | * Thumbnail regeneration progress is now shown beside the matching status tool. |
| 452 | * |
| 453 | * @return void |
| 454 | */ |
| 455 | public static function regenerating_thumbnails_notice() { |
| 456 | self::remove_notice( 'regenerating_thumbnails' ); |
| 457 | } |
| 458 | |
| 459 | /** |
| 460 | * Previously showed a notice while product lookup tables regenerated. |
| 461 | * |
| 462 | * Product lookup table regeneration status is now shown beside the matching status tool. |
| 463 | * |
| 464 | * @since 3.6.0 |
| 465 | * @return void |
| 466 | */ |
| 467 | public static function regenerating_lookup_table_notice() { |
| 468 | self::remove_notice( 'regenerating_lookup_table' ); |
| 469 | } |
| 470 | |
| 471 | /** |
| 472 | * Add notice about minimum PHP and WordPress requirement. |
| 473 | * |
| 474 | * @deprecated 11.0.0 WordPress and PHP minimum requirements notices are no longer shown. |
| 475 | * |
| 476 | * @since 3.6.5 |
| 477 | * @return void |
| 478 | */ |
| 479 | public static function add_min_version_notice() { |
| 480 | } |
| 481 | |
| 482 | /** |
| 483 | * Notice about WordPress and PHP minimum requirements. |
| 484 | * |
| 485 | * @deprecated 8.2.0 WordPress and PHP minimum requirements notices are no longer shown. |
| 486 | * |
| 487 | * @since 3.6.5 |
| 488 | * @return void |
| 489 | */ |
| 490 | public static function wp_php_min_requirements_notice() { |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * Previously added a MaxMind missing license key notice. |
| 495 | * |
| 496 | * MaxMind geolocation status is now shown in Site Health. |
| 497 | * |
| 498 | * @since 3.9.0 |
| 499 | * @return void |
| 500 | */ |
| 501 | public static function add_maxmind_missing_license_key_notice() { |
| 502 | self::remove_notice( 'maxmind_license_key' ); |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * Previously added a Redirect only download method notice. |
| 507 | * |
| 508 | * Download method status is now shown in Site Health. |
| 509 | * |
| 510 | * @return void |
| 511 | */ |
| 512 | public static function add_redirect_download_method_notice() { |
| 513 | self::remove_notice( 'redirect_download_method' ); |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * Previously displayed the approved download directories sync completion notice. |
| 518 | * |
| 519 | * Approved download directory sync status is now shown in Site Health. The notice ID |
| 520 | * remains stored until the merchant marks it reviewed in Site Health. |
| 521 | * |
| 522 | * @return void |
| 523 | */ |
| 524 | public static function download_directories_sync_complete() { |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * Previously displayed a MaxMind missing license key notice. |
| 529 | * |
| 530 | * MaxMind geolocation status is now shown in Site Health. |
| 531 | * |
| 532 | * @since 3.9.0 |
| 533 | * @return void |
| 534 | */ |
| 535 | public static function maxmind_missing_license_key_notice() { |
| 536 | self::remove_notice( 'maxmind_license_key' ); |
| 537 | } |
| 538 | |
| 539 | /** |
| 540 | * Previously displayed a Redirect only download method notice. |
| 541 | * |
| 542 | * Download method status is now shown in Site Health. |
| 543 | * |
| 544 | * @since 4.0 |
| 545 | * @return void |
| 546 | */ |
| 547 | public static function redirect_download_method_notice() { |
| 548 | self::remove_notice( 'redirect_download_method' ); |
| 549 | } |
| 550 | |
| 551 | /** |
| 552 | * Previously displayed an uploads directory protection notice. |
| 553 | * |
| 554 | * Uploads directory protection status is now shown in Site Health. |
| 555 | * |
| 556 | * @since 4.2.0 |
| 557 | * @return void |
| 558 | */ |
| 559 | public static function uploads_directory_is_unprotected_notice() { |
| 560 | self::remove_notice( 'uploads_directory_is_unprotected' ); |
| 561 | } |
| 562 | |
| 563 | /** |
| 564 | * Previously displayed a missing database tables notice. |
| 565 | * |
| 566 | * Database table status is now shown in Site Health. |
| 567 | * |
| 568 | * @return void |
| 569 | */ |
| 570 | public static function base_tables_missing_notice() { |
| 571 | self::remove_notice( 'base_tables_missing' ); |
| 572 | } |
| 573 | |
| 574 | /** |
| 575 | * Previously displayed a notice about HPOS sync-on-read being disabled by default. |
| 576 | * |
| 577 | * HPOS sync-on-read status is now shown in Site Health. |
| 578 | * |
| 579 | * @since 10.7.0 |
| 580 | * @return void |
| 581 | */ |
| 582 | public static function sync_on_read_disabled_notice() { |
| 583 | self::remove_notice( 'hpos_sync_on_read_disabled' ); |
| 584 | } |
| 585 | |
| 586 | /** |
| 587 | * Wrapper for is_plugin_active. |
| 588 | * |
| 589 | * @param string $plugin Plugin to check. |
| 590 | * @return boolean |
| 591 | */ |
| 592 | protected static function is_plugin_active( $plugin ) { |
| 593 | if ( ! function_exists( 'is_plugin_active' ) ) { |
| 594 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 595 | } |
| 596 | return is_plugin_active( $plugin ); |
| 597 | } |
| 598 | |
| 599 | /** |
| 600 | * Simplify Commerce is no longer in core. |
| 601 | * |
| 602 | * @deprecated 3.6.0 No longer shown. |
| 603 | * @return void |
| 604 | */ |
| 605 | public static function simplify_commerce_notice() { |
| 606 | wc_deprecated_function( 'WC_Admin_Notices::simplify_commerce_notice', '3.6.0' ); |
| 607 | } |
| 608 | |
| 609 | /** |
| 610 | * Show the Theme Check notice. |
| 611 | * |
| 612 | * @deprecated 3.3.0 No longer shown. |
| 613 | * @return void |
| 614 | */ |
| 615 | public static function theme_check_notice() { |
| 616 | wc_deprecated_function( 'WC_Admin_Notices::theme_check_notice', '3.3.0' ); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | WC_Admin_Notices::init(); |
| 621 |