Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../includes/admin
File: class-wc-admin-notices.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Display notices in admin
[2] Fix | Delete
*
[3] Fix | Delete
* @package WooCommerce\Admin
[4] Fix | Delete
* @version 3.4.0
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
use Automattic\Jetpack\Constants;
[8] Fix | Delete
use Automattic\WooCommerce\Internal\Utilities\Users;
[9] Fix | Delete
use Automattic\WooCommerce\Internal\Utilities\WebhookUtil;
[10] Fix | Delete
[11] Fix | Delete
defined( 'ABSPATH' ) || exit;
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* WC_Admin_Notices Class.
[15] Fix | Delete
*/
[16] Fix | Delete
class WC_Admin_Notices {
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Local notices cache.
[20] Fix | Delete
*
[21] Fix | Delete
* DON'T manipulate this field directly!
[22] Fix | Delete
* Always use get_notices and set_notices instead.
[23] Fix | Delete
*
[24] Fix | Delete
* @var array
[25] Fix | Delete
*/
[26] Fix | Delete
private static $notices = array();
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Array of notices - name => callback.
[30] Fix | Delete
*
[31] Fix | Delete
* @var array
[32] Fix | Delete
*/
[33] Fix | Delete
private static $core_notices = array(
[34] Fix | Delete
'update' => 'update_notice',
[35] Fix | Delete
'template_files' => 'template_file_check_notice',
[36] Fix | Delete
'legacy_shipping' => 'legacy_shipping_notice',
[37] Fix | Delete
'no_shipping_methods' => 'no_shipping_methods_notice',
[38] Fix | Delete
'regenerating_thumbnails' => 'regenerating_thumbnails_notice',
[39] Fix | Delete
'regenerating_lookup_table' => 'regenerating_lookup_table_notice',
[40] Fix | Delete
'no_secure_connection' => 'secure_connection_notice',
[41] Fix | Delete
'maxmind_license_key' => 'maxmind_missing_license_key_notice',
[42] Fix | Delete
'redirect_download_method' => 'redirect_download_method_notice',
[43] Fix | Delete
'uploads_directory_is_unprotected' => 'uploads_directory_is_unprotected_notice',
[44] Fix | Delete
'base_tables_missing' => 'base_tables_missing_notice',
[45] Fix | Delete
'download_directories_sync_complete' => 'download_directories_sync_complete',
[46] Fix | Delete
);
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Stores a flag indicating if the code is running in a multisite setup.
[50] Fix | Delete
*
[51] Fix | Delete
* @var bool
[52] Fix | Delete
*/
[53] Fix | Delete
private static bool $is_multisite;
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Initializes the class.
[57] Fix | Delete
*
[58] Fix | Delete
* @return void
[59] Fix | Delete
*/
[60] Fix | Delete
public static function init() {
[61] Fix | Delete
self::$is_multisite = is_multisite();
[62] Fix | Delete
self::set_notices( get_option( 'woocommerce_admin_notices', array() ) );
[63] Fix | Delete
[64] Fix | Delete
add_action( 'switch_theme', array( __CLASS__, 'reset_admin_notices' ) );
[65] Fix | Delete
add_action( 'woocommerce_installed', array( __CLASS__, 'reset_admin_notices' ) );
[66] Fix | Delete
add_action( 'update_option_woocommerce_file_download_method', array( __CLASS__, 'add_redirect_download_method_notice' ) );
[67] Fix | Delete
add_action( 'admin_init', array( __CLASS__, 'hide_notices' ), 20 );
[68] Fix | Delete
add_action( 'admin_init', array( __CLASS__, 'maybe_remove_legacy_api_removal_notice' ), 20 );
[69] Fix | Delete
[70] Fix | Delete
// @TODO: This prevents Action Scheduler async jobs from storing empty list of notices during WC installation.
[71] Fix | Delete
// That could lead to OBW not starting and 'Run setup wizard' notice not appearing in WP admin, which we want
[72] Fix | Delete
// to avoid.
[73] Fix | Delete
if ( ! WC_Install::is_new_install() || ! wc_is_running_from_async_action_scheduler() ) {
[74] Fix | Delete
add_action( 'shutdown', array( __CLASS__, 'store_notices' ) );
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
if ( current_user_can( 'manage_woocommerce' ) ) {
[78] Fix | Delete
add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) );
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* Parses query to create nonces when available.
[84] Fix | Delete
*
[85] Fix | Delete
* @deprecated 5.4.0
[86] Fix | Delete
* @param object $response The WP_REST_Response we're working with.
[87] Fix | Delete
* @return object $response The prepared WP_REST_Response object.
[88] Fix | Delete
*/
[89] Fix | Delete
public static function prepare_note_with_nonce( $response ) {
[90] Fix | Delete
wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '5.4.0' );
[91] Fix | Delete
[92] Fix | Delete
return $response;
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Store the locally cached notices to DB.
[97] Fix | Delete
*
[98] Fix | Delete
* @return void
[99] Fix | Delete
*/
[100] Fix | Delete
public static function store_notices() {
[101] Fix | Delete
$current_notices = self::get_notices();
[102] Fix | Delete
$prev_notices = get_option( 'woocommerce_admin_notices', array() );
[103] Fix | Delete
[104] Fix | Delete
// Store notices.
[105] Fix | Delete
update_option( 'woocommerce_admin_notices', $current_notices );
[106] Fix | Delete
[107] Fix | Delete
// Clean up removed notices.
[108] Fix | Delete
foreach ( array_diff( $prev_notices, $current_notices ) as $notice ) {
[109] Fix | Delete
if ( isset( self::$core_notices[ $notice ] ) ) {
[110] Fix | Delete
continue;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
delete_option( 'woocommerce_admin_notice_' . $notice );
[114] Fix | Delete
}
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
/**
[118] Fix | Delete
* Get the value of the locally cached notices array for the current site.
[119] Fix | Delete
*
[120] Fix | Delete
* @return array
[121] Fix | Delete
*/
[122] Fix | Delete
public static function get_notices() {
[123] Fix | Delete
if ( ! self::$is_multisite ) {
[124] Fix | Delete
return self::$notices;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
$blog_id = get_current_blog_id();
[128] Fix | Delete
$notices = self::$notices[ $blog_id ] ?? null;
[129] Fix | Delete
if ( ! is_null( $notices ) ) {
[130] Fix | Delete
return $notices;
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
self::$notices[ $blog_id ] = get_option( 'woocommerce_admin_notices', array() );
[134] Fix | Delete
return self::$notices[ $blog_id ];
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Set the locally cached notices array for the current site.
[139] Fix | Delete
*
[140] Fix | Delete
* @param array $notices New value for the locally cached notices array.
[141] Fix | Delete
* @return void
[142] Fix | Delete
*/
[143] Fix | Delete
private static function set_notices( array $notices ) {
[144] Fix | Delete
if ( self::$is_multisite ) {
[145] Fix | Delete
self::$notices[ get_current_blog_id() ] = $notices;
[146] Fix | Delete
} else {
[147] Fix | Delete
self::$notices = $notices;
[148] Fix | Delete
}
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
/**
[152] Fix | Delete
* Remove all notices from the locally cached notices array.
[153] Fix | Delete
*
[154] Fix | Delete
* @return void
[155] Fix | Delete
*/
[156] Fix | Delete
public static function remove_all_notices() {
[157] Fix | Delete
self::set_notices( array() );
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
/**
[161] Fix | Delete
* Reset notices for themes when switched or a new version of WC is installed.
[162] Fix | Delete
*
[163] Fix | Delete
* @return void
[164] Fix | Delete
*/
[165] Fix | Delete
public static function reset_admin_notices() {
[166] Fix | Delete
if ( ! self::is_ssl() ) {
[167] Fix | Delete
self::add_notice( 'no_secure_connection' );
[168] Fix | Delete
}
[169] Fix | Delete
if ( ! self::is_uploads_directory_protected() ) {
[170] Fix | Delete
self::add_notice( 'uploads_directory_is_unprotected' );
[171] Fix | Delete
}
[172] Fix | Delete
self::add_notice( 'template_files' );
[173] Fix | Delete
self::add_min_version_notice();
[174] Fix | Delete
self::add_maxmind_missing_license_key_notice();
[175] Fix | Delete
self::maybe_add_legacy_api_removal_notice();
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
/**
[179] Fix | Delete
* Add an admin notice about unsupported webhooks with Legacy API payload if at least one of these exist
[180] Fix | Delete
* and the Legacy REST API plugin is not installed.
[181] Fix | Delete
*
[182] Fix | Delete
* @return void
[183] Fix | Delete
*/
[184] Fix | Delete
private static function maybe_add_legacy_api_removal_notice() {
[185] Fix | Delete
if ( wc_get_container()->get( WebhookUtil::class )->get_legacy_webhooks_count() > 0 && ! WC()->legacy_rest_api_is_available() ) {
[186] Fix | Delete
self::add_custom_notice(
[187] Fix | Delete
'legacy_webhooks_unsupported_in_woo_90',
[188] Fix | Delete
sprintf(
[189] Fix | Delete
'%s%s',
[190] Fix | Delete
sprintf(
[191] Fix | Delete
'<h4>%s</h4>',
[192] Fix | Delete
esc_html__( 'WooCommerce webhooks that use the Legacy REST API are unsupported', 'woocommerce' )
[193] Fix | Delete
),
[194] Fix | Delete
sprintf(
[195] Fix | Delete
// translators: Placeholders are URLs.
[196] Fix | Delete
wpautop( __( '⚠️ The WooCommerce Legacy REST API has been removed from WooCommerce, this will cause <a href="%1$s">webhooks on this site that are configured to use the Legacy REST API</a> to stop working. <a target="_blank" href="%2$s">A separate WooCommerce extension is available</a> to allow these webhooks to keep using the Legacy REST API without interruption. You can also edit these webhooks to use the current REST API version to generate the payload instead. <b><a target="_blank" href="%3$s">Learn more about this change.</a></b>', 'woocommerce' ) ),
[197] Fix | Delete
admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&legacy=true' ),
[198] Fix | Delete
'https://wordpress.org/plugins/woocommerce-legacy-rest-api/',
[199] Fix | Delete
'https://developer.woocommerce.com/2023/10/03/the-legacy-rest-api-will-move-to-a-dedicated-extension-in-woocommerce-9-0/'
[200] Fix | Delete
)
[201] Fix | Delete
)
[202] Fix | Delete
);
[203] Fix | Delete
}
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
/**
[207] Fix | Delete
* Remove the admin notice about the unsupported webhooks if the Legacy REST API plugin is installed.
[208] Fix | Delete
*
[209] Fix | Delete
* @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed.
[210] Fix | Delete
* @return void
[211] Fix | Delete
*/
[212] Fix | Delete
public static function maybe_remove_legacy_api_removal_notice() {
[213] Fix | Delete
if ( self::has_notice( 'legacy_webhooks_unsupported_in_woo_90' ) && ( WC()->legacy_rest_api_is_available() || 0 === wc_get_container()->get( WebhookUtil::class )->get_legacy_webhooks_count() ) ) {
[214] Fix | Delete
self::remove_notice( 'legacy_webhooks_unsupported_in_woo_90' );
[215] Fix | Delete
}
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
/**
[219] Fix | Delete
* Show a notice.
[220] Fix | Delete
*
[221] Fix | Delete
* @param string $name Notice name.
[222] Fix | Delete
* @param bool $force_save Force saving inside this method instead of at the 'shutdown'.
[223] Fix | Delete
* @return void
[224] Fix | Delete
*/
[225] Fix | Delete
public static function add_notice( $name, $force_save = false ) {
[226] Fix | Delete
self::set_notices( array_unique( array_merge( self::get_notices(), array( $name ) ) ) );
[227] Fix | Delete
[228] Fix | Delete
if ( $force_save ) {
[229] Fix | Delete
// Adding early save to prevent more race conditions with notices.
[230] Fix | Delete
self::store_notices();
[231] Fix | Delete
}
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
/**
[235] Fix | Delete
* Remove a notice from being displayed.
[236] Fix | Delete
*
[237] Fix | Delete
* @param string $name Notice name.
[238] Fix | Delete
* @param bool $force_save Force saving inside this method instead of at the 'shutdown'.
[239] Fix | Delete
* @return void
[240] Fix | Delete
*/
[241] Fix | Delete
public static function remove_notice( $name, $force_save = false ) {
[242] Fix | Delete
if ( self::has_notice( $name ) ) {
[243] Fix | Delete
self::set_notices( array_diff( self::get_notices(), array( $name ) ) );
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
if ( $force_save ) {
[247] Fix | Delete
// Adding early save to prevent more race conditions with notices.
[248] Fix | Delete
self::store_notices();
[249] Fix | Delete
}
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
/**
[253] Fix | Delete
* Remove a given set of notices.
[254] Fix | Delete
*
[255] Fix | Delete
* An array of notice names or a regular expression string can be passed, in the later case
[256] Fix | Delete
* all the notices whose name matches the regular expression will be removed.
[257] Fix | Delete
*
[258] Fix | Delete
* @param array|string $names_array_or_regex An array of notice names, or a string representing a regular expression.
[259] Fix | Delete
* @param bool $force_save Force saving inside this method instead of at the 'shutdown'.
[260] Fix | Delete
* @return void
[261] Fix | Delete
*/
[262] Fix | Delete
public static function remove_notices( $names_array_or_regex, $force_save = false ) {
[263] Fix | Delete
if ( ! is_array( $names_array_or_regex ) ) {
[264] Fix | Delete
$names_array_or_regex = array_filter( self::get_notices(), fn( $notice_name ) => 1 === preg_match( $names_array_or_regex, $notice_name ) );
[265] Fix | Delete
}
[266] Fix | Delete
self::set_notices( array_diff( self::get_notices(), $names_array_or_regex ) );
[267] Fix | Delete
[268] Fix | Delete
if ( $force_save ) {
[269] Fix | Delete
// Adding early save to prevent more race conditions with notices.
[270] Fix | Delete
self::store_notices();
[271] Fix | Delete
}
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
/**
[275] Fix | Delete
* See if a notice is being shown.
[276] Fix | Delete
*
[277] Fix | Delete
* @param string $name Notice name.
[278] Fix | Delete
*
[279] Fix | Delete
* @return boolean
[280] Fix | Delete
*/
[281] Fix | Delete
public static function has_notice( $name ) {
[282] Fix | Delete
return in_array( $name, self::get_notices(), true );
[283] Fix | Delete
}
[284] Fix | Delete
[285] Fix | Delete
/**
[286] Fix | Delete
* Hide a notice if the GET variable is set.
[287] Fix | Delete
*
[288] Fix | Delete
* @return void
[289] Fix | Delete
*/
[290] Fix | Delete
public static function hide_notices() {
[291] Fix | Delete
if ( isset( $_GET['wc-hide-notice'] ) && isset( $_GET['_wc_notice_nonce'] ) ) {
[292] Fix | Delete
if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_wc_notice_nonce'] ) ), 'woocommerce_hide_notices_nonce' ) ) {
[293] Fix | Delete
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
[294] Fix | Delete
}
[295] Fix | Delete
[296] Fix | Delete
$notice_name = sanitize_text_field( wp_unslash( $_GET['wc-hide-notice'] ) );
[297] Fix | Delete
[298] Fix | Delete
/**
[299] Fix | Delete
* Filter the capability required to dismiss a given notice.
[300] Fix | Delete
*
[301] Fix | Delete
* @since 6.7.0
[302] Fix | Delete
*
[303] Fix | Delete
* @param string $default_capability The default required capability.
[304] Fix | Delete
* @param string $notice_name The notice name.
[305] Fix | Delete
*/
[306] Fix | Delete
$required_capability = apply_filters( 'woocommerce_dismiss_admin_notice_capability', 'manage_woocommerce', $notice_name );
[307] Fix | Delete
[308] Fix | Delete
if ( ! current_user_can( $required_capability ) ) {
[309] Fix | Delete
wp_die( esc_html__( 'You don&#8217;t have permission to do this.', 'woocommerce' ) );
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
self::hide_notice( $notice_name );
[313] Fix | Delete
}
[314] Fix | Delete
}
[315] Fix | Delete
[316] Fix | Delete
/**
[317] Fix | Delete
* Hide a single notice.
[318] Fix | Delete
*
[319] Fix | Delete
* @param string $name Notice name.
[320] Fix | Delete
* @return void
[321] Fix | Delete
*/
[322] Fix | Delete
private static function hide_notice( $name ) {
[323] Fix | Delete
self::remove_notice( $name );
[324] Fix | Delete
[325] Fix | Delete
update_user_meta( get_current_user_id(), 'dismissed_' . $name . '_notice', true );
[326] Fix | Delete
[327] Fix | Delete
do_action( 'woocommerce_hide_' . $name . '_notice' );
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
/**
[331] Fix | Delete
* Check if a given user has dismissed a given admin notice.
[332] Fix | Delete
*
[333] Fix | Delete
* @since 8.5.0
[334] Fix | Delete
*
[335] Fix | Delete
* @param string $name The name of the admin notice to check.
[336] Fix | Delete
* @param int|null $user_id User id, or null for the current user.
[337] Fix | Delete
* @return bool True if the user has dismissed the notice.
[338] Fix | Delete
*/
[339] Fix | Delete
public static function user_has_dismissed_notice( string $name, ?int $user_id = null ): bool {
[340] Fix | Delete
return (bool) get_user_meta( $user_id ?? get_current_user_id(), "dismissed_{$name}_notice", true );
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
/**
[344] Fix | Delete
* Add notices + styles if needed.
[345] Fix | Delete
*
[346] Fix | Delete
* @return void
[347] Fix | Delete
*/
[348] Fix | Delete
public static function add_notices() {
[349] Fix | Delete
$notices = self::get_notices();
[350] Fix | Delete
[351] Fix | Delete
if ( empty( $notices ) ) {
[352] Fix | Delete
return;
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
require_once WC_ABSPATH . 'includes/admin/wc-admin-functions.php';
[356] Fix | Delete
[357] Fix | Delete
$screen = get_current_screen();
[358] Fix | Delete
$screen_id = $screen ? $screen->id : '';
[359] Fix | Delete
$show_on_screens = array(
[360] Fix | Delete
'dashboard',
[361] Fix | Delete
'plugins',
[362] Fix | Delete
);
[363] Fix | Delete
[364] Fix | Delete
// Notices should only show on WooCommerce screens, the main dashboard, and on the plugins screen.
[365] Fix | Delete
if ( ! in_array( $screen_id, wc_get_screen_ids(), true ) && ! in_array( $screen_id, $show_on_screens, true ) ) {
[366] Fix | Delete
return;
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', WC_PLUGIN_FILE ), array(), Constants::get_constant( 'WC_VERSION' ) );
[370] Fix | Delete
[371] Fix | Delete
// Add RTL support.
[372] Fix | Delete
wp_style_add_data( 'woocommerce-activation', 'rtl', 'replace' );
[373] Fix | Delete
[374] Fix | Delete
foreach ( $notices as $notice ) {
[375] Fix | Delete
if ( ! empty( self::$core_notices[ $notice ] ) && apply_filters( 'woocommerce_show_admin_notice', true, $notice ) ) {
[376] Fix | Delete
add_action( 'admin_notices', array( __CLASS__, self::$core_notices[ $notice ] ) );
[377] Fix | Delete
} else {
[378] Fix | Delete
add_action( 'admin_notices', array( __CLASS__, 'output_custom_notices' ) );
[379] Fix | Delete
}
[380] Fix | Delete
}
[381] Fix | Delete
}
[382] Fix | Delete
[383] Fix | Delete
/**
[384] Fix | Delete
* Add a custom notice.
[385] Fix | Delete
*
[386] Fix | Delete
* @param string $name Notice name.
[387] Fix | Delete
* @param string $notice_html Notice HTML.
[388] Fix | Delete
* @return void
[389] Fix | Delete
*/
[390] Fix | Delete
public static function add_custom_notice( $name, $notice_html ) {
[391] Fix | Delete
self::add_notice( $name );
[392] Fix | Delete
update_option( 'woocommerce_admin_notice_' . $name, wp_kses_post( $notice_html ) );
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
/**
[396] Fix | Delete
* Output any stored custom notices.
[397] Fix | Delete
*
[398] Fix | Delete
* @return void
[399] Fix | Delete
*/
[400] Fix | Delete
public static function output_custom_notices() {
[401] Fix | Delete
$notices = self::get_notices();
[402] Fix | Delete
[403] Fix | Delete
if ( ! empty( $notices ) ) {
[404] Fix | Delete
foreach ( $notices as $notice ) {
[405] Fix | Delete
if ( empty( self::$core_notices[ $notice ] ) ) {
[406] Fix | Delete
$notice_html = get_option( 'woocommerce_admin_notice_' . $notice );
[407] Fix | Delete
[408] Fix | Delete
if ( $notice_html ) {
[409] Fix | Delete
include __DIR__ . '/views/html-notice-custom.php';
[410] Fix | Delete
}
[411] Fix | Delete
}
[412] Fix | Delete
}
[413] Fix | Delete
}
[414] Fix | Delete
}
[415] Fix | Delete
[416] Fix | Delete
/**
[417] Fix | Delete
* If we need to update the database, include a message with the DB update button.
[418] Fix | Delete
*
[419] Fix | Delete
* @return void
[420] Fix | Delete
*/
[421] Fix | Delete
public static function update_notice() {
[422] Fix | Delete
$screen = get_current_screen();
[423] Fix | Delete
$screen_id = $screen ? $screen->id : '';
[424] Fix | Delete
if ( WC()->is_wc_admin_active() && in_array( $screen_id, wc_get_screen_ids(), true ) ) {
[425] Fix | Delete
return;
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
if ( WC_Install::needs_db_update() ) {
[429] Fix | Delete
$next_scheduled_date = WC()->queue()->get_next( 'woocommerce_run_update_callback', null, 'woocommerce-db-updates' );
[430] Fix | Delete
[431] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[432] Fix | Delete
if ( $next_scheduled_date || ! empty( $_GET['do_update_woocommerce'] ) ) {
[433] Fix | Delete
include __DIR__ . '/views/html-notice-updating.php';
[434] Fix | Delete
} else {
[435] Fix | Delete
include __DIR__ . '/views/html-notice-update.php';
[436] Fix | Delete
}
[437] Fix | Delete
} else {
[438] Fix | Delete
include __DIR__ . '/views/html-notice-updated.php';
[439] Fix | Delete
}
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
/**
[443] Fix | Delete
* If we have just installed, show a message with the install pages button.
[444] Fix | Delete
*
[445] Fix | Delete
* @deprecated 4.6.0
[446] Fix | Delete
* @return void
[447] Fix | Delete
*/
[448] Fix | Delete
public static function install_notice() {
[449] Fix | Delete
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', esc_html__( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
[450] Fix | Delete
}
[451] Fix | Delete
[452] Fix | Delete
/**
[453] Fix | Delete
* Show a notice highlighting bad template files.
[454] Fix | Delete
*
[455] Fix | Delete
* @return void
[456] Fix | Delete
*/
[457] Fix | Delete
public static function template_file_check_notice() {
[458] Fix | Delete
$core_templates = WC_Admin_Status::scan_template_files( WC()->plugin_path() . '/templates' );
[459] Fix | Delete
$outdated = false;
[460] Fix | Delete
[461] Fix | Delete
foreach ( $core_templates as $file ) {
[462] Fix | Delete
[463] Fix | Delete
$theme_file = false;
[464] Fix | Delete
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
[465] Fix | Delete
$theme_file = get_stylesheet_directory() . '/' . $file;
[466] Fix | Delete
} elseif ( file_exists( get_stylesheet_directory() . '/' . WC()->template_path() . $file ) ) {
[467] Fix | Delete
$theme_file = get_stylesheet_directory() . '/' . WC()->template_path() . $file;
[468] Fix | Delete
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
[469] Fix | Delete
$theme_file = get_template_directory() . '/' . $file;
[470] Fix | Delete
} elseif ( file_exists( get_template_directory() . '/' . WC()->template_path() . $file ) ) {
[471] Fix | Delete
$theme_file = get_template_directory() . '/' . WC()->template_path() . $file;
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
if ( false !== $theme_file ) {
[475] Fix | Delete
$core_version = WC_Admin_Status::get_file_version( WC()->plugin_path() . '/templates/' . $file );
[476] Fix | Delete
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
[477] Fix | Delete
[478] Fix | Delete
if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
[479] Fix | Delete
$outdated = true;
[480] Fix | Delete
break;
[481] Fix | Delete
}
[482] Fix | Delete
}
[483] Fix | Delete
}
[484] Fix | Delete
[485] Fix | Delete
if ( $outdated ) {
[486] Fix | Delete
include __DIR__ . '/views/html-notice-template-check.php';
[487] Fix | Delete
} else {
[488] Fix | Delete
self::remove_notice( 'template_files' );
[489] Fix | Delete
}
[490] Fix | Delete
}
[491] Fix | Delete
[492] Fix | Delete
/**
[493] Fix | Delete
* Show a notice asking users to convert to shipping zones.
[494] Fix | Delete
*
[495] Fix | Delete
* @todo remove in 4.0.0
[496] Fix | Delete
* @return void
[497] Fix | Delete
*/
[498] Fix | Delete
public static function legacy_shipping_notice() {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function