add_panel( 'hestia_appearance_settings', array(
'priority' => 25,
'title' => esc_html__( 'Appearance Settings', 'hestia-pro' ),
));
$wp_customize->add_panel( 'hestia_frontpage_sections', array(
'priority' => 30,
'title' => esc_html__( 'Frontpage Sections', 'hestia-pro' ),
'description' => esc_html__( 'Drag and drop panels to change sections order.','hestia-pro' ),
));
$wp_customize->add_panel( 'hestia_blog_settings', array(
'priority' => 35,
'title' => esc_html__( 'Blog Settings', 'hestia-pro' ),
));
$wp_customize->get_section( 'header_image' )->panel = 'hestia_appearance_settings';
$wp_customize->get_section( 'background_image' )->panel = 'hestia_appearance_settings';
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'custom_logo' )->transport = 'postMessage';
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'custom_logo', array(
'selector' => '.navbar-brand',
'settings' => 'custom_logo',
'render_callback' => 'hestia_custom_logo_callback',
));
}
}
add_action( 'customize_register', 'hestia_customize_register' );
/**
* Custom logo callback function.
*
* @return string
*/
function hestia_custom_logo_callback() {
if ( get_theme_mod( 'custom_logo' ) ) {
$logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ) , 'full' );
$logo = '';
} else {
if ( is_front_page() ) {
$logo = '
' . get_bloginfo( 'name' ) . '
'; } } return $logo; } /** * Function to sanitize alpha color. * * @param string $input Hex or RGBA color. * * @return string|void */ function hestia_sanitize_colors( $input ) { // Is this an rgba color or a hex? $mode = ( false === strpos( $input, 'rgba' ) ) ? 'hex' : 'rgba'; if ( 'rgba' === $mode ) { return hestia_sanitize_rgba( $input ); } else { return sanitize_hex_color( $input ); } } /** * Sanitize rgba color. * * @param string $value Color in rgba format. * * @return string */ function hestia_sanitize_rgba( $value ) { $red = $green = $blue = $alpha = 'rgba(0,0,0,0)'; // If empty or an array return transparent if ( empty( $value ) || is_array( $value ) ) { return ''; } // By now we know the string is formatted as an rgba color so we need to further sanitize it. $value = str_replace( ' ', '', $value ); sscanf( $value, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha ); return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')'; }