WC_Product_Usage_Notice::get_current_notice_rule
Get product usage notice rule from a given WP_Screen object.
Method of the class: WC_Product_Usage_Notice{}
No Hooks.
Returns
Array.
Usage
$result = WC_Product_Usage_Notice::get_current_notice_rule( $screen );
- $screen(WP_Screen) (required)
- Current \WP_Screen object.
WC_Product_Usage_Notice::get_current_notice_rule() WC Product Usage Notice::get current notice rule code WC 10.3.3
private static function get_current_notice_rule( $screen ) {
foreach ( self::$product_usage_notice_rules['products'] as $product_id => $rule ) {
if ( ! isset( $rule['screens'][ $screen->id ] ) ) {
continue;
}
// Check query strings.
if ( ! self::query_string_matches( $screen, $rule ) ) {
continue;
}
$product_id = absint( $product_id );
$state = WC_Helper::get_product_subscription_state( $product_id );
if ( $state['expired'] || $state['unregistered'] ) {
$rule['id'] = $product_id;
$rule['state'] = $state;
return $rule;
}
}
return array();
}