WP_Customize_Setting::js_value() WordPress Method

The WP_Customize_Setting::js_value() method is used to return the value of a setting for use in JavaScript. This is useful when you need to dynamically update the value of a setting on the front-end of a WordPress site.

WP_Customize_Setting::js_value() #

Sanitize the setting’s value for use in JavaScript.


Return

(mixed) The requested escaped value.


Top ↑

Source

File: wp-includes/class-wp-customize-setting.php

	public function js_value() {

		/**
		 * Filters a Customize setting value for use in JavaScript.
		 *
		 * The dynamic portion of the hook name, `$this->id`, refers to the setting ID.
		 *
		 * @since 3.4.0
		 *
		 * @param mixed                $value   The setting value.
		 * @param WP_Customize_Setting $setting WP_Customize_Setting instance.
		 */
		$value = apply_filters( "customize_sanitize_js_{$this->id}", $this->value(), $this );

		if ( is_string( $value ) ) {
			return html_entity_decode( $value, ENT_QUOTES, 'UTF-8' );
		}

		return $value;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.