本文整理汇总了PHP中WP_Customize_Setting::js_value方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Setting::js_value方法的具体用法?PHP WP_Customize_Setting::js_value怎么用?PHP WP_Customize_Setting::js_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Customize_Setting
的用法示例。
在下文中一共展示了WP_Customize_Setting::js_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_js_value
/**
* Test js_value and json methods.
*
* @see WP_Customize_Setting::js_value()
* @see WP_Customize_Setting::json()
*/
public function test_js_value()
{
$default = "";
$args = array('type' => 'binary', 'default' => $default, 'transport' => 'postMessage', 'dirty' => true, 'sanitize_js_callback' => create_function('$value', 'return base64_encode( $value );'));
$setting = new WP_Customize_Setting($this->manager, 'name', $args);
$this->assertEquals($default, $setting->value());
$this->assertEquals(base64_encode($default), $setting->js_value());
$exported = $setting->json();
$this->assertArrayHasKey('type', $exported);
$this->assertArrayHasKey('value', $exported);
$this->assertArrayHasKey('transport', $exported);
$this->assertArrayHasKey('dirty', $exported);
$this->assertEquals($setting->js_value(), $exported['value']);
$this->assertEquals($args['type'], $setting->type);
$this->assertEquals($args['transport'], $setting->transport);
$this->assertEquals($args['dirty'], $setting->dirty);
}