prefix = 'mp_profit'; //Handles the theme's theme customizer functionality. add_action( 'customize_register', array( $this, 'customize_register' ) ); add_action( 'after_setup_theme', array( $this, 'custom_header_setup' ), 11 ); add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_control_js' ) ); add_action( 'customize_preview_init', array( $this, 'customize_preview_js' ) ); } /** * Get prefix. * * @access public * @return sting */ private function getPrefix() { return $this->prefix . '_'; } /** * Set up the WordPress core custom header arguments and settings. * * @uses add_theme_support() to register support for 3.4 and up. * @uses * mp_profit_header_style() to style front-end. * * @since Profit 1.0 */ function custom_header_setup() { $mp_profit_color_scheme = $this->get_color_scheme(); $mp_profit_args = array( // Text color and image (empty to use none). 'default-text-color' => $mp_profit_color_scheme[1], 'wp-head-callback' => $this->getPrefix() . 'header_style', 'admin-head-callback' => $this->getPrefix() . 'header_style', 'admin-preview-callback' => $this->getPrefix() . 'header_style', ); add_theme_support( 'custom-header', $mp_profit_args ); } /** * Sets up the theme customizer sections, controls, and settings. * * @since 1.0.0 * @access public * * @param object $wp_customize * * @return void */ function customize_register( $wp_customize ) { /* Enable live preview for WordPress theme features. */ $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->remove_section( "header_image" ); $mp_profit_color_scheme = $this->get_color_scheme(); /* * Add 'gemeral' section */ $wp_customize->add_section( $this->getPrefix() . 'general_section', array( 'title' => esc_html__( 'General', 'profit-lite' ), 'priority' => 20, 'capability' => 'edit_theme_options' ) ); /* * Add the 'Show sticky menu' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'show_sticky_menu', array( 'default' => 1, 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), ) ); /* * Add the upload control for the 'Show sticky menu' setting. */ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $this->getPrefix() . 'show_sticky_menu', array( 'label' => esc_html__( 'Sticky menu on scroll', 'profit-lite' ), 'section' => $this->getPrefix() . 'general_section', 'settings' => $this->getPrefix() . 'show_sticky_menu', 'type' => 'checkbox', 'priority' => 1 ) ) ); /* * Add the 'copyright ' setting. */ /* * Add color scheme setting and control. */ $wp_customize->add_setting( $this->getPrefix() . 'color_scheme', array( 'sanitize_callback' => array( $this, 'sanitize_color_scheme' ), 'default' => 'default', 'transport' => 'postMessage', ) ); $wp_customize->add_control( $this->getPrefix() . 'color_scheme', array( 'label' => __( 'Base Color Scheme', 'profit-lite' ), 'section' => 'colors', 'type' => 'select', 'choices' => $this->get_color_scheme_choices(), 'priority' => 1, ) ); // Brand Color $wp_customize->add_setting( $this->getPrefix() . 'color_text', array( 'sanitize_callback' => 'sanitize_hex_color', 'default' => MP_PROFIT_THEME_TEXT_COLOR, 'type' => 'option', 'capability' => 'edit_theme_options' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $this->getPrefix() . 'color_text', array( 'label' => __( 'Text Color', 'profit-lite' ), 'section' => 'colors', 'settings' => $this->getPrefix() . 'color_text', ) ) ); $wp_customize->add_setting( $this->getPrefix() . 'color_primary', array( 'sanitize_callback' => 'sanitize_hex_color', 'default' => $mp_profit_color_scheme[0], 'type' => 'option', 'capability' => 'edit_theme_options' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $this->getPrefix() . 'color_primary', array( 'label' => __( 'Accent Color', 'profit-lite' ), 'section' => 'colors', 'settings' => $this->getPrefix() . 'color_primary' ) ) ); /* * Add 'logo' section */ //$mp_profit_logo_section_title = esc_html__( 'Logo', 'profit-lite' ); // $wp_customize->add_section( // $this->getPrefix() . 'logo_section', array( // 'title' => $mp_profit_logo_section_title, // 'priority' => 30, // 'capability' => 'edit_theme_options' // ) // ); // /* // * Add the 'logo' upload setting. // */ // $wp_customize->add_setting( // $this->getPrefix() . 'logo', array( // 'sanitize_callback' => 'esc_url_raw', // 'default' => false, // 'capability' => 'edit_theme_options', // ) // ); /* * Add the upload control for the $this->getPrefix().'logo' setting. */ // $wp_customize->add_control( // new WP_Customize_Image_Control( // $wp_customize, $this->getPrefix() . 'logo', array( // 'label' => esc_html__( 'Logo', 'profit-lite' ), // 'section' => $this->getPrefix() . 'logo_section', // 'settings' => $this->getPrefix() . 'logo', // ) // ) // ); /* Add 'header_socials' section */ $wp_customize->add_section( $this->getPrefix() . 'header_socials', array( 'title' => esc_html__( 'Social Links', 'profit-lite' ), 'priority' => 78, 'capability' => 'edit_theme_options' ) ); /* Add the 'facebook link' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'facebook_link', array( 'sanitize_callback' => array( $this, 'sanitize_text' ), 'default' => '', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', ) ); /* Add the upload control for the 'facebook link' setting. */ $wp_customize->add_control( $this->getPrefix() . 'facebook_link', array( 'label' => esc_html__( 'Facebook link', 'profit-lite' ), 'section' => $this->getPrefix() . 'header_socials', 'settings' => $this->getPrefix() . 'facebook_link', ) ); /* Add the 'twitter link' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'twitter_link', array( 'sanitize_callback' => 'esc_url_raw', 'default' => '', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', ) ); /* Add the upload control for the 'twitter link' setting. */ $wp_customize->add_control( $this->getPrefix() . 'twitter_link', array( 'label' => esc_html__( 'Twitter link', 'profit-lite' ), 'section' => $this->getPrefix() . 'header_socials', 'settings' => $this->getPrefix() . 'twitter_link', ) ); /* Add the 'linkedin link' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'linkedin_link', array( 'sanitize_callback' => 'esc_url_raw', 'default' => '', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', ) ); /* Add the upload control for the 'linkedin link' setting. */ $wp_customize->add_control( $this->getPrefix() . 'linkedin_link', array( 'label' => esc_html__( 'LinkedIn link', 'profit-lite' ), 'section' => $this->getPrefix() . 'header_socials', 'settings' => $this->getPrefix() . 'linkedin_link', ) ); /* Add the 'google plus link' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'google_plus_link', array( 'sanitize_callback' => 'esc_url_raw', 'default' => '', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', ) ); /* Add the upload control for the 'google plus link' setting. */ $wp_customize->add_control( $this->getPrefix() . 'google_plus_link', array( 'label' => esc_html__( 'Google+ link', 'profit-lite' ), 'section' => $this->getPrefix() . 'header_socials', 'settings' => $this->getPrefix() . 'google_plus_link', ) ); /* Add the 'Instagram link' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'instagram_link', array( 'sanitize_callback' => 'esc_url_raw', 'default' => '', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', ) ); /* Add the upload control for the 'Instagram link' setting. */ $wp_customize->add_control( $this->getPrefix() . 'instagram_link', array( 'label' => esc_html__( 'Instagram link', 'profit-lite' ), 'section' => $this->getPrefix() . 'header_socials', 'settings' => $this->getPrefix() . 'instagram_link', ) ); /* Add the 'pinterest link' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'pinterest_link', array( 'sanitize_callback' => 'esc_url_raw', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', ) ); /* Add the upload control for the 'pinterest link' setting. */ $wp_customize->add_control( $this->getPrefix() . 'pinterest_link', array( 'label' => esc_html__( 'Pinterest link', 'profit-lite' ), 'section' => $this->getPrefix() . 'header_socials', 'settings' => $this->getPrefix() . 'pinterest_link', ) ); /* Add the 'tumblrlink' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'tumblr_link', array( 'sanitize_callback' => 'esc_url_raw', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', ) ); /* Add the upload control for the 'tumblr link' setting. */ $wp_customize->add_control( $this->getPrefix() . 'tumblr_link', array( 'label' => esc_html__( 'Tumblr link', 'profit-lite' ), 'section' => $this->getPrefix() . 'header_socials', 'settings' => $this->getPrefix() . 'tumblr_link', ) ); /* Add the 'youtube link' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'youtube_link', array( 'sanitize_callback' => 'esc_url_raw', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', ) ); /* Add the upload control for the 'google plus link' setting. */ $wp_customize->add_control( $this->getPrefix() . 'youtube_link', array( 'label' => esc_html__( 'Youtube link', 'profit-lite' ), 'section' => $this->getPrefix() . 'header_socials', 'settings' => $this->getPrefix() . 'youtube_link', ) ); /* Add the 'google plus link' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'rss_link', array( 'sanitize_callback' => 'esc_url_raw', 'default' => '', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', ) ); /* Add the upload control for the 'google plus link' setting. */ $wp_customize->add_control( $this->getPrefix() . 'rss_link', array( 'label' => esc_html__( 'Rss link', 'profit-lite' ), 'section' => $this->getPrefix() . 'header_socials', 'settings' => $this->getPrefix() . 'rss_link', ) ); /* Add 'header_socials' section */ $wp_customize->add_section( $this->getPrefix() . 'posts_settings', array( 'title' => esc_html__( 'Posts Settings', 'profit-lite' ), 'priority' => 100, 'capability' => 'edit_theme_options' ) ); /* * Add blog type. */ $wp_customize->add_setting( $this->getPrefix() . 'blog_style', array( 'default' => 'masonry', 'sanitize_callback' => array( $this, 'sanitize_text' ), ) ); $wp_customize->add_control( $this->getPrefix() . 'blog_style', array( 'label' => __( 'Blog Layout', 'profit-lite' ), 'section' => $this->getPrefix() . 'posts_settings', 'type' => 'select', 'choices' => $this->blog_list() ) ); /* Add the 'Show meta' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'show_meta', array( 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), 'default' => '1', ) ); /* Add the upload control for the 'Show meta' setting. */ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $this->getPrefix() . 'show_meta', array( 'label' => esc_html__( 'Show Meta', 'profit-lite' ), 'section' => $this->getPrefix() . 'posts_settings', 'settings' => $this->getPrefix() . 'show_meta', 'type' => 'checkbox', ) ) ); /* Add the 'Show Categories' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'show_categories', array( 'default' => '1', 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), ) ); /* Add the upload control for the 'Show Categories'setting. */ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $this->getPrefix() . 'show_categories', array( 'label' => esc_html__( 'Show Categories', 'profit-lite' ), 'section' => $this->getPrefix() . 'posts_settings', 'settings' => $this->getPrefix() . 'show_categories', 'type' => 'checkbox', ) ) ); /* Add the 'Show Tags' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'show_tags', array( 'default' => '1', 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), ) ); /* Add the upload control for the 'Show Tags' setting. */ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $this->getPrefix() . 'show_tags', array( 'label' => esc_html__( 'Show Tags', 'profit-lite' ), 'section' => $this->getPrefix() . 'posts_settings', 'settings' => $this->getPrefix() . 'show_tags', 'type' => 'checkbox', ) ) ); /* * Add the 'second to call action section'. */ $wp_customize->add_section( $this->getPrefix() . 'second_action_section', array( 'title' => __( 'Second to Call Action Section', 'profit-lite' ), 'priority' => 83, 'capability' => 'edit_theme_options' ) ); /* * Add the 'Hide second_action section?' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'second_action_show', array( 'default' => 0, 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), ) ); /* * Add the upload control for the 'Hide second_action section?' setting. */ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $this->getPrefix() . 'second_action_show', array( 'label' => esc_html__( 'Hide this section', 'profit-lite' ), 'section' => $this->getPrefix() . 'second_action_section', 'settings' => $this->getPrefix() . 'second_action_show', 'type' => 'checkbox', 'priority' => 1, ) ) ); /* * Add the 'second to call action' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'second_action_title', array( 'default' => __( 'Boost your business right now', 'profit-lite' ), 'capability' => 'edit_theme_options', 'sanitize_callback' => array( $this, 'sanitize_text' ), 'transport' => 'postMessage' ) ); /* * Add the upload control for the 'second to call action' setting. */ $wp_customize->add_control( $this->getPrefix() . 'second_action_title', array( 'label' => __( 'Title', 'profit-lite' ), 'section' => $this->getPrefix() . 'second_action_section', 'settings' => $this->getPrefix() . 'second_action_title', 'priority' => 2 ) ); /* * Add the 'second to call action' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'second_action_subtitle', array( 'default' => __( 'Focus on your business and leave all money questions to us.', 'profit-lite' ), 'capability' => 'edit_theme_options', 'sanitize_callback' => array( $this, 'sanitize_text' ), 'transport' => 'postMessage' ) ); /* * Add the upload control for the 'second to call action' setting. */ $wp_customize->add_control( $this->getPrefix() . 'second_action_subtitle', array( 'label' => __( 'Sub Title', 'profit-lite' ), 'section' => $this->getPrefix() . 'second_action_section', 'settings' => $this->getPrefix() . 'second_action_subtitle', 'priority' => 2 ) ); /* * Add the 'second to call action' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'second_action_description', array( 'sanitize_callback' => array( $this, 'sanitize_text' ), 'default' => __( 'Our company has more than 20 years of experience in trading market and knows what exactly our customers and partners need to succeed in business. Just give us a try and we’ll provide you with high level service and professional solutions.', 'profit-lite' ), 'capability' => 'edit_theme_options', 'transport' => 'postMessage' ) ); /* * Add the upload control for the 'second to call action' setting. */ $wp_customize->add_control( new MP_Profit_Customize_Textarea_Control( $wp_customize, $this->getPrefix() . 'second_action_description', array( 'label' => __( 'Description', 'profit-lite' ), 'section' => $this->getPrefix() . 'second_action_section', 'settings' => $this->getPrefix() . 'second_action_description', 'priority' => 3 ) ) ); /* * Add the 'second to call actionsecond_action brand button label' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'second_action_brandbutton_label', array( 'sanitize_callback' => array( $this, 'sanitize_text' ), 'default' => __( 'Know More', 'profit-lite' ), 'capability' => 'edit_theme_options', 'transport' => 'postMessage' ) ); /* * Add the upload control for the 'second to call action brand button label' setting. */ $wp_customize->add_control( $this->getPrefix() . 'second_action_brandbutton_label', array( 'label' => __( 'Button label', 'profit-lite' ), 'section' => $this->getPrefix() . 'second_action_section', 'settings' => $this->getPrefix() . 'second_action_brandbutton_label', 'priority' => 4 ) ); /* * Add the 'second to call action brand button url' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'second_action_brandbutton_url', array( 'sanitize_callback' => array( $this, 'sanitize_text' ), 'default' => '#', 'capability' => 'edit_theme_options', 'transport' => 'postMessage' ) ); /* * Add the upload control for the 'second to call action brand button url' setting. */ $wp_customize->add_control( $this->getPrefix() . 'second_action_brandbutton_url', array( 'label' => __( 'Button url', 'profit-lite' ), 'section' => $this->getPrefix() . 'second_action_section', 'settings' => $this->getPrefix() . 'second_action_brandbutton_url', 'priority' => 5 ) ); /* * Add the 'second to call action position' setting. */ $wp_customize->add_setting( $this->getPrefix() . 'second_action_position', array( 'default' => 70, 'capability' => 'edit_theme_options', 'sanitize_callback' => array( $this, 'sanitize_position' ) ) ); /* * Add the upload control for the 'second to call action position' setting. */ $wp_customize->add_control( $this->getPrefix() . 'second_action_position', array( 'label' => __( 'Section position', 'profit-lite' ), 'section' => $this->getPrefix() . 'second_action_section', 'settings' => $this->getPrefix() . 'second_action_position', 'priority' => 30 ) ); /* * Add the 'news section'. */ $wp_customize->add_section( $this->getPrefix() . 'news_section', array( 'title' => __( 'News Section', 'profit-lite' ), 'priority' => 86, 'capability' => 'edit_theme_options', 'description' => __( 'Automatically filled by your latest posts.