Astra_Dynamic_CSS::return_meta_output( string $dynamic_css, string $dynamic_css_filtered = '' )

Return post meta CSS


Description


Parameters

$dynamic_css

(string) (Required) Astra Dynamic CSS.

$dynamic_css_filtered

(string) (Optional) Astra Dynamic CSS Filters.

Default value: ''


Return

(mixed) Return the CSS.


Source

File: inc/class-astra-dynamic-css.php

		public static function return_meta_output( $dynamic_css, $dynamic_css_filtered = '' ) {

			/**
			 * - Page Layout
			 *
			 *   - Sidebar Positions CSS
			 */
			$secondary_width = astra_get_option( 'site-sidebar-width' );
			$primary_width   = absint( 100 - $secondary_width );
			$meta_style      = '';

			// Header Separator.
			$header_separator       = astra_get_option( 'header-main-sep' );
			$header_separator_color = astra_get_option( 'header-main-sep-color' );

			$meta_style = array(
				'.ast-header-break-point .main-header-bar' => array(
					'border-bottom-width' => astra_get_css_value( $header_separator, 'px' ),
					'border-bottom-color' => esc_attr( $header_separator_color ),
				),
			);

			$parse_css = astra_parse_css( $meta_style );

			$meta_style = array(
				'.main-header-bar' => array(
					'border-bottom-width' => astra_get_css_value( $header_separator, 'px' ),
					'border-bottom-color' => esc_attr( $header_separator_color ),
				),
			);

			$parse_css .= astra_parse_css( $meta_style, astra_get_tablet_breakpoint( '', 1 ) );

			if ( 'no-sidebar' !== astra_page_layout() ) :

				$meta_style = array(
					'#primary'   => array(
						'width' => astra_get_css_value( $primary_width, '%' ),
					),
					'#secondary' => array(
						'width' => astra_get_css_value( $secondary_width, '%' ),
					),
				);

				$parse_css .= astra_parse_css( $meta_style, astra_get_tablet_breakpoint( '', 1 ) );

			endif;

			if ( false === self::astra_submenu_below_header_fix() ) :
				// If submenu below header fix is not to be loaded then add removed flex properties from class `ast-flex`.
				// Also restore the padding to class `main-header-bar`.
				$submenu_below_header = array(
					'.ast-flex'          => array(
						'-webkit-align-content' => 'center',
						'-ms-flex-line-pack'    => 'center',
						'align-content'         => 'center',
						'-webkit-box-align'     => 'center',
						'-webkit-align-items'   => 'center',
						'-moz-box-align'        => 'center',
						'-ms-flex-align'        => 'center',
						'align-items'           => 'center',
					),
					'.main-header-bar'   => array(
						'padding' => '1em 0',
					),
					'.ast-site-identity' => array(
						'padding' => '0',
					),
					// CSS to open submenu just below menu.
					'.header-main-layout-1 .ast-flex.main-header-container, .header-main-layout-3 .ast-flex.main-header-container' => array(
						'-webkit-align-content' => 'center',
						'-ms-flex-line-pack'    => 'center',
						'align-content'         => 'center',
						'-webkit-box-align'     => 'center',
						'-webkit-align-items'   => 'center',
						'-moz-box-align'        => 'center',
						'-ms-flex-align'        => 'center',
						'align-items'           => 'center',
					),
				);

				$parse_css .= astra_parse_css( $submenu_below_header );

			else :
				// `.menu-item` required display:flex, although weight of this css increases because of which custom CSS added from child themes to be not working.
				// Hence this is added to dynamic CSS which will be applied only if this filter `astra_submenu_below_header_fix` is enabled.
				// @see https://github.com/brainstormforce/astra/pull/828
				$submenu_below_header = array(
					'.ast-safari-browser-less-than-11 .main-header-menu .menu-item, .ast-safari-browser-less-than-11 .main-header-bar .ast-masthead-custom-menu-items' => array(
						'display' => 'block',
					),
					'.main-header-menu .menu-item, #astra-footer-menu .menu-item, .main-header-bar .ast-masthead-custom-menu-items' => array(
						'-js-display'             => 'flex',
						'display'                 => '-webkit-box',
						'display'                 => '-webkit-flex',
						'display'                 => '-moz-box',
						'display'                 => '-ms-flexbox',
						'display'                 => 'flex',
						'-webkit-box-pack'        => 'center',
						'-webkit-justify-content' => 'center',
						'-moz-box-pack'           => 'center',
						'-ms-flex-pack'           => 'center',
						'justify-content'         => 'center',
						'-webkit-box-orient'      => 'vertical',
						'-webkit-box-direction'   => 'normal',
						'-webkit-flex-direction'  => 'column',
						'-moz-box-orient'         => 'vertical',
						'-moz-box-direction'      => 'normal',
						'-ms-flex-direction'      => 'column',
						'flex-direction'          => 'column',
					),
					'.main-header-menu > .menu-item > .menu-link, #astra-footer-menu > .menu-item > .menu-link,' => array(
						'height'              => '100%',
						'-webkit-box-align'   => 'center',
						'-webkit-align-items' => 'center',
						'-moz-box-align'      => 'center',
						'-ms-flex-align'      => 'center',
						'align-items'         => 'center',
						'-js-display'         => 'flex',
						'display'             => '-webkit-box',
						'display'             => '-webkit-flex',
						'display'             => '-moz-box',
						'display'             => '-ms-flexbox',
						'display'             => 'flex',
					),
				);

				if ( false === Astra_Builder_Helper::$is_header_footer_builder_active ) {
					$submenu_below_header['.ast-primary-menu-disabled .main-header-bar .ast-masthead-custom-menu-items'] = array(
						'flex' => 'unset',
					);
				}

				$parse_css .= astra_parse_css( $submenu_below_header );

			endif;

			if ( false === self::astra_submenu_open_below_header_fix() ) {
				// If submenu below header fix is not to be loaded then add removed flex properties from class `ast-flex`.
				// Also restore the padding to class `main-header-bar`.
				$submenu_below_header = array(
					// CSS to open submenu just below menu.
					'.header-main-layout-1 .ast-flex.main-header-container, .header-main-layout-3 .ast-flex.main-header-container' => array(
						'-webkit-align-content' => 'center',
						'-ms-flex-line-pack'    => 'center',
						'align-content'         => 'center',
						'-webkit-box-align'     => 'center',
						'-webkit-align-items'   => 'center',
						'-moz-box-align'        => 'center',
						'-ms-flex-align'        => 'center',
						'align-items'           => 'center',
					),
				);

				$parse_css .= astra_parse_css( $submenu_below_header );
			}

			$submenu_toggle = '';
			$is_site_rtl    = is_rtl();

			if ( false === Astra_Icons::is_svg_icons() ) {
				// Update styles depend on RTL sites.
				$transform_svg_style            = 'translate(0,-50%) rotate(270deg)';
				$transform_nested_svg_transform = 'translate(0, -2px) rotateZ(270deg)';
				$default_left_rtl_right         = 'left';
				$default_right_rtl_left         = 'right';
				if ( $is_site_rtl ) {
					$transform_svg_style            = 'translate(0,-50%) rotate(90deg)';
					$transform_nested_svg_transform = 'translate(0, -2px) rotateZ(90deg)';
					$default_left_rtl_right         = 'right';
					$default_right_rtl_left         = 'left';
				}
				$submenu_toggle = array(
					// HFB / Old Header Footer - CSS compatibility when SVGs are disabled.
					'.main-header-menu .sub-menu .menu-item.menu-item-has-children > .menu-link:after' => array(
						'position'              => 'absolute',
						$default_right_rtl_left => '1em',
						'top'                   => '50%',
						'transform'             => $transform_svg_style,
					),
					'.ast-header-break-point .main-header-bar .main-header-bar-navigation .page_item_has_children > .ast-menu-toggle::before, .ast-header-break-point .main-header-bar .main-header-bar-navigation .menu-item-has-children > .ast-menu-toggle::before, .ast-mobile-popup-drawer .main-header-bar-navigation .menu-item-has-children>.ast-menu-toggle::before, .ast-header-break-point .ast-mobile-header-wrap .main-header-bar-navigation .menu-item-has-children > .ast-menu-toggle::before' => array(
						'font-weight'     => 'bold',
						'content'         => '"\e900"',
						'font-family'     => 'Astra',
						'text-decoration' => 'inherit',
						'display'         => 'inline-block',
					),
					'.ast-header-break-point .main-navigation ul.sub-menu .menu-item .menu-link:before' => array(
						'content'         => '"\e900"',
						'font-family'     => 'Astra',
						'font-size'       => '.65em',
						'text-decoration' => 'inherit',
						'display'         => 'inline-block',
						'transform'       => $transform_nested_svg_transform,
						'margin-' . $default_right_rtl_left => '5px',
					),
					'.widget_search .search-form:after' => array(
						'font-family'           => 'Astra',
						'font-size'             => '1.2em',
						'font-weight'           => 'normal',
						'content'               => '"\e8b6"',
						'position'              => 'absolute',
						'top'                   => '50%',
						$default_right_rtl_left => '15px',
						'transform'             => 'translate(0, -50%)',
					),
					'.astra-search-icon::before'        => array(
						'content'                 => '"\e8b6"',
						'font-family'             => 'Astra',
						'font-style'              => 'normal',
						'font-weight'             => 'normal',
						'text-decoration'         => 'inherit',
						'text-align'              => 'center',
						'-webkit-font-smoothing'  => 'antialiased',
						'-moz-osx-font-smoothing' => 'grayscale',
					),
					'.main-header-bar .main-header-bar-navigation .page_item_has_children > a:after, .main-header-bar .main-header-bar-navigation .menu-item-has-children > a:after, .site-header-focus-item .main-header-bar-navigation .menu-item-has-children > .menu-link:after' => array(
						'content'                 => '"\e900"',
						'display'                 => 'inline-block',
						'font-family'             => 'Astra',
						'font-size'               => '9px',
						'font-size'               => '.6rem',
						'font-weight'             => 'bold',
						'text-rendering'          => 'auto',
						'-webkit-font-smoothing'  => 'antialiased',
						'-moz-osx-font-smoothing' => 'grayscale',
						'margin-' . $default_left_rtl_right => '10px',
						'line-height'             => 'normal',
					),
					'.ast-mobile-popup-drawer .main-header-bar-navigation .ast-submenu-expanded>.ast-menu-toggle::before' => array(
						'transform' => 'rotateX(180deg)',
					),
					'.ast-header-break-point .main-header-bar-navigation .menu-item-has-children > .menu-link:after' => array(
						'display' => 'none',
					),
				);
			} else {
				if ( ! Astra_Builder_Helper::$is_header_footer_builder_active ) {
					// Update styles depend on RTL sites.
					$transform_svg_style            = 'translate(0,-50%) rotate(270deg)';
					$transform_nested_svg_transform = 'translate(0, -2px) rotateZ(270deg)';
					$default_left_rtl_right         = 'left';
					$default_right_rtl_left         = 'right';
					if ( $is_site_rtl ) {
						$transform_svg_style            = 'translate(0,-50%) rotate(900deg)';
						$transform_nested_svg_transform = 'translate(0, -2px) rotateZ(90deg)';
						$default_left_rtl_right         = 'right';
						$default_right_rtl_left         = 'left';
					}
					$submenu_toggle = array(
						// Old Header Footer - SVG Support.
						'.ast-desktop .main-header-menu .sub-menu .menu-item.menu-item-has-children>.menu-link .icon-arrow svg' => array(
							'position'              => 'absolute',
							$default_right_rtl_left => '.6em',
							'top'                   => '50%',
							'transform'             => $transform_svg_style,
						),
						'.ast-header-break-point .main-navigation ul .menu-item .menu-link .icon-arrow:first-of-type svg' => array(
							$default_left_rtl_right => '.1em',
							'top'                   => '.1em',
							'transform'             => $transform_nested_svg_transform,
						),
					);
				} else {
					$transform_svg_style    = 'translate(0, -2px) rotateZ(270deg)';
					$default_left_rtl_right = 'left';
					if ( $is_site_rtl ) {
						$transform_svg_style    = 'translate(0, -2px) rotateZ(90deg)';
						$default_left_rtl_right = 'right';
					}
					$submenu_toggle = array(
						// New Header Footer - SVG Support.
						'.ast-header-break-point .main-navigation ul .menu-item .menu-link .icon-arrow:first-of-type svg' => array(
							'top'        => '.2em',
							'margin-top' => '0px',
							'margin-' . $default_left_rtl_right => '0px',
							'width'      => '.65em',
							'transform'  => $transform_svg_style,
						),
						'.ast-mobile-popup-content .ast-submenu-expanded > .ast-menu-toggle' => array(
							'transform' => 'rotateX(180deg)',
						),
					);
				}
			}

			$parse_css .= astra_parse_css( $submenu_toggle );

			$dynamic_css .= $parse_css;

			return $dynamic_css;
		}


User Contributed Notes

You must log in before being able to contribute a note or feedback.