<?php

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

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

$wp_customize->add_section("digital_poststyle_section", [
    "title" => __("Post Layout Style", "digital"),
    "description" => __("Post Layout Style", "digital"),
    "capability" => "edit_theme_options",
    "panel" => "digital_theme_postsset",
    "priority" => apply_filters("digital_poststyle_section_priority", 10),
]);
// Add customizer settings and controls using the digital_Image_Radio_Control class
$wp_customize->add_setting("digital_posts_layout", [
    "default" => "blokstyle",
    "type" => "theme_mod",
    "sanitize_callback" => "digital_customize_sanitize_select",
    "capability" => "edit_theme_options",
]);

$wp_customize->add_control(
    new digital_Image_Radio_Control(
        $wp_customize,
        "digital_posts_layout",
        [
            "label" => __("Posts Layout", "digital"),
            "description" => __(
                "Choose between Fixed or Full width container",
                "digital"
            ),
            "section" => "digital_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",
                "poststylefour" =>
                get_template_directory_uri() .
                "/images/posts/poststyle4.jpg",
            ],
            "priority" => apply_filters(
                "digital_container_type_priority",
                10
            ),
        ]
    )
);

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

$wp_customize->add_control(
    new digital_Customizer_Heading_Control(
        $wp_customize,
        "digital_poststylethree_heading",
        [
            "label" => esc_html__("Layout Settings", "digital"),
            "section" => "digital_poststyle_section",
            "priority" => 25,
        ]
    )
);

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

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

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

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

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

//Add Section 1

$wp_customize->add_section("digital_readmore_section", [
    "title" => __("Read More Button", "digital"),
    "description" => __("Read More Section", "digital"),
    "capability" => "edit_theme_options",
    "panel" => "digital_theme_postsset",
    "priority" => apply_filters("digital_readmore_section_priority", 10),
]);

// Read more
$wp_customize->add_setting("digital_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, "digital_enable_readmore", [
        "label" => __("Read More Button", "digital"),
        "description" => __(
            "Enable or disable Read More Button & Customize",
            "digital"
        ),
        "section" => "digital_readmore_section",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "digital"),
            "enable" => __("Enable", "digital"),
        ],
        "priority" => apply_filters(
            "digital_bootstrap_version_priority",
            10
        ),
    ])
);

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

$wp_customize->add_control("digital_readmore_text", [
    "label" => __("Change Button Text", "digital"),
    "section" => "digital_readmore_section",
    "settings" => "digital_readmore_text",
    "type" => "text",
    "active_callback" => "digital_is_readmore_enabled",
]);
$wp_customize->add_setting("digital_readmore_color", [
    "default" => "#0d6efd",
    "transport" => "refresh",
    "sanitize_callback" => "sanitize_hex_color",
]);

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        "digital_readmore_color",
        [
            "label" => __("Read More Text Color", "digital"),
            "section" => "digital_readmore_section",
            "settings" => "digital_readmore_color",
        ]
    )
);

//Add Section 2

$wp_customize->add_section("digital_postmeta_section", [
    "title" => __("Post Meta Section Blog", "digital"),
    "capability" => "edit_theme_options",
    "panel" => "digital_theme_postsset",
    "priority" => apply_filters("digital_postmeta_section_priority", 10),
]);

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

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

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

//Hide Post Comments
$wp_customize->add_setting("digital_blogmeta_comments", [
    "default" => "enable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "digital_customize_sanitize_select",
]);
$wp_customize->add_control("digital_blogmeta_comments", [
    "type" => "radio",
    "label" => __("Comments", "digital"),
    "settings" => "digital_blogmeta_comments",
    "section" => "digital_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "digital"),
        "disable" => __("Disable", "digital"),
    ],
    "active_callback" => "digital_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide View Count
$wp_customize->add_setting("digital_blog_viewcount", [
    "default" => "enable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "digital_customize_sanitize_select",
]);
$wp_customize->add_control("digital_blog_viewcount", [
    "type" => "radio",
    "label" => __("View Count", "digital"),
    "settings" => "digital_blog_viewcount",
    "section" => "digital_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "digital"),
        "disable" => __("Disable", "digital"),
    ],
    "active_callback" => "digital_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide Post Categories
$wp_customize->add_setting("digital_blogmeta_category", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "digital_customize_sanitize_select",
]);
$wp_customize->add_control("digital_blogmeta_category", [
    "type" => "radio",
    "label" => __("Hide post Categories", "digital"),
    "settings" => "digital_blogmeta_category",
    "section" => "digital_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "digital"),
        "disable" => __("Disable", "digital"),
    ],
    "active_callback" => "digital_is_post_meta_enabled", // Add this line to set the active callback
]);
//Hide Post Tags
$wp_customize->add_setting("digital_blogmeta_tags", [
    "default" => "disable",
    "type" => "theme_mod",
    "capability" => "edit_theme_options",
    "sanitize_callback" => "digital_customize_sanitize_select",
]);
$wp_customize->add_control("digital_blogmeta_tags", [
    "type" => "radio",
    "label" => __("Hide post tags", "digital"),
    "settings" => "digital_blogmeta_tags",
    "section" => "digital_postmeta_section",
    "choices" => [
        "enable" => __("Enable", "digital"),
        "disable" => __("Disable", "digital"),
    ],
    "active_callback" => "digital_is_post_meta_enabled", // Add this line to set the active callback
]);

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

//Post Exerpt
$wp_customize->add_section("digital_postsexcerpt_settings", [
    "title" => __("Post Excerpt (Description)", "digital"),
    "capability" => "edit_theme_options",
    "description" => __('Default Post Excerpt "20"', "digital"),
    "panel" => "digital_theme_postsset",
]);
$wp_customize->add_setting("digital_excerpt_number", [
    "default" => "20",
    "sanitize_callback" => "absint",
]);
$wp_customize->add_control("digital_excerpt_number", [
    "section" => "digital_postsexcerpt_settings",
    "label" => __("Numbers of words in post excerpt to show", "digital"),
    "settings" => "digital_excerpt_number",
    "type" => "number",
]);
// Excerpt
$wp_customize->add_setting("digital_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, "digital_enable_excerpt", [
        "label" => __("Post Description (excerpt)", "digital"),
        "description" => __("Enable or disable excerpt", "digital"),
        "section" => "digital_postsexcerpt_settings",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "digital"),
            "enable" => __("Enable", "digital"),
        ],
        "priority" => apply_filters(
            "digital_bootstrap_version_priority",
            10
        ),
    ])
);

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

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        "digital_postexcert_color",
        [
            "label" => __("Font Color", "digital"),
            "section" => "digital_postsexcerpt_settings",
            "settings" => "digital_postexcert_color",
        ]
    )
);
$wp_customize->add_setting("digital_postexcert_size", [
    "default" => "17", // Default font size
    "sanitize_callback" => "absint",
]);

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

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

$wp_customize->add_setting("digital_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, "digital_postexcert_style", [
        "label" => __("Font Style", "digital"),
        "section" => "digital_postsexcerpt_settings",
        "type" => "select",
        "choices" => [
            "normal" => __("Normal", "digital"),
            "italic" => __("Italic", "digital"),
        ],
    ])
);
//Text Transform
$wp_customize->add_setting("digital_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,
        "digital_postexcert_transform",
        [
            "label" => __("Text Transform", "digital"),
            "section" => "digital_postsexcerpt_settings",
            "type" => "select",
            "choices" => [
                "none" => __("None", "digital"),
                "capitalize" => __("Capitalize", "digital"),
                "lowercase" => __("Lowercase", "digital"),
                "uppercase" => __("Uppercase", "digital"),
            ],
        ]
    )
);

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

// Thumbnail Hover
$wp_customize->add_setting("digital_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, "digital_thumbhover", [
        "label" => __("Thumbnail Hover Zoom", "digital"),
        "section" => "digital_poststhumbnail_blogs",
        "type" => "select",
        "choices" => [
            "disable" => __("Disable", "digital"),
            "enable" => __("Enable", "digital"),
        ],
        "priority" => apply_filters("digital_thumbhover_priority", 10),
    ])
);

//*******Post title
$wp_customize->add_section("digital_poststitle_section", [
    "title" => __("Post Title", "digital"),
    "capability" => "edit_theme_options",
    "description" => __('Front Page Posts Fonts', "digital"),
    "panel" => "digital_theme_postsset",
]);
// Title Font
$wp_customize->add_setting("digital_posttitlefont_color", [
    "default" => "#333333", // Default font color
    "sanitize_callback" => "sanitize_hex_color",
]);

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        "digital_posttitlefont_color",
        [
            "label" => __("Font Color", "digital"),
            "section" => "digital_poststitle_section",
            "settings" => "digital_posttitlefont_color",
        ]
    )
);
$wp_customize->add_setting("digital_posttitlefont", [
    "default" => "17", // Default font size
    "sanitize_callback" => "absint",
]);

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

$wp_customize->add_setting("digital_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, "digital_posttitlefont_style", [
        "label" => __("Font Style", "digital"),
        "section" => "digital_poststitle_section",
        "type" => "select",
        "choices" => [
            "normal" => __("Normal", "digital"),
            "italic" => __("Italic", "digital"),
        ],
    ])
);
//Text Transform
$wp_customize->add_setting("digital_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,
        "digital_posttitlefont_transform",
        [
            "label" => __("Text Transform", "digital"),
            "section" => "digital_poststitle_section",
            "type" => "select",
            "choices" => [
                "none" => __("None", "digital"),
                "capitalize" => __("Capitalize", "digital"),
                "lowercase" => __("Lowercase", "digital"),
                "uppercase" => __("Uppercase", "digital"),
            ],
        ]
    )
);
