get_setting('blogname')->transport = 'postMessage'; // @phpstan-ignore-line. Assume that this setting exists. $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; // @phpstan-ignore-line. Assume that this setting exists. // Add partial for blogname. // $wp_customize->selective_refresh->add_partial( // 'blogname', // array( // 'selector' => '.site-title', // 'render_callback' => akbar_partial_blogname(), // ) // ); // Add partial for blogdescription. // $wp_customize->selective_refresh->add_partial( // 'blogdescription', // array( // 'selector' => '.site-description', // 'render_callback' => akbar_partial_blogdescription(), // ) // ); // // $wp_customize->add_section( // 'layout_section', // array( // 'title' => __('Layout', 'akbar'), // 'capability' => 'edit_theme_options', // 'description' => __('Allows you to edit your theme layout.', 'akbar'), // 'priority' => 25, // ) // ); // $wp_customize->add_setting('akbar_layout_options[address_text]', array( // 'capability' => 'edit_theme_options', // 'type' => 'theme_mods', // 'default' => '555 5th St NW', // )); // $wp_customize->add_control('akbar_layout_options[address_text]', array( // 'label' => 'Address', // 'section' => 'layout_section', // 'type' => 'text', // )); // $wp_customize->add_setting('akbar_layout_options[phone_text]', array( // 'capability' => 'edit_theme_options', // 'type' => 'theme_mods', // 'default' => '555-555-5555', // )); // $wp_customize->add_control('akbar_layout_options[phone_text]', array( // 'label' => 'Phone', // 'section' => 'layout_section', // 'type' => 'text', // )); // // // $colors = array(); // $colors[] = array( // 'slug' => 'link_text_color', // 'default' => '#333', // 'label' => __('Link Text Color', 'akbar') // ); // $colors[] = array( // 'slug' => 'paragraph_text_color', // 'default' => '#fff', // 'label' => __('Paragraph Text Color', 'akbar') // ); // foreach ($colors as $color) { // $wp_customize->add_setting( // $color['slug'], // array( // 'default' => $color['default'], // 'type' => 'theme_mods', // 'capability' => 'edit_theme_options' // ) // ); // $wp_customize->add_control( // new WP_Customize_Color_Control( // $wp_customize, // $color['slug'], // array( // 'label' => $color['label'], // 'section' => 'colors', // 'settings' => $color['slug'] // ) // ) // ); // } // // $wp_customize->add_section( // 'logo', // array( // 'title' => __('Logo', 'akbar'), // 'capability' => 'edit_theme_options', // 'description' => __('Allows you to change your theme logo.', 'akbar'), // 'priority' => 26, // ) // ); // $wp_customize->add_setting('akbar_layout_options[user_logo]', array( // 'capability' => 'edit_theme_options', // 'type' => 'theme_mods', // )); // $wp_customize->add_control( // new WP_Customize_Image_Control( // $wp_customize, // 'user_logo', // array( // 'label' => __('Upload a logo', 'akbar'), // 'section' => 'logo', // 'settings' => 'my_great_layout_options[user_logo]', // ) // ) // ); // $logo_ctrl = new WP_Customize_Image_Control( // $wp_customize, // 'user_logo', // array( // 'label' => __( 'Upload a logo', 'akbar' ), // 'section' => 'logo', // 'settings' => 'my_great_layout_options[user_logo]', // )); // $logo_ctrl->add_tab( // 'media_lib', // __( 'Or Use An Old One' ), // 'akbar_media_lib_tab' // ); // $wp_customize->add_control($logo_ctrl); // // Add "display_title_and_tagline" setting for displaying the site-title & tagline. // $wp_customize->add_setting( // 'display_title_and_tagline', // array( // 'capability' => 'edit_theme_options', // 'default' => true, // 'sanitize_callback' => akbar_sanitize_checkbox(), // ) // ); // // // Add control for the "display_title_and_tagline" setting. // $wp_customize->add_control( // 'display_title_and_tagline', // array( // 'type' => 'checkbox', // 'section' => 'title_tagline', // 'label' => esc_html__('Display Site Title & Tagline', 'akbar'), // ) // ); // // /** // * Add excerpt or full text selector to customizer // */ // $wp_customize->add_section( // 'excerpt_settings', // array( // 'title' => esc_html__('Excerpt Settings', 'akbar'), // 'priority' => 120, // ) // ); // // $wp_customize->add_setting( // 'display_excerpt_or_full_post', // array( // 'capability' => 'edit_theme_options', // 'default' => 'excerpt', // 'sanitize_callback' => function ($value) { // return 'excerpt' === $value || 'full' === $value ? $value : 'excerpt'; // }, // ) // ); // // $wp_customize->add_control( // 'display_excerpt_or_full_post', // array( // 'type' => 'radio', // 'section' => 'excerpt_settings', // 'label' => esc_html__('On Archive Pages, posts show:', 'akbar'), // 'choices' => array( // 'excerpt' => esc_html__('Summary', 'akbar'), // 'full' => esc_html__('Full text', 'akbar'), // ), // ) // ); // // // Background color. // // Include the custom control class. //// include_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-color-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound // // // Register the custom control. //// $wp_customize->register_control_type( 'Twenty_Twenty_One_Customize_Color_Control' ); // // // Get the palette from theme-supports. // $palette = get_theme_support('editor-color-palette'); // // // Build the colors array from theme-support. // $colors = array(); // if (isset($palette[0]) && is_array($palette[0])) { // foreach ($palette[0] as $palette_color) { // $colors[] = $palette_color['color']; // } // } // $wp_customize->save(); // Add the control. Overrides the default background-color control. // $wp_customize->add_control( // new Twenty_Twenty_One_Customize_Color_Control( // $wp_customize, // 'background_color', // array( // 'label' => esc_html_x( 'Background color', 'Customizer control', 'akbar' ), // 'section' => 'colors', // 'palette' => $colors, // ) // ) // ); // $wp_customize->add_section('custom_js', array( // 'title' => __('Additional JS', 'textdomain'), // 'priority' => 190, // )); // $wp_customize->add_setting('custom_js', array( // 'type' => 'theme_mods', // )); // $wp_customize->add_control(new WP_Customize_Code_Editor_Control($wp_customize, 'custom_html', array( // 'label' => 'Additional JS', // 'code_type' => 'javascript', // 'settings' => 'custom_js', // 'section' => 'custom_js', // ))); } add_action('customize_register', 'akbar_customize_register'); //add_action('customize_register', 'akbar_customize_register'); function akbar_sanitize_checkbox($checked = null) { return (bool)isset($checked) && true === $checked; } /** * Render the site title for the selective refresh partial. * * @access public * * @since 1.0.0 * * @return void */ function akbar_partial_blogname() { bloginfo('name'); } /** * Render the site tagline for the selective refresh partial. * * @access public * * @since 1.0.0 * * @return void */ function akbar_partial_blogdescription() { bloginfo('description'); } function akbar_layout_options($name, $default = false) { $options = (get_option('akbar_layout_options')) ? get_option('akbar_layout_options') : null; if (isset($options[$name])) { return apply_filters('akbar_layout_options_$name', $options[$name]); } return apply_filters('akbar_layout_options_$name', $default); }