本文整理汇总了PHP中WP_Customize_Manager::setup_theme方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Manager::setup_theme方法的具体用法?PHP WP_Customize_Manager::setup_theme怎么用?PHP WP_Customize_Manager::setup_theme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Customize_Manager
的用法示例。
在下文中一共展示了WP_Customize_Manager::setup_theme方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
/**
* Test WP_Customize_Manager::setup_theme() for frontend.
*
* @covers WP_Customize_Manager::setup_theme()
*/
function test_setup_theme_in_frontend()
{
global $wp_customize, $pagenow, $show_admin_bar;
$pagenow = 'front';
set_current_screen('front');
wp_set_current_user(0);
$exception = null;
$wp_customize = new WP_Customize_Manager();
wp_set_current_user(self::$subscriber_user_id);
try {
$wp_customize->setup_theme();
} catch (Exception $e) {
$exception = $e;
}
$this->assertInstanceOf('WPDieException', $exception);
$this->assertContains('Non-existent changeset UUID', $exception->getMessage());
wp_set_current_user(self::$admin_user_id);
$wp_customize = new WP_Customize_Manager(array('messenger_channel' => 'preview-1'));
$wp_customize->setup_theme();
$this->assertFalse($show_admin_bar);
show_admin_bar(true);
wp_set_current_user(self::$admin_user_id);
$wp_customize = new WP_Customize_Manager(array('messenger_channel' => null));
$wp_customize->setup_theme();
$this->assertTrue($show_admin_bar);
}
示例2: get_settings_fields
/**
* Retrieve the settings fields details
* @access public
* @param string $section field section.
* @since 1.0.0
* @return array Settings fields.
*/
public function get_settings_fields($section)
{
$settings_fields = array();
// Declare the default settings fields.
switch ($section) {
case 'pp-cc-fields':
if ($this->customizeManager != null) {
$customizeManager = $this->customizeManager;
} else {
if (isset($GLOBALS['wp_customize'])) {
$customizeManager = $GLOBALS['wp_customize'];
} else {
if (!class_exists('WP_Customize_Manager')) {
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
// Init Customize class
$customizeManager = new WP_Customize_Manager();
// this is to initialize some data fields using this method
$customizeManager->setup_theme();
} else {
// $customizeManager = new WP_Customize_Manager;
//
// // this is to initialize some data fields using this method
// $customizeManager->setup_theme();
return array();
}
}
}
remove_action('customize_register', array(PP_Customizer_Customizer_Admin::instance(), 'customize_register'), 100);
do_action('customize_register', $customizeManager);
add_action('customize_register', array(PP_Customizer_Customizer_Admin::instance(), 'customize_register'), 100);
$temp = array();
foreach ($customizeManager->panels() as $key => $panel) {
$temp[$key] = $panel;
}
foreach ($customizeManager->sections() as $key => $section) {
if (isset($section->panel) && $section->panel != null) {
continue;
}
$temp[$key] = $section;
}
uasort($temp, function ($a, $b) {
return $a->priority - $b->priority;
});
foreach ($temp as $key => $value) {
$settings_fields[$key] = array('name' => $value->title, 'type' => 'checkbox', 'default' => 'true', 'section' => 'pp-cc-fields', 'description' => 'Enabled');
}
break;
case 'standard-fields':
$settings_fields['text'] = array('name' => __('Example Text Input', 'pp-customizer-customizer'), 'type' => 'text', 'default' => '', 'section' => 'standard-fields', 'description' => __('Place the field description text here.', 'pp-customizer-customizer'));
$settings_fields['textarea'] = array('name' => __('Example Textarea', 'pp-customizer-customizer'), 'type' => 'textarea', 'default' => '', 'section' => 'standard-fields', 'description' => __('Place the field description text here.', 'pp-customizer-customizer'));
$settings_fields['checkbox'] = array('name' => __('Example Checkbox', 'pp-customizer-customizer'), 'type' => 'checkbox', 'default' => '', 'section' => 'standard-fields', 'description' => __('Place the field description text here.', 'pp-customizer-customizer'));
$settings_fields['radio'] = array('name' => __('Example Radio Buttons', 'pp-customizer-customizer'), 'type' => 'radio', 'default' => '', 'section' => 'standard-fields', 'options' => array('one' => __('One', 'pp-customizer-customizer'), 'two' => __('Two', 'pp-customizer-customizer'), 'three' => __('Three', 'pp-customizer-customizer')), 'description' => __('Place the field description text here.', 'pp-customizer-customizer'));
$settings_fields['select'] = array('name' => __('Example Select', 'pp-customizer-customizer'), 'type' => 'select', 'default' => '', 'section' => 'standard-fields', 'options' => array('one' => __('One', 'pp-customizer-customizer'), 'two' => __('Two', 'pp-customizer-customizer'), 'three' => __('Three', 'pp-customizer-customizer')), 'description' => __('Place the field description text here.', 'pp-customizer-customizer'));
break;
case 'special-fields':
$settings_fields['select_taxonomy'] = array('name' => __('Example Taxonomy Selector', 'pp-customizer-customizer'), 'type' => 'select_taxonomy', 'default' => '', 'section' => 'special-fields', 'description' => __('Place the field description text here.', 'pp-customizer-customizer'));
break;
default:
# code...
break;
}
return (array) apply_filters('pp-customizer-customizer-settings-fields', $settings_fields);
}
示例3: set_up_valid_state
/**
* Set up valid user state.
*
* @param string $uuid Changeset UUID.
* @return WP_Customize_Manager
*/
protected function set_up_valid_state($uuid = null)
{
global $wp_customize;
wp_set_current_user(self::$admin_user_id);
$wp_customize = new WP_Customize_Manager(array('changeset_uuid' => $uuid));
$wp_customize->register_controls();
$nonce = wp_create_nonce('save-customize_' . $wp_customize->get_stylesheet());
$_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
$wp_customize->setup_theme();
return $wp_customize;
}