WC_Settings_Tracking::add_option_to_list
Add a WooCommerce option name to our allowed options list and attach the update_option Rather than inspecting every updated option and pattern matching for "woocommerce", just build a dynamic list for WooCommerce options that might get updated.
Method of the class: WC_Settings_Tracking{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_Settings_Tracking = new WC_Settings_Tracking(); $WC_Settings_Tracking->add_option_to_list( $option );
- $option(array) (required)
- WooCommerce option (config) that might get updated.
WC_Settings_Tracking::add_option_to_list() WC Settings Tracking::add option to list code WC 10.9.1
public function add_option_to_list( $option ) {
$this->allowed_options[] = $option['id'];
if ( isset( $option['options'] ) ) {
$this->dropdown_menu_options[] = $option['id'];
}
// Delay attaching this action since it could get fired a lot.
if ( false === has_action( 'update_option', array( $this, 'track_setting_change' ) ) ) {
add_action( 'update_option', array( $this, 'track_setting_change' ), 10, 3 );
}
}