/** * Admin functions - Functions that add some functionality to WordPress admin panel * * @package Astra * @since 1.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Register menus */ if ( ! function_exists( 'astra_register_menu_locations' ) ) { /** * Register menus * * @since 1.0.0 */ function astra_register_menu_locations() { /** * Primary Menus */ register_nav_menus( array( 'primary' => __( 'Primary Menu', 'astra' ), ) ); if ( Astra_Builder_Helper::$is_header_footer_builder_active ) { /** * Register the Secondary & Mobile menus. */ register_nav_menus( array( 'secondary_menu' => __( 'Secondary Menu', 'astra' ), 'mobile_menu' => __( 'Mobile Menu', 'astra' ), ) ); $component_limit = defined( 'ASTRA_EXT_VER' ) ? Astra_Builder_Helper::$component_limit : Astra_Builder_Helper::$num_of_header_menu; for ( $index = 3; $index <= $component_limit; $index++ ) { if ( ! is_customize_preview() && ! Astra_Builder_Helper::is_component_loaded( 'menu-' . $index ) ) { continue; } register_nav_menus( array( 'menu_' . $index => __( 'Menu ', 'astra' ) . $index, ) ); } /** * Register the Account menus. */ register_nav_menus( array( 'loggedin_account_menu' => __( 'Logged In Account Menu', 'astra' ), ) ); } /** * Footer Menus */ register_nav_menus( array( 'footer_menu' => __( 'Footer Menu', 'astra' ), ) ); } } add_action( 'init', 'astra_register_menu_locations' );/** * Heading Colors Loader for Astra theme. * * @package Astra * @author Brainstorm Force * @copyright Copyright (c) 2020, Brainstorm Force * @link https://www.brainstormforce.com * @since Astra 2.2.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Customizer Initialization * * @since 2.2.0 */ class Astra_Heading_Colors_Loader { /** * Constructor * * @since 2.2.0 */ public function __construct() { add_filter( 'astra_theme_defaults', array( $this, 'theme_defaults' ) ); add_action( 'customize_register', array( $this, 'customize_register' ), 2 ); add_action( 'customize_preview_init', array( $this, 'preview_scripts' ), 110 ); // Load Google fonts. add_action( 'astra_get_fonts', array( $this, 'add_fonts' ), 1 ); } /** * Enqueue google fonts. * * @since 2.2.0 */ public function add_fonts() { $font_family_h1 = astra_get_option( 'font-family-h1' ); $font_weight_h1 = astra_get_option( 'font-weight-h1' ); Astra_Fonts::add_font( $font_family_h1, $font_weight_h1 ); $font_family_h2 = astra_get_option( 'font-family-h2' ); $font_weight_h2 = astra_get_option( 'font-weight-h2' ); Astra_Fonts::add_font( $font_family_h2, $font_weight_h2 ); $font_family_h3 = astra_get_option( 'font-family-h3' ); $font_weight_h3 = astra_get_option( 'font-weight-h3' ); Astra_Fonts::add_font( $font_family_h3, $font_weight_h3 ); $theme_btn_font_family = astra_get_option( 'font-family-button' ); $theme_btn_font_weight = astra_get_option( 'font-weight-button' ); Astra_Fonts::add_font( $theme_btn_font_family, $theme_btn_font_weight ); $header_btn_font_family = astra_get_option( 'primary-header-button-font-family' ); $header_btn_font_weight = astra_get_option( 'primary-header-button-font-weight' ); Astra_Fonts::add_font( $header_btn_font_family, $header_btn_font_weight ); } /** * Set Options Default Values * * @param array $defaults Astra options default value array. * @return array * * @since 2.2.0 */ public function theme_defaults( $defaults ) { /** * Heading Tags

to

*/ $defaults['h1-color'] = ''; $defaults['h2-color'] = ''; $defaults['h3-color'] = ''; $defaults['h4-color'] = ''; $defaults['h5-color'] = ''; $defaults['h6-color'] = ''; // Header

. $defaults['font-family-h1'] = 'inherit'; $defaults['font-weight-h1'] = 'inherit'; $defaults['text-transform-h1'] = ''; $defaults['line-height-h1'] = ''; // Header

. $defaults['font-family-h2'] = 'inherit'; $defaults['font-weight-h2'] = 'inherit'; $defaults['text-transform-h2'] = ''; $defaults['line-height-h2'] = ''; // Header

. $defaults['font-family-h3'] = 'inherit'; $defaults['font-weight-h3'] = 'inherit'; $defaults['text-transform-h3'] = ''; $defaults['line-height-h3'] = ''; /** * Theme button Font Defaults */ $defaults['font-weight-button'] = 'inherit'; $defaults['font-family-button'] = 'inherit'; $defaults['font-size-button'] = array( 'desktop' => '', 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ); $defaults['text-transform-button'] = ''; /** * Check backward compatibility for button line height. */ $defaults['theme-btn-line-height'] = 1; $defaults['theme-btn-letter-spacing'] = ''; return $defaults; } /** * Load color configs for the Heading Colors. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. * * @since 2.2.0 */ public function customize_register( $wp_customize ) { /** * Register Panel & Sections */ require_once ASTRA_THEME_HEADING_COLORS_DIR . 'customizer/class-astra-heading-colors-configs.php';// phpcs:ignore: WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound } /** * Customizer Preview * * @since 2.2.0 */ public function preview_scripts() { /** * Load unminified if SCRIPT_DEBUG is true. */ /* Directory and Extension */ $dir_name = ( SCRIPT_DEBUG ) ? 'unminified' : 'minified'; $file_prefix = ( SCRIPT_DEBUG ) ? '' : '.min'; wp_enqueue_script( 'astra-heading-colors-customizer-preview-js', ASTRA_THEME_HEADING_COLORS_URI . 'assets/js/' . $dir_name . '/customizer-preview' . $file_prefix . '.js', array( 'customize-preview', 'astra-customizer-preview-js' ), ASTRA_THEME_VERSION, true ); } } /** * Kicking this off by creating the object of the class. */ new Astra_Heading_Colors_Loader();/** * Heading Colors - Dynamic CSS * * @package Astra * @since 2.1.4 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Heading Colors */ add_filter( 'astra_dynamic_theme_css', 'astra_heading_colors_section_dynamic_css' ); /** * Dynamic CSS * * @param string $dynamic_css Astra Dynamic CSS. * @param string $dynamic_css_filtered Astra Dynamic CSS Filters. * @return String Generated dynamic CSS for Heading Colors. * * @since 2.1.4 */ function astra_heading_colors_section_dynamic_css( $dynamic_css, $dynamic_css_filtered = '' ) { /** * Heading Colors - h1 - h6. */ $heading_base_color = astra_get_option( 'heading-base-color' ); /** * Normal Colors without reponsive option. * [1]. Heading Colors */ $css_output = array( /** * Content base heading color. */ 'h1, .entry-content h1, h2, .entry-content h2, h3, .entry-content h3, h4, .entry-content h4, h5, .entry-content h5, h6, .entry-content h6' => array( 'color' => esc_attr( $heading_base_color ), ), ); /* Parse CSS from array() */ $css_output = astra_parse_css( $css_output ); $dynamic_css .= $css_output; return $dynamic_css; }/** * Site_Identity for Astra theme. * * @package astra-builder * @author Astra * @copyright Copyright (c) 2020, Astra * @link https://wpastra.com/ * @since 3.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } define( 'ASTRA_HEADER_SITE_IDENTITY_DIR', ASTRA_THEME_DIR . 'inc/builder/type/header/site-identity' ); define( 'ASTRA_HEADER_SITE_IDENTITY_URI', ASTRA_THEME_URI . 'inc/builder/type/header/site-identity' ); /** * Heading Initial Setup * * @since 3.0.0 */ class Astra_Header_Site_Identity_Component { /** * Constructor function that initializes required actions and hooks */ public function __construct() { // @codingStandardsIgnoreStart WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound require_once ASTRA_HEADER_SITE_IDENTITY_DIR . '/class-astra-header-site-identity-component-loader.php'; // Include front end files. if ( ! is_admin() ) { require_once ASTRA_HEADER_SITE_IDENTITY_DIR . '/dynamic-css/dynamic.css.php'; } // @codingStandardsIgnoreEnd WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound } } /** * Kicking this off by creating an object. */ new Astra_Header_Site_Identity_Component();/** * WIdget control - Dynamic CSS * * @package Astra Builder * @since 3.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Heading Colors */ add_filter( 'astra_dynamic_theme_css', 'astra_hb_widget_dynamic_css' ); /** * Dynamic CSS * * @param string $dynamic_css Astra Dynamic CSS. * @param string $dynamic_css_filtered Astra Dynamic CSS Filters. * @return String Generated dynamic CSS for Heading Colors. * * @since 3.0.0 */ function astra_hb_widget_dynamic_css( $dynamic_css, $dynamic_css_filtered = '' ) { $dynamic_css .= Astra_Widget_Component_Dynamic_CSS::astra_widget_dynamic_css( 'header' ); return $dynamic_css; }/** * Mobile Trigger. * * @package astra-builder * @author Brainstorm Force * @copyright Copyright (c) 2020, Brainstorm Force * @link https://www.brainstormforce.com * @since 3.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } define( 'ASTRA_MOBILE_TRIGGER_DIR', ASTRA_THEME_DIR . 'inc/builder/type/header/mobile-trigger' ); define( 'ASTRA_MOBILE_TRIGGER_URI', ASTRA_THEME_URI . 'inc/builder/type/header/mobile-trigger' ); /** * Mobile Trigger Initial Setup * * @since 3.0.0 */ class Astra_Mobile_Trigger { /** * Constructor function that initializes required actions and hooks. */ public function __construct() { // @codingStandardsIgnoreStart WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound require_once ASTRA_MOBILE_TRIGGER_DIR . '/class-astra-mobile-trigger-loader.php'; // Include front end files. if ( ! is_admin() ) { require_once ASTRA_MOBILE_TRIGGER_DIR . '/dynamic-css/dynamic.css.php'; } // @codingStandardsIgnoreEnd WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound } } /** * Kicking this off by creating an object. */ new Astra_Mobile_Trigger();