本文整理汇总了PHP中WP_Customize_Manager::post_value方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Manager::post_value方法的具体用法?PHP WP_Customize_Manager::post_value怎么用?PHP WP_Customize_Manager::post_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Customize_Manager
的用法示例。
在下文中一共展示了WP_Customize_Manager::post_value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Test the WP_Customize_Manager::post_value() method to make sure that the validation and sanitization are done in the right order.
*
* @ticket 37247
*/
function test_post_value_validation_sanitization_order()
{
$default_value = '0';
$setting = $this->manager->add_setting('numeric', array('validate_callback' => array($this, 'filter_customize_validate_numeric'), 'sanitize_callback' => array($this, 'filter_customize_sanitize_numeric')));
$this->assertEquals($default_value, $this->manager->post_value($setting, $default_value));
$this->assertEquals($default_value, $setting->post_value($default_value));
$post_value = '42';
$this->manager->set_post_value('numeric', $post_value);
$this->assertEquals($post_value, $this->manager->post_value($setting, $default_value));
$this->assertEquals($post_value, $setting->post_value($default_value));
}
示例2: post_value
/**
* Fetch and sanitize the $_POST value for the setting.
*
* @since 3.4.0
*
* @param mixed $default A default value which is used as a fallback. Default is null.
* @return mixed The default value on failure, otherwise the sanitized value.
*/
public final function post_value($default = null)
{
// Check for a cached value
if (isset($this->_post_value)) {
return $this->_post_value;
}
// Call the manager for the post value
$result = $this->manager->post_value($this);
if (isset($result)) {
return $this->_post_value = $result;
} else {
return $default;
}
}
示例3: array
/**
* Test the WP_Customize_Manager::post_value() method for a setting value that fails validation.
*
* @ticket 34893
*/
function test_invalid_post_value()
{
$default_value = 'foo_default';
$setting = $this->manager->add_setting('foo', array('validate_callback' => array($this, 'filter_customize_validate_foo'), 'sanitize_callback' => array($this, 'filter_customize_sanitize_foo')));
$this->assertEquals($default_value, $this->manager->post_value($setting, $default_value));
$this->assertEquals($default_value, $setting->post_value($default_value));
$post_value = 'bar';
$this->manager->set_post_value('foo', $post_value);
$this->assertEquals(strtoupper($post_value), $this->manager->post_value($setting, $default_value));
$this->assertEquals(strtoupper($post_value), $setting->post_value($default_value));
$this->manager->set_post_value('foo', 'return_wp_error_in_sanitize');
$this->assertEquals($default_value, $this->manager->post_value($setting, $default_value));
$this->assertEquals($default_value, $setting->post_value($default_value));
$this->manager->set_post_value('foo', 'return_null_in_sanitize');
$this->assertEquals($default_value, $this->manager->post_value($setting, $default_value));
$this->assertEquals($default_value, $setting->post_value($default_value));
$post_value = '<script>evil</script>';
$this->manager->set_post_value('foo', $post_value);
$this->assertEquals($default_value, $this->manager->post_value($setting, $default_value));
$this->assertEquals($default_value, $setting->post_value($default_value));
}
示例4: post_value
/**
* Fetch and sanitize the $_POST value for the setting.
*
* @since 3.4.0
*
* @param mixed $default A default value which is used as a fallback. Default is null.
* @return mixed The default value on failure, otherwise the sanitized value.
*/
public final function post_value($default = null)
{
return $this->manager->post_value($this, $default);
}