本文整理汇总了PHP中WP_Customize_Manager::prepare_setting_validity_for_js方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Manager::prepare_setting_validity_for_js方法的具体用法?PHP WP_Customize_Manager::prepare_setting_validity_for_js怎么用?PHP WP_Customize_Manager::prepare_setting_validity_for_js使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Customize_Manager
的用法示例。
在下文中一共展示了WP_Customize_Manager::prepare_setting_validity_for_js方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Test WP_Customize_Manager::prepare_setting_validity_for_js().
*
* @see WP_Customize_Manager::prepare_setting_validity_for_js()
*/
function test_prepare_setting_validity_for_js()
{
$this->assertTrue($this->manager->prepare_setting_validity_for_js(true));
$error = new WP_Error();
$error->add('bad_letter', 'Bad letter', 'A');
$error->add('bad_letter', 'Bad letra', 123);
$error->add('bad_number', 'Bad number', array('number' => 123));
$validity = $this->manager->prepare_setting_validity_for_js($error);
$this->assertInternalType('array', $validity);
foreach ($error->errors as $code => $messages) {
$this->assertArrayHasKey($code, $validity);
$this->assertInternalType('array', $validity[$code]);
$this->assertEquals(join(' ', $messages), $validity[$code]['message']);
$this->assertArrayHasKey('data', $validity[$code]);
$this->assertEquals($validity[$code]['data'], $error->get_error_data($code));
}
$this->assertArrayHasKey('number', $validity['bad_number']['data']);
$this->assertEquals(123, $validity['bad_number']['data']['number']);
}