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

function feminine_lifestyle_blog_customize_register_general_page_settings( $wp_customize ) {
    
    /**  Pages Settings */
    $wp_customize->add_section(
        'pages_settings',
        array(
            'title'    => __( 'Pages', 'feminine-lifestyle-blog' ),
            'priority' => 50,
            'panel'    => 'general_settings',
        )
    );
    
    /** Prefix Archive Page */
    $wp_customize->add_setting( 
        'ed_prefix_archive', 
        array(
            'default'           => true,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox'
        ) 
    );
    
    $wp_customize->add_control(
		new Feminine_Lifestyle_Blog_Toggle_Control( 
			$wp_customize,
			'ed_prefix_archive',
			array(
				'section'     => 'pages_settings',
				'label'	      => __( 'Hide Prefix in Archive Page', 'feminine-lifestyle-blog' ),
                'description' => __( 'Enable to hide prefix in archive page.', 'feminine-lifestyle-blog' ),
			)
		)
	);
        
    /** Blog Excerpt */
    $wp_customize->add_setting( 
        'ed_excerpt', 
        array(
            'default'           => true,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox'
        ) 
    );
    
    $wp_customize->add_control(
		new Feminine_Lifestyle_Blog_Toggle_Control( 
			$wp_customize,
			'ed_excerpt',
			array(
				'section'     => 'pages_settings',
				'label'	      => __( 'Enable Blog Excerpt', 'feminine-lifestyle-blog' ),
                'description' => __( 'Enable to show excerpt or disable to show full post content.', 'feminine-lifestyle-blog' ),
			)
		)
	);
    
    /** Excerpt Length */
    $wp_customize->add_setting( 
        'excerpt_length', 
        array(
            'default'           => 25,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_number_absint'
        ) 
    );
    
    $wp_customize->add_control(
		new Feminine_Lifestyle_Blog_Slider_Control( 
			$wp_customize,
			'excerpt_length',
			array(
				'section'	  => 'pages_settings',
				'label'		  => __( 'Excerpt Length', 'feminine-lifestyle-blog' ),
				'description' => __( 'Automatically generated excerpt length (in words).', 'feminine-lifestyle-blog' ),
                'choices'	  => array(
					'min' 	=> 10,
					'max' 	=> 100,
					'step'	=> 5,
				)                 
			)
		)
	);
    
    /** Read More Text */
    $wp_customize->add_setting(
        'read_more_text',
        array(
            'default'           => __( 'Read More', 'feminine-lifestyle-blog' ),
            'sanitize_callback' => 'sanitize_text_field',
            'transport'         => 'postMessage' 
        )
    );
    
    $wp_customize->add_control(
        'read_more_text',
        array(
            'type'    => 'text',
            'section' => 'pages_settings',
            'label'   => __( 'Read More Text', 'feminine-lifestyle-blog' ),
        )
    );
    
    $wp_customize->selective_refresh->add_partial( 'read_more_text', array(
        'selector' => '.entry-footer .secondary-btn',
        'render_callback' => 'feminine_lifestyle_blog_get_read_more',
    ) );

    /** Enable Image Cropped Size In Home, Archive And Search Posts */
    $wp_customize->add_setting( 
        'ed_crop_blog', 
        array(
            'default'           => false,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox'
        ) 
    );
    
    $wp_customize->add_control(
        new Feminine_Lifestyle_Blog_Toggle_Control( 
            $wp_customize,
            'ed_crop_blog',
            array(
                'section'     => 'pages_settings',
                'label'       => __( 'Blog Post Image Crop', 'feminine-lifestyle-blog' ),
                'description' => __( 'Enable to avoid automatic cropping of featured image in home, archive and search posts.', 'feminine-lifestyle-blog' ),
            )
        )
    );

        /** Search Page Title  */
        $wp_customize->add_setting(
            'search_title',
            array(
                'default'           => __( 'Search Result For', 'feminine-lifestyle-blog' ),
                'sanitize_callback' => 'sanitize_text_field',
                'transport'         => 'postMessage'
            )
        );
        
        $wp_customize->add_control(
            'search_title',
            array(
                'label'       => __( 'Search Page Title', 'feminine-lifestyle-blog' ),
                'description' => __( 'You can change title of your search page from here.', 'feminine-lifestyle-blog' ),
                'section'     => 'pages_settings',
                'type'        => 'text',                                 
            )
        );

        $wp_customize->selective_refresh->add_partial( 'search_title', array(
            'selector' => '.search .page-header__content-wrapper .page-title',
            'render_callback' => 'feminine_lifestyle_blog_get_search_title',
        ) );
    
        $wp_customize->add_setting( 
            'error_show_image',
            array(
                'default'           => '',
                'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_image',
            )
        );
    
        $wp_customize->add_control( 
            new WP_Customize_Image_Control( 
                $wp_customize, 
                'error_show_image',
                array(
                    'label'         => esc_html__( 'Add 404 Image', 'feminine-lifestyle-blog' ),
                    'description'   => esc_html__( 'Recommended size for this image is 430px by 650px.', 'feminine-lifestyle-blog' ),
                    'section'       => 'pages_settings',
                    'type'          => 'image',
                )
            )
        );
    
    /** Pages Settings Ends */
    
}
add_action( 'customize_register', 'feminine_lifestyle_blog_customize_register_general_page_settings' );