<?php

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

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

$wp_customize->add_section("wrockmetro_poststyle_section", [
    "title" => __("Post Layout Style", "wrock-metro"),
    "description" => __("Post Layout Style", "wrock-metro"),
    "capability" => "edit_theme_options",
    "panel" => "wrockmetro_theme_postsset",
    "priority" => apply_filters("wrockmetro_poststyle_section_priority", 10),
]);
// Add customizer settings and controls using the wrockmetro_Image_Radio_Control class
$wp_customize->add_setting("wrockmetro_posts_layout", [
    "default" => "liststyle",
    "type" => "theme_mod",
    "sanitize_callback" => "wrockmetro_customize_sanitize_select",
    "capability" => "edit_theme_options",
]);

$wp_customize->add_control(
    new wrockmetro_Image_Radio_Control(
        $wp_customize,
        "wrockmetro_posts_layout",
        [
            "label" => __("Posts Layout", "wrock-metro"),
            "description" => __(
                "Choose between Fixed or Full width container",
                "wrock-metro"
            ),
            "section" => "wrockmetro_poststyle_section",
            "choices" => [
                "liststyle" =>
                    get_template_directory_uri() .
                    "/images/posts/poststyle1.jpg",
                "blokstyle" =>
                    get_template_directory_uri() .
                    "/images/posts/poststyle2.jpg",
                "moviestyle" =>
                    get_template_directory_uri() .
                    "/images/posts/poststyle3.jpg",
            ],
            "priority" => apply_filters(
                "wrockmetro_container_type_priority",
                10
            ),
        ]
    )
);

/****************************
Wrock Metro 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("wrockmetro_wrockmetro_heading", [
    "sanitize_callback" => "wp_kses",
]);

$wp_customize->add_control(
    new wrockmetro_Customizer_Heading_Control(
        $wp_customize,
        "wrockmetro_wrockmetro_heading",
        [
            "label" => esc_html__("Layout Settings", "wrock-metro"),
            "section" => "wrockmetro_poststyle_section",
            "priority" => 25,
        ]
    )
);

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

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

$wp_customize->add_control("cat_contlr_top", [
    "settings" => "topcateid",
    "type" => "select",
    "choices" => $cats,
    "section" => "wrockmetro_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" => "wrockmetro_sanitize_select",
]);
$wp_customize->add_control("leftcateid_hide", [
    "type" => "radio",
    "label" => __("Left Parent Category Select", "wrock-metro"),
    "settings" => "leftcateid_hide",
    "section" => "wrockmetro_poststyle_section",
    "priority" => 40,
    "choices" => [
        "show" => __("Show", "wrock-metro"),
        "hide" => __("Hide", "wrock-metro"),
    ],
]);
$wp_customize->add_setting("leftcateid", [
    "default" => 1,
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("cat_contlr_left", [
    "settings" => "leftcateid",
    "type" => "select",
    "choices" => $cats,
    "section" => "wrockmetro_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" => "wrockmetro_sanitize_select",
]);
$wp_customize->add_control("rightcateid_hide", [
    "type" => "radio",
    "label" => __("Right Parent Category Select", "wrock-metro"),
    "settings" => "rightcateid_hide",
    "section" => "wrockmetro_poststyle_section",
    "priority" => 50,
    "choices" => [
        "show" => __("Show", "wrock-metro"),
        "hide" => __("Hide", "wrock-metro"),
    ],
]);
$wp_customize->add_setting("rightcateid", [
    "default" => 1,
    "sanitize_callback" => "absint",
]);

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

//Add Section 1

$wp_customize->add_section("wrockmetro_readmore_section", [
    "title" => __("Read More Button", "wrock-metro"),
    "description" => __("Read More Section", "wrock-metro"),
    "capability" => "edit_theme_options",
    "panel" => "wrockmetro_theme_postsset",
    "priority" => apply_filters("wrockmetro_readmore_section_priority", 10),
]);

// Read more
$wp_customize->add_setting("wrockmetro_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, "wrockmetro_enable_readmore", [
        "label" => __("Read More Button", "wrock-metro"),
        "description" => __(
            "Enable or disable Read More Button & Customize",
            "wrock-metro"
        ),
        "section" => "wrockmetro_readmore_section",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "wrock-metro"),
            "enable" => __("Enable", "wrock-metro"),
        ],
        "priority" => apply_filters(
            "wrockmetro_bootstrap_version_priority",
            10
        ),
    ])
);

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

$wp_customize->add_control("wrockmetro_readmore_text", [
    "label" => __("Change Button Text", "wrock-metro"),
    "section" => "wrockmetro_readmore_section",
    "settings" => "wrockmetro_readmore_text",
    "type" => "text",
    "active_callback" => "wrockmetro_is_readmore_enabled",
]);
$wp_customize->add_setting("wrockmetro_readmore_color", [
    "default" => "#0d6efd",
    "transport" => "refresh",
    "sanitize_callback" => "sanitize_hex_color",
]);

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        "wrockmetro_readmore_color",
        [
            "label" => __("Read More Text Color (Pro Only)", "wrock-metro"),
            "section" => "wrockmetro_readmore_section",
            "settings" => "wrockmetro_readmore_color",
        ]
    )
);

//Add Section 2

$wp_customize->add_section("wrockmetro_postmeta_section", [
    "title" => __("Post Meta Section Blog", "wrock-metro"),
    "capability" => "edit_theme_options",
    "panel" => "wrockmetro_theme_postsset",
    "priority" => apply_filters("wrockmetro_postmeta_section_priority", 10),
]);

$wp_customize->add_setting("wrockmetro_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, "wrockmetro_blog_postmeta", [
        "label" => __("Post Footer Meta", "wrock-metro"),
        "description" => __(
            "Enable or disable post footer meta Date, Author, Read more etc.",
            "wrock-metro"
        ),
        "section" => "wrockmetro_postmeta_section",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "wrock-metro"),
            "enable" => __("Enable", "wrock-metro"),
        ],
        "priority" => apply_filters(
            "wrockmetro_bootstrap_version_priority",
            10
        ),
    ])
);

//Hide Post date
$wp_customize->add_setting("wrockmetro_blog_date", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "wrockmetro_customize_sanitize_select",
]);
$wp_customize->add_control("wrockmetro_blog_date", [
    "type" => "radio",
    "label" => __("Post date", "wrock-metro"),
    "settings" => "wrockmetro_blog_date",
    "section" => "wrockmetro_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "wrock-metro"),
        "disable" => __("Disable", "wrock-metro"),
    ],
    "active_callback" => "wrockmetro_is_post_meta_enabled", // Add this line to set the active callback
]);

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

//Hide Post Comments
$wp_customize->add_setting("wrockmetro_blogmeta_comments", [
    "default" => "enable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "wrockmetro_customize_sanitize_select",
]);
$wp_customize->add_control("wrockmetro_blogmeta_comments", [
    "type" => "radio",
    "label" => __("Comments", "wrock-metro"),
    "settings" => "wrockmetro_blogmeta_comments",
    "section" => "wrockmetro_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "wrock-metro"),
        "disable" => __("Disable", "wrock-metro"),
    ],
    "active_callback" => "wrockmetro_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide View Count
$wp_customize->add_setting("wrockmetro_blog_viewcount", [
    "default" => "enable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "wrockmetro_customize_sanitize_select",
]);
$wp_customize->add_control("wrockmetro_blog_viewcount", [
    "type" => "radio",
    "label" => __("View Count", "wrock-metro"),
    "settings" => "wrockmetro_blog_viewcount",
    "section" => "wrockmetro_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "wrock-metro"),
        "disable" => __("Disable", "wrock-metro"),
    ],
    "active_callback" => "wrockmetro_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide Post Categories
$wp_customize->add_setting("wrockmetro_blogmeta_category", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "wrockmetro_customize_sanitize_select",
]);
$wp_customize->add_control("wrockmetro_blogmeta_category", [
    "type" => "radio",
    "label" => __("Hide post Categories", "wrock-metro"),
    "settings" => "wrockmetro_blogmeta_category",
    "section" => "wrockmetro_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "wrock-metro"),
        "disable" => __("Disable", "wrock-metro"),
    ],
    "active_callback" => "wrockmetro_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide Post Tags
$wp_customize->add_setting("wrockmetro_blogmeta_tags", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "wrockmetro_customize_sanitize_select",
]);
$wp_customize->add_control("wrockmetro_blogmeta_tags", [
    "type" => "radio",
    "label" => __("Hide post tags", "wrock-metro"),
    "settings" => "wrockmetro_blogmeta_tags",
    "section" => "wrockmetro_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "wrock-metro"),
        "disable" => __("Disable", "wrock-metro"),
    ],
    "active_callback" => "wrockmetro_is_post_meta_enabled", // Add this line to set the active callback
]);

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

//Post Exerpt
$wp_customize->add_section("wrockmetro_postsexcerpt_settings", [
    "title" => __("Post Excerpt (Description)", "wrock-metro"),
    "capability" => "edit_theme_options",
    "description" => __('Default Post Excerpt "20"', "wrock-metro"),
    "panel" => "wrockmetro_theme_postsset",
]);
$wp_customize->add_setting("wrockmetro_excerpt_number", [
    "default" => "20",
    "transport" => "postMessage",
    "sanitize_callback" => "absint",
]);
$wp_customize->add_control("wrockmetro_excerpt_number", [
    "section" => "wrockmetro_postsexcerpt_settings",
    "label" => __("Numbers of words in post excerpt to show (Pro Only)", "wrock-metro"),
    "settings" => "wrockmetro_excerpt_number",
    "type" => "number",
]);
// Excerpt
$wp_customize->add_setting("wrockmetro_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, "wrockmetro_enable_excerpt", [
        "label" => __("Post Description (excerpt)", "wrock-metro"),
        "description" => __("Enable or disable excerpt", "wrock-metro"),
        "section" => "wrockmetro_postsexcerpt_settings",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "wrock-metro"),
            "enable" => __("Enable", "wrock-metro"),
        ],
        "priority" => apply_filters(
            "wrockmetro_bootstrap_version_priority",
            10
        ),
    ])
);

// Title Font
$wp_customize->add_setting("wrockmetro_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,
        "wrockmetro_postexcert_color",
        [
            "label" => __("Font Color (Pro Only)", "wrock-metro"),
            "section" => "wrockmetro_postsexcerpt_settings",
            "settings" => "wrockmetro_postexcert_color",
        ]
    )
);
$wp_customize->add_setting("wrockmetro_postexcert_size", [
    "default" => "17", // Default font size
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("wrockmetro_postexcert_size", [
    "label" => __("Post Title Font Size - px", "wrock-metro"),
    "section" => "wrockmetro_postsexcerpt_settings",
    "settings" => "wrockmetro_postexcert_size",
    "type" => "number",
]);

//Font Weight
$wp_customize->add_setting("wrockmetro_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, "wrockmetro_postexcert_weight", [
        "label" => __("Font Weight", "wrock-metro"),
        "section" => "wrockmetro_postsexcerpt_settings",
        "type" => "select",
        "choices" => [
            "100" => __("100", "wrock-metro"),
            "200" => __("200", "wrock-metro"),
            "400" => __("400", "wrock-metro"),
            "500" => __("500", "wrock-metro"),
            "600" => __("600", "wrock-metro"),
            "700" => __("700", "wrock-metro"),
            "800" => __("800", "wrock-metro"),
            "900" => __("900", "wrock-metro"),
        ],
    ])
);
//font style

$wp_customize->add_setting("wrockmetro_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, "wrockmetro_postexcert_style", [
        "label" => __("Font Style", "wrock-metro"),
        "section" => "wrockmetro_postsexcerpt_settings",
        "type" => "select",
        "choices" => [
            "normal" => __("Normal", "wrock-metro"),
            "italic" => __("Italic", "wrock-metro"),
        ],
    ])
);
//Text Transform
$wp_customize->add_setting("wrockmetro_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,
        "wrockmetro_postexcert_transform",
        [
            "label" => __("Text Transform", "wrock-metro"),
            "section" => "wrockmetro_postsexcerpt_settings",
            "type" => "select",
            "choices" => [
                "none" => __("None", "wrock-metro"),
                "capitalize" => __("Capitalize", "wrock-metro"),
                "lowercase" => __("Lowercase", "wrock-metro"),
                "uppercase" => __("Uppercase", "wrock-metro"),
            ],
        ]
    )
);

//Featured Image
$wp_customize->add_section("wrockmetro_poststhumbnail_blogs", [
    "title" => __("Featured Thumbnail on Blogs", "wrock-metro"),
    "capability" => "edit_theme_options",
    "description" => __('Default Post Excerpt "20"', "wrock-metro"),
    "panel" => "wrockmetro_theme_postsset",
]);
$wp_customize->add_setting("wrockmetro_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, "wrockmetro_enable_featured", [
        "label" => __(
            "Featured Post Image on Posts Index & Archive",
            "wrock-metro"
        ),
        "description" => __("Enable or disable Featured Image", "wrock-metro"),
        "section" => "wrockmetro_poststhumbnail_blogs",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "wrock-metro"),
            "enable" => __("Enable", "wrock-metro"),
        ],
        "priority" => apply_filters(
            "wrockmetro_bootstrap_version_priority",
            10
        ),
    ])
);

// Thumbnail Hover
$wp_customize->add_setting("wrockmetro_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, "wrockmetro_thumbhover", [
        "label" => __("Thumbnail Hover Zoom", "wrock-metro"),
        "section" => "wrockmetro_poststhumbnail_blogs",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "wrock-metro"),
            "enable" => __("Enable", "wrock-metro"),
        ],
        "priority" => apply_filters("wrockmetro_thumbhover_priority", 10),
    ])
);

//*******Post title
$wp_customize->add_section("wrockmetro_poststitle_section", [
    "title" => __("Post Title", "wrock-metro"),
    "capability" => "edit_theme_options",
    "description" => __('Default Post Excerpt "20"', "wrock-metro"),
    "panel" => "wrockmetro_theme_postsset",
]);
// Title Font
$wp_customize->add_setting("wrockmetro_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,
        "wrockmetro_posttitlefont_color",
        [
            "label" => __("Font Color (Pro Only)", "wrock-metro"),
            "section" => "wrockmetro_poststitle_section",
            "settings" => "wrockmetro_posttitlefont_color",
        ]
    )
);
$wp_customize->add_setting("wrockmetro_posttitlefont", [
    "default" => "20", // Default font size
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("wrockmetro_posttitlefont", [
    "label" => __("Font Size - px", "wrock-metro"),
    "section" => "wrockmetro_poststitle_section",
    "settings" => "wrockmetro_posttitlefont",
    "type" => "number",
]);
//Font Weight
$wp_customize->add_setting("wrockmetro_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,
        "wrockmetro_posttitlefont_weight",
        [
            "label" => __("Font Weight", "wrock-metro"),
            "section" => "wrockmetro_poststitle_section",
            "type" => "select",
            "choices" => [
                "100" => __("100", "wrock-metro"),
                "200" => __("200", "wrock-metro"),
                "400" => __("400", "wrock-metro"),
                "600" => __("600", "wrock-metro"),
                "800" => __("800", "wrock-metro"),
            ],
        ]
    )
);
//font style

$wp_customize->add_setting("wrockmetro_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, "wrockmetro_posttitlefont_style", [
        "label" => __("Font Style", "wrock-metro"),
        "section" => "wrockmetro_poststitle_section",
        "type" => "select",
        "choices" => [
            "normal" => __("Normal", "wrock-metro"),
            "italic" => __("Italic", "wrock-metro"),
        ],
    ])
);
//Text Transform
$wp_customize->add_setting("wrockmetro_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,
        "wrockmetro_posttitlefont_transform",
        [
            "label" => __("Text Transform", "wrock-metro"),
            "section" => "wrockmetro_poststitle_section",
            "type" => "select",
            "choices" => [
                "none" => __("None", "wrock-metro"),
                "capitalize" => __("Capitalize", "wrock-metro"),
                "lowercase" => __("Lowercase", "wrock-metro"),
                "uppercase" => __("Uppercase", "wrock-metro"),
            ],
        ]
    )
);
