<?php
/**
 * Manage the function for customizer selective refresh
 * 
 * @package Ogma
 */

if ( ! function_exists( 'ogma_customizer_selective_refresh' ) ) :

	/**
	 * function about control partial refresh for the customizer preview
	 * 
	 * @since 1.0.0
	 */
	function ogma_customizer_selective_refresh( $wp_customize ) {

		// Abort if selective refresh is not available.
	    if ( ! isset( $wp_customize->selective_refresh ) ) {
	        return;
	    }

	    //site mode switcher -- Header Settings > Main Area
	    $wp_customize->selective_refresh->add_partial( 'header_site_mode_switch_enable',
	        array(
	            'selector'        => '#masthead #ogma-site-mode-wrap',
	            'render_callback' => 'ogma_site_mode_switcher',
	        )
	    );

	    //custom button label -- Header Settings > Main Area
	    $wp_customize->selective_refresh->add_partial( 'header_custom_button_label',
	        array(
	            'selector'        => '#masthead .custom-button-wrap a',
	            'render_callback' => 'ogma_customize_partial_custom_button_label',
	        )
	    );

	    //news ticker label -- Header Settings > News Ticker
	    $wp_customize->selective_refresh->add_partial( 'header_ticker_label',
	        array(
	            'selector'        => '.header-news-ticker-wrapper .news-ticker-label span.label-text',
	            'render_callback' => 'ogma_customize_partial_ticker_label',
	        )
	    );

	    //copyright info -- Footer Settings > Bottom Area
	    $wp_customize->selective_refresh->add_partial( 'footer_copyright_info',
	        array(
	            'selector'        => '.site-info .copyright-content',
	            'render_callback' => 'ogma_customize_partial_copyright_info',
	        )
	    );
	    



	}

endif;

add_action( 'customize_register', 'ogma_customizer_selective_refresh' );

/**
 * Render the value of custom button label for the selective refresh partial.
 *
 * @return void
 */
function ogma_customize_partial_custom_button_label() {
	$custom_button_label = ogma_get_customizer_option_value( 'header_custom_button_label' );
	return ( '<span class="custom-button-bell-icon"> <i class="bx bx-bell"></i></span>'.$custom_button_label );
}

/**
 * Render the value of ticker label for the selective refresh partial.
 *
 * @return void
 */
function ogma_customize_partial_ticker_label() {
	$ticker_label = ogma_get_customizer_option_value( 'header_ticker_label' );
	return $ticker_label;
}

/**
 * Render the value of copyright info for the selective refresh partial.
 *
 * @return void
 */
function ogma_customize_partial_copyright_info() {
	$copyright_info = ogma_get_customizer_option_value( 'footer_copyright_info' );
	return $copyright_info;
}

