setup_actions(); } return $instance; } /** * Constructor method. * * @since 1.0.0 * @access private * @return void */ private function __construct() {} /** * Sets up initial actions. * * @since 1.0.0 * @access private * @return void */ private function setup_actions() { // Register panels, sections, settings, controls, and partials. add_action( 'customize_register', array( $this, 'sections' ) ); // Register scripts and styles for the controls. add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ), 0 ); } /** * Sets up the customizer sections. * * @since 1.0.0 * @access public * @param object $manager * @return void */ public function sections( $manager ) { // Load custom sections. locate_template( 'vendors/bptadvisor-customizer/section-pro.php', TRUE, TRUE ); $manager->add_section( 'bpt_theme_options', array( 'title' => esc_attr__( 'Theme Options', 'bptadvisor' ), 'priority' => 2, ) ); $manager->add_setting( 'bpt_theme_color', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => 'slug_sanitize_select', 'default' => 'default', ) ); $manager->add_control( 'bpt_theme_color', array( 'type' => 'select', 'label' => __( 'Theme Color Scheme', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'bpt_theme_color', 'description' => __( 'Theme color scheme', 'bptadvisor' ), 'choices' => array( 'default' => __( 'Color Default', 'bptadvisor' ), 'blue' => __( 'Color Blue', 'bptadvisor' ), 'dark-blue' => __( 'Color Dark Blue', 'bptadvisor' ), 'light-blue' => __( 'Color Light Blue', 'bptadvisor' ), 'orange' => __( 'Color Orange', 'bptadvisor' ), 'pink' => __( 'Color Pink', 'bptadvisor' ), 'red' => __( 'Color Red', 'bptadvisor' ), ), ) ); $manager->add_setting('bpt_quick_button', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $manager->add_control('bpt_quick_button', array( 'label' => __( 'Quick Button', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'bpt_quick_button', 'type' => 'url', )); $manager->add_setting('bpt_quick_button_url', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', ) ); $manager->add_control('bpt_quick_button_url', array( 'label' => __( 'Quick Button Link', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'bpt_quick_button_url', 'type' => 'url', )); $manager->add_setting('fb_link', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', ) ); $manager->add_control('fb_link', array( 'label' => __( 'Facebook', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'fb_link', 'type' => 'url', )); $manager->add_setting('tw_link', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', ) ); $manager->add_control('tw_link', array( 'label' => __( 'Twitter', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'tw_link', 'type' => 'url', )); $manager->add_setting('google_plus', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', ) ); $manager->add_control('google_plus', array( 'label' => __( 'Google Plus', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'google_plus', 'type' => 'url', )); $manager->add_setting('linkedin', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', ) ); $manager->add_control('linkedin', array( 'label' => __( 'Linkedin', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'linkedin', 'type' => 'url', )); $manager->add_setting('bpt_phone', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $manager->add_control('bpt_phone', array( 'label' => __( 'Phone Number', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'bpt_phone', 'type' => 'text', )); $manager->add_setting('bpt_email', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_email', ) ); $manager->add_control('bpt_email', array( 'label' => __( 'Email', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'bpt_email', 'type' => 'text', )); $manager->add_setting('bpt_skype', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $manager->add_control('bpt_skype', array( 'label' => __( 'Skype', 'bptadvisor' ), 'section' => 'bpt_theme_options', 'settings' => 'bpt_skype', 'type' => 'text', )); // Register custom section types. $manager->register_section_type( 'bptadvisor_Customize_Section_Pro' ); // Register sections. $manager->add_section( new bptadvisor_Customize_Section_Pro( $manager, 'bptadvisor-type', array( 'title' => esc_html__( 'BPTAdvisor Pro Version', 'bptadvisor' ), 'pro_text' => esc_html__( 'Go Pro', 'bptadvisor' ), 'pro_url' => 'http://bptadvisor.com', 'priority' => 1, ) ) ); //select sanitization function function slug_sanitize_select( $input, $setting ) { $input = sanitize_key( $input ); $choices = $setting->manager->get_control( $setting->id )->choices; return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } } /** * Loads theme customizer CSS. * * @since 1.0.0 * @access public * @return void */ public function enqueue_control_scripts() { wp_enqueue_script( 'bptadvisor-customize-controls', trailingslashit( get_template_directory_uri() ) . 'vendors/bptadvisor-customizer/customize-controls.js', array( 'customize-controls' ) ); wp_enqueue_style( 'bptadvisor-customize-controls', trailingslashit( get_template_directory_uri() ) . 'vendors/bptadvisor-customizer/customize-controls.css' ); } } // Doing this customizer thang! bptadvisor_Customize::get_instance();