<?php
/**
 * Instagram Settings
 *
 * @package Feminine_Lifestyle_Blog
 */

function feminine_lifestyle_blog_customize_register_general_instagram( $wp_customize ) {
    
    /** Instagram Settings */
    $wp_customize->add_section(
        'instagram_settings',
        array(
            'title'    => __( 'Instagram', 'feminine-lifestyle-blog' ),
            'priority' => 70,
            'panel'    => 'homepage_settings',
        )
    );
    
    if( feminine_lifestyle_blog_is_sbif_activated() ){
        /** Enable Instagram Section */
        $wp_customize->add_setting( 
            'ed_instagram', 
            array(
                'default'           => false,
                'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox'
            ) 
        );
        
        $wp_customize->add_control(
    		new Feminine_Lifestyle_Blog_Toggle_Control( 
    			$wp_customize,
    			'ed_instagram',
    			array(
    				'section'     => 'instagram_settings',
    				'label'	      => __( 'Instagram Section', 'feminine-lifestyle-blog' ),
                    'description' => __( 'Enable to show Instagram Section', 'feminine-lifestyle-blog' ),
    			)
    		)
    	);
        
        
        /** Instagram title */
        $wp_customize->add_setting(
            'instagram_title',
            array(
                'default'           => __( 'Instagram', 'feminine-lifestyle-blog' ),
                'sanitize_callback' => 'sanitize_text_field',
                'transport'         => 'postMessage'
            )
        );
        
        $wp_customize->add_control(
            'instagram_title',
            array(
                'section'           => 'instagram_settings',
                'label'             => __( 'Section Title', 'feminine-lifestyle-blog' ),
                'type'              => 'text',
            )
        );

        $wp_customize->selective_refresh->add_partial( 'instagram_title', array(
            'selector'          => '.instagram-section .section-header h2.section-title',
            'render_callback'   => 'feminine_lifestyle_blog_get_instagram_title',
        ) );

        $wp_customize->add_setting(
            'instagram_shortcode',
            array(
                'default'           => '',
                'sanitize_callback' => 'wp_kses_post',
            )
        );
        
        $wp_customize->add_control(
            'instagram_shortcode',
            array(
                'label'             => __( 'Instagram Shortcode', 'feminine-lifestyle-blog' ),
                'description'       => __( 'Please insert the shortcode created from the Smash Balloon Social Photo Feed Plugin', 'feminine-lifestyle-blog' ),
                'type'              => 'text',
                'section'           => 'instagram_settings',
            )
        );

    }else{
        $wp_customize->add_setting(
			'instagram_recommend',
			array(
				'sanitize_callback' => 'wp_kses_post',
			)
		);

		$wp_customize->add_control(
			new Feminine_Lifestyle_Blog_Plugin_Recommend_Control(
				$wp_customize,
				'instagram_recommend',
				array(
					'section'     => 'instagram_settings',
					'capability'  => 'install_plugins',
					'plugin_slug' => 'instagram-feed',//This is the slug of recommended plugin.
					'description' => sprintf( __( 'Please install and activate the recommended plugin %1$sSmash Balloon Social Photo Feed%2$s. After that option related with this section will be visible.', 'feminine-lifestyle-blog' ), '<strong>', '</strong>' ),
				)
			)
		);
    }
    
}
add_action( 'customize_register', 'feminine_lifestyle_blog_customize_register_general_instagram' );