get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; $wp_customize->get_section( 'static_front_page' )->panel = 'theme_home_pannel'; $wp_customize->get_section( 'static_front_page' )->title = esc_html__('Homepage Page/Post Option','beginner-blog'); $wp_customize->get_section( 'colors' )->panel = 'theme_colors_panel'; $wp_customize->get_section( 'colors' )->title = esc_html__('Color Options','beginner-blog'); $wp_customize->get_section( 'title_tagline' )->panel = 'theme_general_settings'; $wp_customize->get_section( 'header_image' )->panel = 'theme_general_settings'; $wp_customize->get_section( 'background_image' )->panel = 'theme_general_settings'; if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'beginner_blog_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'beginner_blog_customize_partial_blogdescription', ) ); } $beginner_blog_default = beginner_blog_get_default_theme_options(); $wp_customize->add_setting('logo_width_range', array( 'default' => $beginner_blog_default['logo_width_range'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'beginner_blog_sanitize_number_range', ) ); $wp_customize->add_control('logo_width_range', array( 'label' => esc_html__('Logo With', 'beginner-blog'), 'description' => esc_html__( 'Define logo size min-200 to max-700 (step-20)', 'beginner-blog' ), 'section' => 'title_tagline', 'type' => 'range', 'input_attrs' => array( 'min' => 200, 'max' => 700, 'step' => 20, ), ) ); // Theme Options Panel. $wp_customize->add_panel( 'theme_option_panel', array( 'title' => esc_html__( 'Theme Options', 'beginner-blog' ), 'priority' => 150, 'capability' => 'edit_theme_options', ) ); $wp_customize->add_panel( 'theme_general_settings', array( 'title' => esc_html__( 'General Settings', 'beginner-blog' ), 'priority' => 10, 'capability' => 'edit_theme_options', ) ); $wp_customize->add_panel( 'theme_colors_panel', array( 'title' => esc_html__( 'Color Settings', 'beginner-blog' ), 'priority' => 15, 'capability' => 'edit_theme_options', ) ); // Theme Options Panel. $wp_customize->add_panel( 'theme_footer_option_panel', array( 'title' => esc_html__( 'Footer Setting', 'beginner-blog' ), 'priority' => 150, 'capability' => 'edit_theme_options', ) ); // Template Options $wp_customize->add_panel( 'theme_home_pannel', array( 'title' => esc_html__( 'Frontpage Settings', 'beginner-blog' ), 'priority' => 150, 'capability' => 'edit_theme_options', ) ); $beginner_blog_defaults = beginner_blog_get_default_theme_options(); $home_section_arrange_vals_4 = get_theme_mod( 'home_section_arrange_vals_4', $beginner_blog_defaults['home_section_arrange_vals_4'] ); $home_section_arrange_vals_4 = explode(",",$home_section_arrange_vals_4 ); $j = 1; foreach( $home_section_arrange_vals_4 as $home_section_arrange ){ if ($j <= 5) { $wp_customize->get_section( $home_section_arrange )->priority = $j; } $j ++; } // Register custom section types. $wp_customize->register_section_type( 'Beginner_Blog_Customize_Section_Upsell' ); // Register sections. $wp_customize->add_section( new Beginner_Blog_Customize_Section_Upsell( $wp_customize, 'theme_upsell', array( 'title' => esc_html__( 'Beginner Blog Pro', 'beginner-blog' ), 'pro_text' => esc_html__( 'Upgrade To Pro', 'beginner-blog' ), 'pro_url' => esc_url('https://www.themeinwp.com/theme/beginner-blog-pro/'), 'priority' => 1, ) ) ); } endif; add_action( 'customize_register', 'beginner_blog_customize_register' ); add_action( 'wp_ajax_beginner_blog_arrange_home_section', 'beginner_blog_arrange_home_section' ); add_action('wp_ajax_nopriv_beginner_blog_arrange_home_section', 'beginner_blog_arrange_home_section'); function beginner_blog_arrange_home_section() { if ( isset( $_POST['sections'] ) ) { set_theme_mod( 'home_section_arrange_vals_4', wp_unslash( $_POST['sections'] ) ); } wp_die(); // this is required to terminate immediately and return a proper response } /** * Customizer Enqueue scripts and styles. */ if (!function_exists('beginner_blog_customizer_scripts')) : function beginner_blog_customizer_scripts(){ wp_enqueue_script('jquery-ui-button'); wp_enqueue_style('beginner-blog-customizer', get_template_directory_uri() . '/assets/lib/custom/css/customizer.css'); wp_enqueue_script('beginner-blog-customizer', get_template_directory_uri() . '/assets/lib/custom/js/customizer.js', array('jquery','customize-controls'), '', 1); wp_enqueue_script('beginner-blog-re-customizer', get_template_directory_uri() . '/assets/lib/custom/js/re-customizer.js', array('jquery','customize-controls'), '', 1); $ajax_nonce = wp_create_nonce('beginner_blog_ajax_nonce'); wp_localize_script( 'beginner-blog-customizer', 'beginner_blog_customizer', array( 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), 'ajax_nonce' => $ajax_nonce, ) ); $home_section_arrange_vals_4 = get_theme_mod( 'home_section_arrange_vals_4' ); $home_section_arrange_vals_4 = explode(",",$home_section_arrange_vals_4 ); $key_sidebar = ''; $home_url = esc_url( home_url('/') ); wp_localize_script( 'beginner-blog-re-customizer', 'beginner_blog_re_customizer', array( 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), 'ajax_nonce' => $ajax_nonce, 'key_sidebar' => $key_sidebar, 'home_url' => $home_url, ) ); } endif; add_action('customize_controls_enqueue_scripts', 'beginner_blog_customizer_scripts'); add_action('customize_controls_init', 'beginner_blog_customizer_scripts'); /** * Render the site title for the selective refresh partial. * * @return void */ if (!function_exists('beginner_blog_customize_partial_blogname')) : function beginner_blog_customize_partial_blogname() { bloginfo( 'name' ); } endif; /** * Render the site tagline for the selective refresh partial. * * @return void */ if (!function_exists('beginner_blog_customize_partial_blogdescription')) : function beginner_blog_customize_partial_blogdescription() { bloginfo( 'description' ); } endif;