Automattic\WooCommerce\Internal\Features
FeaturesController::process_updated_option()
Handler for the updated_option
It fires FEATURE_ENABLED_CHANGED_ACTION when a feature is enabled or disabled.
Метод класса: FeaturesController{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
$FeaturesController = new FeaturesController(); $FeaturesController->process_updated_option( $option, $old_value, $value );
- $option(строка) (обязательный)
- The option that has been modified.
- $old_value(разное) (обязательный)
- The old value of the option.
- $value(разное) (обязательный)
- The new value of the option.
Код FeaturesController::process_updated_option() FeaturesController::process updated option WC 9.6.0
public function process_updated_option( string $option, $old_value, $value ) { $matches = array(); $is_default_key = preg_match( '/^woocommerce_feature_([a-zA-Z0-9_]+)_enabled$/', $option, $matches ); $features_with_custom_keys = array_filter( $this->get_feature_definitions(), function ( $feature ) { return ! empty( $feature['option_key'] ); } ); $custom_keys = wp_list_pluck( $features_with_custom_keys, 'option_key' ); if ( ! $is_default_key && ! in_array( $option, $custom_keys, true ) ) { return; } if ( $value === $old_value ) { return; } $feature_id = ''; if ( $is_default_key ) { $feature_id = $matches[1]; } elseif ( in_array( $option, $custom_keys, true ) ) { $feature_id = array_search( $option, $custom_keys, true ); } if ( ! $feature_id ) { return; } /** * Action triggered when a feature is enabled or disabled (the value of the corresponding setting option is changed). * * @param string $feature_id The id of the feature. * @param bool $enabled True if the feature has been enabled, false if it has been disabled. * * @since 7.0.0 */ do_action( self::FEATURE_ENABLED_CHANGED_ACTION, $feature_id, 'yes' === $value ); }