本文整理汇总了PHP中WP_Customize_Setting::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Setting::__construct方法的具体用法?PHP WP_Customize_Setting::__construct怎么用?PHP WP_Customize_Setting::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Customize_Setting
的用法示例。
在下文中一共展示了WP_Customize_Setting::__construct方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* WP_Customize_Custom_CSS_Setting constructor.
*
* @since 4.7.0
* @access public
*
* @throws Exception If the setting ID does not match the pattern `custom_css[$stylesheet]`.
*
* @param WP_Customize_Manager $manager The Customize Manager class.
* @param string $id An specific ID of the setting. Can be a
* theme mod or option name.
* @param array $args Setting arguments.
*/
public function __construct($manager, $id, $args = array())
{
parent::__construct($manager, $id, $args);
if ('custom_css' !== $this->id_data['base']) {
throw new Exception('Expected custom_css id_base.');
}
if (1 !== count($this->id_data['keys']) || empty($this->id_data['keys'][0])) {
throw new Exception('Expected single stylesheet key.');
}
$this->stylesheet = $this->id_data['keys'][0];
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:24,代码来源:class-wp-customize-custom-css-setting.php
示例2: __construct
/**
* WP_Customize_REST_Resource_Setting constructor.
*
* @param \WP_Customize_Manager $manager Manager.
* @param string $id Setting ID.
* @param array $args Setting args.
* @throws Exception If the ID is in an invalid format.
*/
public function __construct($manager, $id, $args = array())
{
if (!isset($args['sanitize_callback'])) {
$args['sanitize_callback'] = array($this, 'sanitize');
}
if (!preg_match('#^rest_resource\\[(?P<route>.+?)]$#', $id, $matches)) {
throw new Exception('Illegal setting id: ' . $id);
}
$this->route = trim($matches['route'], '/');
if (!isset($args['plugin']) || !$args['plugin'] instanceof Plugin) {
throw new Exception(sprintf('Missing plugin arg for %s', get_class($this)));
}
parent::__construct($manager, $id, $args);
}
开发者ID:xwp,项目名称:wp-customize-rest-resources,代码行数:22,代码来源:class-wp-customize-rest-resource-setting.php
示例3: __construct
/**
* Constructor.
*
* Any supplied $args override class property defaults.
*
* @param \WP_Customize_Manager $manager Manager instance.
* @param string $id An specific ID of the setting. Can be a
* theme mod or option name.
* @param array $args Setting arguments.
* @throws Exception If $id is not valid for a widget.
*/
public function __construct(\WP_Customize_Manager $manager, $id, array $args = array())
{
unset($args['type']);
if (!preg_match(static::WIDGET_SETTING_ID_PATTERN, $id, $matches)) {
throw new Exception("Illegal widget setting ID: {$id}");
}
$this->widget_id_base = $matches['widget_id_base'];
if (isset($matches['widget_number'])) {
$this->widget_number = intval($matches['widget_number']);
}
parent::__construct($manager, $id, $args);
if (empty($this->widget_posts)) {
throw new Exception('Missing argument: widget_posts');
}
}
开发者ID:BE-Webdesign,项目名称:wp-customize-widgets-plus,代码行数:26,代码来源:class-wp-customize-widget-setting.php
示例4: __construct
public function __construct($manager, $id, $args = array())
{
parent::__construct($manager, $id, $args);
// Will onvert the setting from JSON to array. Must be triggered very soon
add_filter("customize_sanitize_{$this->id}", array($this, 'sanitize_repeater_setting'), 10, 1);
}
示例5: __construct
/**
* Constructor.
*
* Any supplied $args override class property defaults.
*
* @since 4.3.0
* @access public
*
* @param WP_Customize_Manager $manager Bootstrap Customizer instance.
* @param string $id An specific ID of the setting. Can be a
* theme mod or option name.
* @param array $args Optional. Setting arguments.
*
* @throws Exception If $id is not valid for this setting type.
*/
public function __construct(WP_Customize_Manager $manager, $id, array $args = array())
{
if (empty($manager->nav_menus)) {
throw new Exception('Expected WP_Customize_Manager::$nav_menus to be set.');
}
if (!preg_match(self::ID_PATTERN, $id, $matches)) {
throw new Exception("Illegal widget setting ID: {$id}");
}
$this->post_id = intval($matches['id']);
add_action('wp_update_nav_menu_item', array($this, 'flush_cached_value'), 10, 2);
parent::__construct($manager, $id, $args);
// Ensure that an initially-supplied value is valid.
if (isset($this->value)) {
$this->populate_value();
foreach (array_diff(array_keys($this->default), array_keys($this->value)) as $missing) {
throw new Exception("Supplied nav_menu_item value missing property: {$missing}");
}
}
}
示例6: __construct
/**
* Constructor.
*
* Any supplied $args override class property defaults.
*
* @since 4.3.0
* @access public
*
* @param WP_Customize_Manager $manager Bootstrap Customizer instance.
* @param string $id An specific ID of the setting. Can be a
* theme mod or option name.
* @param array $args Optional. Setting arguments.
*
* @throws Exception If $id is not valid for this setting type.
*/
public function __construct(WP_Customize_Manager $manager, $id, array $args = array())
{
if (empty($manager->nav_menus)) {
throw new Exception('Expected WP_Customize_Manager::$nav_menus to be set.');
}
if (!preg_match(self::ID_PATTERN, $id, $matches)) {
throw new Exception("Illegal widget setting ID: {$id}");
}
$this->term_id = intval($matches['id']);
parent::__construct($manager, $id, $args);
}
示例7: __construct
public function __construct($manager, $id, $args = array())
{
parent::__construct($manager, $id, $args);
// set up the id_data, etc.
if (!WeaverX_Customize_Setting::$filter_added) {
add_filter('pre_option_' . $this->id_data['base'], 'WeaverX_Customize_Setting::_preview_filter_cache');
add_filter('option_' . $this->id_data['base'], 'WeaverX_Customize_Setting::_preview_filter_cache');
add_filter('default_option_' . $this->id_data['base'], 'WeaverX_Customize_Setting::_preview_filter_cache');
WeaverX_Customize_Setting::$filter_added = true;
}
}