Title: WP_Customize_Control::to_json
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Customize_Control::to_json()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/WP_Customize_Control/to_json/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/WP_Customize_Control/to_json/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/WP_Customize_Control/to_json/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/WP_Customize_Control/to_json/?output_format=md#wp--skip-link--target)

Refreshes the parameters passed to the JavaScript via JSON.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/WP_Customize_Control/to_json/?output_format=md#source)󠁿

    ```php
    public function to_json() {
    	$this->json['settings'] = array();
    	foreach ( $this->settings as $key => $setting ) {
    		$this->json['settings'][ $key ] = $setting->id;
    	}

    	$this->json['type']           = $this->type;
    	$this->json['priority']       = $this->priority;
    	$this->json['active']         = $this->active();
    	$this->json['section']        = $this->section;
    	$this->json['content']        = $this->get_content();
    	$this->json['label']          = $this->label;
    	$this->json['description']    = $this->description;
    	$this->json['instanceNumber'] = $this->instance_number;

    	if ( 'dropdown-pages' === $this->type ) {
    		$this->json['allow_addition'] = $this->allow_addition;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-customize-control.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-customize-control.php#L314)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-customize-control.php#L314-L332)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/WP_Customize_Control/to_json/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Customize_Control::get_content()](https://developer.wordpress.org/reference/classes/wp_customize_control/get_content/)`wp-includes/class-wp-customize-control.php` |

Gets the control’s content for insertion into the Customizer pane.

  | 
| [WP_Customize_Control::active()](https://developer.wordpress.org/reference/classes/wp_customize_control/active/)`wp-includes/class-wp-customize-control.php` |

Checks whether control is active to current Customizer preview.

  |

| Used by | Description | 
| [WP_Customize_Nav_Menu_Location_Control::to_json()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menu_location_control/to_json/)`wp-includes/customize/class-wp-customize-nav-menu-location-control.php` |

Refresh the parameters passed to JavaScript via JSON.

  | 
| [WP_Customize_Theme_Control::to_json()](https://developer.wordpress.org/reference/classes/wp_customize_theme_control/to_json/)`wp-includes/customize/class-wp-customize-theme-control.php` |

Refresh the parameters passed to the JavaScript via JSON.

  | 
| [WP_Customize_Media_Control::to_json()](https://developer.wordpress.org/reference/classes/wp_customize_media_control/to_json/)`wp-includes/customize/class-wp-customize-media-control.php` |

Refresh the parameters passed to the JavaScript via JSON.

  | 
| [WP_Customize_Control::json()](https://developer.wordpress.org/reference/classes/wp_customize_control/json/)`wp-includes/class-wp-customize-control.php` |

Gets the data to export to the client via JSON.

  | 
| [WP_Widget_Area_Customize_Control::to_json()](https://developer.wordpress.org/reference/classes/wp_widget_area_customize_control/to_json/)`wp-includes/customize/class-wp-widget-area-customize-control.php` |

Refreshes the parameters passed to the JavaScript via JSON.

  | 
| [WP_Widget_Form_Customize_Control::to_json()](https://developer.wordpress.org/reference/classes/wp_widget_form_customize_control/to_json/)`wp-includes/customize/class-wp-widget-form-customize-control.php` |

Gather control params for exporting to JavaScript.

  | 
| [WP_Customize_Color_Control::to_json()](https://developer.wordpress.org/reference/classes/wp_customize_color_control/to_json/)`wp-includes/customize/class-wp-customize-color-control.php` |

Refresh the parameters passed to the JavaScript via JSON.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/WP_Customize_Control/to_json/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/WP_Customize_Control/to_json/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/WP_Customize_Control/to_json/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_control%2Fto_json%2F)
before being able to contribute a note or feedback.