to_json() public method

Refresh the parameters passed to the JavaScript via JSON.
Since: 3.4.0
public to_json ( )
 /**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  * @see WP_Customize_Media_Control::to_json()
  * @since 0.1
  */
 public function to_json()
 {
     parent::to_json();
     $clc = CLC_Content_Layout_Control();
     $this->json['components'] = array_intersect($this->components, array_keys($clc->components));
     $this->json['i18n'] = $this->i18n;
 }
 /**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  * @since 3.4.0
  * @since 4.2.0 Moved from WP_Customize_Upload_Control.
  *
  * @see WP_Customize_Control::to_json()
  */
 public function to_json()
 {
     parent::to_json();
     $this->json['label'] = html_entity_decode($this->label, ENT_QUOTES, get_bloginfo('charset'));
     $this->json['mime_type'] = $this->mime_type;
     $this->json['button_labels'] = $this->button_labels;
     $this->json['canUpload'] = current_user_can('upload_files');
     $value = $this->value();
     if (is_object($this->setting)) {
         if ($this->setting->default) {
             // Fake an attachment model - needs all fields used by template.
             // Note that the default value must be a URL, NOT an attachment ID.
             $type = in_array(substr($this->setting->default, -3), array('jpg', 'png', 'gif', 'bmp')) ? 'image' : 'document';
             $default_attachment = array('id' => 1, 'url' => $this->setting->default, 'type' => $type, 'icon' => wp_mime_type_icon($type), 'title' => basename($this->setting->default));
             if ('image' === $type) {
                 $default_attachment['sizes'] = array('full' => array('url' => $this->setting->default));
             }
             $this->json['defaultAttachment'] = $default_attachment;
         }
         if ($value && $this->setting->default && $value === $this->setting->default) {
             // Set the default as the attachment.
             $this->json['attachment'] = $this->json['defaultAttachment'];
         } elseif ($value) {
             $this->json['attachment'] = wp_prepare_attachment_for_js($value);
         }
     }
 }
 /**
  * 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();
     $this->json['statuses'] = $this->statuses;
     $this->json['defaultValue'] = $this->setting->default;
     $this->json['mode'] = $this->mode;
 }
 /**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  * @since 3.1.0
  * @uses WP_Customize_Control::to_json()
  */
 public function to_json()
 {
     parent::to_json();
     $this->json['posts'] = $this->get_posts();
     $this->json['postTypes'] = $this->post_types;
     $this->json['l10n'] = array('responseError' => __('An error has occurred. Please reload the page and try again.', 'huesos'));
 }
 public function to_json()
 {
     parent::to_json();
     $this->json['value'] = $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
 }
 public function to_json()
 {
     parent::to_json();
     $exported_properties = array('widget_id', 'widget_id_base', 'sidebar_id', 'width', 'height', 'is_wide', 'is_live_previewable');
     foreach ($exported_properties as $key) {
         $this->json[$key] = $this->{$key};
     }
 }
 /**
  * Refreshes the parameters passed to the JavaScript via JSON.
  *
  * @since 3.9.0
  * @access public
  */
 public function to_json()
 {
     parent::to_json();
     $exported_properties = array('sidebar_id');
     foreach ($exported_properties as $key) {
         $this->json[$key] = $this->{$key};
     }
 }
 /**
  * Add custom parameters to pass to the JS via JSON.
  *
  * @since  3.0.0
  * @access public
  * @return void
  */
 public function to_json()
 {
     parent::to_json();
     $this->json['value'] = !is_array($this->value()) ? explode(',', $this->value()) : $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['id'] = $this->id;
 }
 public function to_json()
 {
     parent::to_json();
     if (is_array($this->togglable)) {
         $valid_togglables = array_intersect_key(array_flip($this->togglable), $this->choices);
         $this->json['togglable'] = !empty($valid_togglables);
     } else {
         $this->json['togglable'] = (bool) $this->togglable;
     }
 }
 public function to_json()
 {
     parent::to_json();
     $this->json['value'] = $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['numeric_value'] = $this->numeric_value();
     $this->json['unit_value'] = $this->unit_value();
     $this->json['available_units'] = $this->get_units();
 }
 public function to_json()
 {
     parent::to_json();
     $this->json['value'] = $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['choices'] = is_array($this->choices) ? array('top' => in_array('top', $this->choices) ? true : false, 'bottom' => in_array('bottom', $this->choices) ? true : false, 'left' => in_array('left', $this->choices) ? true : false, 'right' => in_array('right', $this->choices) ? true : false, 'units' => isset($this->choices['units']) ? $this->choices['units'] : false) : array();
     $i18n = Kirki_Toolkit::i18n();
     $this->json['l10n'] = array('top' => $i18n['top'], 'bottom' => $i18n['bottom'], 'left' => $i18n['left'], 'right' => $i18n['right']);
 }
 /**
  * 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();
     $this->json['removed'] = $this->removed;
     if ($this->context) {
         $this->json['context'] = $this->context;
     }
     if ($this->extensions) {
         $this->json['extensions'] = implode(',', $this->extensions);
     }
 }
 public function to_json()
 {
     parent::to_json();
     $this->json['item_title'] = $this->item_title;
     $this->json['item_fields'] = $this->item_fields;
     $this->json['item_key'] = $this->item_key();
     $this->json['item_defaults'] = array();
     foreach ($this->item_fields as $key => $field) {
         $this->json['item_defaults'][$key] = isset($field['std']) ? $field['std'] : '';
     }
 }
 public function to_json()
 {
     parent::to_json();
     $this->json['value'] = $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['default'] = $this->setting->default;
     $this->json['choices']['min'] = isset($this->choices['min']) ? $this->choices['min'] : '0';
     $this->json['choices']['max'] = isset($this->choices['max']) ? $this->choices['max'] : '100';
     $this->json['choices']['step'] = isset($this->choices['step']) ? $this->choices['step'] : '1';
 }
 public function to_json()
 {
     parent::to_json();
     $this->json['value'] = $this->value();
     $this->json['link'] = $this->get_link();
     $this->json['description'] = $this->description;
     $this->json['subtitle'] = $this->subtitle;
     $this->json['defaultValue'] = $this->setting->default;
     $this->json['choices'] = $this->choices;
     $this->json['id'] = $this->id;
 }
 public function to_json()
 {
     parent::to_json();
     $i18n = Kirki_Toolkit::i18n();
     $this->choices = empty($this->choices) || !is_array($this->choices) ? array() : $this->choices;
     $this->choices['on'] = isset($this->choices['on']) ? $this->choices['on'] : $i18n['on'];
     $this->choices['off'] = isset($this->choices['off']) ? $this->choices['off'] : $i18n['off'];
     $this->json['id'] = $this->id;
     $this->json['value'] = $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
 }
Example #17
0
 /**
  * Add custom parameters to pass to the JS via JSON.
  *
  * @since  3.0.0
  * @access public
  * @return void
  */
 public function to_json()
 {
     parent::to_json();
     // Make sure the colors have a hash.
     foreach ($this->choices as $choice => $value) {
         $this->choices[$choice]['colors'] = array_map('maybe_hash_hex_color', $value['colors']);
     }
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['value'] = $this->value();
     $this->json['id'] = $this->id;
 }
 public function to_json()
 {
     parent::to_json();
     $i18n = Kirki_Toolkit::i18n();
     $this->json['id'] = $this->id;
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['fonts'] = $this->get_all_fonts();
     $value = $this->value();
     $this->json['value'] = array('bold' => isset($value['bold']) ? $value['bold'] : false, 'italic' => isset($value['italic']) ? $value['italic'] : false, 'underline' => isset($value['underline']) ? $value['underline'] : false, 'strikethrough' => isset($value['strikethrough']) ? $value['strikethrough'] : false, 'font-family' => isset($value['font-family']) ? $value['font-family'] : false, 'font-size' => isset($value['font-size']) ? $value['font-size'] : false, 'font-weight' => isset($value['font-weight']) ? $value['font-weight'] : false, 'line-height' => isset($value['line-height']) ? $value['line-height'] : false, 'letter-spacing' => isset($value['letter-spacing']) ? $value['letter-spacing'] : false);
     $this->json['l10n'] = array('font-family' => $i18n['font-family'], 'font-size' => $i18n['font-size'], 'font-weight' => $i18n['font-weight'], 'line-height' => $i18n['line-height'], 'letter-spacing' => $i18n['letter-spacing']);
 }
 /**
  * Add custom parameters to pass to the JS via JSON.
  *
  * @since  3.0.0
  * @access public
  * @return void
  */
 public function to_json()
 {
     parent::to_json();
     // We need to make sure we have the correct image URL.
     foreach ($this->choices as $value => $args) {
         $this->choices[$value]['url'] = esc_url(sprintf($args['url'], get_template_directory_uri(), get_stylesheet_directory_uri()));
     }
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['value'] = $this->value();
     $this->json['id'] = $this->id;
 }
 public function to_json()
 {
     parent::to_json();
     if (isset($this->default)) {
         $this->json['default'] = $this->default;
     } else {
         $this->json['default'] = $this->setting->default;
     }
     $this->json['value'] = $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['help'] = $this->help;
     $this->json['id'] = $this->id;
 }
 /**
  * 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();
     // 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($this->l10n[$setting_key]) ? $this->l10n[$setting_key] : '');
         if ('family' === $setting_key) {
             $this->json[$setting_key]['choices'] = $this->get_font_families();
         } elseif ('weight' === $setting_key) {
             $this->json[$setting_key]['choices'] = $this->get_font_weight_choices();
         } elseif ('style' === $setting_key) {
             $this->json[$setting_key]['choices'] = $this->get_font_style_choices();
         }
     }
 }
 public function to_json()
 {
     parent::to_json();
     if (!isset($this->choices['language'])) {
         $this->choices['language'] = 'css';
     }
     if (!isset($this->choices['theme'])) {
         $this->choices['theme'] = 'monokai';
     }
     if (!isset($this->choices['height'])) {
         $this->choices['height'] = 200;
     }
     $this->json['value'] = $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
 }
 /**
  * Add custom parameters to pass to the JS via JSON.
  *
  * @since  3.0.0
  * @access public
  * @return void
  */
 public function to_json()
 {
     parent::to_json();
     $choices = $group = array();
     foreach ($this->choices as $choice => $maybe_group) {
         if (is_array($maybe_group)) {
             $group[$choice] = $maybe_group;
         } else {
             $choices[$choice] = $maybe_group;
         }
     }
     $this->json['choices'] = $choices;
     $this->json['group'] = $group;
     $this->json['link'] = $this->get_link();
     $this->json['value'] = $this->value();
     $this->json['id'] = $this->id;
 }
 public function to_json()
 {
     parent::to_json();
     if (isset($this->default)) {
         $this->json['default'] = $this->default;
     } else {
         $this->json['default'] = $this->setting->default;
     }
     $this->json['js_vars'] = $this->js_vars;
     $this->json['output'] = $this->output;
     $this->json['value'] = $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['help'] = $this->help;
     $this->json['id'] = $this->id;
     $this->json['i18n'] = Kirki_Toolkit::i18n();
 }
 /**
  * Gather control params for exporting to JavaScript.
  *
  * @global array $wp_registered_widgets
  */
 public function to_json()
 {
     global $wp_registered_widgets;
     parent::to_json();
     $exported_properties = array('widget_id', 'widget_id_base', 'sidebar_id', 'width', 'height', 'is_wide');
     foreach ($exported_properties as $key) {
         $this->json[$key] = $this->{$key};
     }
     // Get the widget_control and widget_content.
     require_once ABSPATH . '/wp-admin/includes/widgets.php';
     $widget = $wp_registered_widgets[$this->widget_id];
     if (!isset($widget['params'][0])) {
         $widget['params'][0] = array();
     }
     $args = array('widget_id' => $widget['id'], 'widget_name' => $widget['name']);
     $args = wp_list_widget_controls_dynamic_sidebar(array(0 => $args, 1 => $widget['params'][0]));
     $widget_control_parts = $this->manager->widgets->get_widget_control_parts($args);
     $this->json['widget_control'] = $widget_control_parts['control'];
     $this->json['widget_content'] = $widget_control_parts['content'];
 }
 /**
  * Refresh the parameters passed to JavaScript via JSON.
  *
  * @since 4.3.0
  * @access public
  *
  * @see WP_Customize_Control::to_json()
  */
 public function to_json()
 {
     parent::to_json();
     $this->json['locationId'] = $this->location_id;
 }
 public function to_json()
 {
     parent::to_json();
     $value = $this->value();
     if (empty($value)) {
         $value = json_encode($this->defined_values);
     } elseif (is_array($this->defined_values) && !empty($this->defined_values)) {
         if (!is_array($value)) {
             $value = json_decode($value, true);
         }
         $value = $this->merge_data($value, $this->defined_values);
         $value = json_encode($value);
     }
     $this->json['live_title_id'] = $this->live_title_id;
     $this->json['title_format'] = $this->title_format;
     $this->json['max_item'] = $this->max_item;
     $this->json['limited_msg'] = $this->limited_msg;
     $this->json['changeable'] = $this->changeable;
     $this->json['default_empty_title'] = $this->default_empty_title;
     $this->json['value'] = $value;
     $this->json['id_key'] = $this->id_key;
     $this->json['fields'] = $this->fields;
 }
Example #28
0
 public function to_json()
 {
     parent::to_json();
     $this->json['statuses'] = $this->statuses;
 }
 /**
  * Set Font Control JSON
  * 
  * Refresh the parameters passed to the 
  * JavaScript via JSON.
  * 
  * @since 1.3.4
  * @version 1.3.7
  * 
  */
 public function to_json()
 {
     parent::to_json();
     $this->json['id'] = $this->id;
     // Define additional json parameters.
     $this->json['egf_properties'] = $this->args['option']['properties'];
     $this->json['egf_defaults'] = $this->args['option']['default'];
     $this->json['egf_subsets'] = $this->get_subsets();
     $this->json['egf_text_decoration'] = $this->get_text_decoration_options();
     $this->json['egf_text_transform'] = $this->get_text_transform_options();
     $this->json['egf_display'] = $this->get_display_options();
     $this->json['egf_border_styles'] = $this->get_border_style_options();
 }
 /**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  * @see WP_Customize_Control::to_json()
  */
 public function to_json()
 {
     parent::to_json();
     if (isset($this->default)) {
         $this->json['default'] = $this->default;
     } else {
         $this->json['default'] = $this->setting->default;
     }
     $this->json['js_vars'] = $this->js_vars;
     $this->json['output'] = $this->output;
     $this->json['value'] = $this->value();
     $this->json['choices'] = $this->choices;
     $this->json['link'] = $this->get_link();
     $this->json['tooltip'] = $this->tooltip;
     $this->json['id'] = $this->id;
     $this->json['l10n'] = $this->l10n;
     $this->json['kirkiConfig'] = $this->kirki_config;
     if ('user_meta' === $this->option_type) {
         $this->json['value'] = get_user_meta(get_current_user_id(), $this->id, true);
     }
     $this->json['inputAttrs'] = '';
     foreach ($this->input_attrs as $attr => $value) {
         $this->json['inputAttrs'] .= $attr . '="' . esc_attr($value) . '" ';
     }
 }