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/Font_Styles.php

<?php
/**
 * Font Styles
 *
 * @package pally
 * @since 1.0.0
 */

namespace Pally;

use WP_Customize_Manager;
use WP_Customize_Control;

/**
 * Font Styles
 *
 * @since 1.0.0
 */
class Font_Styles {

	/**
	 * 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' ], 11 );
	}

	/**
	 * Adds a Customizer section, settings, controls and partials.
	 *
	 * @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_section(
			'font_styles',
			[
				'title' => __( 'Font sizes', 'pally' ),
				'panel' => 'theme_options',
			]
		);

		$wp_customize->add_setting(
			'basic_font_size',
			[
				'default'           => '16',
				'transport'         => 'postMessage',
				'sanitize_callback' => 'sanitize_text_field',
			]
		);

		$base_choices = [
			'12' => __( 'Small (12px)', 'pally' ),
			'16' => __( 'Medium (16px)', 'pally' ),
			'20' => __( 'Large (20px)', 'pally' ),
			'24' => __( 'XLarge (24px)', 'pally' ),
		];

		$wp_customize->add_control(
			'basic_font_size',
			[
				'label'       => __( 'Basic font size', 'pally' ),
				'description' => __( 'This is the basis for all font sizes on the website.', 'pally' ) . ' ' . __( 'You can choose a smaller or a bigger base.', 'pally' ) . ' ' . __( 'Sizes may also be adjusted for you, depending on screen size, to ensure that your website is responsive.', 'pally' ),
				'section'     => 'font_styles',
				'type'        => 'radio',
				'choices' => $base_choices,
			]
		);

		$wp_customize->selective_refresh->add_partial(
			'basic_font_size',
			[
				'selector' => 'html',
			]
		);



	}

	/**
	 * Output our custom font styles.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function action_custom_css() {
		echo '<style id="pally-font-css">:root{';

		if ( get_theme_mod( 'basic_font_size', '16' ) ) {
            echo '--basic_font_size:' . esc_html( get_theme_mod( 'basic_font_size', '16' ) ) . 'px; ';
		}

		echo '}</style>';
	}

}