/** * Set up our control. * * @since 0.9.0 * @access public * @param object $manager * @return void */ public function __construct($manager) { /* Let WP handle this. */ parent::__construct($manager); /* Allow themes to register custom backgrounds. */ $this->default_backgrounds = apply_filters('omega_default_backgrounds', $this->default_backgrounds); /* WordPress will only output the 'default' tab if there's a default image. Make sure it gets added. */ if (!$this->setting->default && !empty($this->default_backgrounds)) { $this->add_tab('default', _x('Default', 'theme customizer tab', 'omega'), array($this, 'tab_default_background')); } }
/** * Refresh the parameters passed to the JavaScript via JSON. * * @since 3.4.0 * @uses WP_Customize_Control::to_json() */ public function to_json() { parent::to_json(); $value = $this->value(); if (is_object($this->setting)) { $current_image = array('id' => 1, 'url' => $value, 'type' => 'image', 'icon' => wp_mime_type_icon('image'), 'title' => basename($value), 'sizes' => array('full' => array('url' => $value))); if ($value) { // Get the attachment model for the existing file. $attachment_id = attachment_url_to_postid($value); if ($attachment_id) { $this->json['attachment'] = wp_prepare_attachment_for_js($attachment_id); } else { $this->json['attachment'] = $current_image; } } } }
/** * Constructor * * @since 0.9 */ public function __construct($manager, $id = false, $args = array()) { parent::__construct($manager); // Presets array $this->presets = isset($args['presets']) ? $args['presets'] : array(); // Add presets tab (multiple) if ($this->presets) { $this->add_tab('ctc_presets', _x('Presets', 'customizer', 'church-theme-framework'), array($this, 'tab_preset_backgrounds')); } // Remove "Default" tab - user can select first in presets $this->remove_tab('default'); }