<?php
/**
 * SiaraDigitalSolutions functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package SiaraDigitalSolutions
 */

/**
 * Enqueue parent and child theme stylesheets
 */

// define('FS_METHOD', 'direct');

function siaradigitalsolutions_enqueue_styles() {
    // Enqueue parent theme stylesheet
    wp_enqueue_style( 'siara-corporate-business-style', get_template_directory_uri() . '/style.css' );
    
    // Enqueue child theme stylesheet
    wp_enqueue_style( 'siara-digital-solutions-style', get_stylesheet_directory_uri() . '/style.css', array( 'siara-corporate-business-style' ), wp_get_theme()->get('Version') );
}
add_action( 'wp_enqueue_scripts', 'siaradigitalsolutions_enqueue_styles' );

if ( ! function_exists( 'siaracorporatebusiness_add_new_read_more_styles' ) ) :
	function siaracorporatebusiness_add_new_read_more_styles( $styles ) {
		return array_merge(
			$styles,
			array(
				'style_4' => __( 'Style 4', 'siara-digital-solutions' ),
			)
		);
	}
endif;
add_filter( 'siaracorporatebusiness_read_more_styles', 'siaracorporatebusiness_add_new_read_more_styles' );

$fresh_site_activate = get_option( 'siaradigitalsolutions_site_activate' );
if ( (bool) $fresh_site_activate === false ) {

    $options = array(
        'accent_color'                               => '#c69d6d',

    );

    foreach ( $options as $key => $value ) {
        set_theme_mod( $key, $value );
    }

	update_option( 'siaradigitalsolutions_site_activate', true );
}



/**
 * Child theme: make "Header Style 3" the default (without locking it).
 * - Sets it once in DB so you see it immediately.
 * - Keeps Customizer + front-end default as Style 3 if unset.
 */

/* 1) Front-end fallback: use Style 3 when no value is saved */
add_filter( 'theme_mod_header_style', function( $value ) {
	if ( empty( $value ) ) {
		return 'header_style_3';
	}
	return $value; // respect saved choice
} );

/* 2) Customizer UI default: preselect Style 3 */
add_action( 'customize_register', function( $wp_customize ) {
	$setting = $wp_customize->get_setting( 'header_style' );
	if ( $setting ) {
		$setting->default = 'header_style_3';
	}
}, 99 );

/* 3) One-time seed: set Style 3 now (does NOT keep forcing it) */
add_action( 'init', function() {
	$flag = 'child_seed_header_style3_done';
	if ( ! get_option( $flag ) ) {
		set_theme_mod( 'header_style', 'header_style_3' ); // write once
		update_option( $flag, 1 );
	}
} );


/**
 * Child theme: Add Services Heading Text setting
 */
function siaradigitalsolutions_customize_register( $wp_customize ) {



	// header_socialicon_twitter_link
	$wp_customize->add_setting(
		'header_socialicon_twitter_link',
		array(
			'default'           => __( '#', 'siara-digital-solutions' ),
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'header_socialicon_twitter_link',
		array(
			'label'           => __( 'Twitter Link', 'siara-digital-solutions' ),
			'section'         => 'header_options',
			'type'            => 'text',
			'priority'        => 18,
		)
	);




	// slider subtitle text
	$wp_customize->add_setting(
		'slider_subtitle_text',
		array(
			'default'           => __( 'Groth Your Business Online', 'siara-digital-solutions' ),
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'slider_subtitle_text',
		array(
			'label'           => __( 'Sub Title Text', 'siara-digital-solutions' ),
			'section'         => 'home_slider_options',
			'type'            => 'text',
			'active_callback' => 'siaracorporatebusiness_is_slider_posts_enabled',
			'priority'        => 11,
		)
	);

	// slider learnmorebtn link 
	$wp_customize->add_setting(
		'slider_learnmorebtn_link',
		array(
			'default'           => __( '#', 'siara-digital-solutions' ),
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'slider_learnmorebtn_link',
		array(
			'label'           => __( 'Explore Services Button Link', 'siara-digital-solutions' ),
			'section'         => 'home_slider_options',
			'type'            => 'text',
			'active_callback' => 'siaracorporatebusiness_is_slider_posts_enabled',
			'priority'        => 16,
		)
	);


	// aboutus list3 text.
	$wp_customize->add_setting(
		'aboutus_list3_text',
		array(
			'default'           => __( 'Affordable Digital Services', 'siara-digital-solutions' ),
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'aboutus_list3_text',
		array(
			'label'           => __( 'Aboutus List 3 Text', 'siara-digital-solutions' ),
			'section'         => 'home_aboutus_options',
			'type'            => 'text',
			'active_callback' => 'siaracorporatebusiness_is_aboutus_posts_enabled',
			'priority'        => 20,
		)
	);

	// aboutus list4 text.
	$wp_customize->add_setting(
		'aboutus_list4_text',
		array(
			'default'           => __( '24/7 Dedicated Support', 'siara-digital-solutions' ),
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'aboutus_list4_text',
		array(
			'label'           => __( 'Aboutus List 4 Text', 'siara-digital-solutions' ),
			'section'         => 'home_aboutus_options',
			'type'            => 'text',
			'active_callback' => 'siaracorporatebusiness_is_aboutus_posts_enabled',
			'priority'        => 20,
		)
	);

	// aboutus yearofexperiencenum.
	$wp_customize->add_setting(
		'aboutus_yearofexperiencenum',
		array(
			'default'           => __( '5+', 'siara-digital-solutions' ),
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'aboutus_yearofexperiencenum',
		array(
			'label'           => __( 'Year of Experience', 'siara-digital-solutions' ),
			'section'         => 'home_aboutus_options',
			'type'            => 'text',
			'active_callback' => 'siaracorporatebusiness_is_aboutus_posts_enabled',
			'priority'        => 23,
		)
	);

	// aboutus Image2.
	$wp_customize->add_setting(
		'aboutus_image2',
		array(
			'sanitize_callback' => 'siaracorporatebusiness_sanitize_image',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Image_Control(
			$wp_customize,
			'aboutus_image2',
			array(
				'label'           => __( 'Aboutus Image 2', 'siara-digital-solutions' ),
				'section'         => 'home_aboutus_options',
				'active_callback' => 'siaracorporatebusiness_is_aboutus_posts_enabled',
				'priority'        => 11,
			)
		)
	);


	// services heading.
	$wp_customize->add_setting(
		'services_heading',
		array(
			'default'           => __( 'Everything You Need To', 'siara-digital-solutions' ),
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'services_heading',
		array(
			'label'           => __( 'Services Heading ', 'siara-digital-solutions' ),
			'section'         => 'home_services_options',
			'type'            => 'text',
			'active_callback' => 'siaracorporatebusiness_is_aboutus_posts_enabled',
			'priority'        => 11,
		)
	);


	
}
add_action( 'customize_register', 'siaradigitalsolutions_customize_register', 20 );


function siaradigitalsolutions_theme_setup() {
    // Let WordPress manage document title
    add_theme_support( 'title-tag' );

	// Add default posts and comments RSS feed links to head
    add_theme_support( 'automatic-feed-links' );

}
add_action( 'after_setup_theme', 'siaradigitalsolutions_theme_setup' );


/**
 * Remove unwanted Customizer settings/controls in child theme
 */

function siaradigitalsolutions_child_customize_remove( $wp_customize ) {


	$wp_customize->remove_section( 'global_buttons_options' );

	// top header
	$wp_customize->remove_control( 'header_topbar_text' );
	$wp_customize->remove_control( 'header_topbar_joinwithus_text' );
	$wp_customize->remove_control( 'header_topbar_joinwithus_link' );

	
	// About us
	$wp_customize->remove_control( 'aboutus_reviewnum' );
	$wp_customize->remove_control( 'aboutus_reviewnumtext' );
	$wp_customize->remove_control( 'aboutus_growthnum' );
	$wp_customize->remove_control( 'aboutus_growthtext' );



}
add_action( 'customize_register', 'siaradigitalsolutions_child_customize_remove', 20 );