/** * Refresh the parameters passed to the JavaScript via JSON. * * @since 3.4.0 * @uses WP_Customize_Upload_Control::to_json() */ public function to_json() { parent::to_json(); $this->json['statuses'] = $this->statuses; }
/** * Add custom parameters to pass to the JS via JSON. * * @since 1.0.0 * @access public * @return void */ public function to_json() { parent::to_json(); $background_choices = $this->background_choices; $field_labels = $this->field_labels; // Loop through each of the settings and set up the data for it. foreach ($this->settings as $setting_key => $setting_id) { $this->json[$setting_key] = array('link' => $this->get_link($setting_key), 'value' => $this->value($setting_key), 'label' => isset($field_labels[$setting_key]) ? $field_labels[$setting_key] : ''); if ('image_url' === $setting_key) { if ($this->value($setting_key)) { // Get the attachment model for the existing file. $attachment_id = attachment_url_to_postid($this->value($setting_key)); if ($attachment_id) { $this->json['attachment'] = wp_prepare_attachment_for_js($attachment_id); } } } elseif ('repeat' === $setting_key) { $this->json[$setting_key]['choices'] = $background_choices['repeat']; } elseif ('size' === $setting_key) { $this->json[$setting_key]['choices'] = $background_choices['size']; } elseif ('position' === $setting_key) { $this->json[$setting_key]['choices'] = $background_choices['position']; } elseif ('attach' === $setting_key) { $this->json[$setting_key]['choices'] = $background_choices['attach']; } } }