Filter invalid statuses from saved statuses (https://github.com/woocommerce/woocommerce-admin/pull/3268)
This commit is contained in:
parent
790e5f59d3
commit
6bb8015cf2
|
@ -64,6 +64,8 @@ class Loader {
|
|||
add_action( 'in_admin_header', array( __CLASS__, 'embed_page_header' ) );
|
||||
add_filter( 'woocommerce_settings_groups', array( __CLASS__, 'add_settings_group' ) );
|
||||
add_filter( 'woocommerce_settings-wc_admin', array( __CLASS__, 'add_settings' ) );
|
||||
add_filter( 'option_woocommerce_actionable_order_statuses', array( __CLASS__, 'filter_invalid_statuses' ) );
|
||||
add_filter( 'option_woocommerce_excluded_report_order_statuses', array( __CLASS__, 'filter_invalid_statuses' ) );
|
||||
add_action( 'admin_head', array( __CLASS__, 'remove_notices' ) );
|
||||
add_action( 'admin_notices', array( __CLASS__, 'inject_before_notices' ), -9999 );
|
||||
add_action( 'admin_notices', array( __CLASS__, 'inject_after_notices' ), PHP_INT_MAX );
|
||||
|
@ -382,7 +384,7 @@ class Loader {
|
|||
wp_enqueue_style( 'wc-material-icons' );
|
||||
|
||||
// Use server-side detection to prevent unneccessary stylesheet loading in other browsers.
|
||||
$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; // WPCS: sanitization ok.
|
||||
$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; // phpcs:ignore sanitization ok.
|
||||
preg_match( '/MSIE (.*?);/', $user_agent, $matches );
|
||||
if ( count( $matches ) < 2 ) {
|
||||
preg_match( '/Trident\/\d{1,2}.\d{1,2}; rv:([0-9]*)/', $user_agent, $matches );
|
||||
|
@ -732,6 +734,21 @@ class Loader {
|
|||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter invalid statuses from saved settings to avoid removed statuses throwing errors.
|
||||
*
|
||||
* @param array|null $value Saved order statuses.
|
||||
* @return array|null
|
||||
*/
|
||||
public static function filter_invalid_statuses( $value ) {
|
||||
if ( is_array( $value ) ) {
|
||||
$valid_statuses = array_keys( self::get_order_statuses( wc_get_order_statuses() ) );
|
||||
$value = array_intersect( $value, $valid_statuses );
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets custom settings used for WC Admin.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue