<?php
/**
 * Defines Footer settings for the Customizer.
 *
 * @package Pawfect
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( ! class_exists( 'Pawfect_Options_Footer' ) ) :

    /**
     * The Footer options class.
     */
    class Pawfect_Options_Footer extends pawfect_Customize_Base_Option {

        /**
         * Get all the settings and controls.
         *
         * @return array
         */
        public function elements() {

            // Get selective refresh transport type.
            $selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';

            return array(

                /**
                 * Footer Widgets Enable/Disable
                 * This setting controls whether footer widgets are displayed.
                 */
                'pawfect_footer_widgets_enabled' => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 5,
                        'label'    => esc_html__( 'Enable Footer Widgets', 'pawfect' ),
                        'description' => esc_html__( 'Show footer widget areas above the footer content.', 'pawfect' ),
                    ),
                ),

                /**
                 * Footer Feature Row Column Layout
                 * This setting controls the number of columns in the feature row.
                 */
                'pawfect_footer_feature_columns' => array(
                    'setting' => array(
                        'default'           => '4',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
                    ),
                    'control' => array(
                        'type'     => 'radio_image',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 15,
                        'label'    => esc_html__( 'Feature Row Columns', 'pawfect' ),
                        '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',
                        ),
                    ),
                ),

                /**
                 * Footer Links Row Column Layout
                 * This setting controls the number of columns in the links row.
                 */
                'pawfect_footer_links_columns' => array(
                    'setting' => array(
                        'default'           => '4',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_radio' ),
                    ),
                    'control' => array(
                        'type'     => 'radio_image',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 25,
                        'label'    => esc_html__( 'Links Row Columns', 'pawfect' ),
                        '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',
                        ),
                    ),
                ),

                /**
                 * Footer Logo Enable/Disable
                 * This setting controls whether the footer logo is displayed.
                 */
                'pawfect_footer_logo_enabled' => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                        'transport'         => $selective_refresh,
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 35,
                        'label'    => esc_html__( 'Enable Footer Logo', 'pawfect' ),
                        'description' => esc_html__( 'Show site logo in the footer.', 'pawfect' ),
                    ),
                ),

                /**
                 * Footer Logo Size - Responsive
                 * This setting controls the size of the footer logo on different devices.
                 */
                'pawfect_footer_logo_size' => array(
                    'setting' => array(
                        'default' => json_encode(array( 
                            'desktop' => 64,
                            'tablet' => 56,
                            'mobile' => 48,
                        )),
                        'sanitize_callback' => array('Pawfect_Responsive_Range_Control', 'sanitize_responsive_range'),
                        'transport' => $selective_refresh,
                    ),
                    'control' => array(
                        'type' => 'pawfect-responsive-range',
                        'section' => 'pawfect_footer_widgets',
                        'priority' => 40,
                        'label' => esc_html__('Footer Logo Size', 'pawfect'),
                        'description' => esc_html__('Set the footer logo size for different devices.', 'pawfect'),
                        'input_attrs' => array(
                            'min' => 20,
                            'max' => 200,
                            'step' => 1,
                        ),
                        'active_callback' => [
                            [ $this, 'is_control_value_active' ],
                            'pawfect_footer_logo_enabled',
                            true
                        ],
                    ),
                ),

                /**
                 * Footer Copyright Text
                 * This setting controls the copyright text in the site footer.
                 */
                'pawfect_footer_copyright_text' => array(
                    'setting' => array(
                        'default'           => sprintf(
                            /* translators: 1: Copyright symbol and year, 2: WordPress link, 3: Theme link */
                            esc_html__( 'Copyright %1$s | Powered by %2$s | Pawfect theme by %3$s', 'pawfect' ),
                            '&copy; ' . date_i18n( 'Y' ),
                            '<a href="' . esc_url( __( 'https://wordpress.org/', 'pawfect' ) ) . '">WordPress</a>',
                            '<a target="_blank" href="' . esc_url( 'https://wpmatcha.com/' ) . '">WP Matcha</a>'
                        ),
                        'sanitize_callback' => 'wp_kses_post', // Use wp_kses_post for HTML content
                        'transport'         => $selective_refresh,
                    ),
                    'control' => array(
                        'type'            => 'textarea',
                        'section'         => 'pawfect_footer_copyright',
                        'priority'        => 10,
                        'label'           => esc_html__( 'Footer Copyright Text', 'pawfect' ),
                        // Assuming you have a master toggle for this section.
                        // If not, you can remove this active_callback.
                        'active_callback' => [
                            [ $this, 'is_control_value_active' ],
                            'pawfect_footer_copyright_disabled', // Assumes a setting with this ID exists
                            true,
                        ],
                    ),
                ),

                /**
                 * Footer Background Image
                 * This setting controls the background image for the footer widget area.
                 */
                'pawfect_footer_background' => array(
                    'setting' => array(
                        'default'           => PAWFECT_THEME_URL . '/assets/images/paw-steps-white.webp',
                        'sanitize_callback' => 'esc_url_raw',
                    ),
                    'control' => array(
                        'type'     => 'image',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 35,
                        'label'    => esc_html__( 'Footer Background Image', 'pawfect' ),
                    ),
                ),

                /**
                 * Payment Cards Section
                 */
                'pawfect_show_payment_cards' => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 40,
                        'label'    => esc_html__( 'Show Payment Cards', 'pawfect' ),
                        'description' => esc_html__( 'Display payment method cards in footer.', 'pawfect' ),
                    ),
                ),

                'pawfect_show_visa' => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 41,
                        'label'    => esc_html__( 'Show Visa Card', 'pawfect' ),
                    ),
                ),

                'pawfect_show_mastercard' => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 42,
                        'label'    => esc_html__( 'Show Mastercard', 'pawfect' ),
                    ),
                ),

                'pawfect_show_amex' => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 43,
                        'label'    => esc_html__( 'Show American Express', 'pawfect' ),
                    ),
                ),

                'pawfect_show_paypal' => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'section'  => 'pawfect_footer_widgets',
                        'priority' => 44,
                        'label'    => esc_html__( 'Show PayPal', 'pawfect' ),
                    ),
                ),

            );
        }
    }

    // Instantiate the class so its settings get registered.
    // Remove automatic instantiation - let main customizer class handle this
    // new Pawfect_Options_Footer();

endif;



