/** * Constructor. * * Supplied $args override class property defaults. * * If $args['fields'] is not defined, use the $id as the field ID. * * @since 3.4.0 * * @param WP_Customize_Manager $manager * @param string $id * @param array $args */ public function __construct($manager, $id, $args = array()) { $this->manager = $manager; $this->object_name = $this->manager->get_customizer_object_name(); // Backwards compatibility for old property names foreach ($this->property_map as $backcompat_arg => $actual_arg) { if (isset($args[$backcompat_arg])) { $args[$actual_arg] = $args[$backcompat_arg]; unset($args[$backcompat_arg]); } } parent::__construct($this->object_type, $id, $args); if (empty($this->active_callback)) { $this->active_callback = array($this, 'active_callback'); } if (!has_action('fields_render_control_' . $this->object_type, array('WP_Customize_Control', 'customize_render_control'))) { add_action('fields_render_control_' . $this->object_type, array('WP_Customize_Control', 'customize_render_control')); } if (!has_filter('fields_control_active_' . $this->object_type, array('WP_Customize_Control', 'customize_control_active'))) { add_filter('fields_control_active_' . $this->object_type, array('WP_Customize_Control', 'customize_control_active'), 10, 2); } if ('' !== $this->id) { add_action('fields_render_control_' . $this->object_type . '_' . $this->object_name . '_' . $this->id, array('WP_Customize_Control', 'customize_render_control_id')); } }
/** * Constructor. * * Any supplied $args override class property defaults. * * @since 4.0.0 * * @param WP_Customize_Manager $manager Customizer bootstrap instance. * @param string $id An specific ID for the panel. * @param array $args Panel arguments. */ public function __construct($manager, $id, $args = array()) { $this->manager = $manager; $this->object_name = $this->manager->get_customizer_object_name(); parent::__construct($this->object_type, $id, $args); if (!has_filter("fields_api_screen_active_{$this->object_type}", array('WP_Customize_Panel', 'customize_panel_active'))) { add_filter("fields_api_screen_active_{$this->object_type}", array('WP_Customize_Panel', 'customize_panel_active'), 10, 2); } if (!has_action("fields_api_render_screen_{$this->object_type}", array('WP_Customize_Panel', 'customize_render_panel'))) { add_action("fields_api_render_screen_{$this->object_type}", array('WP_Customize_Panel', 'customize_render_panel')); } if ('' !== $this->id) { add_action("fields_api_render_screen_{$this->object_type}_{$this->object_name}_{$this->id}", array($this, 'customize_render_panel_id')); } }
/** * 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')); }
/** * Constructor. * * Any supplied $args override class property defaults. * * @since 3.4.0 * * @param WP_Customize_Manager $manager Customizer bootstrap instance. * @param string $id An specific ID of the section. * @param array $args Section arguments. */ public function __construct($manager, $id, $args = array()) { $this->manager = $manager; $this->object_name = $manager->get_customizer_object_name(); // Backwards compatibility for old property names foreach ($this->property_map as $backcompat_arg => $actual_arg) { if (isset($args[$backcompat_arg])) { $args[$actual_arg] = $args[$backcompat_arg]; unset($args[$backcompat_arg]); } } parent::__construct($this->object_type, $id, $args); if (!has_action("fields_api_section_active_{$this->object_type}", array('WP_Customize_Section', 'customize_section_active'))) { add_action("fields_api_section_active_{$this->object_type}", array('WP_Customize_Section', 'customize_section_active'), 10, 2); } if (!has_action("fields_api_render_section_{$this->object_type}", array('WP_Customize_Section', 'customize_render_section'))) { add_action("fields_api_render_section_{$this->object_type}", array('WP_Customize_Section', 'customize_render_section')); } if ('' !== $this->id) { add_action("fields_api_render_section_{$this->object_type}_{$this->object_name}_{$this->id}", array($this, 'customize_render_section_id')); } }