<?php
/**
 * Customizer settings: social links
 *
 * @package Multi
 */

if ( ! defined( 'ABSPATH' ) ) {
	die;
}

/**
 * Customizer settings for social links
 */
class Multimagazine_Customize_Social {

	/**
	 * Registers the section and fires the extension hook.
	 *
	 * @param WP_Customize_Manager $wp_customize Customizer manager instance.
	 */
	public static function register_section( $wp_customize ) {
		$wp_customize->add_panel(
			'social',
			array(
				'title'    => __( 'Social media profiles', 'multimagazine' ),
				'priority' => 60,
			)
		);

		$wp_customize->add_section(
			'social_settings',
			array(
				'title' => __( 'Social media link settings', 'multimagazine' ),
				'panel' => 'social',
			)
		);
		do_action( 'multimagazine_customize_social_settings', $wp_customize );

		$wp_customize->add_section(
			'social_urls',
			array(
				'title' => __( 'Social media profile URLs', 'multimagazine' ),
				'panel' => 'social',
			)
		);
		do_action( 'multimagazine_customize_social_urls', $wp_customize );
	}

	/**
	 * Registers the social new tabs setting.
	 */
	public static function register_social_new_tabs() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_social_new_tabs', 'social_settings', __( 'Open in new window/tab', 'multimagazine' ) );
	}

	/**
	 * Registers the show rss link setting.
	 */
	public static function register_show_rss_link() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_show_rss_link', 'social_settings', __( 'Show RSS link', 'multimagazine' ) );
	}

	/**
	 * Registers the social links color setting.
	 */
	public static function register_social_links_color() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_social_links_color',
			'social_settings',
			array(
				0             => __( 'Default (colors from customizer)', 'multimagazine' ),
				'fc'          => __( 'Brand colors on icon and border', 'multimagazine' ),
				'fc inverted' => __( 'Brand colors on icon backgrounds', 'multimagazine' ),
				'hc'          => __( 'Brand colors on mouse over on icon and border ', 'multimagazine' ),
				'hc inverted' => __( 'Brand colors on mouse over on icon backgrounds', 'multimagazine' ),
			),
			__( 'Social links color', 'multimagazine' )
		);
	}

	/**
	 * Registers the social icons color setting.
	 */
	public static function register_social_icons_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_social_icons_color', 'social_settings', __( 'Social icons color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the social icons hover color setting.
	 */
	public static function register_social_icons_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_social_icons_hover_color', 'social_settings', __( 'Social icons hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the social icons background color setting.
	 */
	public static function register_social_icons_background_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_social_icons_background_color', 'social_settings', __( 'Social icons background color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the social icons background hover color setting.
	 */
	public static function register_social_icons_background_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_social_icons_background_hover_color', 'social_settings', __( 'Social icons background hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the social icons border width setting.
	 */
	public static function register_social_icons_border_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_social_icons_border_width', 'social_settings', 0, 10, 1, __( 'Border width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the social link border radius setting.
	 */
	public static function register_social_link_border_radius() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_social_link_border_radius', 'social_settings', 0, 100, 1, __( 'Border radius', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the social icons border color setting.
	 */
	public static function register_social_icons_border_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_social_icons_border_color', 'social_settings', __( 'Social icons border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the social icons border hover color setting.
	 */
	public static function register_social_icons_border_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_social_icons_border_hover_color', 'social_settings', __( 'Social icons border hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the header social icons color setting.
	 */
	public static function register_header_social_icons_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_header_social_icons_color', 'social_settings', __( 'Header social icons color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the header social icons hover color setting.
	 */
	public static function register_header_social_icons_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_header_social_icons_hover_color', 'social_settings', __( 'Header social icons hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the header social icons background color setting.
	 */
	public static function register_header_social_icons_background_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_header_social_icons_background_color', 'social_settings', __( 'Header social icons background color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the header social icons background hover color setting.
	 */
	public static function register_header_social_icons_background_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_header_social_icons_background_hover_color', 'social_settings', __( 'Header social icons background hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the header social icons border color setting.
	 */
	public static function register_header_social_icons_border_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_header_social_icons_border_color', 'social_settings', __( 'Header social icons border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the header social icons border hover color setting.
	 */
	public static function register_header_social_icons_border_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_header_social_icons_border_hover_color', 'social_settings', __( 'Header social icons border hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the footer social icons color setting.
	 */
	public static function register_footer_social_icons_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_footer_social_icons_color', 'social_settings', __( 'Footer social icons color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the footer social icons hover color setting.
	 */
	public static function register_footer_social_icons_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_footer_social_icons_hover_color', 'social_settings', __( 'Footer social icons hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the footer social icons background color setting.
	 */
	public static function register_footer_social_icons_background_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_footer_social_icons_background_color', 'social_settings', __( 'Footer social icons background color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the footer social icons background hover color setting.
	 */
	public static function register_footer_social_icons_background_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_footer_social_icons_background_hover_color', 'social_settings', __( 'Footer social icons background hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the footer social icons border color setting.
	 */
	public static function register_footer_social_icons_border_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_footer_social_icons_border_color', 'social_settings', __( 'Footer social icons border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the footer social icons border hover color setting.
	 */
	public static function register_footer_social_icons_border_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_footer_social_icons_border_hover_color', 'social_settings', __( 'Footer social icons border hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the social text shadow setting.
	 */
	public static function register_social_text_shadow() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_social_text_shadow', 'social_settings', __( 'Text shadow', 'multimagazine' ) );
	}

	/**
	 * Registers the social box shadow setting.
	 */
	public static function register_social_box_shadow() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_social_box_shadow', 'social_settings', __( 'Box shadow', 'multimagazine' ) );
	}

	/**
	 * Registers the social links icon size setting.
	 */
	public static function register_social_links_icon_size() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_social_links_icon_size', 'social_settings', 0, 100, 1, __( 'Icon size', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the social links box size setting.
	 */
	public static function register_social_links_box_size() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_social_links_box_size', 'social_settings', 0, 150, 1, __( 'Box size', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the social links spacing setting.
	 */
	public static function register_social_links_spacing() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_social_links_spacing', 'social_settings', 0, 100, 1, __( 'Social links spacing', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the social lift setting.
	 */
	public static function register_social_lift() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_social_lift', 'social_settings', 0, 30, 1, __( 'Lift on hover', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the social links footer tooltip setting.
	 */
	public static function register_social_links_footer_tooltip() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_social_links_footer_tooltip', 'social_settings', __( 'Show tooltip in footer', 'multimagazine' ) );
	}

	/**
	 * Registers the social hide links setting.
	 */
	public static function register_social_hide_links() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_social_hide_links', 'social_settings', __( 'Hide social links from bots', 'multimagazine' ) );
	}

	/**
	 * Registers the social urls setting.
	 */
	public static function register_social_urls() {
		global $wp_customize;
		$socials       = array( 'customrss', 'facebook', 'twitter', 'pinterest', 'rss', 'instagram', 'tiktok', 'skype', 'tumblr', 'linkedin', 'flickr', 'vimeo', 'behance', 'youtube', 'dribbble', 'github', 'stumbleupon', 'lastfm', 'tripadvisor', 'snapchat', 'whatsapp', 'discord', 'threads', 'producthunt', 'email' );
		$socials_names = array( 'Custom RSS', 'Facebook', 'Twitter', 'Pinterest', 'RSS', 'Instagram', 'TikTok', 'Skype', 'Tumblr', 'LinkedIn', 'Flickr', 'Vimeo', 'Behance', 'YouTube', 'Dribbble', 'GitHub', 'StumbleUpon', 'Last.fm', 'TripAdvisor', 'Snapchat', 'WhatsApp', 'Discord', 'Threads', 'ProductHunt', 'E-mail' );

		foreach ( $socials as $k => $v ) {
			if ( 'rss' === $v ) {
				continue;
			}
			$setting_name = 'multi_social_' . $v;
			$wp_customize->add_setting(
				$setting_name,
				array(
					'sanitize_callback' => 'esc_url_raw',
				)
			);
			$wp_customize->add_control(
				$setting_name,
				array(
					'label'                      => $socials_names[ $k ],
					'section'                    => 'social_urls',
					'settings'                   => $setting_name,
					'multi_breadcrumb_bg_repeat' => $k + 30,
				)
			);
		}
	}
}

add_action( 'customize_register', array( 'Multimagazine_Customize_Social', 'register_section' ) );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_new_tabs' ), 10 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_show_rss_link' ), 15 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_links_color' ), 20 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_icons_color' ), 25 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_icons_hover_color' ), 30 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_icons_background_color' ), 35 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_icons_background_hover_color' ), 40 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_icons_border_width' ), 45 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_link_border_radius' ), 50 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_icons_border_color' ), 55 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_icons_border_hover_color' ), 60 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_header_social_icons_color' ), 65 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_header_social_icons_hover_color' ), 70 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_header_social_icons_background_color' ), 75 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_header_social_icons_background_hover_color' ), 80 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_header_social_icons_border_color' ), 85 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_header_social_icons_border_hover_color' ), 90 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_footer_social_icons_color' ), 95 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_footer_social_icons_hover_color' ), 100 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_footer_social_icons_background_color' ), 105 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_footer_social_icons_background_hover_color' ), 110 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_footer_social_icons_border_color' ), 115 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_footer_social_icons_border_hover_color' ), 120 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_text_shadow' ), 125 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_box_shadow' ), 130 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_links_icon_size' ), 135 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_links_box_size' ), 140 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_links_spacing' ), 145 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_lift' ), 150 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_links_footer_tooltip' ), 155 );
add_action( 'multimagazine_customize_social_settings', array( 'Multimagazine_Customize_Social', 'register_social_hide_links' ), 160 );
add_action( 'multimagazine_customize_social_urls', array( 'Multimagazine_Customize_Social', 'register_social_urls' ), 10 );
