<?php

/*********************
post-settings
*******************/

// Exit if accessed directly.
if (!defined("ABSPATH")) {
    exit();
}
$wp_customize->add_panel("poster_theme_postsset", [
    "priority" => 30,
    "capability" => "edit_theme_options",
    "description" => __("Blog Posts", "poster"),
    "priority" => apply_filters("poster_theme_postsset_priority", 165),
    "title" => __("Blog Posts", "poster"),
]);

$wp_customize->add_section("poster_poststyle_section", [
    "title" => __("Post Layout Style", "poster"),
    "description" => __("Post Layout Style", "poster"),
    "capability" => "edit_theme_options",
    "panel" => "poster_theme_postsset",
    "priority" => apply_filters("poster_poststyle_section_priority", 10),
]);
// Add customizer settings and controls using the poster_Image_Radio_Control class
$wp_customize->add_setting("poster_posts_layout", [
    "default" => "poster",
    "type" => "theme_mod",
    "sanitize_callback" => "poster_customize_sanitize_select",
    "capability" => "edit_theme_options",
]);

$wp_customize->add_control(
    new poster_Image_Radio_Control(
        $wp_customize,
        "poster_posts_layout",
        [
            "label" => __("Posts Layout", "poster"),
            "description" => __(
                "Choose between Fixed or Full width container",
                "poster"
            ),
            "section" => "poster_poststyle_section",
            "choices" => [
                "liststyle" =>
                    get_template_directory_uri() .
                    "/images/posts/poststyle1.jpg",
                "blokstyle" =>
                    get_template_directory_uri() .
                    "/images/posts/poststyle2.jpg",
                "poster" =>
                    get_template_directory_uri() .
                    "/images/posts/poster3.jpg",
            ],
            "priority" => apply_filters(
                "poster_container_type_priority",
                10
            ),
        ]
    )
);

/****************************
Poster pro 
*******************/
// create an empty array
$cats = [];

// we loop over the categories and set the names and
// labels we need
foreach (get_categories() as $categoriesi => $categoryy) {
    $cats[$categoryy->term_id] = $categoryy->name;
}
$wp_customize->add_setting("poster_poster_heading", [
    "sanitize_callback" => "wp_kses",
]);

$wp_customize->add_control(
    new poster_Customizer_Heading_Control(
        $wp_customize,
        "poster_poster_heading",
        [
            "label" => esc_html__("Layout Settings", "poster"),
            "section" => "poster_poststyle_section",
            "priority" => 25,
        ]
    )
);

$wp_customize->add_setting("topcateid_hide", [
    "default" => "show",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_sanitize_select",
]);
$wp_customize->add_control("topcateid_hide", [
    "type" => "radio",
    "label" => __("Top Parent Category Select", "poster"),
    "settings" => "topcateid_hide",
    "section" => "poster_poststyle_section",
    "priority" => 30,
    "choices" => [
        "show" => __("Show", "poster"),
        "hide" => __("Hide", "poster"),
    ],
]);

$wp_customize->add_setting("topcateid", [
    "default" => 1,
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("cat_contlr_top", [
    "settings" => "topcateid",
    "type" => "select",
    "choices" => $cats,
    "section" => "poster_poststyle_section",
    "priority" => 35, // depending on where you want it to be
]);
$wp_customize->add_setting("leftcateid_hide", [
    "default" => "show",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_sanitize_select",
]);
$wp_customize->add_control("leftcateid_hide", [
    "type" => "radio",
    "label" => __("Left Parent Category Select", "poster"),
    "settings" => "leftcateid_hide",
    "section" => "poster_poststyle_section",
    "priority" => 40,
    "choices" => [
        "show" => __("Show", "poster"),
        "hide" => __("Hide", "poster"),
    ],
]);
$wp_customize->add_setting("leftcateid", [
    "default" => 1,
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("cat_contlr_left", [
    "settings" => "leftcateid",
    "type" => "select",
    "choices" => $cats,
    "section" => "poster_poststyle_section",
    "priority" => 45, // depending on where you want it to be
]);
$wp_customize->add_setting("rightcateid_hide", [
    "default" => "show",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_sanitize_select",
]);
$wp_customize->add_control("rightcateid_hide", [
    "type" => "radio",
    "label" => __("Right Parent Category Select", "poster"),
    "settings" => "rightcateid_hide",
    "section" => "poster_poststyle_section",
    "priority" => 50,
    "choices" => [
        "show" => __("Show", "poster"),
        "hide" => __("Hide", "poster"),
    ],
]);
$wp_customize->add_setting("rightcateid", [
    "default" => 1,
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("cat_contlr_right", [
    "settings" => "rightcateid",
    "type" => "select",
    "choices" => $cats,
    "section" => "poster_poststyle_section",
    "priority" => 55, // depending on where you want it to be
]);

//Add Section 1

$wp_customize->add_section("poster_readmore_section", [
    "title" => __("Read More Button", "poster"),
    "description" => __("Read More Section", "poster"),
    "capability" => "edit_theme_options",
    "panel" => "poster_theme_postsset",
    "priority" => apply_filters("poster_readmore_section_priority", 10),
]);

// Read more
$wp_customize->add_setting("poster_enable_readmore", [
    "default" => "enable",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);

$wp_customize->add_control(
    new WP_Customize_Control($wp_customize, "poster_enable_readmore", [
        "label" => __("Read More Button", "poster"),
        "description" => __(
            "Enable or disable Read More Button & Customize",
            "poster"
        ),
        "section" => "poster_readmore_section",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "poster"),
            "enable" => __("Enable", "poster"),
        ],
        "priority" => apply_filters(
            "poster_bootstrap_version_priority",
            10
        ),
    ])
);

$wp_customize->add_setting("poster_readmore_text", [
    "default" => "Read More",
    "sanitize_callback" => "sanitize_text_field",
]);

$wp_customize->add_control("poster_readmore_text", [
    "label" => __("Change Button Text", "poster"),
    "section" => "poster_readmore_section",
    "settings" => "poster_readmore_text",
    "type" => "text",
    "active_callback" => "poster_is_readmore_enabled",
]);
$wp_customize->add_setting("poster_readmore_color", [
    "default" => "#0d6efd",
    "transport" => "refresh",
    "sanitize_callback" => "sanitize_hex_color",
]);

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        "poster_readmore_color",
        [
            "label" => __("Read More Text Color (Pro Only)", "poster"),
            "section" => "poster_readmore_section",
            "settings" => "poster_readmore_color",
        ]
    )
);

//Add Section 2

$wp_customize->add_section("poster_postmeta_section", [
    "title" => __("Post Meta Section Blog", "poster"),
    "capability" => "edit_theme_options",
    "panel" => "poster_theme_postsset",
    "priority" => apply_filters("poster_postmeta_section_priority", 10),
]);

$wp_customize->add_setting("poster_blog_postmeta", [
    "default" => "enable",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);

$wp_customize->add_control(
    new WP_Customize_Control($wp_customize, "poster_blog_postmeta", [
        "label" => __("Post Footer Meta", "poster"),
        "description" => __(
            "Enable or disable post footer meta Date, Author, Read more etc.",
            "poster"
        ),
        "section" => "poster_postmeta_section",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "poster"),
            "enable" => __("Enable", "poster"),
        ],
        "priority" => apply_filters(
            "poster_bootstrap_version_priority",
            10
        ),
    ])
);

//Hide Post date
$wp_customize->add_setting("poster_blog_date", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_customize_sanitize_select",
]);
$wp_customize->add_control("poster_blog_date", [
    "type" => "radio",
    "label" => __("Post date", "poster"),
    "settings" => "poster_blog_date",
    "section" => "poster_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "poster"),
        "disable" => __("Disable", "poster"),
    ],
    "active_callback" => "poster_is_post_meta_enabled", // Add this line to set the active callback
]);

//Hide Post author
$wp_customize->add_setting("poster_blogmeta_author", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_customize_sanitize_select",
]);
$wp_customize->add_control("poster_blogmeta_author", [
    "type" => "radio",
    "label" => __("Hide post Author", "poster"),
    "settings" => "poster_blogmeta_author",
    "section" => "poster_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "poster"),
        "disable" => __("Disable", "poster"),
    ],
    "active_callback" => "poster_is_post_meta_enabled", // Add this line to set the active callback
]);

//Hide Post Comments
$wp_customize->add_setting("poster_blogmeta_comments", [
    "default" => "enable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_customize_sanitize_select",
]);
$wp_customize->add_control("poster_blogmeta_comments", [
    "type" => "radio",
    "label" => __("Comments", "poster"),
    "settings" => "poster_blogmeta_comments",
    "section" => "poster_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "poster"),
        "disable" => __("Disable", "poster"),
    ],
    "active_callback" => "poster_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide View Count
$wp_customize->add_setting("poster_blog_viewcount", [
    "default" => "enable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_customize_sanitize_select",
]);
$wp_customize->add_control("poster_blog_viewcount", [
    "type" => "radio",
    "label" => __("View Count", "poster"),
    "settings" => "poster_blog_viewcount",
    "section" => "poster_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "poster"),
        "disable" => __("Disable", "poster"),
    ],
    "active_callback" => "poster_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide Post Categories
$wp_customize->add_setting("poster_blogmeta_category", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_customize_sanitize_select",
]);
$wp_customize->add_control("poster_blogmeta_category", [
    "type" => "radio",
    "label" => __("Hide post Categories", "poster"),
    "settings" => "poster_blogmeta_category",
    "section" => "poster_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "poster"),
        "disable" => __("Disable", "poster"),
    ],
    "active_callback" => "poster_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide Post Tags
$wp_customize->add_setting("poster_blogmeta_tags", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_customize_sanitize_select",
]);
$wp_customize->add_control("poster_blogmeta_tags", [
    "type" => "radio",
    "label" => __("Hide post tags", "poster"),
    "settings" => "poster_blogmeta_tags",
    "section" => "poster_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "poster"),
        "disable" => __("Disable", "poster"),
    ],
    "active_callback" => "poster_is_post_meta_enabled", // Add this line to set the active callback
]);

// Hide website in comment
$wp_customize->add_setting("poster_website_field", [
    "default" => "enable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "poster_customize_sanitize_select",
]);
$wp_customize->add_control("poster_website_field", [
    "type" => "radio",
    "label" => __("Show Website Field in Comments", "poster"),
    "settings" => "poster_website_field",
    "section" => "poster_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "poster"),
        "disable" => __("Disable", "poster"),
    ],
    "active_callback" => "poster_is_post_meta_enabled", // Add this line to set the active callback
]);

//Post Exerpt
$wp_customize->add_section("poster_postsexcerpt_settings", [
    "title" => __("Post Excerpt (Description)", "poster"),
    "capability" => "edit_theme_options",
    "description" => __('Default Post Excerpt "20"', "poster"),
    "panel" => "poster_theme_postsset",
]);
$wp_customize->add_setting("poster_excerpt_number", [
    "default" => "20",
    "transport" => "postMessage",
    "sanitize_callback" => "absint",
]);
$wp_customize->add_control("poster_excerpt_number", [
    "section" => "poster_postsexcerpt_settings",
    "label" => __("Numbers of words in post excerpt to show (Pro Only)", "poster"),
    "settings" => "poster_excerpt_number",
    "type" => "number",
]);
// Excerpt
$wp_customize->add_setting("poster_enable_excerpt", [
    "default" => "disable",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);
$wp_customize->add_control(
    new WP_Customize_Control($wp_customize, "poster_enable_excerpt", [
        "label" => __("Post Description (excerpt)", "poster"),
        "description" => __("Enable or disable excerpt", "poster"),
        "section" => "poster_postsexcerpt_settings",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "poster"),
            "enable" => __("Enable", "poster"),
        ],
        "priority" => apply_filters(
            "poster_bootstrap_version_priority",
            10
        ),
    ])
);

// Title Font
$wp_customize->add_setting("poster_postexcert_color", [
    "default" => "#5e5d5d", // Default font color
    'transport'   => 'postMessage',
    "sanitize_callback" => "sanitize_hex_color",
]);

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        "poster_postexcert_color",
        [
            "label" => __("Font Color (Pro Only)", "poster"),
            "section" => "poster_postsexcerpt_settings",
            "settings" => "poster_postexcert_color",
        ]
    )
);
$wp_customize->add_setting("poster_postexcert_size", [
    "default" => "17", // Default font size
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("poster_postexcert_size", [
    "label" => __("Post Title Font Size - px", "poster"),
    "section" => "poster_postsexcerpt_settings",
    "settings" => "poster_postexcert_size",
    "type" => "number",
]);

//Font Weight
$wp_customize->add_setting("poster_postexcert_weight", [
    "default" => "100",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);
$wp_customize->add_control(
    new WP_Customize_Control($wp_customize, "poster_postexcert_weight", [
        "label" => __("Font Weight", "poster"),
        "section" => "poster_postsexcerpt_settings",
        "type" => "select",
        "choices" => [
            "100" => __("100", "poster"),
            "200" => __("200", "poster"),
            "400" => __("400", "poster"),
            "500" => __("500", "poster"),
            "600" => __("600", "poster"),
            "700" => __("700", "poster"),
            "800" => __("800", "poster"),
            "900" => __("900", "poster"),
        ],
    ])
);
//font style

$wp_customize->add_setting("poster_postexcert_style", [
    "default" => "normal",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);
$wp_customize->add_control(
    new WP_Customize_Control($wp_customize, "poster_postexcert_style", [
        "label" => __("Font Style", "poster"),
        "section" => "poster_postsexcerpt_settings",
        "type" => "select",
        "choices" => [
            "normal" => __("Normal", "poster"),
            "italic" => __("Italic", "poster"),
        ],
    ])
);
//Text Transform
$wp_customize->add_setting("poster_postexcert_transform", [
    "default" => "none",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);
$wp_customize->add_control(
    new WP_Customize_Control(
        $wp_customize,
        "poster_postexcert_transform",
        [
            "label" => __("Text Transform", "poster"),
            "section" => "poster_postsexcerpt_settings",
            "type" => "select",
            "choices" => [
                "none" => __("None", "poster"),
                "capitalize" => __("Capitalize", "poster"),
                "lowercase" => __("Lowercase", "poster"),
                "uppercase" => __("Uppercase", "poster"),
            ],
        ]
    )
);

//Featured Image
$wp_customize->add_section("poster_poststhumbnail_blogs", [
    "title" => __("Featured Thumbnail on Blogs", "poster"),
    "capability" => "edit_theme_options",
    "description" => __('Default Post Excerpt "20"', "poster"),
    "panel" => "poster_theme_postsset",
]);
$wp_customize->add_setting("poster_enable_featured", [
    "default" => "enable",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);
$wp_customize->add_control(
    new WP_Customize_Control($wp_customize, "poster_enable_featured", [
        "label" => __(
            "Featured Post Image on Posts Index & Archive",
            "poster"
        ),
        "description" => __("Enable or disable Featured Image", "poster"),
        "section" => "poster_poststhumbnail_blogs",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "poster"),
            "enable" => __("Enable", "poster"),
        ],
        "priority" => apply_filters(
            "poster_bootstrap_version_priority",
            10
        ),
    ])
);

// Thumbnail Hover
$wp_customize->add_setting("poster_thumbhover", [
    "default" => "enable",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);
$wp_customize->add_control(
    new WP_Customize_Control($wp_customize, "poster_thumbhover", [
        "label" => __("Thumbnail Hover Zoom", "poster"),
        "section" => "poster_poststhumbnail_blogs",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "poster"),
            "enable" => __("Enable", "poster"),
        ],
        "priority" => apply_filters("poster_thumbhover_priority", 10),
    ])
);

//*******Post title
$wp_customize->add_section("poster_poststitle_section", [
    "title" => __("Post Title", "poster"),
    "capability" => "edit_theme_options",
    "description" => __('Default Post Excerpt "20"', "poster"),
    "panel" => "poster_theme_postsset",
]);
// Title Font
$wp_customize->add_setting("poster_posttitlefont_color", [
    "default" => "#333333", // Default font color
    'transport'   => 'postMessage',
    "sanitize_callback" => "sanitize_hex_color",
]);

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        "poster_posttitlefont_color",
        [
            "label" => __("Font Color (Pro Only)", "poster"),
            "section" => "poster_poststitle_section",
            "settings" => "poster_posttitlefont_color",
        ]
    )
);
$wp_customize->add_setting("poster_posttitlefont", [
    "default" => "20", // Default font size
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("poster_posttitlefont", [
    "label" => __("Font Size - px", "poster"),
    "section" => "poster_poststitle_section",
    "settings" => "poster_posttitlefont",
    "type" => "number",
]);
//Font Weight
$wp_customize->add_setting("poster_posttitlefont_weight", [
    "default" => "600",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);
$wp_customize->add_control(
    new WP_Customize_Control(
        $wp_customize,
        "poster_posttitlefont_weight",
        [
            "label" => __("Font Weight", "poster"),
            "section" => "poster_poststitle_section",
            "type" => "select",
            "choices" => [
                "100" => __("100", "poster"),
                "200" => __("200", "poster"),
                "400" => __("400", "poster"),
                "600" => __("600", "poster"),
                "800" => __("800", "poster"),
            ],
        ]
    )
);
//font style

$wp_customize->add_setting("poster_posttitlefont_style", [
    "default" => "normal",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);
$wp_customize->add_control(
    new WP_Customize_Control($wp_customize, "poster_posttitlefont_style", [
        "label" => __("Font Style", "poster"),
        "section" => "poster_poststitle_section",
        "type" => "select",
        "choices" => [
            "normal" => __("Normal", "poster"),
            "italic" => __("Italic", "poster"),
        ],
    ])
);
//Text Transform
$wp_customize->add_setting("poster_posttitlefont_transform", [
    "default" => "none",
    "type" => "theme_mod",
    "sanitize_callback" => "sanitize_text_field",
    "capability" => "edit_theme_options",
]);
$wp_customize->add_control(
    new WP_Customize_Control(
        $wp_customize,
        "poster_posttitlefont_transform",
        [
            "label" => __("Text Transform", "poster"),
            "section" => "poster_poststitle_section",
            "type" => "select",
            "choices" => [
                "none" => __("None", "poster"),
                "capitalize" => __("Capitalize", "poster"),
                "lowercase" => __("Lowercase", "poster"),
                "uppercase" => __("Uppercase", "poster"),
            ],
        ]
    )
);
