/** * Content Background - Dynamic CSS * * @package astra * @since 3.7.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } add_filter( 'astra_dynamic_theme_css', 'astra_content_background_css', 11 ); /** * Content Background - Dynamic CSS * * @param string $dynamic_css Astra Dynamic CSS. * @return String Generated dynamic CSS for content background. * * @since 3.2.0 */ function astra_content_background_css( $dynamic_css ) { if ( ! astra_has_gcp_typo_preset_compatibility() ) { return $dynamic_css; } $content_bg_obj = astra_get_option( 'content-bg-obj-responsive' ); // Override content background with meta value if set. $meta_background_enabled = astra_get_option_meta( 'ast-page-background-enabled' ); // Check for third party pages meta. if ( '' === $meta_background_enabled && astra_with_third_party() ) { $meta_background_enabled = astra_third_party_archive_meta( 'ast-page-background-enabled' ); if ( isset( $meta_background_enabled ) && 'enabled' === $meta_background_enabled ) { $content_bg_obj = astra_third_party_archive_meta( 'ast-content-background-meta' ); } } elseif ( isset( $meta_background_enabled ) && 'enabled' === $meta_background_enabled ) { $content_bg_obj = astra_get_option_meta( 'ast-content-background-meta' ); } $blog_layout = astra_get_blog_layout(); $blog_grid = astra_get_option( 'blog-grid' ); $sidebar_default_css = $content_bg_obj; $is_boxed = astra_is_content_style_boxed(); $is_sidebar_boxed = astra_is_sidebar_style_boxed(); $current_layout = astra_get_content_layout(); $narrow_dynamic_selector = 'narrow-width-container' === $current_layout && $is_boxed ? ', .ast-narrow-container .site-content' : ''; $comments_wrapper_bg_selector = Astra_Dynamic_CSS::astra_4_6_0_compatibility() ? ', .ast-separate-container .comments-area' : ', .ast-separate-container .comments-area .comment-respond, .ast-separate-container .comments-area .ast-comment-list li, .ast-separate-container .comments-area .comments-title'; $author_box_extra_selector = true === astra_check_is_structural_setup() ? '.site-main' : ''; // Apply unboxed container with sidebar boxed look by changing background color to site background color. $content_bg_obj = astra_apply_unboxed_container( $content_bg_obj, $is_boxed, $is_sidebar_boxed, $current_layout ); // Container Layout Colors. $container_css = array( astra_parse_selector( '.ast-separate-container .ast-article-single:not(.ast-related-post), .woocommerce.ast-separate-container .ast-woocommerce-container, .ast-separate-container .error-404, .ast-separate-container .no-results, .single.ast-separate-container ' . esc_attr( $author_box_extra_selector ) . ' .ast-author-meta, .ast-separate-container .related-posts-title-wrapper,.ast-separate-container .comments-count-wrapper, .ast-box-layout.ast-plain-container .site-content,.ast-padded-layout.ast-plain-container .site-content, .ast-separate-container .ast-archive-description' . $narrow_dynamic_selector . $comments_wrapper_bg_selector, 'wc' ) => astra_get_responsive_background_obj( $content_bg_obj, 'desktop' ), ); // Container Layout Colors. $container_css_tablet = array( astra_parse_selector( '.ast-separate-container .ast-article-single:not(.ast-related-post), .woocommerce.ast-separate-container .ast-woocommerce-container, .ast-separate-container .error-404, .ast-separate-container .no-results, .single.ast-separate-container ' . esc_attr( $author_box_extra_selector ) . ' .ast-author-meta, .ast-separate-container .related-posts-title-wrapper,.ast-separate-container .comments-count-wrapper, .ast-box-layout.ast-plain-container .site-content,.ast-padded-layout.ast-plain-container .site-content, .ast-separate-container .ast-archive-description' . $narrow_dynamic_selector, 'wc' ) => astra_get_responsive_background_obj( $content_bg_obj, 'tablet' ), ); // Container Layout Colors. $container_css_mobile = array( astra_parse_selector( '.ast-separate-container .ast-article-single:not(.ast-related-post), .woocommerce.ast-separate-container .ast-woocommerce-container, .ast-separate-container .error-404, .ast-separate-container .no-results, .single.ast-separate-container ' . esc_attr( $author_box_extra_selector ) . ' .ast-author-meta, .ast-separate-container .related-posts-title-wrapper,.ast-separate-container .comments-count-wrapper, .ast-box-layout.ast-plain-container .site-content,.ast-padded-layout.ast-plain-container .site-content, .ast-separate-container .ast-archive-description' . $narrow_dynamic_selector, 'wc' ) => astra_get_responsive_background_obj( $content_bg_obj, 'mobile' ), ); // Sidebar specific css. $sidebar_css = array( '.ast-separate-container.ast-two-container #secondary .widget' => astra_get_responsive_background_obj( $sidebar_default_css, 'desktop' ), ); // Sidebar specific css. $sidebar_css_tablet = array( '.ast-separate-container.ast-two-container #secondary .widget' => astra_get_responsive_background_obj( $sidebar_default_css, 'tablet' ), ); // Sidebar specific css. $sidebar_css_mobile = array( '.ast-separate-container.ast-two-container #secondary .widget' => astra_get_responsive_background_obj( $sidebar_default_css, 'mobile' ), ); // Apply Content BG Color for Narrow Unboxed Container. if ( ! astra_is_content_style_boxed() && 'narrow-container' === $current_layout ) { $container_css = array_merge( $container_css, array( '.ast-narrow-container .site-content' => astra_get_responsive_background_obj( $content_bg_obj, 'desktop' ) ) ); $container_css_tablet = array_merge( $container_css_tablet, array( '.ast-narrow-container .site-content' => astra_get_responsive_background_obj( $content_bg_obj, 'tablet' ) ) ); $container_css_mobile = array_merge( $container_css_mobile, array( '.ast-narrow-container .site-content' => astra_get_responsive_background_obj( $content_bg_obj, 'mobile' ) ) ); } // Blog Pro Layout Colors. if ( ( 'blog-layout-1' === $blog_layout || 'blog-layout-4' === $blog_layout || 'blog-layout-6' === $blog_layout ) || ( defined( 'ASTRA_EXT_VER' ) && ( 'blog-layout-1' === $blog_layout || 'blog-layout-4' === $blog_layout || 'blog-layout-6' === $blog_layout ) && 1 !== $blog_grid ) ) { $blog_layouts = array( '.ast-separate-container .ast-article-inner' => astra_get_responsive_background_obj( $content_bg_obj, 'desktop' ), ); $blog_layouts_tablet = array( '.ast-separate-container .ast-article-inner' => astra_get_responsive_background_obj( $content_bg_obj, 'tablet' ), ); $blog_layouts_mobile = array( '.ast-separate-container .ast-article-inner' => astra_get_responsive_background_obj( $content_bg_obj, 'mobile' ), ); } else { $blog_layouts = array( '.ast-separate-container .ast-article-post' => astra_get_responsive_background_obj( $content_bg_obj, 'desktop' ), ); $blog_layouts_tablet = array( '.ast-separate-container .ast-article-post' => astra_get_responsive_background_obj( $content_bg_obj, 'tablet' ), ); $blog_layouts_mobile = array( '.ast-separate-container .ast-article-post' => astra_get_responsive_background_obj( $content_bg_obj, 'mobile' ), ); $inner_layout = array( '.ast-separate-container .ast-article-inner' => array( 'background-color' => 'transparent', 'background-image' => 'none', ), ); $dynamic_css .= astra_parse_css( $inner_layout ); } $dynamic_css .= astra_parse_css( $blog_layouts ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $dynamic_css .= astra_parse_css( $blog_layouts_tablet, '', astra_get_tablet_breakpoint() ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $dynamic_css .= astra_parse_css( $blog_layouts_mobile, '', astra_get_mobile_breakpoint() ); $dynamic_css .= astra_parse_css( $container_css ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $dynamic_css .= astra_parse_css( $container_css_tablet, '', astra_get_tablet_breakpoint() ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $dynamic_css .= astra_parse_css( $container_css_mobile, '', astra_get_mobile_breakpoint() ); $dynamic_css .= astra_parse_css( $sidebar_css ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $dynamic_css .= astra_parse_css( $sidebar_css_tablet, '', astra_get_tablet_breakpoint() ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $dynamic_css .= astra_parse_css( $sidebar_css_mobile, '', astra_get_mobile_breakpoint() ); if ( astra_apply_content_background_fullwidth_layouts() ) { $fullwidth_layout = array( '.ast-plain-container, .ast-page-builder-template' => astra_get_responsive_background_obj( $content_bg_obj, 'desktop' ), ); $fullwidth_layout_tablet = array( '.ast-plain-container, .ast-page-builder-template' => astra_get_responsive_background_obj( $content_bg_obj, 'tablet' ), ); $fullwidth_layout_mobile = array( '.ast-plain-container, .ast-page-builder-template' => astra_get_responsive_background_obj( $content_bg_obj, 'mobile' ), ); $dynamic_css .= astra_parse_css( $fullwidth_layout ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $dynamic_css .= astra_parse_css( $fullwidth_layout_tablet, '', astra_get_tablet_breakpoint() ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $dynamic_css .= astra_parse_css( $fullwidth_layout_mobile, '', astra_get_mobile_breakpoint() ); } return $dynamic_css; } /** * Applies an unboxed container to the content. * * @since 4.2.0 * @param array $content_bg_obj The background object for the content. * @param bool $is_boxed Container style is boxed or not. * @param bool $is_sidebar_boxed Sidebar style is boxed or not. * @param mixed $current_layout The current container layout applied. * @return array $content_bg_obj The updated background object for the content. */ function astra_apply_unboxed_container( $content_bg_obj, $is_boxed, $is_sidebar_boxed, $current_layout ) { $site_bg_obj = astra_get_option( 'site-layout-outside-bg-obj-responsive' ); $meta_background_enabled = astra_get_option_meta( 'ast-page-background-enabled' ); // Check for third party pages meta. if ( '' === $meta_background_enabled && astra_with_third_party() ) { $meta_background_enabled = astra_third_party_archive_meta( 'ast-page-background-enabled' ); if ( isset( $meta_background_enabled ) && 'enabled' === $meta_background_enabled ) { $site_bg_obj = astra_third_party_archive_meta( 'ast-page-background-meta' ); } } elseif ( isset( $meta_background_enabled ) && 'enabled' === $meta_background_enabled ) { $site_bg_obj = astra_get_option_meta( 'ast-page-background-meta' ); } if ( 'plain-container' === $current_layout && ! $is_boxed && $is_sidebar_boxed && 'no-sidebar' !== astra_page_layout() ) { $content_bg_obj = $site_bg_obj; } return $content_bg_obj; }/** * Global color palette - Dynamic CSS * * @package astra-builder * @since 3.7.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } add_filter( 'astra_dynamic_theme_css', 'astra_generate_global_palette_style' ); /** * Generate palette CSS variable styles on the front end. * * @since 3.7.0 * @param string $dynamic_css dynamic css. * @return string */ function astra_generate_global_palette_style( $dynamic_css ) { $global_palette = astra_get_option( 'global-color-palette' ); $palette_style = array(); $variable_prefix = Astra_Global_Palette::get_css_variable_prefix(); $palette_css_vars = array(); /** * Filter the current global color palette. * * @param array $global_palette The current global color palette. * * @return array The filtered global color palette. * @since 4.10.0 */ $global_palette = apply_filters( 'astra_global_current_palette', $global_palette ); if ( isset( $global_palette['palette'] ) ) { foreach ( $global_palette['palette'] as $key => $color ) { $palette_key = str_replace( '--', '-', $variable_prefix ) . $key; $palette_style[ ':root .has' . $palette_key . '-color' ] = array( 'color' => 'var(' . $variable_prefix . $key . ')', ); $palette_style[ ':root .has' . $palette_key . '-background-color' ] = array( 'background-color' => 'var(' . $variable_prefix . $key . ')', ); $palette_style[ ':root .wp-block-button .has' . $palette_key . '-color' ] = array( 'color' => 'var(' . $variable_prefix . $key . ')', ); $palette_style[ ':root .wp-block-button .has' . $palette_key . '-background-color' ] = array( 'background-color' => 'var(' . $variable_prefix . $key . ')', ); $palette_css_vars[ $variable_prefix . $key ] = $color; } } $palette_style[':root'] = $palette_css_vars; $dynamic_css .= astra_parse_css( $palette_style ); return $dynamic_css; }/** * Theme Hook Alliance hook stub list. * * @see https://github.com/zamoose/themehookalliance * * @package Astra * @link https://wpastra.com/ * @since Astra 1.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Themes and Plugins can check for astra_hooks using current_theme_supports( 'astra_hooks', $hook ) * to determine whether a theme declares itself to support this specific hook type. * * Example: * * // 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
* // 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' ) ); *
* if ( current_theme_supports( 'astra_hooks', 'header' ) ) * add_action( 'astra_head_top', 'prefix_header_top' ); *