<?php
/**
 * Footer Customizer Fields
 *
 * @package buddyx
 */

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

		/**
		 *  Footer Section
		 */
		\BuddyX\Buddyx\Customizer_Framework\Field::add( 'switch',
			array(
				'settings' => 'site_footer_bg',
				'label'    => esc_html__( 'Customize Background ?', 'buddyx' ),
				'section'  => 'site_footer_section',
				'default'  => 'off',
				'choices'  => array(
					'on'  => esc_html__( 'Enable', 'buddyx' ),
					'off' => esc_html__( 'Disable', 'buddyx' ),
				),
			)
		);

		\BuddyX\Buddyx\Customizer_Framework\Field::add( 'background',
			array(
				'settings'        => 'background_setting',
				'label'           => esc_html__( 'Background Control', 'buddyx' ),
				'section'         => 'site_footer_section',
				'default'         => array(
					'background-color'      => '',
					'background-image'      => '',
					'background-repeat'     => 'repeat',
					'background-position'   => 'center center',
					'background-size'       => 'cover',
					'background-attachment' => 'scroll',
				),
				'transport'       => 'auto',
				'sanitize_callback' => function( $value ) {
					if ( isset( $value['background-color'] ) && is_string( $value['background-color'] ) ) {
						$value['background-color'] = preg_replace( '/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0\s*\)/', 'rgba($1,$2,$3,0.01)', $value['background-color'] );
					}
					return $value;
				},
				'output'          => array(
					array(
						'element' => '.site-footer-wrapper',
					),
				),
				// Saved background CSS must stop rendering when the customer
				// flips 'Customize Background?' back off - active_callback only
				// hides the control, it does not suppress emission.
				'output_condition' => static function () {
					return buddyx_is_truthy( get_theme_mod( 'site_footer_bg', 'off' ) );
				},
				'active_callback' => array(
					array(
						'setting'  => 'site_footer_bg',
						'operator' => '==',
						'value'    => '1',
					),
				),
			)
		);

		/**
		 *  Site Copyright
		 */
		\BuddyX\Buddyx\Customizer_Framework\Field::add( 'textarea',
			array(
				'settings' => 'site_copyright_text',
				'label'    => esc_html__( 'Add Content', 'buddyx' ),
				'section'  => 'site_copyright_section',
				// Shared with the render site (inc/extra.php) so the Customizer default
				// and what a fresh site actually prints cannot diverge.
				'default'  => buddyx_footer_default_copyright_text(),
				'priority' => 10,
			)
		);

		/*
		 * WordPress core auto-links the site's Privacy Policy page (Settings >
		 * Privacy) beneath the copyright line. Default stays 'on' so existing
		 * sites keep today's output; site owners who don't want it can turn it
		 * off here instead of editing template-parts/footer/info.php directly,
		 * which gets overwritten on every theme update.
		 */
		\BuddyX\Buddyx\Customizer_Framework\Field::add( 'switch',
			array(
				'settings'    => 'site_copyright_privacy_link',
				'label'       => esc_html__( 'Show Privacy Policy Link', 'buddyx' ),
				'description' => esc_html__( 'Displays a link to your Privacy Policy page (set under Settings > Privacy) beneath the copyright text.', 'buddyx' ),
				'section'     => 'site_copyright_section',
				'default'     => 'on',
				'priority'    => 15,
				'choices'     => array(
					'on'  => esc_html__( 'Yes', 'buddyx' ),
					'off' => esc_html__( 'No', 'buddyx' ),
				),
			)
		);
