<?php

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

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

$wp_customize->add_section("magazinestyle_poststyle_section", [
    "title" => __("Post Layout Style", "magazine-style"),
    "description" => __("Post Layout Style", "magazine-style"),
    "capability" => "edit_theme_options",
    "panel" => "magazinestyle_theme_postsset",
    "priority" => apply_filters("magazinestyle_poststyle_section_priority", 10),
]);
// Add customizer settings and controls using the magazinestyle_Image_Radio_Control class
$wp_customize->add_setting("magazinestyle_posts_layout", [
    "default" => "blokstyle",
    "type" => "theme_mod",
    "sanitize_callback" => "magazinestyle_customize_sanitize_select",
    "capability" => "edit_theme_options",
]);

$wp_customize->add_control(
    new magazinestyle_Image_Radio_Control(
        $wp_customize,
        "magazinestyle_posts_layout",
        [
            "label" => __("Posts Layout", "magazine-style"),
            "description" => __(
                "Choose between Fixed or Full width container",
                "magazine-style"
            ),
            "section" => "magazinestyle_poststyle_section",
            "choices" => [
                "liststyle" =>
                    get_template_directory_uri() .
                    "/images/posts/poststyle1.jpg",
                "blokstyle" =>
                    get_template_directory_uri() .
                    "/images/posts/poststyle2.jpg",
                "poststylethree" =>
                    get_template_directory_uri() .
                    "/images/posts/poststyle3.jpg",
            ],
            "priority" => apply_filters(
                "magazinestyle_container_type_priority",
                10
            ),
        ]
    )
);

/****************************
Magazine Style 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("magazinestyle_poststylethree_heading", [
    "sanitize_callback" => "wp_kses",
]);

$wp_customize->add_control(
    new magazinestyle_Customizer_Heading_Control(
        $wp_customize,
        "magazinestyle_poststylethree_heading",
        [
            "label" => esc_html__("Layout Settings", "magazine-style"),
            "section" => "magazinestyle_poststyle_section",
            "priority" => 25,
        ]
    )
);

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

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

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

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

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

//Add Section 1

$wp_customize->add_section("magazinestyle_readmore_section", [
    "title" => __("Read More Button", "magazine-style"),
    "description" => __("Read More Section", "magazine-style"),
    "capability" => "edit_theme_options",
    "panel" => "magazinestyle_theme_postsset",
    "priority" => apply_filters("magazinestyle_readmore_section_priority", 10),
]);

// Read more
$wp_customize->add_setting("magazinestyle_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, "magazinestyle_enable_readmore", [
        "label" => __("Read More Button", "magazine-style"),
        "description" => __(
            "Enable or disable Read More Button & Customize",
            "magazine-style"
        ),
        "section" => "magazinestyle_readmore_section",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "magazine-style"),
            "enable" => __("Enable", "magazine-style"),
        ],
        "priority" => apply_filters(
            "magazinestyle_bootstrap_version_priority",
            10
        ),
    ])
);

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

$wp_customize->add_control("magazinestyle_readmore_text", [
    "label" => __("Change Button Text", "magazine-style"),
    "section" => "magazinestyle_readmore_section",
    "settings" => "magazinestyle_readmore_text",
    "type" => "text",
    "active_callback" => "magazinestyle_is_readmore_enabled",
]);
$wp_customize->add_setting("magazinestyle_readmore_color", [
    "default" => "#0d6efd",
    "transport" => "postMessage",
    "sanitize_callback" => "sanitize_hex_color",
]);

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        "magazinestyle_readmore_color",
        [
            "label" => __("Read More Text Color (Pro Only)", "magazine-style"),
            "section" => "magazinestyle_readmore_section",
            "settings" => "magazinestyle_readmore_color",
        ]
    )
);

//Add Section 2

$wp_customize->add_section("magazinestyle_postmeta_section", [
    "title" => __("Post Meta Section Blog", "magazine-style"),
    "capability" => "edit_theme_options",
    "panel" => "magazinestyle_theme_postsset",
    "priority" => apply_filters("magazinestyle_postmeta_section_priority", 10),
]);

$wp_customize->add_setting("magazinestyle_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, "magazinestyle_blog_postmeta", [
        "label" => __("Post Footer Meta", "magazine-style"),
        "description" => __(
            "Enable or disable post footer meta Date, Author, Read more etc.",
            "magazine-style"
        ),
        "section" => "magazinestyle_postmeta_section",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "magazine-style"),
            "enable" => __("Enable", "magazine-style"),
        ],
        "priority" => apply_filters(
            "magazinestyle_bootstrap_version_priority",
            10
        ),
    ])
);

//Hide Post date
$wp_customize->add_setting("magazinestyle_blog_date", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "magazinestyle_customize_sanitize_select",
]);
$wp_customize->add_control("magazinestyle_blog_date", [
    "type" => "radio",
    "label" => __("Post date", "magazine-style"),
    "settings" => "magazinestyle_blog_date",
    "section" => "magazinestyle_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "magazine-style"),
        "disable" => __("Disable", "magazine-style"),
    ],
    "active_callback" => "magazinestyle_is_post_meta_enabled", // Add this line to set the active callback
]);

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

//Hide Post Comments
$wp_customize->add_setting("magazinestyle_blogmeta_comments", [
    "default" => "enable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "magazinestyle_customize_sanitize_select",
]);
$wp_customize->add_control("magazinestyle_blogmeta_comments", [
    "type" => "radio",
    "label" => __("Comments", "magazine-style"),
    "settings" => "magazinestyle_blogmeta_comments",
    "section" => "magazinestyle_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "magazine-style"),
        "disable" => __("Disable", "magazine-style"),
    ],
    "active_callback" => "magazinestyle_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide View Count
$wp_customize->add_setting("magazinestyle_blog_viewcount", [
    "default" => "enable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "magazinestyle_customize_sanitize_select",
]);
$wp_customize->add_control("magazinestyle_blog_viewcount", [
    "type" => "radio",
    "label" => __("View Count", "magazine-style"),
    "settings" => "magazinestyle_blog_viewcount",
    "section" => "magazinestyle_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "magazine-style"),
        "disable" => __("Disable", "magazine-style"),
    ],
    "active_callback" => "magazinestyle_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide Post Categories
$wp_customize->add_setting("magazinestyle_blogmeta_category", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "magazinestyle_customize_sanitize_select",
]);
$wp_customize->add_control("magazinestyle_blogmeta_category", [
    "type" => "radio",
    "label" => __("Hide post Categories", "magazine-style"),
    "settings" => "magazinestyle_blogmeta_category",
    "section" => "magazinestyle_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "magazine-style"),
        "disable" => __("Disable", "magazine-style"),
    ],
    "active_callback" => "magazinestyle_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide Post Tags
$wp_customize->add_setting("magazinestyle_blogmeta_tags", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "magazinestyle_customize_sanitize_select",
]);
$wp_customize->add_control("magazinestyle_blogmeta_tags", [
    "type" => "radio",
    "label" => __("Hide post tags", "magazine-style"),
    "settings" => "magazinestyle_blogmeta_tags",
    "section" => "magazinestyle_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "magazine-style"),
        "disable" => __("Disable", "magazine-style"),
    ],
    "active_callback" => "magazinestyle_is_post_meta_enabled", // Add this line to set the active callback
]);

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

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

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

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        "magazinestyle_postexcert_color",
        [
            "label" => __("Font Color(Pro Only)", "magazine-style"),
            "section" => "magazinestyle_postsexcerpt_settings",
            "settings" => "magazinestyle_postexcert_color",
        ]
    )
);
$wp_customize->add_setting("magazinestyle_postexcert_size", [
    "default" => "17", // Default font size
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("magazinestyle_postexcert_size", [
    "label" => __("Post Title Font Size - px", "magazine-style"),
    "section" => "magazinestyle_postsexcerpt_settings",
    "settings" => "magazinestyle_postexcert_size",
    "type" => "number",
]);

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

$wp_customize->add_setting("magazinestyle_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, "magazinestyle_postexcert_style", [
        "label" => __("Font Style", "magazine-style"),
        "section" => "magazinestyle_postsexcerpt_settings",
        "type" => "select",
        "choices" => [
            "normal" => __("Normal", "magazine-style"),
            "italic" => __("Italic", "magazine-style"),
        ],
    ])
);
//Text Transform
$wp_customize->add_setting("magazinestyle_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,
        "magazinestyle_postexcert_transform",
        [
            "label" => __("Text Transform", "magazine-style"),
            "section" => "magazinestyle_postsexcerpt_settings",
            "type" => "select",
            "choices" => [
                "none" => __("None", "magazine-style"),
                "capitalize" => __("Capitalize", "magazine-style"),
                "lowercase" => __("Lowercase", "magazine-style"),
                "uppercase" => __("Uppercase", "magazine-style"),
            ],
        ]
    )
);

//Featured Image
$wp_customize->add_section("magazinestyle_poststhumbnail_blogs", [
    "title" => __("Featured Thumbnail on Blogs", "magazine-style"),
    "capability" => "edit_theme_options",
    "description" => __('Default Post Excerpt "20"', "magazine-style"),
    "panel" => "magazinestyle_theme_postsset",
]);
$wp_customize->add_setting("magazinestyle_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, "magazinestyle_enable_featured", [
        "label" => __(
            "Featured Post Image on Posts Index & Archive",
            "magazine-style"
        ),
        "description" => __("Enable or disable Featured Image", "magazine-style"),
        "section" => "magazinestyle_poststhumbnail_blogs",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "magazine-style"),
            "enable" => __("Enable", "magazine-style"),
        ],
        "priority" => apply_filters(
            "magazinestyle_bootstrap_version_priority",
            10
        ),
    ])
);

// Thumbnail Hover
$wp_customize->add_setting("magazinestyle_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, "magazinestyle_thumbhover", [
        "label" => __("Thumbnail Hover Zoom", "magazine-style"),
        "section" => "magazinestyle_poststhumbnail_blogs",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "magazine-style"),
            "enable" => __("Enable", "magazine-style"),
        ],
        "priority" => apply_filters("magazinestyle_thumbhover_priority", 10),
    ])
);

//*******Post title
$wp_customize->add_section("magazinestyle_poststitle_section", [
    "title" => __("Post Title", "magazine-style"),
    "capability" => "edit_theme_options",
    "description" => __('Customize post title on index & archive pages', "magazine-style"),
    "panel" => "magazinestyle_theme_postsset",
]);
// Title Font
$wp_customize->add_setting("magazinestyle_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,
        "magazinestyle_posttitlefont_color",
        [
            "label" => __("Font Color (Pro Only)", "magazine-style"),
            "section" => "magazinestyle_poststitle_section",
            "settings" => "magazinestyle_posttitlefont_color",
        ]
    )
);
$wp_customize->add_setting("magazinestyle_posttitlefont", [
    "default" => "20", // Default font size
    "sanitize_callback" => "absint",
]);

$wp_customize->add_control("magazinestyle_posttitlefont", [
    "label" => __("Font Size - px", "magazine-style"),
    "section" => "magazinestyle_poststitle_section",
    "settings" => "magazinestyle_posttitlefont",
    "type" => "number",
]);
//Font Weight
$wp_customize->add_setting("magazinestyle_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,
        "magazinestyle_posttitlefont_weight",
        [
            "label" => __("Font Weight", "magazine-style"),
            "section" => "magazinestyle_poststitle_section",
            "type" => "select",
            "choices" => [
                "100" => __("100", "magazine-style"),
                "200" => __("200", "magazine-style"),
                "400" => __("400", "magazine-style"),
                "600" => __("600", "magazine-style"),
                "800" => __("800", "magazine-style"),
            ],
        ]
    )
);
//font style

$wp_customize->add_setting("magazinestyle_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, "magazinestyle_posttitlefont_style", [
        "label" => __("Font Style", "magazine-style"),
        "section" => "magazinestyle_poststitle_section",
        "type" => "select",
        "choices" => [
            "normal" => __("Normal", "magazine-style"),
            "italic" => __("Italic", "magazine-style"),
        ],
    ])
);
//Text Transform
$wp_customize->add_setting("magazinestyle_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,
        "magazinestyle_posttitlefont_transform",
        [
            "label" => __("Text Transform", "magazine-style"),
            "section" => "magazinestyle_poststitle_section",
            "type" => "select",
            "choices" => [
                "none" => __("None", "magazine-style"),
                "capitalize" => __("Capitalize", "magazine-style"),
                "lowercase" => __("Lowercase", "magazine-style"),
                "uppercase" => __("Uppercase", "magazine-style"),
            ],
        ]
    )
);
