<?php
/**
* Posts Grid options
*
* @package GridMini 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 gridmini_posts_grid_options($wp_customize) {

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

    $wp_customize->add_setting( 'gridmini_options[disable_equal_height_grid_items]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridmini_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridmini_disable_equal_height_grid_items_control', array( 'label' => esc_html__( 'Disable Equal Height Grid Items', 'gridmini' ), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[disable_equal_height_grid_items]', 'type' => 'checkbox', ) );

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

    $wp_customize->add_control( 'gridmini_hide_posts_heading_control', array( 'label' => esc_html__( 'Hide HomePage Posts Heading', 'gridmini' ), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[hide_posts_heading]', 'type' => 'checkbox', ) );

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

    $wp_customize->add_control( 'gridmini_posts_heading_control', array( 'label' => esc_html__( 'HomePage Posts Heading', 'gridmini' ), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_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' => 'gridmini_sanitize_positive_integer' ) );

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

    $wp_customize->add_setting( 'gridmini_options[hide_thumbnail_home]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridmini_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridmini_hide_thumbnail_home_control', array( 'label' => esc_html__( 'Hide Thumbnails of Featured Images from Posts Grid', 'gridmini' ), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[hide_thumbnail_home]', 'type' => 'checkbox', ) );

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

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

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

    $wp_customize->add_control( 'gridmini_hide_post_title_home_control', array( 'label' => esc_html__( 'Hide Post Headers from Posts Grid', 'gridmini' ), 'description' => esc_html__('If you check this option, it will hide post titles and post author images(if author images are enabled).', 'gridmini'), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[hide_post_title_home]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridmini_options[post_title_link_home]', array( 'default' => 'yes', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridmini_sanitize_yes_no' ) );

    $wp_customize->add_control( 'gridmini_post_title_link_home_control', array( 'label' => esc_html__( 'Posts Titles Links', 'gridmini' ), 'description' => esc_html__('Do you want post titles in the posts grid to be linked to their posts?', 'gridmini'), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[post_title_link_home]', 'type' => 'select', 'choices' => array( 'yes' => esc_html__('Yes', 'gridmini'), 'no' => esc_html__('No', 'gridmini') ) ) );

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

    $wp_customize->add_control( 'gridmini_hide_post_author_home_control', array( 'label' => esc_html__( 'Hide Post Author Names from Posts Grid', 'gridmini' ), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[hide_post_author_home]', 'type' => 'checkbox', ) );

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

    $wp_customize->add_control( 'gridmini_hide_posted_date_home_control', array( 'label' => esc_html__( 'Hide Posted Dates from Posts Grid', 'gridmini' ), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[hide_posted_date_home]', 'type' => 'checkbox', ) );

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

    $wp_customize->add_control( 'gridmini_hide_comments_link_home_control', array( 'label' => esc_html__( 'Hide Comment Links from Posts Grid', 'gridmini' ), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[hide_comments_link_home]', 'type' => 'checkbox', ) );

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

    $wp_customize->add_control( 'gridmini_hide_post_categories_home_control', array( 'label' => esc_html__( 'Hide Post Categories from Posts Grid', 'gridmini' ), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[hide_post_categories_home]', 'type' => 'checkbox', ) );

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

    $wp_customize->add_control( 'gridmini_disable_responsive_grid_data_control', array( 'label' => esc_html__( 'Do not Hide Grid Posts Contents According to Screen Size', 'gridmini' ), 'section' => 'gridmini_section_posts_grid', 'settings' => 'gridmini_options[disable_responsive_grid_data]', 'type' => 'checkbox', ) );

}