Your IP : 216.73.216.1


Current Path : /home/fotouserdopd8j/agenciacrabli.com/wp-contentn/themes/pally/inc/classes/
Upload File :
Current File : /home/fotouserdopd8j/agenciacrabli.com/wp-contentn/themes/pally/inc/classes/Colors.php

<?php
/**
 * pally Color Options
 *
 * @package pally
 * @since 1.0.0
 */

namespace Pally;

use WP_Customize_Manager;
use WP_Customize_Color_Control;

/**
 * Color Options
 *
 * @since 1.0.0
 */
class Colors {

	/**
	 * Constructor.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function __construct() {
		add_action( 'customize_register', [ $this, 'action_register_customizer_control' ] );
		add_action( 'wp_head', [ $this, 'action_custom_css' ], 998 );
	}

	/**
	 * Adds a Customizer setting and control for selecting colors.
	 *
	 * @param WP_Customize_Manager $wp_customize Customizer manager instance.
	 * @since 1.0.0
	 * @access public
	 */
	public function action_register_customizer_control( WP_Customize_Manager $wp_customize ) {


		$wp_customize->add_setting(
			'body_bgcolor',
			[
				'default'           => '#fff',
				'sanitize_callback' => 'sanitize_hex_color',
			]
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'body_bgcolor',
				[
					'label'    => __( 'Body Background Color', 'pally' ),
					'section'  => 'colors',
					'settings' => 'body_bgcolor',
				]
			)
		);

		$wp_customize->add_setting(
			'header_bgcolor',
			array(
				'default'           => '#fff',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'header_bgcolor',
				array(
					'label'    => __( 'Main menu Background Color', 'pally' ),
					'section'  => 'colors',
					'settings' => 'header_bgcolor',
				)
			)
		);

		$wp_customize->add_setting(
			'header_branding_bgcolor',
			array(
				'default'           => '#000',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'header_branding_bgcolor',
				array(
					'label'    => __( 'Header-Image Area Background Color', 'pally' ),
					'section'  => 'colors',
					'settings' => 'header_branding_bgcolor',
				)
			)
		);

		$wp_customize->add_setting(
			'header_branding_color',
			array(
				'default'           => '#fff',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'header_branding_color',
				array(
					'label'    => __( 'Header-Image Area Font Color', 'pally' ),
					'section'  => 'colors',
					'settings' => 'header_branding_color',
				)
			)
		);


		$wp_customize->add_setting(
			'body_text_color',
			array(
				'default'           => '#000',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'body_text_color',
				array(
					'label'    => __( 'Body Text Color', 'pally' ),
					'section'  => 'colors',
					'settings' => 'body_text_color',
				)
			)
		);

		$wp_customize->add_setting(
			'link_color',
			array(
				'default'           => '#E90716',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'link_color',
				array(
					'label'    => __( 'Link Color', 'pally' ),
					'section'  => 'colors',
					'settings' => 'link_color',
				)
			)
		);
		$wp_customize->add_setting(
			'meta_color',
			array(
				'default'           => '#727272',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'meta_color',
				array(
					'label'    => __( 'Meta Link Color', 'pally' ),
					'section'  => 'colors',
					'settings' => 'meta_color',
				)
			)
		);

		$wp_customize->add_setting(
			'tag_color_inside',
			array(
				'default'           => '#fff',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);
		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'tag_color_inside',
				array(
					'label'    => __( 'Text color on tags and other buttons', 'pally' ),
					'section'  => 'colors',
					'settings' => 'tag_color_inside',
				)
			)
		);

		$wp_customize->add_setting(
			'tag_bgcolor',
			array(
				'default'           => '#E90716',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);
		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'tag_bgcolor',
				array(
					'label'    => __( 'Background color of tags and other buttons', 'pally' ),
					'section'  => 'colors',
					'settings' => 'tag_bgcolor',
				)
			)
		);

		$wp_customize->add_setting(
			'hover_color',
			array(
				'default'           => '#fff',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);
		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'hover_color',
				array(
					'label'    => __( 'Hover & Focus Color for all links and tags/buttons', 'pally' ),
					'description' => __( 'Used for hover, focus or active.', 'pally' ),
					'section'  => 'colors',
					'settings' => 'hover_color',
				)
			)
		);

		$wp_customize->add_setting(
			'hover_bgcolor',
			array(
				'default'           => '#000',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);
		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'hover_bgcolor',
				array(
					'label'    => __( 'Hover & Focus Background Color for all links and tags/buttons', 'pally' ),
					'description' => __( 'Used for hover, focus or active.', 'pally' ),
					'section'  => 'colors',
					'settings' => 'hover_bgcolor',
				)
			)
		);

		$wp_customize->add_setting(
			'menu_title_color',
			array(
				'default'           => '#000',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'menu_title_color',
				array(
					'label'    => __( 'Menu Title Color', 'pally' ),
					'section'  => 'menu-colors',
					'settings' => 'menu_title_color',
				)
			)
		);

		$wp_customize->add_setting(
			'menu_link_color',
			array(
				'default'           => '#000',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'menu_link_color',
				array(
					'label'    => __( 'Menu Text & Link Color', 'pally' ),
					'section'  => 'menu-colors',
					'settings' => 'menu_link_color',
				)
			)
		);

		$wp_customize->add_setting(
			'current_menu_link_color',
			array(
				'default'           => '#000',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'current_menu_link_color',
				array(
					'label'    => __( 'Current Menu Item Link Color', 'pally' ),
					'section'  => 'menu-colors',
					'settings' => 'current_menu_link_color',
				)
			)
		);

		$wp_customize->add_setting(
			'menu_shadow',
			array(
				'default'           => true,
				'sanitize_callback' => 'Pally\Customizer::sanitize_checkbox',
			)
		);

		$wp_customize->add_control(
			'menu_shadow',
			array(
				'label'       => __( 'Menu Shadow', 'pally' ),
				'description' => __( 'Show a shadow below the menu.', 'pally' ),
				'section'     => 'menu-colors',
				'type'        => 'checkbox',
			)
		);


		$wp_customize->add_setting(
			'button_bgcolor',
			array(
				'default'           => '#E90716',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'button_bgcolor',
				array(
					'label'       => __( 'Button Background Color', 'pally' ),
					'description' => __( 'The options are applied on form buttons, such as submit buttons.', 'pally' ),
					'section'     => 'button-colors',
					'settings'    => 'button_bgcolor',
				)
			)
		);

		$wp_customize->add_setting(
			'button_color',
			array(
				'default'           => '#fff',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'button_color',
				array(
					'label'    => __( 'Button Text Color', 'pally' ),
					'section'  => 'button-colors',
					'settings' => 'button_color',
				)
			)
		);

		$wp_customize->add_setting(
			'button_hover_bgcolor',
			array(
				'default'           => '#000',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'button_hover_bgcolor',
				array(
					'label'       => __( 'Active Button Background Color', 'pally' ),
					'description' => __( 'Used for hover, focus or active.', 'pally' ),
					'section'     => 'button-colors',
					'settings'    => 'button_hover_bgcolor',
				)
			)
		);

		$wp_customize->add_setting(
			'button_hover_color',
			array(
				'default'           => '#fff',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'button_hover_color',
				array(
					'label'       => __( 'Active Button Text Color', 'pally' ),
					'description' => __( 'Used for hover, focus or active.', 'pally' ),
					'section'     => 'button-colors',
					'settings'    => 'button_hover_color',
				)
			)
		);

		$wp_customize->add_setting(
			'footerbg_color',
			array(
				'default'           => '#E90716',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'footerbg_color',
				array(
					'label'    => __( 'Footer Background Color', 'pally' ),
					'section'  => 'footer-colors',
					'settings' => 'footerbg_color',
				)
			)
		);

		$wp_customize->add_setting(
			'footer_color',
			array(
				'default'           => '#fff',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'footer_color',
				array(
					'label'    => __( 'Footer Text & Link Color', 'pally' ),
					'section'  => 'footer-colors',
					'settings' => 'footer_color',
				)
			)
		);


		$wp_customize->add_setting(
			'siteinfo_color',
			array(
				'default'           => '#fff',
				'sanitize_callback' => 'sanitize_hex_color',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control(
				$wp_customize,
				'siteinfo_color',
				array(
					'label'    => __( 'Footer Site Info Text & Link Color', 'pally' ),
					'section'  => 'footer-colors',
					'settings' => 'siteinfo_color',
				)
			)
		);



	}

	/**
	 * Output our colors and custom CSS.
	 *
	 * @since 1.0.0
	 * @access public
	 */

     /**
     * Increases or decreases the brightness of a color by a percentage of the current brightness.
     *
     * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
     * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
     *
     * @return  string
     *
     * @author  maliayas
     */
     function adjustBrightness($hexCode, $adjustPercent) {
         $hexCode = ltrim($hexCode, '#');

         if (strlen($hexCode) == 3) {
             $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
         }

         $hexCode = array_map('hexdec', str_split($hexCode, 2));

         foreach ($hexCode as & $color) {
             $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
             $adjustAmount = ceil($adjustableLimit * $adjustPercent);

             $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
         }

         return '#' . implode($hexCode);
     }

	public function action_custom_css() {
				echo '<style id="pally-theme-mod-css">';

        if ( get_theme_mod( 'menu_shadow', true ) === true ) {
            $menu_shadow = "0 1em 1em -0.5em rgba(0, 0, 0, 0.1)";
        } else{
            $menu_shadow = "none";
        }

        echo ':root{
            --body_bgcolor: ' . esc_html( get_theme_mod( 'body_bgcolor', '#fff') ) . ';
            --header_bgcolor: ' . esc_html( get_theme_mod( 'header_bgcolor', '#fff' ) ) . ';
			--header_branding_bgcolor: ' . esc_html( get_theme_mod( 'header_branding_bgcolor', '#000' ) ) . ';
			--header_branding_color: ' . esc_html( get_theme_mod( 'header_branding_color', '#fff' ) ) . ';
            --body_text_color: ' . esc_html( get_theme_mod( 'body_text_color', '#000' ) ) . ';
            --link_color: ' . esc_html( get_theme_mod( 'link_color', '#E90716' ) ) . ';
			--meta_color: ' . esc_html( get_theme_mod( 'meta_color', '#727272' ) ) . ';
            --tag_color_inside: ' . esc_html( get_theme_mod( 'tag_color_inside', '#fff' ) ) . ';
			--tag_bgcolor: ' . esc_html( get_theme_mod( 'tag_bgcolor', '#E90716' ) ) . ';
			--hover_color: ' . esc_html( get_theme_mod( 'hover_color', '#fff' ) ) . ';
			--hover_bgcolor: ' . esc_html( get_theme_mod( 'hover_bgcolor', '#000' ) ) . ';
			--menu_title_color: ' . esc_html( get_theme_mod( 'menu_title_color', '#000' ) ) . ';
			--menu_link_color: ' . esc_html( get_theme_mod( 'menu_link_color', '#000' ) ) . ';
			--current_menu_link_color: ' . esc_html( get_theme_mod( 'current_menu_link_color', '#000' ) ) . ';
			--menu_shadow: ' . $menu_shadow . ';
            --button_bgcolor: ' . esc_html( get_theme_mod( 'button_bgcolor', '#E90716' ) ) . ';
            --button_hover_bgcolor: ' . esc_html( get_theme_mod( 'button_hover_bgcolor', '#000' ) ) . ';
            --button_color: ' . esc_html( get_theme_mod( 'button_color', '#fff' ) ) . ';
            --button_hover_color: ' . esc_html( get_theme_mod( 'button_hover_color', '#fff' ) ) . ';
            --footerbg_color: ' . esc_html( get_theme_mod( 'footerbg_color', '#E90716' ) ) . ';
            --footer_color: ' . esc_html( get_theme_mod( 'footer_color', '#fff' ) ) . ';
            --siteinfo_color: ' . esc_html( get_theme_mod( 'siteinfo_color', '#fff' ) ) . ';
			--border_color: ' . esc_html( get_theme_mod( 'border_color', '#8f8f8f' ) ) . ';
			--widget_special_bgcolor: #fafafa;
			--widget_special_shadow: 3px 3px 10px 1px rgba(0,0,0,0.1);
			--offscreen-bgcolor: #535353;
			--offscreen-color: #ffffff;
        }';
		echo '</style>';
	}

}