Fixed PHPCS violations
This commit is contained in:
parent
8350f88f57
commit
b270bd2c5b
|
@ -2,15 +2,11 @@
|
|||
/**
|
||||
* Display notices in admin
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 2.3.0
|
||||
* @package WooCommerce\Admin
|
||||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Admin_Notices Class.
|
||||
|
@ -86,7 +82,7 @@ class WC_Admin_Notices {
|
|||
$simplify_options = get_option( 'woocommerce_simplify_commerce_settings', array() );
|
||||
$location = wc_get_base_location();
|
||||
|
||||
if ( ! class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) && ! empty( $simplify_options['enabled'] ) && 'yes' === $simplify_options['enabled'] && in_array( $location['country'], apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ) ) ) {
|
||||
if ( ! class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) && ! empty( $simplify_options['enabled'] ) && 'yes' === $simplify_options['enabled'] && in_array( $location['country'], apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ), true ) ) {
|
||||
WC_Admin_Notices::add_notice( 'simplify_commerce' );
|
||||
}
|
||||
|
||||
|
@ -96,7 +92,7 @@ class WC_Admin_Notices {
|
|||
/**
|
||||
* Show a notice.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name Notice name.
|
||||
*/
|
||||
public static function add_notice( $name ) {
|
||||
self::$notices = array_unique( array_merge( self::get_notices(), array( $name ) ) );
|
||||
|
@ -105,7 +101,7 @@ class WC_Admin_Notices {
|
|||
/**
|
||||
* Remove a notice from being displayed.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name Notice name.
|
||||
*/
|
||||
public static function remove_notice( $name ) {
|
||||
self::$notices = array_diff( self::get_notices(), array( $name ) );
|
||||
|
@ -115,27 +111,27 @@ class WC_Admin_Notices {
|
|||
/**
|
||||
* See if a notice is being shown.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name Notice name.
|
||||
* @return boolean
|
||||
*/
|
||||
public static function has_notice( $name ) {
|
||||
return in_array( $name, self::get_notices() );
|
||||
return in_array( $name, self::get_notices(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide a notice if the GET variable is set.
|
||||
*/
|
||||
public static function hide_notices() {
|
||||
if ( isset( $_GET['wc-hide-notice'] ) && isset( $_GET['_wc_notice_nonce'] ) ) {
|
||||
if ( ! wp_verify_nonce( $_GET['_wc_notice_nonce'], 'woocommerce_hide_notices_nonce' ) ) {
|
||||
wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
|
||||
if ( isset( $_GET['wc-hide-notice'] ) && isset( $_GET['_wc_notice_nonce'] ) ) { // WPCS: input var ok, CSRF ok.
|
||||
if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_wc_notice_nonce'] ) ), 'woocommerce_hide_notices_nonce' ) ) { // WPCS: input var ok, CSRF ok.
|
||||
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'manage_woocommerce' ) ) {
|
||||
wp_die( __( 'You don’t have permission to do this.', 'woocommerce' ) );
|
||||
wp_die( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
$hide_notice = sanitize_text_field( $_GET['wc-hide-notice'] );
|
||||
$hide_notice = sanitize_text_field( wp_unslash( $_GET['wc-hide-notice'] ) ); // WPCS: input var ok, CSRF ok.
|
||||
|
||||
self::remove_notice( $hide_notice );
|
||||
|
||||
|
@ -154,7 +150,7 @@ class WC_Admin_Notices {
|
|||
if ( ! empty( $notices ) ) {
|
||||
wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', WC_PLUGIN_FILE ), array(), WC_VERSION );
|
||||
|
||||
// Add RTL support
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'woocommerce-activation', 'rtl', 'replace' );
|
||||
|
||||
foreach ( $notices as $notice ) {
|
||||
|
@ -170,8 +166,8 @@ class WC_Admin_Notices {
|
|||
/**
|
||||
* Add a custom notice.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $notice_html
|
||||
* @param string $name Notice name.
|
||||
* @param string $notice_html Notice HTML.
|
||||
*/
|
||||
public static function add_custom_notice( $name, $notice_html ) {
|
||||
self::add_notice( $name );
|
||||
|
@ -190,7 +186,7 @@ class WC_Admin_Notices {
|
|||
$notice_html = get_option( 'woocommerce_admin_notice_' . $notice );
|
||||
|
||||
if ( $notice_html ) {
|
||||
include 'views/html-notice-custom.php';
|
||||
include dirname( __FILE__ ) . '/views/html-notice-custom.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,13 +199,13 @@ class WC_Admin_Notices {
|
|||
public static function update_notice() {
|
||||
if ( version_compare( get_option( 'woocommerce_db_version' ), WC_VERSION, '<' ) ) {
|
||||
$updater = new WC_Background_Updater();
|
||||
if ( $updater->is_updating() || ! empty( $_GET['do_update_woocommerce'] ) ) {
|
||||
include 'views/html-notice-updating.php';
|
||||
if ( $updater->is_updating() || ! empty( $_GET['do_update_woocommerce'] ) ) { // WPCS: input var ok, CSRF ok.
|
||||
include dirname( __FILE__ ) . '/views/html-notice-updating.php';
|
||||
} else {
|
||||
include 'views/html-notice-update.php';
|
||||
include dirname( __FILE__ ) . '/views/html-notice-update.php';
|
||||
}
|
||||
} else {
|
||||
include 'views/html-notice-updated.php';
|
||||
include dirname( __FILE__ ) . '/views/html-notice-updated.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +213,7 @@ class WC_Admin_Notices {
|
|||
* If we have just installed, show a message with the install pages button.
|
||||
*/
|
||||
public static function install_notice() {
|
||||
include 'views/html-notice-install.php';
|
||||
include dirname( __FILE__ ) . '/views/html-notice-install.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -229,7 +225,7 @@ class WC_Admin_Notices {
|
|||
wc_deprecated_function( 'WC_Admin_Notices::theme_check_notice', '3.3.0' );
|
||||
|
||||
if ( ! current_theme_supports( 'woocommerce' ) ) {
|
||||
include 'views/html-notice-theme-support.php';
|
||||
include dirname( __FILE__ ) . '/views/html-notice-theme-support.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,7 +261,7 @@ class WC_Admin_Notices {
|
|||
}
|
||||
|
||||
if ( $outdated ) {
|
||||
include 'views/html-notice-template-check.php';
|
||||
include dirname( __FILE__ ) . '/views/html-notice-template-check.php';
|
||||
} else {
|
||||
self::remove_notice( 'template_files' );
|
||||
}
|
||||
|
@ -286,7 +282,7 @@ class WC_Admin_Notices {
|
|||
}
|
||||
|
||||
if ( $enabled ) {
|
||||
include 'views/html-notice-legacy-shipping.php';
|
||||
include dirname( __FILE__ ) . '/views/html-notice-legacy-shipping.php';
|
||||
} else {
|
||||
self::remove_notice( 'template_files' );
|
||||
}
|
||||
|
@ -296,12 +292,12 @@ class WC_Admin_Notices {
|
|||
* No shipping methods.
|
||||
*/
|
||||
public static function no_shipping_methods_notice() {
|
||||
if ( wc_shipping_enabled() && ( empty( $_GET['page'] ) || empty( $_GET['tab'] ) || 'wc-settings' !== $_GET['page'] || 'shipping' !== $_GET['tab'] ) ) {
|
||||
if ( wc_shipping_enabled() && ( empty( $_GET['page'] ) || empty( $_GET['tab'] ) || 'wc-settings' !== $_GET['page'] || 'shipping' !== $_GET['tab'] ) ) { // WPCS: input var ok, CSRF ok.
|
||||
$product_count = wp_count_posts( 'product' );
|
||||
$method_count = wc_get_shipping_method_count();
|
||||
|
||||
if ( $product_count->publish > 0 && 0 === $method_count ) {
|
||||
include 'views/html-notice-no-shipping-methods.php';
|
||||
include dirname( __FILE__ ) . '/views/html-notice-no-shipping-methods.php';
|
||||
}
|
||||
|
||||
if ( $method_count > 0 ) {
|
||||
|
@ -316,12 +312,12 @@ class WC_Admin_Notices {
|
|||
public static function simplify_commerce_notice() {
|
||||
$location = wc_get_base_location();
|
||||
|
||||
if ( class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) || ! in_array( $location['country'], apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ) ) ) {
|
||||
if ( class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) || ! in_array( $location['country'], apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ), true ) ) {
|
||||
self::remove_notice( 'simplify_commerce' );
|
||||
return;
|
||||
}
|
||||
if ( empty( $_GET['action'] ) ) {
|
||||
include 'views/html-notice-simplify-commerce.php';
|
||||
if ( empty( $_GET['action'] ) ) { // WPCS: input var ok, CSRF ok.
|
||||
include dirname( __FILE__ ) . '/views/html-notice-simplify-commerce.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,7 +325,7 @@ class WC_Admin_Notices {
|
|||
* Notice shown when regenerating thumbnails background process is running.
|
||||
*/
|
||||
public static function regenerating_thumbnails_notice() {
|
||||
include 'views/html-notice-regenerating-thumbnails.php';
|
||||
include dirname( __FILE__ ) . '/views/html-notice-regenerating-thumbnails.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue