WPSEO_Option::__construct()
Add all the actions and filters for the option.
Метод класса: WPSEO_Option{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->__construct();
Код WPSEO_Option::__construct() WPSEO Option:: construct Yoast 24.9
protected function __construct() { /* Add filters which get applied to the get_options() results. */ $this->add_default_filters(); // Return defaults if option not set. $this->add_option_filters(); // Merge with defaults if option *is* set. if ( $this->multisite_only !== true ) { /** * The option validation routines remove the default filters to prevent failing * to insert an option if it's new. Let's add them back afterwards. */ add_action( 'add_option', [ $this, 'add_default_filters_if_same_option' ] ); // Adding back after INSERT. add_action( 'update_option', [ $this, 'add_default_filters_if_same_option' ] ); add_filter( 'pre_update_option', [ $this, 'add_default_filters_if_not_changed' ], PHP_INT_MAX, 3 ); // Refills the cache when the option has been updated. add_action( 'update_option_' . $this->option_name, [ 'WPSEO_Options', 'clear_cache' ], 10 ); } elseif ( is_multisite() ) { /* * The option validation routines remove the default filters to prevent failing * to insert an option if it's new. Let's add them back afterwards. * * For site_options, this method is not foolproof as these actions are not fired * on an insert/update failure. Please use the WPSEO_Options::update_site_option() method * for updating site options to make sure the filters are in place. */ add_action( 'add_site_option_' . $this->option_name, [ $this, 'add_default_filters' ] ); add_action( 'update_site_option_' . $this->option_name, [ $this, 'add_default_filters' ] ); add_filter( 'pre_update_site_option_' . $this->option_name, [ $this, 'add_default_filters_if_not_changed' ], PHP_INT_MAX, 3 ); // Refills the cache when the option has been updated. add_action( 'update_site_option_' . $this->option_name, [ 'WPSEO_Options', 'clear_cache' ], 1, 0 ); } /* * Make sure the option will always get validated, independently of register_setting() * (only available on back-end). */ add_filter( 'sanitize_option_' . $this->option_name, [ $this, 'validate' ] ); /* Register our option for the admin pages */ add_action( 'admin_init', [ $this, 'register_setting' ] ); /* Set option group name if not given */ if ( ! isset( $this->group_name ) || $this->group_name === '' ) { $this->group_name = 'yoast_' . $this->option_name . '_options'; } /* Translate some defaults as early as possible - textdomain is loaded in init on priority 1. */ if ( method_exists( $this, 'translate_defaults' ) ) { add_action( 'init', [ $this, 'translate_defaults' ], 2 ); } /** * Enrich defaults once custom post types and taxonomies have been registered * which is normally done on the init action. * * @todo [JRF/testers] Verify that none of the options which are only available after * enrichment are used before the enriching. */ if ( method_exists( $this, 'enrich_defaults' ) ) { add_action( 'init', [ $this, 'enrich_defaults' ], 99 ); } }