本文整理匯總了PHP中WP_Customize_Setting::json方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_Customize_Setting::json方法的具體用法?PHP WP_Customize_Setting::json怎麽用?PHP WP_Customize_Setting::json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WP_Customize_Setting
的用法示例。
在下文中一共展示了WP_Customize_Setting::json方法的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);
}