setup_theme() public method

Check if customize query variable exist. Init filters to filter the current theme.
Since: 3.4.0
public setup_theme ( )
 /**
  * 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);
 }
 /**
  * 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);
 }
Esempio n. 3
0
 /**
  * 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;
 }