/** * Constructor. * * Any supplied $args override class property defaults. * * @since 3.4.0 * * @param WP_Customize_Manager $manager * @param string $id An specific ID of the setting. Can be a * theme mod or option name. * @param array $args Setting arguments. */ public function __construct($manager, $id, $args = array()) { if (isset($args['type'])) { $this->type = $args['type']; } $this->manager = $manager; parent::__construct($this->type, $id, $args); // Add compatibility hooks add_action("fields_preview_{$this->id}", array($this, 'customize_preview_id')); add_action("fields_preview_{$this->type}", array($this, 'customize_preview_type')); add_action('fields_save_' . $this->type . '_' . $this->id_data['base'], array($this, 'customize_save')); add_filter("fields_sanitize_{$this->type}_{$this->id}", array($this, 'customize_sanitize')); add_filter("fields_sanitize_js_{$this->type}_{$this->id}", array($this, 'customize_sanitize_js_value')); add_action("fields_update_{$this->type}", array($this, 'customize_update')); add_action('fields_value_' . $this->type . '_' . $this->id_data['base'], array($this, 'customize_value')); }
/** * Constructor. * * Any supplied $args override class property defaults. * * @since 3.4.0 * * @param WP_Customize_Manager $manager * @param string $id An specific ID of the setting. Can be a * theme mod or option name. * @param array $args Setting arguments. */ public function __construct($manager, $id, $args = array()) { $this->manager = $manager; $this->object_name = $this->manager->get_customizer_object_name(); // Backwards compatibility for callbacks on old filters, // Remove from args so they don't get handled by WP Fields API $sanitize_callback = null; $sanitize_js_callback = null; if (!empty($args['sanitize_callback'])) { $sanitize_callback = $args['sanitize_callback']; unset($args['sanitize_callback']); } if (!empty($args['sanitize_js_callback'])) { $sanitize_js_callback = $args['sanitize_js_callback']; unset($args['sanitize_js_callback']); } parent::__construct($this->object_type, $id, $args); if ($sanitize_callback) { add_filter("customize_sanitize_{$this->id}", $sanitize_callback); $this->sanitize_callback = $sanitize_callback; } if ($sanitize_js_callback) { add_filter("customize_sanitize_js_{$this->id}", $sanitize_js_callback); $this->sanitize_js_callback = $sanitize_js_callback; } // @todo Figure out proper backwards compat for $this->type vs $this->object_type in hooks // @todo Add methods that hook into $this->object_type hooks instead, and run $this->type logic for backwards compat // Add compatibility hooks add_filter("fields_sanitize_{$this->object_type}_{$this->object_name}_{$this->id}", array($this, 'customize_sanitize')); add_filter("fields_sanitize_js_{$this->object_type}_{$this->object_name}_{$this->id}", array($this, 'customize_sanitize_js_value')); }