WooCommerce Code Reference

WC_Admin_Notices
in package
Uses AccessiblePrivateMethods

WC_Admin_Notices Class.

Table of Contents

$core_notices  : array<string|int, mixed>
Array of notices - name => callback.
$is_multisite  : bool
Stores a flag indicating if the code is running in a multisite setup.
$notices  : array<string|int, mixed>
Local notices cache.
add_custom_notice()  : mixed
Add a custom notice.
add_maxmind_missing_license_key_notice()  : mixed
Add MaxMind missing license key notice.
add_min_version_notice()  : mixed
Add notice about minimum PHP and WordPress requirement.
add_notice()  : mixed
Show a notice.
add_notices()  : mixed
Add notices + styles if needed.
add_redirect_download_method_notice()  : mixed
Add notice about Redirect-only download method, nudging user to switch to a different method instead.
base_tables_missing_notice()  : mixed
Notice about base tables missing.
download_directories_sync_complete()  : mixed
Notice about the completion of the product downloads sync, with further advice for the site operator.
get_notices()  : array<string|int, mixed>
Get the value of the locally cached notices array for the current site.
has_notice()  : bool
See if a notice is being shown.
hide_notices()  : mixed
Hide a notice if the GET variable is set.
init()  : mixed
Initializes the class.
install_notice()  : mixed
If we have just installed, show a message with the install pages button.
legacy_shipping_notice()  : mixed
Show a notice asking users to convert to shipping zones.
maxmind_missing_license_key_notice()  : mixed
Display MaxMind missing license key notice.
no_shipping_methods_notice()  : mixed
No shipping methods.
output_custom_notices()  : mixed
Output any stored custom notices.
prepare_note_with_nonce()  : object
Parses query to create nonces when available.
redirect_download_method_notice()  : mixed
Notice about Redirect-Only download method.
regenerating_lookup_table_notice()  : mixed
Notice shown when regenerating thumbnails background process is running.
regenerating_thumbnails_notice()  : mixed
Notice shown when regenerating thumbnails background process is running.
remove_all_notices()  : mixed
Remove all notices from the locally cached notices array.
remove_notice()  : mixed
Remove a notice from being displayed.
remove_notices()  : void
Remove a given set of notices.
reset_admin_notices()  : mixed
Reset notices for themes when switched or a new version of WC is installed.
secure_connection_notice()  : mixed
Notice about secure connection.
simplify_commerce_notice()  : mixed
Simplify Commerce is no longer in core.
store_notices()  : mixed
Store the locally cached notices to DB.
template_file_check_notice()  : mixed
Show a notice highlighting bad template files.
theme_check_notice()  : mixed
Show the Theme Check notice.
update_notice()  : mixed
If we need to update the database, include a message with the DB update button.
uploads_directory_is_unprotected_notice()  : mixed
Notice about uploads directory begin unprotected.
user_has_dismissed_notice()  : bool
Check if a given user has dismissed a given admin notice.
wp_php_min_requirements_notice()  : void
Notice about WordPress and PHP minimum requirements.
is_plugin_active()  : bool
Wrapper for is_plugin_active.
is_ssl()  : bool
Determine if the store is running SSL.
is_uploads_directory_protected()  : bool
Check if uploads directory is protected.
hide_notice()  : mixed
Hide a single notice.
maybe_add_legacy_api_removal_notice()  : mixed
Add an admin notice about unsupported webhooks with Legacy API payload if at least one of these exist and the Legacy REST API plugin is not installed.
maybe_remove_legacy_api_removal_notice()  : mixed
Remove the admin notice about the unsupported webhooks if the Legacy REST API plugin is installed.
set_notices()  : mixed
Set the locally cached notices array for the current site.

Properties

$core_notices

Array of notices - name => callback.

private static array<string|int, mixed> $core_notices = array('update' => 'update_notice', 'template_files' => 'template_file_check_notice', 'legacy_shipping' => 'legacy_shipping_notice', 'no_shipping_methods' => 'no_shipping_methods_notice', 'regenerating_thumbnails' => 'regenerating_thumbnails_notice', 'regenerating_lookup_table' => 'regenerating_lookup_table_notice', 'no_secure_connection' => 'secure_connection_notice', 'maxmind_license_key' => 'maxmind_missing_license_key_notice', 'redirect_download_method' => 'redirect_download_method_notice', 'uploads_directory_is_unprotected' => 'uploads_directory_is_unprotected_notice', 'base_tables_missing' => 'base_tables_missing_notice', 'download_directories_sync_complete' => 'download_directories_sync_complete')

$notices

Local notices cache.

private static array<string|int, mixed> $notices = array()

DON'T manipulate this field directly! Always use get_notices and set_notices instead.

Methods

add_custom_notice()

Add a custom notice.

public static add_custom_notice(string $name, string $notice_html) : mixed
Parameters
$name : string

Notice name.

$notice_html : string

Notice HTML.

Return values
mixed

add_maxmind_missing_license_key_notice()

Add MaxMind missing license key notice.

public static add_maxmind_missing_license_key_notice() : mixed
Tags
since
3.9.0
Return values
mixed

add_min_version_notice()

Add notice about minimum PHP and WordPress requirement.

public static add_min_version_notice() : mixed
Tags
since
3.6.5
Return values
mixed

add_notice()

Show a notice.

public static add_notice(string $name[, bool $force_save = false ]) : mixed
Parameters
$name : string

Notice name.

$force_save : bool = false

Force saving inside this method instead of at the 'shutdown'.

Return values
mixed

add_redirect_download_method_notice()

Add notice about Redirect-only download method, nudging user to switch to a different method instead.

public static add_redirect_download_method_notice() : mixed
Return values
mixed

download_directories_sync_complete()

Notice about the completion of the product downloads sync, with further advice for the site operator.

public static download_directories_sync_complete() : mixed
Return values
mixed

get_notices()

Get the value of the locally cached notices array for the current site.

public static get_notices() : array<string|int, mixed>
Return values
array<string|int, mixed>

install_notice()

If we have just installed, show a message with the install pages button.

public static install_notice() : mixed
Tags
deprecated
4.6.0
Return values
mixed

legacy_shipping_notice()

Show a notice asking users to convert to shipping zones.

public static legacy_shipping_notice() : mixed
Tags
todo

remove in 4.0.0

Return values
mixed

maxmind_missing_license_key_notice()

Display MaxMind missing license key notice.

public static maxmind_missing_license_key_notice() : mixed
Tags
since
3.9.0
Return values
mixed

prepare_note_with_nonce()

Parses query to create nonces when available.

public static prepare_note_with_nonce(object $response) : object
Parameters
$response : object

The WP_REST_Response we're working with.

Tags
deprecated
5.4.0
Return values
object$response The prepared WP_REST_Response object.

redirect_download_method_notice()

Notice about Redirect-Only download method.

public static redirect_download_method_notice() : mixed
Tags
since
4.0
Return values
mixed

regenerating_lookup_table_notice()

Notice shown when regenerating thumbnails background process is running.

public static regenerating_lookup_table_notice() : mixed
Tags
since
3.6.0
Return values
mixed

regenerating_thumbnails_notice()

Notice shown when regenerating thumbnails background process is running.

public static regenerating_thumbnails_notice() : mixed
Return values
mixed

remove_notice()

Remove a notice from being displayed.

public static remove_notice(string $name[, bool $force_save = false ]) : mixed
Parameters
$name : string

Notice name.

$force_save : bool = false

Force saving inside this method instead of at the 'shutdown'.

Return values
mixed

remove_notices()

Remove a given set of notices.

public static remove_notices(array<string|int, mixed>|string $names_array_or_regex[, bool $force_save = false ]) : void

An array of notice names or a regular expression string can be passed, in the later case all the notices whose name matches the regular expression will be removed.

Parameters
$names_array_or_regex : array<string|int, mixed>|string

An array of notice names, or a string representing a regular expression.

$force_save : bool = false

Force saving inside this method instead of at the 'shutdown'.

Return values
void

reset_admin_notices()

Reset notices for themes when switched or a new version of WC is installed.

public static reset_admin_notices() : mixed
Return values
mixed

simplify_commerce_notice()

Simplify Commerce is no longer in core.

public static simplify_commerce_notice() : mixed
Tags
deprecated
3.6.0

No longer shown.

Return values
mixed

theme_check_notice()

Show the Theme Check notice.

public static theme_check_notice() : mixed
Tags
deprecated
3.3.0

No longer shown.

Return values
mixed

update_notice()

If we need to update the database, include a message with the DB update button.

public static update_notice() : mixed
Return values
mixed

uploads_directory_is_unprotected_notice()

Notice about uploads directory begin unprotected.

public static uploads_directory_is_unprotected_notice() : mixed
Tags
since
4.2.0
Return values
mixed

user_has_dismissed_notice()

Check if a given user has dismissed a given admin notice.

public static user_has_dismissed_notice(string $name[, int|null $user_id = null ]) : bool
Parameters
$name : string

The name of the admin notice to check.

$user_id : int|null = null

User id, or null for the current user.

Tags
since
8.5.0
Return values
boolTrue if the user has dismissed the notice.

wp_php_min_requirements_notice()

Notice about WordPress and PHP minimum requirements.

public static wp_php_min_requirements_notice() : void
Tags
deprecated
8.2.0

WordPress and PHP minimum requirements notices are no longer shown.

since
3.6.5
Return values
void

is_plugin_active()

Wrapper for is_plugin_active.

protected static is_plugin_active(string $plugin) : bool
Parameters
$plugin : string

Plugin to check.

Return values
bool

is_uploads_directory_protected()

Check if uploads directory is protected.

protected static is_uploads_directory_protected() : bool
Tags
since
4.2.0
Return values
bool

maybe_add_legacy_api_removal_notice()

Add an admin notice about unsupported webhooks with Legacy API payload if at least one of these exist and the Legacy REST API plugin is not installed.

private static maybe_add_legacy_api_removal_notice() : mixed
Return values
mixed

maybe_remove_legacy_api_removal_notice()

Remove the admin notice about the unsupported webhooks if the Legacy REST API plugin is installed.

private static maybe_remove_legacy_api_removal_notice() : mixed
Return values
mixed

set_notices()

Set the locally cached notices array for the current site.

private static set_notices(array<string|int, mixed> $notices) : mixed
Parameters
$notices : array<string|int, mixed>

New value for the locally cached notices array.

Return values
mixed