/**
  * Main PP_Customizer_Customizer_Admin Instance
  *
  * Ensures only one instance of PP_Customizer_Customizer_Admin is loaded or can be loaded.
  *
  * @since 1.0.0
  * @static
  * @return Main PP_Customizer_Customizer_Admin instance
  */
 public static function instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 /**
  * 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);
 }
Ejemplo n.º 3
0
 /**
  * Constructor function.
  * @access  public
  * @since   1.0.0
  * @return  void
  */
 public function __construct()
 {
     $this->token = 'pp-customizer-customizer';
     $this->plugin_url = plugin_dir_url(__FILE__);
     $this->plugin_path = plugin_dir_path(__FILE__);
     $this->version = '1.0.0';
     // Admin - Start
     require_once 'classes/class-pp-customizer-customizer-settings.php';
     $this->settings = PP_Customizer_Customizer_Settings::instance();
     if (is_admin()) {
         require_once 'classes/class-pp-customizer-customizer-admin.php';
         $this->admin = PP_Customizer_Customizer_Admin::instance();
     }
     // Post Types - End
     register_activation_hook(__FILE__, array($this, 'install'));
     add_action('init', array($this, 'load_plugin_textdomain'));
 }