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

if ( ! function_exists( 'ogma_news_customizer_selective_refresh' ) ) :

	/**
	 * function about control partial refresh for the customizer preview
	 * 
	 * @since 1.0.0
	 */
	function ogma_news_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( 'ogma_news_header_site_mode_switch_enable',
	        array(
	            'selector'        => '#masthead #ogma-news-site-mode-wrap',
	            'render_callback' => 'ogma_news_site_mode_switcher',
	        )
	    );

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

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

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



	}

endif;

add_action( 'customize_register', 'ogma_news_customizer_selective_refresh' );

/**
 * Render the value of custom button label for the selective refresh partial.
 *
 * @return void
 */
function ogma_news_customize_partial_custom_button_label() {
	$custom_button_label = ogma_news_get_customizer_option_value( 'ogma_news_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_news_customize_partial_ticker_label() {
	$ticker_label = ogma_news_get_customizer_option_value( 'ogma_news_header_ticker_label' );
	return $ticker_label;
}

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

