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

function gridfeel_posts_grid_options($wp_customize) {

    $wp_customize->add_section( 'gridfeel_section_posts_grid', array( 'title' => esc_html__( 'Posts Grid Options', 'gridfeel' ), '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."', 'gridfeel'), 'panel' => 'gridfeel_main_options_panel', 'priority' => 160 ) );

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

    $wp_customize->add_control( 'gridfeel_hide_posts_heading_control', array( 'label' => esc_html__( 'Hide HomePage Posts Heading', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[hide_posts_heading]', 'type' => 'checkbox', ) );

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

    $wp_customize->add_control( 'gridfeel_posts_heading_control', array( 'label' => esc_html__( 'HomePage Posts Heading', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_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' => 'gridfeel_sanitize_positive_integer' ) );

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

    $wp_customize->add_setting( 'gridfeel_options[grid_item_height]', array( 'default' => '220px', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field' ) );

    $wp_customize->add_control( 'gridfeel_grid_item_height_control', array( 'label' => esc_html__( 'Height of Grid Post Items', 'gridfeel' ), 'description' => esc_html__('Enter the height of each grid post item in your posts grid. Default is "220px". If you do not want a fixed height for grid items, then enter the value "auto". This option has no effect if you check the option "Enable Masonry Grid"', 'gridfeel'), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[grid_item_height]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridfeel_options[grid_thumb_position]', array( 'default' => 'top', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_grid_thumb_position' ) );

    $wp_customize->add_control( 'gridfeel_grid_thumb_position_control', array( 'label' => esc_html__( 'Thumbnails Background Position', 'gridfeel' ), 'description' => esc_html__('Select the background position of thumbnails in the post grid. Default is "top". This option has no effect if you check the option "Enable Masonry Grid"', 'gridfeel'), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[grid_thumb_position]', 'type' => 'select', 'choices' => array( 'top' => esc_html__('Top', 'gridfeel'), 'bottom' => esc_html__('Bottom', 'gridfeel'), 'left' => esc_html__('Left', 'gridfeel'), 'right' => esc_html__('Right', 'gridfeel'), 'center' => esc_html__('Center', 'gridfeel'), 'initial' => esc_html__('Initial', 'gridfeel') ) ) );

    $wp_customize->add_setting( 'gridfeel_options[thumbnail_link_home]', array( 'default' => 'yes', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_yes_no' ) );

    $wp_customize->add_control( 'gridfeel_thumbnail_link_home_control', array( 'label' => esc_html__( 'Thumbnails Links', 'gridfeel' ), 'description' => esc_html__('Do you want thumbnails in the posts grid to be linked to their posts?', 'gridfeel'), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[thumbnail_link_home]', 'type' => 'select', 'choices' => array( 'yes' => esc_html__('Yes', 'gridfeel'), 'no' => esc_html__('No', 'gridfeel') ) ) );

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

    $wp_customize->add_control( 'gridfeel_hide_post_title_home_control', array( 'label' => esc_html__( 'Hide Post Titles from Posts Grid', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[hide_post_title_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridfeel_options[remove_post_title_link_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridfeel_remove_post_title_link_home_control', array( 'label' => esc_html__( 'Remove Links of Post Titles from Posts Grid', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[remove_post_title_link_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridfeel_options[limit_post_titles_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridfeel_limit_post_titles_home_control', array( 'label' => esc_html__( 'Limit the Length of Post Titles in Posts Grid', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[limit_post_titles_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridfeel_options[post_title_length_home]', array( 'default' => 6, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_positive_integer' ) );

    $wp_customize->add_control( 'gridfeel_post_title_length_home_control', array( 'label' => esc_html__( 'Maximum Length of Post Titles in Posts Grid', 'gridfeel' ), 'description' => esc_html__('Enter the maximum number of words need to display in grid post titles. Default is 6 words. This option only work if you have check the option "Limit the Length of Post Titles in Posts Grid".', 'gridfeel'), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[post_title_length_home]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridfeel_options[hide_post_author_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridfeel_hide_post_author_home_control', array( 'label' => esc_html__( 'Hide Post Author Names from Posts Grid', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[hide_post_author_home]', 'type' => 'checkbox', ) );

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

    $wp_customize->add_control( 'gridfeel_hide_posted_date_home_control', array( 'label' => esc_html__( 'Hide Post Dates from Posts Grid', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[hide_posted_date_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridfeel_options[post_date_home_type]', array( 'default' => 'published', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_date_type' ) );

    $wp_customize->add_control( 'gridfeel_post_date_home_type_control', array( 'label' => esc_html__( 'Grid Post Date Type', 'gridfeel' ), 'description' => esc_html__('You can choose to display published or updated date of your post.', 'gridfeel'), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[post_date_home_type]', 'type' => 'select', 'choices' => array( 'published' => esc_html__('Published', 'gridfeel'), 'updated' => esc_html__('Updated', 'gridfeel') ) ) );

    $wp_customize->add_setting( 'gridfeel_options[show_comments_link_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridfeel_show_comments_link_home_control', array( 'label' => esc_html__( 'Show Comment Links on Posts Grid', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[show_comments_link_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridfeel_options[comments_count_full_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridfeel_comments_count_full_home_control', array( 'label' => esc_html__( 'Display Comment Texts instead of Comments Counts on Posts Grid', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[comments_count_full_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridfeel_options[hide_post_categories_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridfeel_hide_post_categories_home_control', array( 'label' => esc_html__( 'Hide Post Categories from Posts Grid', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[hide_post_categories_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridfeel_options[activate_responsive_grid_data]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridfeel_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridfeel_activate_responsive_grid_data_control', array( 'label' => esc_html__( 'Hide Grid Posts Contents According to Screen Size', 'gridfeel' ), 'section' => 'gridfeel_section_posts_grid', 'settings' => 'gridfeel_options[activate_responsive_grid_data]', 'type' => 'checkbox', ) );

}