<?php
/**
* GridFlex Theme Customizer.
*
* @package GridFlex WordPress Theme
* @copyright Copyright (C) 2024 ThemesDNA
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
* @author ThemesDNA <themesdna@gmail.com>
*/

if ( ! class_exists( 'WP_Customize_Control' ) ) {return null;}

/**
* GridFlex_Customize_Static_Text_Control class
*
*/
class GridFlex_Customize_Static_Text_Control extends WP_Customize_Control {
    public $type = 'gridflex-static-text';

    public function __construct( $manager, $id, $args = array() ) {
        parent::__construct( $manager, $id, $args );
    }

    protected function render_content() {
        if ( ! empty( $this->label ) ) :
            ?><span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span><?php
        endif;

        if ( ! empty( $this->description ) ) :
            ?><div class="description customize-control-description"><?php

        echo wp_kses_post( $this->description );

            ?></div><?php
        endif;

    }
}

/**
* GridFlex_Customize_Button_Control class
*
*/
class GridFlex_Customize_Button_Control extends WP_Customize_Control {
        public $type = 'gridflex-button';
        protected $button_tag = 'button';
        protected $button_class = 'button button-primary';
        protected $button_href = 'javascript:void(0)';
        protected $button_target = '';
        protected $button_onclick = '';
        protected $button_tag_id = '';

        public function render_content() {
        ?>
        <span class="center">
        <?php
        echo '<' . esc_html($this->button_tag);
        if (!empty($this->button_class)) {
            echo ' class="' . esc_attr($this->button_class) . '"';
        }
        if ('button' == $this->button_tag) {
            echo ' type="button"';
        }
        else {
            echo ' href="' . esc_url($this->button_href) . '"' . (empty($this->button_tag) ? '' : ' target="' . esc_attr($this->button_target) . '"');
        }
        if (!empty($this->button_onclick)) {
            echo ' onclick="' . esc_js($this->button_onclick) . '"';
        }
        if (!empty($this->button_tag_id)) {
            echo ' id="' . esc_attr($this->button_tag_id) . '"';
        }
        echo '>';
        echo esc_html($this->label);
        echo '</' . esc_html($this->button_tag) . '>';
        ?>
        </span>
        <?php
        }
}

/**
* GridFlex_Customize_Submit_Control class
*
*/
class GridFlex_Customize_Submit_Control extends WP_Customize_Control {
        public $type = 'gridflex-submit-button';
        protected $button_class = '';
        protected $button_id = '';
        protected $button_value = '';
        protected $button_onclick = '';

        public function render_content() {
        ?>
        <form action="customize.php" method="get">
        <label>
        <span style="font-weight:normal;margin-bottom:10px;" class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
        <?php
        echo '<input type="submit"';
        if (!empty($this->button_class)) {
            echo ' class="' . esc_attr($this->button_class) . '"';
        }
        if (!empty($this->button_id)) {
            echo ' name="' . esc_attr($this->button_id) . '"';
        }
        if (!empty($this->button_id)) {
            echo ' id="' . esc_attr($this->button_id) . '"';
        }
        if (!empty($this->button_value)) {
            echo ' value="' . esc_attr($this->button_value) . '"';
        }
        if (!empty($this->button_onclick)) {
            echo ' onclick="return confirm(\'' . esc_js($this->button_onclick) . '\');"';
        }
        echo '/>';
        ?>
        </label>
        </form>
        <?php
        }
}

/* Getting started options */
function gridflex_getting_started($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_getting_started', array( 'title' => esc_html__( 'Getting Started', 'gridflex' ), 'description' => esc_html__( 'Thanks for your interest in GridFlex! If you have any questions or run into any trouble, please visit us the following links. We will get you fixed up!', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 5, ) );

    $wp_customize->add_setting( 'gridflex_options[documentation]', array( 'default' => '', 'sanitize_callback' => '__return_false', ) );

    $wp_customize->add_control( new GridFlex_Customize_Button_Control( $wp_customize, 'gridflex_documentation_control', array( 'label' => esc_html__( 'Documentation', 'gridflex' ), 'section' => 'gridflex_section_getting_started', 'settings' => 'gridflex_options[documentation]', 'type' => 'gridflex-button', 'button_tag' => 'a', 'button_class' => 'button button-primary', 'button_href' => esc_url( 'https://themesdna.com/gridflex-wordpress-theme/' ), 'button_target' => '_blank', ) ) );

    $wp_customize->add_setting( 'gridflex_options[contact]', array( 'default' => '', 'sanitize_callback' => '__return_false', ) );

    $wp_customize->add_control( new GridFlex_Customize_Button_Control( $wp_customize, 'gridflex_contact_control', array( 'label' => esc_html__( 'Contact Us', 'gridflex' ), 'section' => 'gridflex_section_getting_started', 'settings' => 'gridflex_options[contact]', 'type' => 'gridflex-button', 'button_tag' => 'a', 'button_class' => 'button button-primary', 'button_href' => esc_url( 'https://themesdna.com/contact/' ), 'button_target' => '_blank', ) ) );

}

/* Menu options */
function gridflex_menu_options($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_menu_options', array( 'title' => esc_html__( 'Menu Options', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 100 ) );

    $wp_customize->add_setting( 'gridflex_options[primary_menu_text]', array( 'default' => esc_html__( 'Menu', 'gridflex' ), 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) );

    $wp_customize->add_control( 'gridflex_primary_menu_text_control', array( 'label' => esc_html__( 'Primary Menu Mobile Text', 'gridflex' ), 'section' => 'gridflex_section_menu_options', 'settings' => 'gridflex_options[primary_menu_text]', 'type' => 'text', ) );

    $wp_customize->add_setting( 'gridflex_options[disable_primary_menu]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_disable_primary_menu_control', array( 'label' => esc_html__( 'Disable Primary Menu', 'gridflex' ), 'section' => 'gridflex_section_menu_options', 'settings' => 'gridflex_options[disable_primary_menu]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[center_primary_menu]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_center_primary_menu_control', array( 'label' => esc_html__( 'Center Primary Menu', 'gridflex' ), 'description' => '<br/><hr/>', 'section' => 'gridflex_section_menu_options', 'settings' => 'gridflex_options[center_primary_menu]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[secondary_menu_text]', array( 'default' => esc_html__( 'Menu', 'gridflex' ), 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) );

    $wp_customize->add_control( 'gridflex_secondary_menu_text_control', array( 'label' => esc_html__( 'Secondary Menu Mobile Text', 'gridflex' ), 'section' => 'gridflex_section_menu_options', 'settings' => 'gridflex_options[secondary_menu_text]', 'type' => 'text', ) );

    $wp_customize->add_setting( 'gridflex_options[disable_secondary_menu]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_disable_secondary_menu_control', array( 'label' => esc_html__( 'Disable Secondary Menu', 'gridflex' ), 'section' => 'gridflex_section_menu_options', 'settings' => 'gridflex_options[disable_secondary_menu]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[secondary_menu_location]', array( 'default' => 'before-header', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_secondary_menu_location' ) );

    $wp_customize->add_control( 'gridflex_secondary_menu_location_control', array( 'label' => esc_html__( 'Select Secondary Menu Location', 'gridflex' ), 'description' => esc_html__('Select where you want to display secondary menu.', 'gridflex'), 'section' => 'gridflex_section_menu_options', 'settings' => 'gridflex_options[secondary_menu_location]', 'type' => 'select', 'choices' => array( 'before-header' => esc_html__('Before Header', 'gridflex'), 'after-header' => esc_html__('After Header', 'gridflex'), 'before-footer' => esc_html__('Before Footer', 'gridflex'), 'after-footer' => esc_html__('After Footer', 'gridflex') ) ) );

    $wp_customize->add_setting( 'gridflex_options[center_secondary_menu]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_center_secondary_menu_control', array( 'label' => esc_html__( 'Center Secondary Menu', 'gridflex' ), 'section' => 'gridflex_section_menu_options', 'settings' => 'gridflex_options[center_secondary_menu]', 'type' => 'checkbox', ) );

}

/* Header options */
function gridflex_header_options($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_header', array( 'title' => esc_html__( 'Header Options', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 120 ) );

    $wp_customize->add_setting( 'gridflex_options[hide_tagline]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_tagline_control', array( 'label' => esc_html__( 'Hide Tagline', 'gridflex' ), 'section' => 'gridflex_section_header', 'settings' => 'gridflex_options[hide_tagline]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_header_content]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_header_content_control', array( 'label' => esc_html__( 'Hide Header Content', 'gridflex' ), 'section' => 'gridflex_section_header', 'settings' => 'gridflex_options[hide_header_content]', 'type' => 'checkbox', ) );


    $wp_customize->add_setting( 'gridflex_options[logo_location]', array( 'default' => 'above-title', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_logo_location' ) );

    $wp_customize->add_control( 'gridflex_logo_location_control', array( 'label' => esc_html__( 'Logo Location', 'gridflex' ), 'description' => esc_html__('Select how you want to display the site logo with site title and tagline.', 'gridflex'), 'section' => 'title_tagline', 'settings' => 'gridflex_options[logo_location]', 'type' => 'select', 'choices' => array( 'beside-title' => esc_html__( 'Before Site Title and Tagline', 'gridflex' ), 'above-title' => esc_html__( 'Above Site Title and Tagline', 'gridflex' ) ), 'priority'   => 8 ) );


    $wp_customize->add_setting( 'gridflex_options[hide_header_image]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_header_image_control', array( 'label' => esc_html__( 'Hide Header Image from Everywhere', 'gridflex' ), 'section' => 'header_image', 'settings' => 'gridflex_options[hide_header_image]', 'type' => 'checkbox', ) );


    $wp_customize->add_setting( 'gridflex_options[remove_header_image_link]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_remove_header_image_link_control', array( 'label' => esc_html__( 'Remove Link from Header Image', 'gridflex' ), 'section' => 'header_image', 'settings' => 'gridflex_options[remove_header_image_link]', 'type' => 'checkbox', ) );


   $wp_customize->add_setting( 'gridflex_options[hide_header_image_details]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_header_image_details_control', array( 'label' => esc_html__( 'Hide both Title and Description from Header Image', 'gridflex' ), 'description' => esc_html__('If you checked this option, header image title and description will be hidden from all screen sizes.', 'gridflex'), 'section' => 'header_image', 'settings' => 'gridflex_options[hide_header_image_details]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_header_image_title]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_header_image_title_control', array( 'label' => esc_html__( 'Hide Title from Header Image', 'gridflex' ), 'description' => esc_html__('If you checked this option, header image title will be hidden from all screen sizes. This option has no effect if you have checked the option: "Hide both Title and Description from Header Image"', 'gridflex'), 'section' => 'header_image', 'settings' => 'gridflex_options[hide_header_image_title]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_header_image_description]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_header_image_description_control', array( 'label' => esc_html__( 'Hide Description from Header Image', 'gridflex' ), 'description' => esc_html__('If you checked this option, header image description will be hidden from all screen sizes. This option has no effect if you have checked the option: "Hide both Title and Description from Header Image"', 'gridflex'), 'section' => 'header_image', 'settings' => 'gridflex_options[hide_header_image_description]', 'type' => 'checkbox', ) );


    $wp_customize->add_setting( 'gridflex_options[header_image_custom_text]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_header_image_custom_text_control', array( 'label' => esc_html__( 'Add Custom Title/Custom Description to Header Image', 'gridflex' ), 'section' => 'header_image', 'settings' => 'gridflex_options[header_image_custom_text]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[header_image_custom_title]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_html', ) );

    $wp_customize->add_control( 'gridflex_header_image_custom_title_control', array( 'label' => esc_html__( 'Header Image Custom Title', 'gridflex' ), 'section' => 'header_image', 'settings' => 'gridflex_options[header_image_custom_title]', 'type' => 'text', ) );

    $wp_customize->add_setting( 'gridflex_options[header_image_custom_description]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_html', ) );

    $wp_customize->add_control( 'gridflex_header_image_custom_description_control', array( 'label' => esc_html__( 'Header Image Custom Description', 'gridflex' ), 'section' => 'header_image', 'settings' => 'gridflex_options[header_image_custom_description]', 'type' => 'text', ) );

    $wp_customize->add_setting( 'gridflex_options[header_image_destination]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_header_image_destination_control', array( 'label' => esc_html__( 'Header Image Destination URL', 'gridflex' ), 'description' => esc_html__( 'Enter the URL a visitor should go when he/she click on the header image. If you did not enter a URL below, header image will be linked to the homepage of your website.', 'gridflex' ), 'section' => 'header_image', 'settings' => 'gridflex_options[header_image_destination]', 'type' => 'text' ) );


    $wp_customize->add_setting( 'gridflex_options[header_image_cover]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_header_image_cover_control', array( 'label' => esc_html__( 'Add a Minimum Height to Header Image on Smaller Screens', 'gridflex' ), 'section' => 'header_image', 'settings' => 'gridflex_options[header_image_cover]', 'type' => 'checkbox', ) );

}

/* Posts Grid options */
function gridflex_posts_grid_options($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_posts_grid', array( 'title' => esc_html__( 'Posts Grid Options', 'gridflex' ), 'description' => esc_html__('To display your latest posts as a grid on your homepage, please set the "Your homepage displays" option to "Your latest posts." You can find this setting in your WordPress Dashboard by navigating to "Settings" -> "Reading" -> "Your homepage displays."', 'gridflex'), 'panel' => 'gridflex_main_options_panel', 'priority' => 160 ) );

    $wp_customize->add_setting( 'gridflex_options[hide_posts_heading]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_posts_heading_control', array( 'label' => esc_html__( 'Hide HomePage Posts Heading', 'gridflex' ), 'section' => 'gridflex_section_posts_grid', 'settings' => 'gridflex_options[hide_posts_heading]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[posts_heading]', array( 'default' => esc_html__( 'Recent Posts', 'gridflex' ), 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) );

    $wp_customize->add_control( 'gridflex_posts_heading_control', array( 'label' => esc_html__( 'HomePage Posts Heading', 'gridflex' ), 'section' => 'gridflex_section_posts_grid', 'settings' => 'gridflex_options[posts_heading]', 'type' => 'text', ) );

    $wp_customize->add_setting( 'posts_per_page', array( 'default' => get_option('posts_per_page'), 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_positive_integer' ) );

    $wp_customize->add_control( 'gridflex_posts_per_page_control', array( 'label' => esc_html__( 'Number of Posts per Page', 'gridflex' ), 'description' => esc_html__('Set the maximum number of posts displayed on each blog page.', 'gridflex'), 'section' => 'gridflex_section_posts_grid', 'settings' => 'posts_per_page', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[hide_post_title_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_post_title_home_control', array( 'label' => esc_html__( 'Hide Post Titles from Posts Grid', 'gridflex' ), 'section' => 'gridflex_section_posts_grid', 'settings' => 'gridflex_options[hide_post_title_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[show_post_categories_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_show_post_categories_home_control', array( 'label' => esc_html__( 'Show Post Categories on Posts Grid', 'gridflex' ), 'section' => 'gridflex_section_posts_grid', 'settings' => 'gridflex_options[show_post_categories_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_posted_date_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_posted_date_home_control', array( 'label' => esc_html__( 'Hide Posted Dates from Posts Grid', 'gridflex' ), 'section' => 'gridflex_section_posts_grid', 'settings' => 'gridflex_options[hide_posted_date_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[show_post_author_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_show_post_author_home_control', array( 'label' => esc_html__( 'Show Post Author Names on Posts Grid', 'gridflex' ), 'section' => 'gridflex_section_posts_grid', 'settings' => 'gridflex_options[show_post_author_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_comments_link_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_comments_link_home_control', array( 'label' => esc_html__( 'Hide Comment Links from Posts Grid', 'gridflex' ), 'section' => 'gridflex_section_posts_grid', 'settings' => 'gridflex_options[hide_comments_link_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[disable_responsive_grid_data]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_disable_responsive_grid_data_control', array( 'label' => esc_html__( 'Do not Hide Grid Posts Contents According to Screen Size', 'gridflex' ), 'section' => 'gridflex_section_posts_grid', 'settings' => 'gridflex_options[disable_responsive_grid_data]', 'type' => 'checkbox', ) );

}

/* Post options */
function gridflex_post_options($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_post', array( 'title' => esc_html__( 'Post Options', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 180 ) );

    $wp_customize->add_setting( 'gridflex_options[thumbnail_link]', array( 'default' => 'yes', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_thumbnail_link' ) );

    $wp_customize->add_control( 'gridflex_thumbnail_link_control', array( 'label' => esc_html__( 'Featured Image Link', 'gridflex' ), 'description' => esc_html__('Do you want the featured image in a single post to be linked to its post?', 'gridflex'), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[thumbnail_link]', 'type' => 'select', 'choices' => array( 'yes' => esc_html__('Yes', 'gridflex'), 'no' => esc_html__('No', 'gridflex') ) ) );

    $wp_customize->add_setting( 'gridflex_options[hide_thumbnail]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_thumbnail_control', array( 'label' => esc_html__( 'Hide Featured Image from Full Post', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[hide_thumbnail]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[featured_media_under_post_title]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_featured_media_under_post_title_control', array( 'label' => esc_html__( 'Move Featured Image to Bottom of Full Post Title', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[featured_media_under_post_title]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_post_title]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_post_title_control', array( 'label' => esc_html__( 'Hide Post Header from Full Post', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[hide_post_title]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[remove_post_title_link]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_remove_post_title_link_control', array( 'label' => esc_html__( 'Remove Link from Full Post Title', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[remove_post_title_link]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_post_categories]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_post_categories_control', array( 'label' => esc_html__( 'Hide Post Categories from Full Post', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[hide_post_categories]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_post_author]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_post_author_control', array( 'label' => esc_html__( 'Hide Post Author from Full Post', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[hide_post_author]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_posted_date]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_posted_date_control', array( 'label' => esc_html__( 'Hide Posted Date from Full Post', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[hide_posted_date]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_comments_link]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_comments_link_control', array( 'label' => esc_html__( 'Hide Comment Link from Full Post', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[hide_comments_link]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_post_edit]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_post_edit_control', array( 'label' => esc_html__( 'Hide Post Edit Link', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[hide_post_edit]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_post_tags]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_post_tags_control', array( 'label' => esc_html__( 'Hide Post Tags from Full Post', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[hide_post_tags]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_author_bio_box]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_author_bio_box_control', array( 'label' => esc_html__( 'Hide Author Bio Box', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[hide_author_bio_box]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[no_underline_content_links]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_no_underline_content_links_control', array( 'label' => esc_html__( 'Do not Underline the Links within the Content', 'gridflex' ), 'section' => 'gridflex_section_post', 'settings' => 'gridflex_options[no_underline_content_links]', 'type' => 'checkbox', ) );

}

/* Navigation options */
function gridflex_navigation_options($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_navigation', array( 'title' => esc_html__( 'Post/Posts Navigation Options', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 185 ) );

    $wp_customize->add_setting( 'gridflex_options[hide_post_navigation]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_post_navigation_control', array( 'label' => esc_html__( 'Hide Post Navigation from Full Posts', 'gridflex' ), 'section' => 'gridflex_section_navigation', 'settings' => 'gridflex_options[hide_post_navigation]', 'type' => 'checkbox', ) );


    $wp_customize->add_setting( 'gridflex_options[hide_posts_navigation]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_posts_navigation_control', array( 'label' => esc_html__( 'Hide Posts Navigation from Home/Archive/Search Pages', 'gridflex' ), 'section' => 'gridflex_section_navigation', 'settings' => 'gridflex_options[hide_posts_navigation]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[posts_navigation_type]', array( 'default' => 'numberednavi', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_posts_navigation_type' ) );

    $wp_customize->add_control( 'gridflex_posts_navigation_type_control', array( 'label' => esc_html__( 'Posts Navigation Type', 'gridflex' ), 'description' => esc_html__('Select posts navigation type you need. If you activate WP-PageNavi plugin, this navigation will be replaced by WP-PageNavi navigation.', 'gridflex'), 'section' => 'gridflex_section_navigation', 'settings' => 'gridflex_options[posts_navigation_type]', 'type' => 'select', 'choices' => array( 'normalnavi' => esc_html__('Normal Navigation', 'gridflex'), 'numberednavi' => esc_html__('Numbered Navigation', 'gridflex') ) ) );

}

/* Page options */
function gridflex_page_options($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_page', array( 'title' => esc_html__( 'Page Options', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 190 ) );

    $wp_customize->add_setting( 'gridflex_options[thumbnail_link_page]', array( 'default' => 'yes', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_thumbnail_link' ) );

    $wp_customize->add_control( 'gridflex_thumbnail_link_page_control', array( 'label' => esc_html__( 'Featured Image Link', 'gridflex' ), 'description' => esc_html__('Do you want the featured image in a page to be linked to its page?', 'gridflex'), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[thumbnail_link_page]', 'type' => 'select', 'choices' => array( 'yes' => esc_html__('Yes', 'gridflex'), 'no' => esc_html__('No', 'gridflex') ) ) );

    $wp_customize->add_setting( 'gridflex_options[hide_page_thumbnail]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_page_thumbnail_control', array( 'label' => esc_html__( 'Hide Featured Image from Single Page', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[hide_page_thumbnail]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[featured_media_under_page_title]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_featured_media_under_page_title_control', array( 'label' => esc_html__( 'Move Featured Image to Bottom of Page Title', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[featured_media_under_page_title]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_page_title]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_page_title_control', array( 'label' => esc_html__( 'Hide Page Header from Single Page', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[hide_page_title]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[remove_page_title_link]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_remove_page_title_link_control', array( 'label' => esc_html__( 'Remove Link from Single Page Title', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[remove_page_title_link]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_page_date]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_page_date_control', array( 'label' => esc_html__( 'Hide Posted Date from Single Page', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[hide_page_date]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_page_author]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_page_author_control', array( 'label' => esc_html__( 'Hide Page Author from Single Page', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[hide_page_author]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_page_comments]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_page_comments_control', array( 'label' => esc_html__( 'Hide Comment Link from Single Page', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[hide_page_comments]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_page_edit]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_page_edit_control', array( 'label' => esc_html__( 'Hide Edit Link from Single Page', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[hide_page_edit]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_static_page_title]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_static_page_title_control', array( 'label' => esc_html__( 'Hide Page Header from Static Homepage', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[hide_static_page_title]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_static_page_meta]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_static_page_meta_control', array( 'label' => esc_html__( 'Hide Page Meta Data (Page Date, Page Author, Comment Link) from Static Homepage', 'gridflex' ), 'section' => 'gridflex_section_page', 'settings' => 'gridflex_options[hide_static_page_meta]', 'type' => 'checkbox', ) );

}

/* Social profiles options */
function gridflex_social_profiles($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_social', array( 'title' => esc_html__( 'Social Links Options', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 240, ));

    $wp_customize->add_setting( 'gridflex_options[social_buttons_location]', array( 'default' => 'secondary-menu', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_social_buttons_location' ) );

    $wp_customize->add_control( 'gridflex_social_buttons_location_control', array( 'label' => esc_html__( 'Social + Search + Login/Logout Buttons Location', 'gridflex' ), 'description' => esc_html__('Select where you want to display social buttons.', 'gridflex'), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[social_buttons_location]', 'type' => 'select', 'choices' => array( 'primary-menu' => esc_html__( 'Primary Menu', 'gridflex' ), 'secondary-menu' => esc_html__( 'Secondary Menu', 'gridflex' ) ) ) );

    $wp_customize->add_setting( 'gridflex_options[hide_social_buttons]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_social_buttons_control', array( 'label' => esc_html__( 'Hide Social + Search + Login/Logout Buttons', 'gridflex' ), 'description' => esc_html__('If you checked this option, there is no any effect from these option: "Hide Search Button", "Show Login/Logout Button".', 'gridflex'), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[hide_social_buttons]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_search_button]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_search_button_control', array( 'label' => esc_html__( 'Hide Search Button', 'gridflex' ), 'description' => esc_html__('This option has no effect if you checked the option: "Hide Social + Search + Login/Logout Buttons"', 'gridflex'), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[hide_search_button]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[show_login_button]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_show_login_button_control', array( 'label' => esc_html__( 'Show Login/Logout Button', 'gridflex' ), 'description' => esc_html__('This option has no effect if you checked the option: "Hide Social + Search + Login/Logout Buttons"', 'gridflex'), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[show_login_button]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[twitterlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_twitterlink_control', array( 'label' => esc_html__( 'X URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[twitterlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[facebooklink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_facebooklink_control', array( 'label' => esc_html__( 'Facebook URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[facebooklink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[threadslink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_threadslink_control', array( 'label' => esc_html__( 'Threads URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[threadslink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[pinterestlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_pinterestlink_control', array( 'label' => esc_html__( 'Pinterest URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[pinterestlink]', 'type' => 'text' ) );
    
    $wp_customize->add_setting( 'gridflex_options[linkedinlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_linkedinlink_control', array( 'label' => esc_html__( 'Linkedin Link', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[linkedinlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[instagramlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_instagramlink_control', array( 'label' => esc_html__( 'Instagram Link', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[instagramlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[vklink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_vklink_control', array( 'label' => esc_html__( 'VK Link', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[vklink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[flickrlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_flickrlink_control', array( 'label' => esc_html__( 'Flickr Link', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[flickrlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[youtubelink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_youtubelink_control', array( 'label' => esc_html__( 'Youtube URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[youtubelink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[vimeolink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_vimeolink_control', array( 'label' => esc_html__( 'Vimeo URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[vimeolink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[soundcloudlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_soundcloudlink_control', array( 'label' => esc_html__( 'Soundcloud URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[soundcloudlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[messengerlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_messengerlink_control', array( 'label' => esc_html__( 'Messenger URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[messengerlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[whatsapplink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_whatsapplink_control', array( 'label' => esc_html__( 'WhatsApp URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[whatsapplink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[tiktoklink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_tiktoklink_control', array( 'label' => esc_html__( 'TikTok URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[tiktoklink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[lastfmlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_lastfmlink_control', array( 'label' => esc_html__( 'Lastfm URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[lastfmlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[mediumlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_mediumlink_control', array( 'label' => esc_html__( 'Medium URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[mediumlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[githublink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_githublink_control', array( 'label' => esc_html__( 'Github URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[githublink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[bitbucketlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_bitbucketlink_control', array( 'label' => esc_html__( 'Bitbucket URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[bitbucketlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[tumblrlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_tumblrlink_control', array( 'label' => esc_html__( 'Tumblr URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[tumblrlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[digglink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_digglink_control', array( 'label' => esc_html__( 'Digg URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[digglink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[deliciouslink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_deliciouslink_control', array( 'label' => esc_html__( 'Delicious URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[deliciouslink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[stumblelink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_stumblelink_control', array( 'label' => esc_html__( 'Stumbleupon URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[stumblelink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[mixlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_mixlink_control', array( 'label' => esc_html__( 'Mix URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[mixlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[redditlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_redditlink_control', array( 'label' => esc_html__( 'Reddit URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[redditlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[dribbblelink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_dribbblelink_control', array( 'label' => esc_html__( 'Dribbble URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[dribbblelink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[flipboardlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_flipboardlink_control', array( 'label' => esc_html__( 'Flipboard URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[flipboardlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[bloggerlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_bloggerlink_control', array( 'label' => esc_html__( 'Blogger URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[bloggerlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[etsylink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_etsylink_control', array( 'label' => esc_html__( 'Etsy URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[etsylink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[behancelink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_behancelink_control', array( 'label' => esc_html__( 'Behance URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[behancelink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[amazonlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_amazonlink_control', array( 'label' => esc_html__( 'Amazon URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[amazonlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[meetuplink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_meetuplink_control', array( 'label' => esc_html__( 'Meetup URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[meetuplink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[mixcloudlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_mixcloudlink_control', array( 'label' => esc_html__( 'Mixcloud URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[mixcloudlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[slacklink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_slacklink_control', array( 'label' => esc_html__( 'Slack URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[slacklink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[snapchatlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_snapchatlink_control', array( 'label' => esc_html__( 'Snapchat URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[snapchatlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[spotifylink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_spotifylink_control', array( 'label' => esc_html__( 'Spotify URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[spotifylink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[yelplink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_yelplink_control', array( 'label' => esc_html__( 'Yelp URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[yelplink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[wordpresslink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_wordpresslink_control', array( 'label' => esc_html__( 'WordPress URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[wordpresslink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[twitchlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_twitchlink_control', array( 'label' => esc_html__( 'Twitch URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[twitchlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[telegramlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_telegramlink_control', array( 'label' => esc_html__( 'Telegram URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[telegramlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[bandcamplink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_bandcamplink_control', array( 'label' => esc_html__( 'Bandcamp URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[bandcamplink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[quoralink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_quoralink_control', array( 'label' => esc_html__( 'Quora URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[quoralink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[foursquarelink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_foursquarelink_control', array( 'label' => esc_html__( 'Foursquare URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[foursquarelink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[deviantartlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_deviantartlink_control', array( 'label' => esc_html__( 'DeviantArt URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[deviantartlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[imdblink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_imdblink_control', array( 'label' => esc_html__( 'IMDB URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[imdblink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[codepenlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_codepenlink_control', array( 'label' => esc_html__( 'Codepen URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[codepenlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[jsfiddlelink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_jsfiddlelink_control', array( 'label' => esc_html__( 'JSFiddle URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[jsfiddlelink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[stackoverflowlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_stackoverflowlink_control', array( 'label' => esc_html__( 'Stack Overflow URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[stackoverflowlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[stackexchangelink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_stackexchangelink_control', array( 'label' => esc_html__( 'Stack Exchange URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[stackexchangelink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[bsalink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_bsalink_control', array( 'label' => esc_html__( 'BuySellAds URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[bsalink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[web500pxlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_web500pxlink_control', array( 'label' => esc_html__( '500px URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[web500pxlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[ellolink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_ellolink_control', array( 'label' => esc_html__( 'Ello URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[ellolink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[discordlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_discordlink_control', array( 'label' => esc_html__( 'Discord URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[discordlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[goodreadslink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_goodreadslink_control', array( 'label' => esc_html__( 'Goodreads URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[goodreadslink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[odnoklassnikilink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_odnoklassnikilink_control', array( 'label' => esc_html__( 'Odnoklassniki URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[odnoklassnikilink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[houzzlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_houzzlink_control', array( 'label' => esc_html__( 'Houzz URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[houzzlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[pocketlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_pocketlink_control', array( 'label' => esc_html__( 'Pocket URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[pocketlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[xinglink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_xinglink_control', array( 'label' => esc_html__( 'XING URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[xinglink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[mastodonlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_mastodonlink_control', array( 'label' => esc_html__( 'Mastodon URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[mastodonlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[googleplaylink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_googleplaylink_control', array( 'label' => esc_html__( 'Google Play URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[googleplaylink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[slidesharelink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_slidesharelink_control', array( 'label' => esc_html__( 'SlideShare URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[slidesharelink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[dropboxlink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_dropboxlink_control', array( 'label' => esc_html__( 'Dropbox URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[dropboxlink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[paypallink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_paypallink_control', array( 'label' => esc_html__( 'PayPal URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[paypallink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[viadeolink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_viadeolink_control', array( 'label' => esc_html__( 'Viadeo URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[viadeolink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[wikipedialink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_wikipedialink_control', array( 'label' => esc_html__( 'Wikipedia URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[wikipedialink]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[skypeusername]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field' ) );

    $wp_customize->add_control( 'gridflex_skypeusername_control', array( 'label' => esc_html__( 'Skype Username', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[skypeusername]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[emailaddress]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_email' ) );

    $wp_customize->add_control( 'gridflex_emailaddress_control', array( 'label' => esc_html__( 'Email Address', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[emailaddress]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridflex_options[rsslink]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' ) );

    $wp_customize->add_control( 'gridflex_rsslink_control', array( 'label' => esc_html__( 'RSS Feed URL', 'gridflex' ), 'section' => 'gridflex_section_social', 'settings' => 'gridflex_options[rsslink]', 'type' => 'text' ) );

}

/* Footer options */
function gridflex_footer_options($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_footer', array( 'title' => esc_html__( 'Footer Options', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 280 ) );

    $wp_customize->add_setting( 'gridflex_options[footer_text]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_html', ) );

    $wp_customize->add_control( 'gridflex_footer_text_control', array( 'label' => esc_html__( 'Footer copyright notice', 'gridflex' ), 'section' => 'gridflex_section_footer', 'settings' => 'gridflex_options[footer_text]', 'type' => 'text', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_footer_widgets]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_footer_widgets_control', array( 'label' => esc_html__( 'Hide Footer Widgets', 'gridflex' ), 'section' => 'gridflex_section_footer', 'settings' => 'gridflex_options[hide_footer_widgets]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[disable_backtotop]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_disable_backtotop_control', array( 'label' => esc_html__( 'Disable Back to Top Button', 'gridflex' ), 'section' => 'gridflex_section_footer', 'settings' => 'gridflex_options[disable_backtotop]', 'type' => 'checkbox', ) );

}

/* 404 options */
function gridflex_search_404_options($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_search_404', array( 'title' => esc_html__( 'Search and 404 Pages Options', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 340 ) );

    $wp_customize->add_setting( 'gridflex_options[no_search_heading]', array( 'default' => esc_html__( 'Nothing Found', 'gridflex' ), 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_html', ) );

    $wp_customize->add_control( 'gridflex_no_search_heading_control', array( 'label' => esc_html__( 'No Search Results Heading', 'gridflex' ), 'description' => esc_html__( 'Enter a heading to display when no search results are found.', 'gridflex' ), 'section' => 'gridflex_section_search_404', 'settings' => 'gridflex_options[no_search_heading]', 'type' => 'textarea' ) );

    $wp_customize->add_setting( 'gridflex_options[no_search_results]', array( 'default' => esc_html__( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'gridflex' ), 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_html', ) );

    $wp_customize->add_control( 'gridflex_no_search_results_control', array( 'label' => esc_html__( 'No Search Results Message', 'gridflex' ), 'description' => esc_html__( 'Enter a message to display when no search results are found.', 'gridflex' ), 'section' => 'gridflex_section_search_404', 'settings' => 'gridflex_options[no_search_results]', 'type' => 'textarea' ) );

    $wp_customize->add_setting( 'gridflex_options[error_404_heading]', array( 'default' => esc_html__( 'Oops! That page can not be found.', 'gridflex' ), 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_html', ) );

    $wp_customize->add_control( 'gridflex_error_404_heading_control', array( 'label' => esc_html__( '404 Error Page Heading', 'gridflex' ), 'description' => esc_html__( 'Enter the heading for the 404 error page.', 'gridflex' ), 'section' => 'gridflex_section_search_404', 'settings' => 'gridflex_options[error_404_heading]', 'type' => 'textarea' ) );

    $wp_customize->add_setting( 'gridflex_options[error_404_message]', array( 'default' => esc_html__( 'It looks like nothing was found at this location. Maybe try one of the links below or a search?', 'gridflex' ), 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_html', ) );

    $wp_customize->add_control( 'gridflex_error_404_message_control', array( 'label' => esc_html__( 'Error 404 Message', 'gridflex' ), 'description' => esc_html__( 'Enter a message to display on the 404 error page.', 'gridflex' ), 'section' => 'gridflex_section_search_404', 'settings' => 'gridflex_options[error_404_message]', 'type' => 'textarea', ) );

    $wp_customize->add_setting( 'gridflex_options[hide_404_search]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_hide_404_search_control', array( 'label' => esc_html__( 'Hide Search Box from 404 Page', 'gridflex' ), 'section' => 'gridflex_section_search_404', 'settings' => 'gridflex_options[hide_404_search]', 'type' => 'checkbox', ) );

}

/* Other options */
function gridflex_other_options($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_other_options', array( 'title' => esc_html__( 'Other Options', 'gridflex' ), 'panel' => 'gridflex_main_options_panel', 'priority' => 600 ) );

    $wp_customize->add_setting( 'gridflex_options[enable_widgets_block_editor]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_enable_widgets_block_editor_control', array( 'label' => esc_html__( 'Enable Gutenberg Widget Block Editor', 'gridflex' ), 'section' => 'gridflex_section_other_options', 'settings' => 'gridflex_options[enable_widgets_block_editor]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[disable_loading_animation]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_disable_loading_animation_control', array( 'label' => esc_html__( 'Disable Site Loading Animation', 'gridflex' ), 'section' => 'gridflex_section_other_options', 'settings' => 'gridflex_options[disable_loading_animation]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridflex_options[enable_fitvids]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridflex_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridflex_enable_fitvids_control', array( 'label' => esc_html__( 'Enable FitVids.JS', 'gridflex' ), 'description' => esc_html__( 'You can enable fitvids.js script if you are using videos on your website and if you want fluid width videos in your post content.', 'gridflex' ), 'section' => 'gridflex_section_other_options', 'settings' => 'gridflex_options[enable_fitvids]', 'type' => 'checkbox', ) );

}

/* Upgrade to pro options */
function gridflex_upgrade_to_pro($wp_customize) {

    $wp_customize->add_section( 'gridflex_section_upgrade', array( 'title' => esc_html__( 'Upgrade to Pro Version', 'gridflex' ), 'priority' => 400 ) );
    
    $wp_customize->add_setting( 'gridflex_options[upgrade_text]', array( 'default' => '', 'sanitize_callback' => '__return_false', ) );
    
    $wp_customize->add_control( new GridFlex_Customize_Static_Text_Control( $wp_customize, 'gridflex_upgrade_text_control', array(
        'label'       => esc_html__( 'GridFlex Pro', 'gridflex' ),
        'section'     => 'gridflex_section_upgrade',
        'settings' => 'gridflex_options[upgrade_text]',
        'description' => esc_html__( 'Do you enjoy GridFlex? Upgrade to GridFlex Pro now and get:', 'gridflex' ).
            '<ul class="gridflex-customizer-pro-features">' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Color Options', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Font Options', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( '1/2/3/4/5/6/7/8/9/10 Columns Options for Posts Grids', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( '10+ Thumbnail Sizes Options for Posts Grids', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Switch between Pure CSS Grid and Masonry Grid (JavaScript based)', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Display Ads/Custom Contents between Posts in the Grid', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Switch between Full and Boxed Layout Type', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( '10+ Layout Styles for Posts/Pages', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( '10+ Layout Styles for Non-Singular Pages', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Width Change Options for Full Website/Main Content/Left Sidebar/Right Sidebar', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( '10+ Custom Page Templates', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( '10+ Custom Post Templates', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( '2 Header Layouts with Width options - (Logo + Header Banner) / (Full Width Header)', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Footer with Layout Options (1/2/3/4/5/6 columns)', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Ability to Change Website Width/Layout Type/Layout Style/Header Style/Footer Style of any Post/Page', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Capability to Add Different Header Images for Each Post/Page with Unique Link, Title and Description', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Ajax Powered Grid Featured Posts Widget (Recent/Categories/Tags/PostIDs based) - with capability to display posts according to Likes/Views/Comments/Dates/... and there are many options', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Ajax Powered List Featured Posts Widget (Recent/Categories/Tags/PostIDs based) - with capability to display posts according to Likes/Views/Comments/Dates/... and there are many options', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Ajax Powered Tabbed Widget (Recent/Categories/Tags/PostIDs based) - with capability to display posts according to Likes/Views/Comments/Dates/... and there are many options.', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'About and Social Widget - 60+ Social Buttons', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'News Ticker (Recent/Categories/Tags/PostIDs based) - It can display posts according to Likes/Views/Comments/Dates/... and there are many options.', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Settings Panel to Control Options in Each Post', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Settings Panel to Control Options in Each Page', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Built-in Posts Views Counter', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Built-in Posts Likes System', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Built-in Infinite Scroll and Load More Button', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Post Share Buttons - 25+ Social Networks are Supported', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Related Posts (Categories/Tags/Author/PostIDs based) with Options', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Sticky Menu/Sticky Sidebars with enable/disable capability', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Author Bio Box with Social Buttons - 60+ Social Buttons', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Ability to Enable/Disable Mobile View from Primary and Secondary Menus', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Post Navigation with Thumbnails', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Ability to add Ads under Post Title and under Post Content', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Ability to Disable Google Fonts - for faster loading', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'More Widget Areas', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Built-in Contact Form', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'WooCommerce Compatible', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Yoast SEO Breadcrumbs Support', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Full RTL Language Support', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Search Engine Optimized', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Random Posts Button in Header', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'Many Useful Customizer Theme options', 'gridflex' ) . '</li>' .
                '<li><i class="fas fa-check" aria-hidden="true"></i> ' . esc_html__( 'More Features...', 'gridflex' ) . '</li>' .
            '</ul>'.
            '<strong><a href="'.GRIDFLEX_PROURL.'" class="button button-primary" target="_blank"><i class="fas fa-shopping-cart" aria-hidden="true"></i> ' . esc_html__( 'Upgrade To GridFlex PRO', 'gridflex' ) . '</a></strong>'
    ) ) );

}

/**
* Sanitize callback functions
*
*/

function gridflex_sanitize_checkbox( $input ) {
    return ( ( isset( $input ) && ( true == $input ) ) ? true : false );
}

function gridflex_sanitize_html( $input ) {
    return wp_kses_post( force_balance_tags( $input ) );
}

function gridflex_sanitize_thumbnail_link( $input, $setting ) {
    $valid = array('yes','no');
    if ( in_array( $input, $valid ) ) {
        return $input;
    } else {
        return $setting->default;
    }
}

function gridflex_sanitize_posts_navigation_type( $input, $setting ) {
    $valid = array('normalnavi','numberednavi');
    if ( in_array( $input, $valid ) ) {
        return $input;
    } else {
        return $setting->default;
    }
}

function gridflex_sanitize_email( $input, $setting ) {
    if ( '' != $input && is_email( $input ) ) {
        $input = sanitize_email( $input );
        return $input;
    } else {
        return $setting->default;
    }
}

function gridflex_sanitize_secondary_menu_location( $input, $setting ) {
    $valid = array(
            'before-header' => esc_html__('Before Header', 'gridflex'),
            'after-header' => esc_html__('After Header', 'gridflex'),
            'before-footer' => esc_html__('Before Footer', 'gridflex'),
            'after-footer' => esc_html__( 'After Footer', 'gridflex' )
    );

    if ( array_key_exists( $input, $valid ) ) {
        return $input;
    } else {
        return $setting->default;
    }
}

function gridflex_sanitize_logo_location( $input, $setting ) {
    $valid = array('beside-title','above-title');
    if ( in_array( $input, $valid ) ) {
        return $input;
    } else {
        return $setting->default;
    }
}

function gridflex_sanitize_social_buttons_location( $input, $setting ) {
    $valid = array('primary-menu','secondary-menu');
    if ( in_array( $input, $valid ) ) {
        return $input;
    } else {
        return $setting->default;
    }
}

function gridflex_sanitize_positive_integer( $input, $setting ) {
    $input = absint( $input ); // Force the value into non-negative integer.
    return ( 0 < $input ) ? $input : $setting->default;
}

function gridflex_register_theme_customizer( $wp_customize ) {

    if(method_exists('WP_Customize_Manager', 'add_panel')):
    $wp_customize->add_panel('gridflex_main_options_panel', array( 'title' => esc_html__('Theme Options', 'gridflex'), 'priority' => 10, ));
    endif;

    $wp_customize->get_section( 'title_tagline' )->panel = 'gridflex_main_options_panel';
    $wp_customize->get_section( 'title_tagline' )->priority = 20;
    $wp_customize->get_section( 'header_image' )->panel = 'gridflex_main_options_panel';
    $wp_customize->get_section( 'header_image' )->priority = 26;
    $wp_customize->get_section( 'background_image' )->panel = 'gridflex_main_options_panel';
    $wp_customize->get_section( 'background_image' )->priority = 27;
    $wp_customize->get_section( 'colors' )->panel = 'gridflex_main_options_panel';
    $wp_customize->get_section( 'colors' )->priority = 40;
      
    $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
    $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
    $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
    $wp_customize->get_setting( 'background_color' )->transport = 'postMessage';
    $wp_customize->get_control( 'background_color' )->description = esc_html__('To change Background Color, need to remove background image first:- go to Appearance : Customize : Theme Options : Background Image', 'gridflex');

    if ( isset( $wp_customize->selective_refresh ) ) {
        $wp_customize->selective_refresh->add_partial( 'blogname', array(
            'selector'        => '.gridflex-site-title a',
            'render_callback' => 'gridflex_customize_partial_blogname',
        ) );
        $wp_customize->selective_refresh->add_partial( 'blogdescription', array(
            'selector'        => '.gridflex-site-description',
            'render_callback' => 'gridflex_customize_partial_blogdescription',
        ) );
    }

    gridflex_getting_started($wp_customize);
    gridflex_menu_options($wp_customize);
    gridflex_header_options($wp_customize);
    gridflex_posts_grid_options($wp_customize);
    gridflex_post_options($wp_customize);
    gridflex_navigation_options($wp_customize);
    gridflex_page_options($wp_customize);
    gridflex_social_profiles($wp_customize);
    gridflex_footer_options($wp_customize);
    gridflex_search_404_options($wp_customize);
    gridflex_other_options($wp_customize);
    gridflex_upgrade_to_pro($wp_customize);

}
add_action( 'customize_register', 'gridflex_register_theme_customizer' );

/**
 * Render the site title for the selective refresh partial.
 *
 * @return void
 */
function gridflex_customize_partial_blogname() {
    bloginfo( 'name' );
}
/**
 * Render the site tagline for the selective refresh partial.
 *
 * @return void
 */
function gridflex_customize_partial_blogdescription() {
    bloginfo( 'description' );
}

function gridflex_customizer_js_scripts() {
    wp_enqueue_script('gridflex-theme-customizer-js', get_template_directory_uri() . '/assets/js/customizer.js', array( 'jquery', 'customize-preview' ), null, true);
}
add_action( 'customize_preview_init', 'gridflex_customizer_js_scripts' );