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