class-astra-enqueue-scripts.php000066600000022104152103702600012623 0ustar00 tag in admin page * * @param String $classes body classes returned from the filter. * @return String body classes to be added to tag in admin page */ public function admin_body_class( $classes ) { $content_layout = astra_get_content_layout(); if ( 'content-boxed-container' == $content_layout ) { $classes .= ' ast-separate-container'; } elseif ( 'boxed-container' == $content_layout ) { $classes .= ' ast-separate-container ast-two-container'; } elseif ( 'page-builder' == $content_layout ) { $classes .= ' ast-page-builder-template'; } elseif ( 'plain-container' == $content_layout ) { $classes .= ' ast-plain-container'; } $classes .= ' ast-' . astra_page_layout(); return $classes; } /** * List of all assets. * * @return array assets array. */ public static function theme_assets() { $default_assets = array( // handle => location ( in /assets/js/ ) ( without .js ext). 'js' => array( 'astra-theme-js' => 'style', ), // handle => location ( in /assets/css/ ) ( without .css ext). 'css' => array( 'astra-theme-css' => 'style', ), ); return apply_filters( 'astra_theme_assets', $default_assets ); } /** * Add Fonts */ public function add_fonts() { $font_family = astra_get_option( 'body-font-family' ); $font_weight = astra_get_option( 'body-font-weight' ); $font_variant = astra_get_option( 'body-font-variant' ); Astra_Fonts::add_font( $font_family, $font_weight ); Astra_Fonts::add_font( $font_family, $font_variant ); // Render headings font. $heading_font_family = astra_get_option( 'headings-font-family' ); $heading_font_weight = astra_get_option( 'headings-font-weight' ); $heading_font_variant = astra_get_option( 'headings-font-variant' ); Astra_Fonts::add_font( $heading_font_family, $heading_font_weight ); Astra_Fonts::add_font( $heading_font_family, $heading_font_variant ); } /** * Enqueue Scripts */ public function enqueue_scripts() { if ( false === self::enqueue_theme_assets() ) { return; } /* Directory and Extension */ $file_prefix = ( SCRIPT_DEBUG ) ? '' : '.min'; $dir_name = ( SCRIPT_DEBUG ) ? 'unminified' : 'minified'; $js_uri = ASTRA_THEME_URI . 'assets/js/' . $dir_name . '/'; $css_uri = ASTRA_THEME_URI . 'assets/css/' . $dir_name . '/'; /** * IE Only Js and CSS Files. */ // Flexibility.js for flexbox IE10 support. wp_enqueue_script( 'astra-flexibility', $js_uri . 'flexibility' . $file_prefix . '.js', array(), ASTRA_THEME_VERSION, false ); wp_add_inline_script( 'astra-flexibility', 'flexibility(document.documentElement);' ); wp_script_add_data( 'astra-flexibility', 'conditional', 'IE' ); // Polyfill for CustomEvent for IE. wp_register_script( 'astra-customevent', $js_uri . 'custom-events-polyfill' . $file_prefix . '.js', array(), ASTRA_THEME_VERSION, false ); // All assets. $all_assets = self::theme_assets(); $styles = $all_assets['css']; $scripts = $all_assets['js']; if ( is_array( $styles ) && ! empty( $styles ) ) { // Register & Enqueue Styles. foreach ( $styles as $key => $style ) { $dependency = array(); // Add dynamic CSS dependency for all styles except for theme's style.css. if ( 'astra-theme-css' !== $key && class_exists( 'Astra_Cache_Base' ) ) { if ( ! Astra_Cache_Base::inline_assets() ) { $dependency[] = 'astra-theme-dynamic'; } } // Generate CSS URL. $css_file = $css_uri . $style . $file_prefix . '.css'; // Register. wp_register_style( $key, $css_file, $dependency, ASTRA_THEME_VERSION, 'all' ); // Enqueue. wp_enqueue_style( $key ); // RTL support. wp_style_add_data( $key, 'rtl', 'replace' ); } } // Fonts - Render Fonts. Astra_Fonts::render_fonts(); /** * Inline styles */ add_filter( 'astra_dynamic_theme_css', array( 'Astra_Dynamic_CSS', 'return_output' ) ); add_filter( 'astra_dynamic_theme_css', array( 'Astra_Dynamic_CSS', 'return_meta_output' ) ); // Submenu Container Animation. $menu_animation = astra_get_option( 'header-main-submenu-container-animation' ); $rtl = ( is_rtl() ) ? '-rtl' : ''; if ( ! empty( $menu_animation ) ) { if ( class_exists( 'Astra_Cache' ) ) { Astra_Cache::add_css_file( ASTRA_THEME_DIR . 'assets/css/' . $dir_name . '/menu-animation' . $rtl . $file_prefix . '.css' ); } else { wp_register_style( 'astra-menu-animation', $css_uri . 'menu-animation' . $file_prefix . '.css', null, ASTRA_THEME_VERSION, 'all' ); wp_enqueue_style( 'astra-menu-animation' ); } } if ( ! class_exists( 'Astra_Cache' ) ) { $theme_css_data = apply_filters( 'astra_dynamic_theme_css', '' ); wp_add_inline_style( 'astra-theme-css', $theme_css_data ); } if ( astra_is_amp_endpoint() ) { return; } // Comment assets. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } if ( is_array( $scripts ) && ! empty( $scripts ) ) { // Register & Enqueue Scripts. foreach ( $scripts as $key => $script ) { // Register. wp_register_script( $key, $js_uri . $script . $file_prefix . '.js', array(), ASTRA_THEME_VERSION, true ); // Enqueue. wp_enqueue_script( $key ); } } $astra_localize = array( 'break_point' => astra_header_break_point(), // Header Break Point. 'isRtl' => is_rtl(), ); wp_localize_script( 'astra-theme-js', 'astra', apply_filters( 'astra_theme_js_localize', $astra_localize ) ); } /** * Trim CSS * * @since 1.0.0 * @param string $css CSS content to trim. * @return string */ public static function trim_css( $css = '' ) { // Trim white space for faster page loading. if ( ! empty( $css ) ) { $css = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css ); $css = str_replace( array( "\r\n", "\r", "\n", "\t", ' ', ' ', ' ' ), '', $css ); $css = str_replace( ', ', ',', $css ); } return $css; } /** * Enqueue Gutenberg assets. * * @since 1.5.2 * * @return void */ public function gutenberg_assets() { /* Directory and Extension */ $rtl = ''; if ( is_rtl() ) { $rtl = '-rtl'; } $css_uri = ASTRA_THEME_URI . 'inc/assets/css/block-editor-styles' . $rtl . '.css'; wp_enqueue_style( 'astra-block-editor-styles', $css_uri, false, ASTRA_THEME_VERSION, 'all' ); // Render fonts in Gutenberg layout. Astra_Fonts::render_fonts(); wp_add_inline_style( 'astra-block-editor-styles', apply_filters( 'astra_block_editor_dynamic_css', Gutenberg_Editor_CSS::get_css() ) ); } /** * Function to check if enqueuing of Astra assets are disabled. * * @since 2.1.0 * @return boolean */ public static function enqueue_theme_assets() { return apply_filters( 'astra_enqueue_theme_assets', true ); } } new Astra_Enqueue_Scripts(); } class-astra-theme-options.php000066600000033636152103702600012276 0ustar00 array( 'single-image', 'single-title-meta', ), 'blog-single-width' => 'default', 'blog-single-max-width' => 1200, 'blog-single-meta' => array( 'comments', 'category', 'author', ), // Blog. 'blog-post-structure' => array( 'image', 'title-meta', ), 'blog-width' => 'default', 'blog-max-width' => 1200, 'blog-post-content' => 'excerpt', 'blog-meta' => array( 'comments', 'category', 'author', ), // Colors. 'text-color' => '#3a3a3a', 'link-color' => '#0274be', 'theme-color' => '#0274be', 'link-h-color' => '#3a3a3a', // Footer Colors. 'footer-bg-obj' => array( 'background-color' => '', 'background-image' => '', 'background-repeat' => 'repeat', 'background-position' => 'center center', 'background-size' => 'auto', 'background-attachment' => 'scroll', ), 'footer-color' => '', 'footer-link-color' => '', 'footer-link-h-color' => '', // Footer Widgets. 'footer-adv-bg-obj' => array( 'background-color' => '', 'background-image' => '', 'background-repeat' => 'repeat', 'background-position' => 'center center', 'background-size' => 'auto', 'background-attachment' => 'scroll', ), 'footer-adv-text-color' => '', 'footer-adv-link-color' => '', 'footer-adv-link-h-color' => '', 'footer-adv-wgt-title-color' => '', // Buttons. 'button-color' => '', 'button-h-color' => '', 'button-bg-color' => '', 'button-bg-h-color' => '', 'theme-button-padding' => array( 'desktop' => array( 'top' => 10, 'right' => 40, 'bottom' => 10, 'left' => 40, ), 'tablet' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'mobile' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'button-radius' => 2, 'theme-button-border-group-border-size' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), // Footer - Small. 'footer-sml-layout' => 'footer-sml-layout-1', 'footer-sml-section-1' => 'custom', 'footer-sml-section-1-credit' => __( 'Copyright © [current_year] [site_title] | Powered by [theme_author]', 'astra' ), 'footer-sml-section-2' => '', 'footer-sml-section-2-credit' => __( 'Copyright © [current_year] [site_title] | Powered by [theme_author]', 'astra' ), 'footer-sml-dist-equal-align' => true, 'footer-sml-divider' => 1, 'footer-sml-divider-color' => '#7a7a7a', 'footer-layout-width' => 'content', // General. 'ast-header-retina-logo' => '', 'ast-header-logo-width' => '', 'ast-header-responsive-logo-width' => array( 'desktop' => '', 'tablet' => '', 'mobile' => '', ), 'display-site-title' => 1, 'display-site-tagline' => 0, 'logo-title-inline' => 1, // Header - Primary. 'disable-primary-nav' => false, 'header-layouts' => 'header-main-layout-1', 'header-main-rt-section' => 'none', 'header-display-outside-menu' => false, 'header-main-rt-section-html' => '', 'header-main-rt-section-button-text' => __( 'Button', 'astra' ), 'header-main-rt-section-button-link' => apply_filters( 'astra_site_url', 'https://www.wpastra.com' ), 'header-main-rt-section-button-link-option' => array( 'url' => apply_filters( 'astra_site_url', 'https://www.wpastra.com' ), 'new_tab' => false, 'link_rel' => '', ), 'header-main-rt-section-button-style' => 'theme-button', 'header-main-rt-section-button-text-color' => '', 'header-main-rt-section-button-back-color' => '', 'header-main-rt-section-button-text-h-color' => '', 'header-main-rt-section-button-back-h-color' => '', 'header-main-rt-section-button-padding' => array( 'desktop' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'tablet' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'mobile' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), ), 'header-main-rt-section-button-border-size' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'header-main-sep' => 1, 'header-main-sep-color' => '', 'header-main-layout-width' => 'content', // Header - Sub menu Border. 'primary-submenu-border' => array( 'top' => '2', 'right' => '0', 'bottom' => '0', 'left' => '0', ), 'primary-submenu-item-border' => false, 'primary-submenu-b-color' => '', 'primary-submenu-item-b-color' => '', 'header-main-menu-label' => '', 'header-main-menu-align' => 'inline', 'header-main-submenu-container-animation' => 'fade', 'mobile-header-breakpoint' => '', 'mobile-header-logo' => '', 'mobile-header-logo-width' => '', // Site Layout. 'site-layout' => 'ast-full-width-layout', 'site-content-width' => 1200, 'site-layout-outside-bg-obj-responsive' => array( 'desktop' => array( 'background-color' => '', 'background-image' => '', 'background-repeat' => 'repeat', 'background-position' => 'center center', 'background-size' => 'auto', 'background-attachment' => 'scroll', ), 'tablet' => array( 'background-color' => '', 'background-image' => '', 'background-repeat' => 'repeat', 'background-position' => 'center center', 'background-size' => 'auto', 'background-attachment' => 'scroll', ), 'mobile' => array( 'background-color' => '', 'background-image' => '', 'background-repeat' => 'repeat', 'background-position' => 'center center', 'background-size' => 'auto', 'background-attachment' => 'scroll', ), ), // Container. 'site-content-layout' => 'content-boxed-container', 'single-page-content-layout' => 'default', 'single-post-content-layout' => 'default', 'archive-post-content-layout' => 'default', // Typography. 'body-font-family' => 'inherit', 'body-font-variant' => '', 'body-font-weight' => 'inherit', 'font-size-body' => array( 'desktop' => 15, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'body-line-height' => '', 'para-margin-bottom' => '', 'body-text-transform' => '', 'headings-font-family' => 'inherit', 'headings-font-weight' => 'inherit', 'headings-text-transform' => '', 'headings-line-height' => '', 'font-size-site-title' => array( 'desktop' => 35, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-site-tagline' => array( 'desktop' => 15, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-entry-title' => array( 'desktop' => 30, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-archive-summary-title' => array( 'desktop' => 40, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-page-title' => array( 'desktop' => 40, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-h1' => array( 'desktop' => 40, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-h2' => array( 'desktop' => 30, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-h3' => array( 'desktop' => 25, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-h4' => array( 'desktop' => 20, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-h5' => array( 'desktop' => 18, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), 'font-size-h6' => array( 'desktop' => 15, 'tablet' => '', 'mobile' => '', 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ), // Sidebar. 'site-sidebar-layout' => 'right-sidebar', 'site-sidebar-width' => 30, 'single-page-sidebar-layout' => 'default', 'single-post-sidebar-layout' => 'default', 'archive-post-sidebar-layout' => 'default', // Sidebar. 'footer-adv' => 'disabled', 'footer-adv-border-width' => '', 'footer-adv-border-color' => '#7a7a7a', // toogle menu style. 'mobile-header-toggle-btn-style' => 'minimal', 'hide-custom-menu-mobile' => 1, // toogle menu target. 'mobile-header-toggle-target' => 'icon', ) ); } /** * Get theme options from static array() * * @return array Return array of theme options. */ public static function get_options() { return self::$db_options; } /** * Update theme static option array. */ public static function refresh() { self::$db_options = wp_parse_args( self::get_db_options(), self::defaults() ); } /** * Get theme options from static array() from database * * @return array Return array of theme options from database. */ public static function get_db_options() { self::$db_options_no_defaults = get_option( ASTRA_THEME_SETTINGS ); return self::$db_options_no_defaults; } } } /** * Kicking this off by calling 'get_instance()' method */ Astra_Theme_Options::get_instance(); class-astra-attr.php000066600000005321152103702600010443 0ustar00astra_parse_attr( $context, $attributes, $args ); $output = ''; // Cycle through attributes, build tag attribute string. foreach ( $attributes as $key => $value ) { if ( ! $value ) { continue; } if ( true === $value ) { $output .= esc_html( $key ) . ' '; } else { $output .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) ); } } $output = apply_filters( "astra_attr_{$context}_output", $output, $attributes, $context, $args ); return trim( $output ); } /** * Merge array of attributes with defaults, and apply contextual filter on array. * * The contextual filter is of the form `astra_attr_{context}`. * * @since 1.6.2 * * @param string $context The context, to build filter name. * @param array $attributes Optional. Extra attributes to merge with defaults. * @param array $args Optional. Custom data to pass to filter. * @return array Merged and filtered attributes. */ public function astra_parse_attr( $context, $attributes = array(), $args = array() ) { $defaults = array( 'class' => sanitize_html_class( $context ), ); $attributes = wp_parse_args( $attributes, $defaults ); // Contextual filter. return apply_filters( "astra_attr_{$context}", $attributes, $context, $args ); } } endif; /** * Kicking this off by calling 'get_instance()' method */ Astra_Attr::get_instance(); theme-hooks.php000066600000021276152103702600007510 0ustar00 * // Declare support for all hook types * add_theme_support( 'astra_hooks', array( 'all' ) ); * * // Declare support for certain hook types only * add_theme_support( 'astra_hooks', array( 'header', 'content', 'footer' ) ); * */ add_theme_support( 'astra_hooks', array( /** * As a Theme developer, use the 'all' parameter, to declare support for all * hook types. * Please make sure you then actually reference all the hooks in this file, * Plugin developers depend on it! */ 'all', /** * Themes can also choose to only support certain hook types. * Please make sure you then actually reference all the hooks in this type * family. * * When the 'all' parameter was set, specific hook types do not need to be * added explicitly. */ 'html', 'body', 'head', 'header', 'content', 'entry', 'comments', 'sidebars', 'sidebar', 'footer', /** * If/when WordPress Core implements similar methodology, Themes and Plugins * will be able to check whether the version of THA supplied by the theme * supports Core hooks. */ ) ); /** * Determines, whether the specific hook type is actually supported. * * Plugin developers should always check for the support of a specific * hook type before hooking a callback function to a hook of this type. * * Example: * * if ( current_theme_supports( 'astra_hooks', 'header' ) ) * add_action( 'astra_head_top', 'prefix_header_top' ); * * * @param bool $bool true. * @param array $args The hook type being checked. * @param array $registered All registered hook types. * * @return bool */ function astra_current_theme_supports( $bool, $args, $registered ) { return in_array( $args[0], $registered[0] ) || in_array( 'all', $registered[0] ); } add_filter( 'current_theme_supports-astra_hooks', 'astra_current_theme_supports', 10, 3 ); /** * HTML hook * Special case, useful for , etc. * $astra_supports[] = 'html; */ function astra_html_before() { do_action( 'astra_html_before' ); } /** * HTML hooks * $astra_supports[] = 'body'; */ function astra_body_top() { do_action( 'astra_body_top' ); } /** * Body Bottom */ function astra_body_bottom() { do_action( 'astra_body_bottom' ); } /** * HTML hooks * * $astra_supports[] = 'head'; */ function astra_head_top() { do_action( 'astra_head_top' ); } /** * Head Bottom */ function astra_head_bottom() { do_action( 'astra_head_bottom' ); } /** * Semantic
hooks * * $astra_supports[] = 'header'; */ function astra_header_before() { do_action( 'astra_header_before' ); } /** * Site Header */ function astra_header() { do_action( 'astra_header' ); } /** * Masthead Top */ function astra_masthead_top() { do_action( 'astra_masthead_top' ); } /** * Masthead */ function astra_masthead() { do_action( 'astra_masthead' ); } /** * Masthead Bottom */ function astra_masthead_bottom() { do_action( 'astra_masthead_bottom' ); } /** * Header After */ function astra_header_after() { do_action( 'astra_header_after' ); } /** * Main Header bar top */ function astra_main_header_bar_top() { do_action( 'astra_main_header_bar_top' ); } /** * Main Header bar bottom */ function astra_main_header_bar_bottom() { do_action( 'astra_main_header_bar_bottom' ); } /** * Main Header Content */ function astra_masthead_content() { do_action( 'astra_masthead_content' ); } /** * Main toggle button before */ function astra_masthead_toggle_buttons_before() { do_action( 'astra_masthead_toggle_buttons_before' ); } /** * Main toggle buttons */ function astra_masthead_toggle_buttons() { do_action( 'astra_masthead_toggle_buttons' ); } /** * Main toggle button after */ function astra_masthead_toggle_buttons_after() { do_action( 'astra_masthead_toggle_buttons_after' ); } /** * Semantic hooks * * $astra_supports[] = 'content'; */ function astra_content_before() { do_action( 'astra_content_before' ); } /** * Content after */ function astra_content_after() { do_action( 'astra_content_after' ); } /** * Content top */ function astra_content_top() { do_action( 'astra_content_top' ); } /** * Content bottom */ function astra_content_bottom() { do_action( 'astra_content_bottom' ); } /** * Content while before */ function astra_content_while_before() { do_action( 'astra_content_while_before' ); } /** * Content loop */ function astra_content_loop() { do_action( 'astra_content_loop' ); } /** * Conten Page Loop. * * Called from page.php */ function astra_content_page_loop() { do_action( 'astra_content_page_loop' ); } /** * Content while after */ function astra_content_while_after() { do_action( 'astra_content_while_after' ); } /** * Semantic hooks * * $astra_supports[] = 'entry'; */ function astra_entry_before() { do_action( 'astra_entry_before' ); } /** * Entry after */ function astra_entry_after() { do_action( 'astra_entry_after' ); } /** * Entry content before */ function astra_entry_content_before() { do_action( 'astra_entry_content_before' ); } /** * Entry content after */ function astra_entry_content_after() { do_action( 'astra_entry_content_after' ); } /** * Entry Top */ function astra_entry_top() { do_action( 'astra_entry_top' ); } /** * Entry bottom */ function astra_entry_bottom() { do_action( 'astra_entry_bottom' ); } /** * Single Post Header Before */ function astra_single_header_before() { do_action( 'astra_single_header_before' ); } /** * Single Post Header After */ function astra_single_header_after() { do_action( 'astra_single_header_after' ); } /** * Single Post Header Top */ function astra_single_header_top() { do_action( 'astra_single_header_top' ); } /** * Single Post Header Bottom */ function astra_single_header_bottom() { do_action( 'astra_single_header_bottom' ); } /** * Comments block hooks * * $astra_supports[] = 'comments'; */ function astra_comments_before() { do_action( 'astra_comments_before' ); } /** * Comments after. */ function astra_comments_after() { do_action( 'astra_comments_after' ); } /** * Semantic hooks * * $astra_supports[] = 'sidebar'; */ function astra_sidebars_before() { do_action( 'astra_sidebars_before' ); } /** * Sidebars after */ function astra_sidebars_after() { do_action( 'astra_sidebars_after' ); } /** * Semantic