<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
 * Frontpage Portfolio Options
 *
 * @package pawfect
 */

if ( ! class_exists( 'Pawfect_Options_Portfolio' ) ) :

    class Pawfect_Options_Portfolio extends pawfect_Customize_Base_Option {

        /**
         * Arguments for options.
         *
         * @return array
         */
        public function elements() {

            return array(

                'pawfect_main_portfolio_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type' => 'heading',
                        'priority' => 1,
                        'label' => esc_html__( 'Portfolio Options', 'pawfect' ),
                        'section' => 'pawfect_theme_portfolio',
                    ),
                ),
                
                'pawfect_portfolio_enabled' => array(
                    'setting' => array(
                        'default' => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type' => 'toggle',
                        'priority' => 2,
                        'label' => esc_html__( 'Disable Portfolio Section', 'pawfect' ),
                        'description' => esc_html__('Toggle ON to hide this section', 'pawfect'),
                        'section' => 'pawfect_theme_portfolio',
                    ),
                ),

                'pawfect_project_area_title' => array(
                    'setting' => array(
                        'default' => esc_html__( 'Shop by Category', 'pawfect' ),
                        'transport' => 'postMessage'
                    ),
                    'control' => array(
                        'type' => 'text',
                        'priority' => 4,
                        'label' => esc_html__( 'Section Subtitle', 'pawfect' ),
                        'section' => 'pawfect_theme_portfolio',
                      'active_callback' => 'pawfect_portfolio_disabled',
                    ),
                ),


                // Shop by Category Section Title
                'pawfect_portfolio_heading' => array(
                    'setting' => array(
                        'default' => esc_html__( 'Tailor Your Pet Experience', 'pawfect' ),
                        'sanitize_callback' => 'sanitize_text_field',
                        'transport' => 'postMessage'
                    ),
                    'control' => array(
                        'type' => 'text',
                        'priority' => 6,
                        'label' => esc_html__( 'Section Title', 'pawfect' ),
                        'section' => 'pawfect_theme_portfolio',
                       'active_callback' => 'pawfect_portfolio_disabled',
                    ),
                ),

                // Shop by Category Section Description
                'pawfect_portfolio_description' => array(
                    'setting' => array(
                        'default' => esc_html__( 'Tailor Your Pet Experience', 'pawfect' ),
                        'sanitize_callback' => 'sanitize_textarea_field',
                        'transport' => 'postMessage'
                    ),
                    'control' => array(
                        'type' => 'textarea',
                        'priority' => 7,
                        'label' => esc_html__( 'Shop by Category - Section Description', 'pawfect' ),
                        'section' => 'pawfect_theme_portfolio',
                       'active_callback' => 'pawfect_portfolio_disabled',
                    ),
                ),

                // Shop by Category Button Text
                'pawfect_portfolio_button_text' => array(
                    'setting' => array(
                        'default' => esc_html__( 'Book Now', 'pawfect' ),
                        'sanitize_callback' => 'sanitize_text_field',
                    ),
                    'control' => array(
                        'type' => 'text',
                        'priority' => 8,
                        'label' => esc_html__( 'Shop by Category - Button Text', 'pawfect' ),
                        'section' => 'pawfect_theme_portfolio',
                       'active_callback' => 'pawfect_portfolio_disabled',
                    ),
                ),

                // Shop by Category Column Layout
                'pawfect_portfolio_homepage1_column_layout' => array(
                    'setting' => array(
                        'default' => 4,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
                    ),
                    'control' => array(
                        'type' => 'simple-radio-image',
                        'priority' => 8,
                        'label' => esc_html__( 'Column Layout', 'pawfect' ),
                        'section' => 'pawfect_theme_portfolio',
                        'choices' => array(
                           
                            '2' => PAWFECT_THEME_URL . '/assets/images/icons/column-2.png',
                            '3' => PAWFECT_THEME_URL . '/assets/images/icons/column-3.png',
                            '4' => PAWFECT_THEME_URL . '/assets/images/icons/column-4.png',
                            
                        ),
                        'active_callback' => 'pawfect_portfolio_disabled',
                    ),
                ),


                'pawfect_portfolio_content' => array(
                    'setting' => array(
                        'default' => json_encode(array(
                            array(
                                'image_url' => get_template_directory_uri() . '/assets/images/category/dog-collar.webp',
                                'title' => esc_html__('Luxury Pet Collar Collection', 'pawfect'),
                                'text' => esc_html__('Handcrafted leather collars with premium hardware and elegant design.', 'pawfect'),
                                'button_text' => esc_html__('Book Now', 'pawfect'),
                                'link' => '#',
                                'id' => 'customizer_repeater_portfolio_001',
                            ),
                            array(
                                'image_url' => get_template_directory_uri() . '/assets/images/category/dog-bad.webp',
                                'title' => esc_html__('Designer Pet Apparel', 'pawfect'),
                                'text' => esc_html__('Stylish and comfortable clothing designed for modern pets.', 'pawfect'),
                                'button_text' => esc_html__('Book Now', 'pawfect'),
                                'link' => '#',
                                'id' => 'customizer_repeater_portfolio_002',
                            ),
                            array(
                                'image_url' => get_template_directory_uri() . '/assets/images/category/dog-food.webp',
                                'title' => esc_html__('Premium Pet Accessories', 'pawfect'),
                                'text' => esc_html__('Essential accessories that combine functionality with style.', 'pawfect'),
                                'button_text' => esc_html__('Book Now', 'pawfect'),
                                'link' => '#',
                                'id' => 'customizer_repeater_portfolio_003',
                            ),
                        )),
                        'sanitize_callback' => 'pawfect_repeater_sanitize',
                        'transport' => 'postMessage',
                    ),
                    'control' => array(
                        'type' => 'repeater',
                        'priority' => 10,
                        'label' => esc_html__( 'Portfolio Items', 'pawfect' ),
                        'section' => 'pawfect_theme_portfolio',
                        'add_field_label' => esc_html__('Add new portfolio item', 'pawfect'),
                        'item_name' => esc_html__('Portfolio Item', 'pawfect'),
                        'customizer_repeater_image_control' => true,
                        'customizer_repeater_title_control' => true,
                        'customizer_repeater_text_control' => true,
                        'customizer_repeater_button_text_control' => true,
                        'customizer_repeater_link_control' => true,
                        'active_callback' => 'pawfect_portfolio_disabled',
                    ),
                ),

                // Upgrade control for portfolio limitation
                'pawfect_portfolio_content_upsale' => array(
                    'setting' => array(
                        'sanitize_callback' => 'sanitize_text_field',
                    ),
                    'control' => array(
                        'type' => 'pawfect-upgrade',
                        'priority' => 11,
                        'label' => esc_html__('Portfolio Items (Max 4 in Free)', 'pawfect'),
                        'section' => 'pawfect_theme_portfolio',
                        'active_callback' => 'pawfect_portfolio_disabled',
                    ),
                ),

            );
        } 

       
    }

    new Pawfect_Options_Portfolio();

endif;

function pawfect_portfolio_disabled($control)
{
    // Following Formula theme pattern - return true when slider is enabled
    // This makes other slider settings visible when main toggle is ON
    return true === ( $control->manager->get_setting( 'pawfect_portfolio_enabled' )->value() == true );
}




