Files
Sophia-After-Dark/inc/customizer/sad-customizer.php
2025-05-20 23:47:21 -07:00

102 lines
4.9 KiB
PHP

<?php
/**
* Sophia After Dark Theme Customizer
*
* @package Sophia After Dark
* @since 1.0.0
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function sophia_after_dark_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_section( 'title_tagline' )->panel = 'sophia_after_dark_general_panel';
$wp_customize->get_section( 'title_tagline' )->priority = '5'; $wp_customize->get_section( 'background_image' )->panel = 'sophia_after_dark_general_panel';
$wp_customize->get_section( 'background_image' )->priority = '15';
$wp_customize->get_section( 'static_front_page' )->panel = 'sophia_after_dark_general_panel';
$wp_customize->get_section( 'static_front_page' )->priority = '20';
$wp_customize->get_section( 'header_image' )->panel = 'sophia_after_dark_header_panel';
$wp_customize->get_section( 'header_image' )->priority = '5';
$wp_customize->get_section( 'header_image' )->description = __( 'Header Image for only Innerpages', 'sophia-after-dark' );
$wp_customize->add_setting('sophia_after_dark_home_og_image', array('default' => '','sanitize_callback' => 'esc_url_raw','type' => 'option',));
$wp_customize->add_setting('sophia_after_dark_home_og_user', array('default' => 1,'sanitize_callback' => 'absint','type' => 'option',));
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => 'sophia_after_dark_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'sophia_after_dark_customize_partial_blogdescription',
) );
}
/**
* Load customizer custom classes.
*/
$wp_customize->register_control_type( 'sophia_after_dark_Control_Toggle' );
$wp_customize->register_control_type( 'sophia_after_dark_Control_Radio_Image' );
}
add_action( 'customize_register', 'sophia_after_dark_customize_register' );
/**
* Render the site title for the selective refresh partial.
*
* @return void
*/
function sophia_after_dark_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @return void
*/
function sophia_after_dark_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function sophia_after_dark_customize_preview_js() {
wp_enqueue_script( 'sophia-after-dark-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'sophia_after_dark_customize_preview_js' );
/*----------------------------------------------------------------------------------------------------------------------------------------*/
/**
* Enqueue required scripts/styles for customizer panel
*
* @since 1.0.0
*/
function sophia_after_dark_customize_backend_scripts() {
global $sophia_after_dark_theme_version;
wp_enqueue_style( 'sophia-after-dark--admin-customizer-style', get_template_directory_uri() . '/assets/css/sad-customizer-styles.css', array(), esc_attr( esc_attr( $sophia_after_dark_theme_version ) ) );
wp_enqueue_style( 'jquery-ui', esc_url( get_template_directory_uri() . '/assets/css/jquery-ui.css' ) );
wp_enqueue_script( 'sophia-after-dark--admin-customizer-script', get_template_directory_uri() . '/assets/js/sad-customizer-controls.js', array( 'jquery', 'customize-controls' ), esc_attr( $sophia_after_dark_theme_version ), true );
}
add_action( 'customize_controls_enqueue_scripts', 'sophia_after_dark_customize_backend_scripts', 10 );
/**
* Add Kirki required file for custom fields
*/
#require get_template_directory() . '/inc/customizer/sad-customizer-additional-open-graph.php';
require get_template_directory() . '/inc/customizer/sad-customizer-custom-classes.php';
require get_template_directory() . '/inc/customizer/sad-customizer-panels.php';
require get_template_directory() . '/inc/customizer/sad-sanitize.php';
require get_template_directory() . '/inc/customizer/sad-callback.php';
require get_template_directory() . '/inc/customizer/sad-customizer-general-panel-options.php';
require get_template_directory() . '/inc/customizer/sad-customizer-header-panel-options.php';
require get_template_directory() . '/inc/customizer/sad-customizer-front-panel-options.php';
require get_template_directory() . '/inc/customizer/sad-customizer-additional-panel-options.php';
require get_template_directory() . '/inc/customizer/sad-customizer-design-panel-options.php';
require get_template_directory() . '/inc/customizer/sad-customizer-footer-panel-options.php';