ddingBtnRightTablet, $attr['tabletPaddingBtnUnit'] ), ), $border_css_tablet ), '.is-grid.uagb-post__items' => array( 'row-gap' => UAGB_Helper::get_css_value( $rowGapTablet, $attr['rowGapUnit'] ), 'column-gap' => UAGB_Helper::get_css_value( $columnGapTablet, $attr['columnGapUnit'] ), ), ':not(.is-grid).uagb-post__items article' => array( 'padding-right' => UAGB_Helper::get_css_value( (int) ( $rowGapTablet / 2 ), $attr['rowGapUnit'] ), 'padding-left' => UAGB_Helper::get_css_value( (int) ( $rowGapTablet / 2 ), $attr['rowGapUnit'] ), 'margin-bottom' => UAGB_Helper::get_css_value( ( $columnGapTablet ), $attr['columnGapUnit'] ), ), ':not(.is-grid).uagb-post__items' => array( 'margin-right' => UAGB_Helper::get_css_value( (int) ( -$rowGapTablet / 2 ), $attr['rowGapUnit'] ), 'margin-left' => UAGB_Helper::get_css_value( (int) ( -$rowGapTablet / 2 ), $attr['rowGapUnit'] ), ), '.is-grid .uagb-post__inner-wrap .uagb-post__image:first-child' => array( 'margin-left' => UAGB_Helper::get_css_value( - (int) ( $paddingLeftTablet ), $attr['tabletPaddingUnit'] ), 'margin-right' => UAGB_Helper::get_css_value( - (int) ( $paddingRightTablet ), $attr['tabletPaddingUnit'] ), 'margin-top' => UAGB_Helper::get_css_value( - (int) ( $paddingTopTablet ), $attr['tabletPaddingUnit'] ), ), ':not(.is-grid) .uagb-post__inner-wrap .uagb-post__text:last-child' => array( 'margin-bottom' => UAGB_Helper::get_css_value( $paddingBottomTablet, $attr['tabletPaddingUnit'] ), ), ':not(.is-grid) .uagb-post__inner-wrap .uagb-post__text:first-child' => array( 'margin-top' => UAGB_Helper::get_css_value( $paddingTopTablet, $attr['tabletPaddingUnit'] ), ), ':not(.is-grid).uagb-post__image-position-background .uagb-post__inner-wrap .uagb-post__text:nth-last-child(2) ' => array( 'margin-bottom' => UAGB_Helper::get_css_value( $paddingBottomTablet, $attr['tabletPaddingUnit'] ), ), ':not(.is-grid) .uagb-post__inner-wrap .uagb-post__text:not(.highlighted)' => array( 'margin-left' => UAGB_Helper::get_css_value( $paddingLeftTablet, $attr['tabletPaddingUnit'] ), 'margin-right' => UAGB_Helper::get_css_value( $paddingRightTablet, $attr['tabletPaddingUnit'] ), ), ':not(.is-grid) .uagb-post__inner-wrap .uagb-post__text:first-child' => array( 'margin-top' => UAGB_Helper::get_css_value( $paddingTopTablet, $attr['tabletPaddingUnit'] ), ), ':not(.is-grid) .uagb-post__inner-wrap .uagb-post__text.highlighted' => array( 'margin-left' => UAGB_Helper::get_css_value( $paddingLeftTablet, $attr['tabletPaddingUnit'] ), ), ); return $t_selector; } /** * Get Timeline Block Desktop Selectors CSS * * @param array $attr The block attributes. * @since 1.8.2 */ public static function get_timeline_selectors( $attr ) { $left_margin = $attr['horizontalSpace']; $right_margin = $attr['horizontalSpace']; $top_padding = isset( $attr['topPadding'] ) ? $attr['topPadding'] : $attr['bgPadding']; $bottom_padding = isset( $attr['bottomPadding'] ) ? $attr['bottomPadding'] : $attr['bgPadding']; $left_padding = isset( $attr['leftPadding'] ) ? $attr['leftPadding'] : $attr['bgPadding']; $right_padding = isset( $attr['rightPadding'] ) ? $attr['rightPadding'] : $attr['bgPadding']; $icon_size_fallback = self::get_fallback_number( $attr['iconSize'], 'iconSize', $attr['blockName'] ); $connector_bg_size_fallback = self::get_fallback_number( $attr['connectorBgsize'], 'connectorBgsize', $attr['blockName'] ); $border_width_fallback = self::get_fallback_number( $attr['borderwidth'], 'borderwidth', $attr['blockName'] ); $separator_width_fallback = self::get_fallback_number( $attr['separatorwidth'], 'separatorwidth', $attr['blockName'] ); $head_space_fallback = self::get_fallback_number( $attr['headSpace'], 'headSpace', $attr['blockName'] ); $border_radius_fallback = self::get_fallback_number( $attr['borderRadius'], 'borderRadius', $attr['blockName'] ); $date_bottom_space_fallback = self::get_fallback_number( $attr['dateBottomspace'], 'dateBottomspace', $attr['blockName'] ); $head_top_spacing_fallback = 'post-timeline' === $attr['blockName'] ? self::get_fallback_number( $attr['headTopSpacing'], 'headTopSpacing', $attr['blockName'] ) : $attr['contentPadding']; $connector_size = UAGB_Helper::get_css_value( $connector_bg_size_fallback, 'px' ); $selectors = array( ' .uagb-timeline__heading' => array( 'margin-top' => UAGB_Helper::get_css_value( $head_top_spacing_fallback, 'px' ), 'margin-bottom' => UAGB_Helper::get_css_value( $head_space_fallback, 'px' ), ), ' .uagb-timeline-desc-content' => array( 'text-align' => $attr['align'], 'color' => $attr['subHeadingColor'], ), ' .uagb-timeline__day-new' => array( 'text-align' => $attr['align'], ), ' .uagb-timeline__day-right .uagb-timeline__arrow:after' => array( 'border-left-color' => $attr['backgroundColor'], ), ' .uagb-timeline__day-right .uagb-timeline__arrow:after' => array( 'border-left-color' => $attr['backgroundColor'], ), ' .uagb-timeline__day-left .uagb-timeline__arrow:after' => array( 'border-right-color' => $attr['backgroundColor'], ), ' .uagb-timeline__day-left .uagb-timeline__arrow:after' => array( 'border-right-color' => $attr['backgroundColor'], ), ' .uagb-timeline__line__inner' => array( 'background-color' => $attr['separatorFillColor'], ), ' .uagb-timeline__line' => array( 'background-color' => $attr['separatorColor'], 'width' => UAGB_Helper::get_css_value( $separator_width_fallback, 'px' ), ), '.uagb-timeline__right-block .uagb-timeline__line' => array( 'right' => 'calc( ' . $connector_bg_size_fallback . 'px / 2 )', ), '.uagb-timeline__left-block .uagb-timeline__line' => array( 'left' => 'calc( ' . $connector_bg_size_fallback . 'px / 2 )', ), '.uagb-timeline__center-block .uagb-timeline__line' => array( 'right' => 'calc( ' . $connector_bg_size_fallback . 'px / 2 )', ), ' .uagb-timeline__marker' => array( 'background-color' => $attr['separatorBg'], 'min-height' => $connector_size, 'min-width' => $connector_size, 'line-height' => $connector_size, 'border' => $border_width_fallback . 'px solid' . $attr['separatorBorder'], ), '.uagb-timeline__left-block .uagb-timeline__left .uagb-timeline__arrow' => array( 'height' => $connector_size, ), '.uagb-timeline__right-block .uagb-timeline__right .uagb-timeline__arrow' => array( 'height' => $connector_size, ), '.uagb-timeline__center-block .uagb-timeline__left .uagb-timeline__arrow' => array( 'height' => $connector_size, ), '.uagb-timeline__center-block .uagb-timeline__right .uagb-timeline__arrow' => array( 'height' => $connector_size, ), '.uagb-timeline__center-block .uagb-timeline__left .uagb-timeline__marker' => array( 'margin-left' => UAGB_Helper::get_css_value( $left_margin, $attr['marginUnit'] ), 'margin-right' => UAGB_Helper::get_css_value( $right_margin, $attr['marginUnit'] ), ), '.uagb-timeline__center-block .uagb-timeline__right .uagb-timeline__marker' => array( 'margin-left' => UAGB_Helper::get_css_value( $left_margin, $attr['marginUnit'] ), 'margin-right' => UAGB_Helper::get_css_value( $right_margin, $attr['marginUnit'] ), ), ' .uagb-timeline__date-hide.uagb-timeline__inner-date-new' => array( // For New User. 'margin-bottom' => UAGB_Helper::get_css_value( $date_bottom_space_fallback, 'px' ), 'color' => $attr['dateColor'], 'text-align' => $attr['align'], ), ' .uagb-timeline__date-hide.uagb-timeline__date-inner' => array( 'margin-bottom' => UAGB_Helper::get_css_value( $date_bottom_space_fallback, 'px' ), 'color' => $attr['dateColor'], 'text-align' => $attr['align'], ), '.uagb-timeline__left-block .uagb-timeline__day-new.uagb-timeline__day-left' => array( 'margin-left' => UAGB_Helper::get_css_value( $left_margin, $attr['marginUnit'] ), ), '.uagb-timeline__right-block .uagb-timeline__day-new.uagb-timeline__day-right' => array( 'margin-right' => UAGB_Helper::get_css_value( $right_margin, $attr['marginUnit'] ), ), ' .uagb-timeline__date-new' => array( 'color' => $attr['dateColor'], 'font-size' => UAGB_Helper::get_css_value( $attr['dateFontsize'], $attr['dateFontsizeType'] ), ), ' .uagb-timeline__events-inner-new' => array( 'background-color' => $attr['backgroundColor'], 'border-radius' => UAGB_Helper::get_css_value( $border_radius_fallback, 'px' ), ), ' .uagb-timeline__events-inner--content' => array( 'padding-left' => UAGB_Helper::get_css_value( $top_padding, $attr['paddingUnit'] ), 'padding-right' => UAGB_Helper::get_css_value( $right_padding, $attr['paddingUnit'] ), 'padding-top' => UAGB_Helper::get_css_value( $top_padding, $attr['paddingUnit'] ), 'padding-bottom' => UAGB_Helper::get_css_value( $bottom_padding, $attr['paddingUnit'] ), ), ' svg' => array( 'color' => $attr['iconColor'], 'font-size' => UAGB_Helper::get_css_value( $icon_size_fallback, 'px' ), 'width' => UAGB_Helper::get_css_value( $icon_size_fallback, 'px' ), 'fill' => $attr['iconColor'], ), ' .uagb-timeline__marker.uagb-timeline__in-view-icon svg' => array( 'fill' => $attr['iconFocus'], 'color' => $attr['iconFocus'], ), ' .uagb-timeline__marker.uagb-timeline__in-view-icon' => array( 'background' => $attr['iconBgFocus'], 'border-color' => $attr['borderFocus'], ), ); return $selectors; } /** * Get Timeline Block Tablet Selectors CSS. * * @param array $attr The block attributes. * @since 1.8.2 */ public static function get_timeline_tablet_selectors( $attr ) { $connector_bg_size_fallback = self::get_fallback_number( $attr['connectorBgsize'], 'connectorBgsize', $attr['blockName'] ); $tablet_selector = array( ' .uagb-timeline__heading' => array( 'margin-top' => UAGB_Helper::get_css_value( $attr['headTopSpacingTablet'], 'px' ), 'margin-bottom' => UAGB_Helper::get_css_value( $attr['headSpaceTablet'], 'px' ), ), ' .uagb-timeline__date-hide.uagb-timeline__inner-date-new' => array( 'margin-bottom' => UAGB_Helper::get_css_value( $attr['dateBottomspaceTablet'], 'px' ), ), '.uagb-timeline__center-block .uagb-timeline__marker' => array( 'margin-left' => 0, 'margin-right' => 0, ), '.uagb-timeline__center-block.uagb-timeline__responsive-tablet .uagb-timeline__day-right .uagb-timeline__arrow:after' => array( 'border-right-color' => $attr['backgroundColor'], ), '.uagb-timeline__center-block.uagb-timeline__responsive-tablet .uagb-timeline__day-left .uagb-timeline__arrow:after' => array( 'border-right-color' => $attr['backgroundColor'], ), '.uagb-timeline__center-block.uagb-timeline__responsive-tablet .uagb-timeline__line' => array( 'left' => 'calc( ' . $connector_bg_size_fallback . 'px / 2 )', ), '.uagb-timeline__center-block .uagb-timeline__day-new.uagb-timeline__day-left' => array( 'margin-left' => UAGB_Helper::get_css_value( $attr['leftMarginTablet'], $attr['tabletMarginUnit'] ), 'margin-right' => UAGB_Helper::get_css_value( $attr['rightMarginTablet'], $attr['tabletMarginUnit'] ), 'margin-top' => UAGB_Helper::get_css_value( $attr['topMarginTablet'], $attr['tabletMarginUnit'] ), 'margin-bottom' => UAGB_Helper::get_css_value( $attr['bottomMarginTablet'], $attr['tabletMarginUnit'] ), ), '.uagb-timeline__center-block .uagb-timeline__day-new.uagb-timeline__day-right' => array( 'margin-left' => UAGB_Helper::get_css_value( $attr['leftMarginTablet'], $attr['tabletMarginUnit'] ), 'margin-right' => UAGB_Helper::get_css_value( $attr['rightMarginTablet'], $attr['tabletMarginUnit'] ), 'margin-top' => UAGB_Helper::get_css_value( $attr['topMarginTablet'], $attr['tabletMarginUnit'] ), 'margin-bottom' => UAGB_Helper::get_css_value( $attr['bottomMarginTablet'], $attr['tabletMarginUnit'] ), ), ' .uagb-timeline__events-inner-new' => array( 'padding-left' => UAGB_Helper::get_css_value( $attr['topPaddingTablet'], $attr['tabletPaddingUnit'] ), 'padding-right' => UAGB_Helper::get_css_value( $attr['rightPaddingTablet'], $attr['tabletPaddingUnit'] ), 'padding-top' => UAGB_Helper::get_css_value( $attr['topPaddingTablet'], $attr['tabletPaddingUnit'] ), 'padding-bottom' => UAGB_Helper::get_css_value( $attr['bottomPaddingTablet'], $attr['tabletPaddingUnit'] ), 'border-radius' => UAGB_Helper::get_css_value( $attr['borderRadiusTablet'], 'px' ), ), ); return $tablet_selector; } /** * Get Timeline Block Mobile Selectors CSS. * * @param array $attr The block attributes. * @since 1.8.2 */ public static function get_timeline_mobile_selectors( $attr ) { $connector_bg_size_fallback = self::get_fallback_number( $attr['connectorBgsize'], 'connectorBgsize', $attr['blockName'] ); $m_selectors = array( ' .uagb-timeline__heading' => array( 'margin-top' => UAGB_Helper::get_css_value( $attr['headTopSpacingMobile'], 'px' ), 'margin-bottom' => UAGB_Helper::get_css_value( $attr['headSpaceMobile'], 'px' ), ), ' .uagb-timeline__date-hide.uagb-timeline__inner-date-new' => array( 'margin-bottom' => UAGB_Helper::get_css_value( $attr['dateBottomspaceMobile'], 'px' ), ), '.uagb-timeline__center-block .uagb-timeline__marker' => array( 'margin-left' => 0, 'margin-right' => 0, ), ' .uagb-timeline__center-block .uagb-timeline__day-new.uagb-timeline__day-left' => array( 'margin-left' => UAGB_Helper::get_css_value( $attr['horizontalSpace'], 'px' ), ), ' .uagb-timeline__center-block .uagb-timeline__day-new.uagb-timeline__day-right' => array( 'margin-left' => UAGB_Helper::get_css_value( $attr['horizontalSpace'], 'px' ), ), '.uagb-timeline__center-block.uagb-timeline__responsive-mobile .uagb-timeline__day-right .uagb-timeline__arrow:after' => array( 'border-right-color' => $attr['backgroundColor'], ), '.uagb-timeline__center-block.uagb-timeline__responsive-mobile .uagb-timeline__line' => array( 'left' => 'calc( ' . $connector_bg_size_fallback . 'px / 2 )', ), '.uagb-timeline__center-block .uagb-timeline__day-new.uagb-timeline__day-left' => array( 'margin-left' => UAGB_Helper::get_css_value( $attr['leftMarginMobile'], $attr['mobileMarginUnit'] ), 'margin-right' => UAGB_Helper::get_css_value( $attr['rightMarginMobile'], $attr['mobileMarginUnit'] ), 'margin-top' => UAGB_Helper::get_css_value( $attr['topMarginMobile'], $attr['mobileMarginUnit'] ), 'margin-bottom' => UAGB_Helper::get_css_value( $attr['bottomMarginMobile'], $attr['mobileMarginUnit'] ), ), '.uagb-timeline__center-block .uagb-timeline__day-new.uagb-timeline__day-right' => array( 'margin-left' => UAGB_Helper::get_css_value( $attr['leftMarginMobile'], $attr['mobileMarginUnit'] ), 'margin-right' => UAGB_Helper::get_css_value( $attr['rightMarginMobile'], $attr['mobileMarginUnit'] ), 'margin-top' => UAGB_Helper::get_css_value( $attr['topMarginMobile'], $attr['mobileMarginUnit'] ), 'margin-bottom' => UAGB_Helper::get_css_value( $attr['bottomMarginMobile'], $attr['mobileMarginUnit'] ), ), ' .uagb-timeline__events-inner-new' => array( 'padding-left' => UAGB_Helper::get_css_value( $attr['topPaddingMobile'], $attr['mobilePaddingUnit'] ), 'padding-right' => UAGB_Helper::get_css_value( $attr['rightPaddingMobile'], $attr['mobilePaddingUnit'] ), 'padding-top' => UAGB_Helper::get_css_value( $attr['topPaddingMobile'], $attr['mobilePaddingUnit'] ), 'padding-bottom' => UAGB_Helper::get_css_value( $attr['bottomPaddingMobile'], $attr['mobilePaddingUnit'] ), 'border-radius' => UAGB_Helper::get_css_value( $attr['borderRadiusMobile'], 'px' ), ), ); return $m_selectors; } /** * Get Condition block CSS. * * @since 1.22.0 */ public static function get_condition_block_css() { return '@media (min-width: 1025px){body .uag-hide-desktop.uagb-google-map__wrap,body .uag-hide-desktop{display:none !important}}@media (min-width: 768px) and (max-width: 1024px){body .uag-hide-tab.uagb-google-map__wrap,body .uag-hide-tab{display:none !important}}@media (max-width: 767px){body .uag-hide-mob.uagb-google-map__wrap,body .uag-hide-mob{display:none !important}}'; } /** * Get Masonry Gallery CSS. * * @since 1.24.0 * @param array $attr The block attributes. * @param string $id The selector ID. */ public static function get_gallery_css( $attr, $id ) { if ( isset( $attr['masonry'] ) && true === $attr['masonry'] ) { $col_count = ( isset( $attr['columns'] ) ) ? $attr['columns'] : 3; $selectors = array(); if ( isset( $attr['masonryGutter'] ) && '' !== $attr['masonryGutter'] ) { $selectors = array( '.wp-block-gallery.has-nested-images.columns-' . $col_count => array( 'column-gap' => UAGB_Helper::get_css_value( $attr['masonryGutter'], 'px' ), ), '.wp-block-gallery.has-nested-images.columns-default' => array( 'column-gap' => UAGB_Helper::get_css_value( $attr['masonryGutter'], 'px' ), ), '.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) img' => array( 'margin-bottom' => UAGB_Helper::get_css_value( $attr['masonryGutter'], 'px' ), ), '.wp-block-gallery.columns-' . $col_count . ' ul.blocks-gallery-grid' => array( // For Backword. 'column-gap' => UAGB_Helper::get_css_value( $attr['masonryGutter'], 'px' ), ), '.wp-block-gallery ul.blocks-gallery-grid li.blocks-gallery-item' => array( // For Backword. 'margin-bottom' => UAGB_Helper::get_css_value( $attr['masonryGutter'], 'px' ), ), ); } $t_selectors = array(); if ( $col_count > 3 ) { $t_selectors = array( '.wp-block-gallery.columns-' . $col_count . ' .blocks-gallery-grid' => array( 'column-count' => '3', ), ); } } $combined_selectors = array( 'desktop' => $selectors, 'tablet' => $t_selectors, 'mobile' => array(), ); return UAGB_Helper::generate_all_css( $combined_selectors, '.uagb-block-' . $id ); } /** * Get Masonry Gallery CSS. * * @since 1.24.0 */ public static function get_masonry_gallery_css() { $selectors = array( '.wp-block-gallery.has-nested-images' => array( 'display' => 'block', 'column-count' => '3', 'column-gap' => '1em', ), '.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image)' => array( 'margin' => 0, 'display' => 'block', 'grid-template-rows' => '1fr auto', 'margin-bottom' => '1em', 'break-inside' => 'avoid', 'width' => 'unset', ), '.columns-default.wp-block-gallery.has-nested-images' => array( 'column-count' => '3', 'width' => 'unset', ), '.columns-1.wp-block-gallery.has-nested-images' => array( 'column-count' => '1', 'width' => 'unset', ), '.columns-2.wp-block-gallery.has-nested-images' => array( 'column-count' => '2', ), '.columns-3.wp-block-gallery.has-nested-images' => array( 'column-count' => '3', 'width' => 'unset', ), '.columns-4.wp-block-gallery.has-nested-images' => array( 'column-count' => '4', 'width' => 'unset', ), '.columns-5.wp-block-gallery.has-nested-images' => array( 'column-count' => '5', 'width' => 'unset', ), '.columns-6.wp-block-gallery.has-nested-images' => array( 'column-count' => '6', 'width' => 'unset', ), '.columns-7.wp-block-gallery.has-nested-images' => array( 'column-count' => '7', 'width' => 'unset', ), '.columns-8.wp-block-gallery.has-nested-images' => array( 'column-count' => '8', 'width' => 'unset', ), /* For Backword */ ' .blocks-gallery-grid .blocks-gallery-item' => array( 'margin' => 0, 'display' => 'block', 'grid-template-rows' => '1fr auto', 'margin-bottom' => '1em', 'break-inside' => 'avoid', 'width' => 'unset', ), '.wp-block-gallery .blocks-gallery-grid' => array( 'column-gap' => '1em', 'display' => 'block', ), '.columns-1 .blocks-gallery-grid' => array( 'column-count' => '1', ), '.columns-2 .blocks-gallery-grid' => array( 'column-count' => '2', ), '.columns-3 .blocks-gallery-grid' => array( 'column-count' => '3', ), '.columns-4 .blocks-gallery-grid' => array( 'column-count' => '4', ), '.columns-5 .blocks-gallery-grid' => array( 'column-count' => '5', ), '.columns-6 .blocks-gallery-grid' => array( 'column-count' => '6', ), '.columns-7 .blocks-gallery-grid' => array( 'column-count' => '7', ), '.columns-8 .blocks-gallery-grid' => array( 'column-count' => '8', ), /* End Backword */ ); $m_selectors = array( '.wp-block-gallery[class*="columns-"].blocks-gallery-grid' => array( 'column-count' => '2', 'column-gap' => '1em', 'display' => 'unset', ), '.wp-block-gallery.columns-1.blocks-gallery-grid' => array( 'column-count' => '1', ), /* For Backword */ '.wp-block-gallery[class*="columns-"] .blocks-gallery-grid' => array( 'column-count' => '2', 'column-gap' => '1em', 'display' => 'unset', ), '.wp-block-gallery.columns-1 .blocks-gallery-grid' => array( 'column-count' => '1', ), /* End Backword */ ); $combined_selectors = array( 'desktop' => $selectors, 'tablet' => array(), 'mobile' => $m_selectors, ); $css = UAGB_Helper::generate_all_css( $combined_selectors, '.uag-masonry' ); $desktop = $css['desktop']; $tablet = $css['tablet']; $mobile = $css['mobile']; $tab_styling_css = ''; $mob_styling_css = ''; if ( ! empty( $tablet ) ) { $tab_styling_css .= '@media only screen and (max-width: ' . UAGB_TABLET_BREAKPOINT . 'px) {'; $tab_styling_css .= $tablet; $tab_styling_css .= '}'; } if ( ! empty( $mobile ) ) { $mob_styling_css .= '@media only screen and (max-width: ' . UAGB_MOBILE_BREAKPOINT . 'px) {'; $mob_styling_css .= $mobile; $mob_styling_css .= '}'; } return $desktop . $tab_styling_css . $mob_styling_css; } /** * Background Control CSS Generator Function. * * @param array $bg_obj Color code in HEX. * * @return array Color code in HEX. */ public static function uag_get_background_obj( $bg_obj ) { $gen_bg_css = array(); $bg_type = isset( $bg_obj['backgroundType'] ) ? $bg_obj['backgroundType'] : ''; $bg_img = isset( $bg_obj['backgroundImage'] ) && isset( $bg_obj['backgroundImage']['url'] ) ? $bg_obj['backgroundImage']['url'] : ''; $bg_color = isset( $bg_obj['backgroundColor'] ) ? $bg_obj['backgroundColor'] : ''; $gradient_value = isset( $bg_obj['gradientValue'] ) ? $bg_obj['gradientValue'] : ''; $repeat = isset( $bg_obj['backgroundRepeat'] ) ? $bg_obj['backgroundRepeat'] : ''; $position = isset( $bg_obj['backgroundPosition'] ) ? $bg_obj['backgroundPosition'] : ''; $size = isset( $bg_obj['backgroundSize'] ) ? $bg_obj['backgroundSize'] : ''; $attachment = isset( $bg_obj['backgroundAttachment'] ) ? $bg_obj['backgroundAttachment'] : ''; $overlay_type = isset( $bg_obj['overlayType'] ) ? $bg_obj['overlayType'] : ''; $bg_image_color = isset( $bg_obj['backgroundImageColor'] ) ? $bg_obj['backgroundImageColor'] : ''; $bg_custom_size = isset( $bg_obj['backgroundCustomSize'] ) ? $bg_obj['backgroundCustomSize'] : ''; $bg_custom_size_type = isset( $bg_obj['backgroundCustomSizeType'] ) ? $bg_obj['backgroundCustomSizeType'] : ''; $bg_video = isset( $bg_obj['backgroundVideo'] ) ? $bg_obj['backgroundVideo'] : ''; $bg_video_color = isset( $bg_obj['backgroundVideoColor'] ) ? $bg_obj['backgroundVideoColor'] : ''; $custom_position = isset( $bg_obj['customPosition'] ) ? $bg_obj['customPosition'] : ''; $x_position = isset( $bg_obj['xPosition'] ) ? $bg_obj['xPosition'] : ''; $x_position_type = isset( $bg_obj['xPositionType'] ) ? $bg_obj['xPositionType'] : ''; $y_position = isset( $bg_obj['yPosition'] ) ? $bg_obj['yPosition'] : ''; $y_position_type = isset( $bg_obj['yPositionType'] ) ? $bg_obj['yPositionType'] : ''; if ( 'custom' === $size ) { $size = $bg_custom_size . $bg_custom_size_type; } if ( '' !== $bg_type ) { switch ( $bg_type ) { case 'color': if ( '' !== $bg_img && '' !== $bg_color ) { $gen_bg_css['background-image'] = 'linear-gradient(to right, ' . $bg_color . ', ' . $bg_color . '), url(' . $bg_img . ');'; } elseif ( '' === $bg_img ) { $gen_bg_css['background-color'] = $bg_color . ';'; } break; case 'image': if ( 'color' === $overlay_type && '' !== $bg_img && '' !== $bg_image_color ) { $gen_bg_css['background-image'] = 'linear-gradient(to right, ' . $bg_image_color . ', ' . $bg_image_color . '), url(' . $bg_img . ');'; } if ( 'gradient' === $overlay_type && '' !== $bg_img && '' !== $gradient_value ) { $gen_bg_css['background-image'] = $gradient_value . ', url(' . $bg_img . ');'; } if ( 'none' === $overlay_type && '' !== $bg_img ) { $gen_bg_css['background-image'] = 'url(' . $bg_img . ');'; } break; case 'gradient': if ( isset( $gradient_value ) ) { $gen_bg_css['background-image'] = $gradient_value . ';'; } break; case 'video': if ( 'color' === $overlay_type && '' !== $bg_video && '' !== $bg_video_color ) { $gen_bg_css['background'] = $bg_video_color . ';'; } if ( 'gradient' === $overlay_type && '' !== $bg_video && '' !== $gradient_value ) { $gen_bg_css['background-image'] = $gradient_value . ';'; } break; default: break; } } elseif ( '' !== $bg_color ) { $gen_bg_css['background-color'] = $bg_color . ';'; } if ( '' !== $bg_img ) { if ( isset( $repeat ) ) { $gen_bg_css['background-repeat'] = esc_attr( $repeat ); } if ( 'custom' !== $custom_position && isset( $position ) && isset( $position['x'] ) && isset( $position['y'] ) ) { $position_value = $position['x'] * 100 . '% ' . $position['y'] * 100 . '%'; $gen_bg_css['background-position'] = $position_value; } elseif ( 'custom' === $custom_position && isset( $x_position ) && isset( $y_position ) && isset( $x_position_type ) && isset( $y_position_type ) ) { $position_value = $x_position . $x_position_type . ' ' . $y_position . $y_position_type; $gen_bg_css['background-position'] = $position_value; } if ( isset( $size ) ) { $gen_bg_css['background-size'] = esc_attr( $size ); } if ( isset( $attachment ) ) { $gen_bg_css['background-attachment'] = esc_attr( $attachment ); } } return $gen_bg_css; } /** * Border attribute generation Function. * * @since 2.0.0 * @param array $prefix Attribute Prefix. * @param array $default_args default attributes args. * @return array */ public static function uag_generate_php_border_attribute( $prefix, $default_args = array() ) { $border_attr = array(); $device = array( '', 'Tablet', 'Mobile' ); foreach ( $device as $slug => $data ) { $border_attr[ "{$prefix}BorderTopWidth{$data}" ] = array( 'type' => 'number', ); $border_attr[ "{$prefix}BorderLeftWidth{$data}" ] = array( 'type' => 'number', ); $border_attr[ "{$prefix}BorderRightWidth{$data}" ] = array( 'type' => 'number', ); $border_attr[ "{$prefix}BorderBottomWidth{$data}" ] = array( 'type' => 'number', ); $border_attr[ "{$prefix}BorderTopLeftRadius{$data}" ] = array( 'type' => 'number', ); $border_attr[ "{$prefix}BorderTopRightRadius{$data}" ] = array( 'type' => 'number', ); $border_attr[ "{$prefix}BorderBottomLeftRadius{$data}" ] = array( 'type' => 'number', ); $border_attr[ "{$prefix}BorderBottomRightRadius{$data}" ] = array( 'type' => 'number', ); $border_attr[ "{$prefix}BorderRadiusUnit{$data}" ] = array( 'type' => 'number', ); } $border_attr[ "{$prefix}BorderStyle" ] = array( 'type' => 'string', ); $border_attr[ "{$prefix}BorderColor" ] = array( 'type' => 'string', ); $border_attr[ "{$prefix}BorderHColor" ] = array( 'type' => 'string', ); $border_attr[ "{$prefix}BorderLink" ] = array( 'type' => 'boolean', 'default' => true, ); $border_attr[ "{$prefix}BorderRadiusLink" ] = array( 'type' => 'boolean', 'default' => true, ); return $border_attr; } /** * Border attribute generation Function. * * @since 2.0.0 * @param array $prefix Attribute Prefix. * @return array */ public static function uag_generate_border_attribute( $prefix ) { $defaults = array( // Width. 'borderTopWidth' => '', 'borderRightWidth' => '', 'borderBottomWidth' => '', 'borderLeftWidth' => '', 'borderTopWidthTablet' => '', 'borderRightWidthTablet' => '', 'borderBottomWidthTablet' => '', 'borderLeftWidthTablet' => '', 'borderTopWidthMobile' => '', 'borderRightWidthMobile' => '', 'borderBottomWidthMobile' => '', 'borderLeftWidthMobile' => '', // Radius. 'borderTopLeftRadius' => '', 'borderTopRightRadius' => '', 'borderBottomRightRadius' => '', 'borderBottomLeftRadius' => '', 'borderTopLeftRadiusTablet' => '', 'borderTopRightRadiusTablet' => '', 'borderBottomRightRadiusTablet' => '', 'borderBottomLeftRadiusTablet' => '', 'borderTopLeftRadiusMobile' => '', 'borderTopRightRadiusMobile' => '', 'borderBottomRightRadiusMobile' => '', 'borderBottomLeftRadiusMobile' => '', // unit. 'borderRadiusUnit' => 'px', 'borderRadiusUnitTablet' => 'px', 'borderRadiusUnitMobile' => 'px', // common. 'borderStyle' => '', 'borderColor' => '', 'borderHColor' => '', ); $border_attr = array(); $device = array( '', 'Tablet', 'Mobile' ); foreach ( $device as $slug => $data ) { $border_attr[ "{$prefix}BorderTopWidth{$data}" ] = ''; $border_attr[ "{$prefix}BorderLeftWidth{$data}" ] = ''; $border_attr[ "{$prefix}BorderRightWidth{$data}" ] = ''; $border_attr[ "{$prefix}BorderBottomWidth{$data}" ] = ''; $border_attr[ "{$prefix}BorderTopLeftRadius{$data}" ] = ''; $border_attr[ "{$prefix}BorderTopRightRadius{$data}" ] = ''; $border_attr[ "{$prefix}BorderBottomLeftRadius{$data}" ] = ''; $border_attr[ "{$prefix}BorderBottomRightRadius{$data}" ] = ''; $border_attr[ "{$prefix}BorderRadiusUnit{$data}" ] = 'px'; } $border_attr[ "{$prefix}BorderStyle" ] = ''; $border_attr[ "{$prefix}BorderColor" ] = ''; $border_attr[ "{$prefix}BorderHColor" ] = ''; return $border_attr; } /** * Border CSS generation Function. * * @since 2.0.0 * @param array $attr Attribute List. * @param string $prefix Attribuate prefix . * @param string $device Responsive. * @return array border css array. */ public static function uag_generate_border_css( $attr, $prefix, $device = 'desktop' ) { $gen_border_css = array(); if ( 'tablet' === $device ) { if ( 'none' !== $attr[ $prefix . 'BorderStyle' ] && ! empty( $attr[ $prefix . 'BorderStyle' ] ) ) { $gen_border_css['border-top-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderTopWidthTablet' ], 'px' ); $gen_border_css['border-left-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderLeftWidthTablet' ], 'px' ); $gen_border_css['border-right-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderRightWidthTablet' ], 'px' ); $gen_border_css['border-bottom-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderBottomWidthTablet' ], 'px' ); } $gen_border_unit_tablet = isset( $attr[ $prefix . 'BorderRadiusUnitTablet' ] ) ? $attr[ $prefix . 'BorderRadiusUnitTablet' ] : 'px'; $gen_border_css['border-top-left-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderTopLeftRadiusTablet' ], $gen_border_unit_tablet ); $gen_border_css['border-top-right-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderTopRightRadiusTablet' ], $gen_border_unit_tablet ); $gen_border_css['border-bottom-left-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderBottomLeftRadiusTablet' ], $gen_border_unit_tablet ); $gen_border_css['border-bottom-right-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderBottomRightRadiusTablet' ], $gen_border_unit_tablet ); } elseif ( 'mobile' === $device ) { if ( 'none' !== $attr[ $prefix . 'BorderStyle' ] && ! empty( $attr[ $prefix . 'BorderStyle' ] ) ) { $gen_border_css['border-top-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderTopWidthMobile' ], 'px' ); $gen_border_css['border-left-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderLeftWidthMobile' ], 'px' ); $gen_border_css['border-right-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderRightWidthMobile' ], 'px' ); $gen_border_css['border-bottom-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderBottomWidthMobile' ], 'px' ); } $gen_border_unit_mobile = isset( $attr[ $prefix . 'borderRadiusUnitMobile' ] ) ? $attr[ $prefix . 'borderRadiusUnitMobile' ] : 'px'; $gen_border_css['border-top-left-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderTopLeftRadiusMobile' ], $gen_border_unit_mobile ); $gen_border_css['border-top-right-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderTopRightRadiusMobile' ], $gen_border_unit_mobile ); $gen_border_css['border-bottom-left-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderBottomLeftRadiusMobile' ], $gen_border_unit_mobile ); $gen_border_css['border-bottom-right-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderBottomRightRadiusMobile' ], $gen_border_unit_mobile ); } else { if ( 'none' !== $attr[ $prefix . 'BorderStyle' ] && ! empty( $attr[ $prefix . 'BorderStyle' ] ) ) { $gen_border_css['border-top-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderTopWidth' ], 'px' ); $gen_border_css['border-left-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderLeftWidth' ], 'px' ); $gen_border_css['border-right-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderRightWidth' ], 'px' ); $gen_border_css['border-bottom-width'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderBottomWidth' ], 'px' ); } $gen_border_unit = isset( $attr[ $prefix . 'BorderRadiusUnit' ] ) ? $attr[ $prefix . 'BorderRadiusUnit' ] : 'px'; $gen_border_css['border-top-left-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderTopLeftRadius' ], $gen_border_unit ); $gen_border_css['border-top-right-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderTopRightRadius' ], $gen_border_unit ); $gen_border_css['border-bottom-left-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderBottomLeftRadius' ], $gen_border_unit ); $gen_border_css['border-bottom-right-radius'] = UAGB_Helper::get_css_value( $attr[ $prefix . 'BorderBottomRightRadius' ], $gen_border_unit ); } $borderStyle = $attr[ $prefix . 'BorderStyle' ]; $borderColor = $attr[ $prefix . 'BorderColor' ]; $gen_border_css['border-style'] = $borderStyle; $gen_border_css['border-color'] = $borderColor; return $gen_border_css; } /** * Deprecated Border CSS generation Function. * * @since 2.0.0 * @param array $current_css Current style list. * @param string $border_width Border Width. * @param string $border_radius Border Radius. * @param string $border_color Border Color. * @param string $border_style Border Style. */ public static function uag_generate_deprecated_border_css( $current_css, $border_width, $border_radius, $border_color = '', $border_style = '' ) { $gen_border_css = array(); $border_width = is_numeric( $border_width ) ? $border_width : ''; $border_radius = is_numeric( $border_radius ) ? $border_radius : ''; // These would either be in the format of '1px', '0', or '-1px'. $gen_border_css['border-top-width'] = ( isset( $current_css['border-top-width'] ) && ( ! empty( $current_css['border-top-width'] ) || 0 === $current_css['border-top-width'] ) ) ? $current_css['border-top-width'] : UAGB_Helper::get_css_value( $border_width, 'px' ); $gen_border_css['border-left-width'] = ( isset( $current_css['border-left-width'] ) && ( ! empty( $current_css['border-left-width'] ) || 0 === $current_css['border-left-width'] ) ) ? $current_css['border-left-width'] : UAGB_Helper::get_css_value( $border_width, 'px' ); $gen_border_css['border-right-width'] = ( isset( $current_css['border-right-width'] ) && ( ! empty( $current_css['border-right-width'] ) || 0 === $current_css['border-right-width'] ) ) ? $current_css['border-right-width'] : UAGB_Helper::get_css_value( $border_width, 'px' ); $gen_border_css['border-bottom-width'] = ( isset( $current_css['border-bottom-width'] ) && ( ! empty( $current_css['border-bottom-width'] ) || 0 === $current_css['border-bottom-width'] ) ) ? $current_css['border-bottom-width'] : UAGB_Helper::get_css_value( $border_width, 'px' ); $gen_border_css['border-top-left-radius'] = ( isset( $current_css['border-top-left-radius'] ) && ( ! empty( $current_css['border-top-left-radius'] ) || 0 === $current_css['border-top-left-radius'] ) ) ? $current_css['border-top-left-radius'] : UAGB_Helper::get_css_value( $border_radius, 'px' ); $gen_border_css['border-top-right-radius'] = ( isset( $current_css['border-top-right-radius'] ) && ( ! empty( $current_css['border-top-right-radius'] ) || 0 === $current_css['border-top-right-radius'] ) ) ? $current_css['border-top-right-radius'] : UAGB_Helper::get_css_value( $border_radius, 'px' ); $gen_border_css['border-bottom-left-radius'] = ( isset( $current_css['border-bottom-left-radius'] ) && ( ! empty( $current_css['border-bottom-left-radius'] ) || 0 === $current_css['border-bottom-left-radius'] ) ) ? $current_css['border-bottom-left-radius'] : UAGB_Helper::get_css_value( $border_radius, 'px' ); $gen_border_css['border-bottom-right-radius'] = ( isset( $current_css['border-bottom-right-radius'] ) && ( ! empty( $current_css['border-bottom-right-radius'] ) || 0 === $current_css['border-bottom-right-radius'] ) ) ? $current_css['border-bottom-right-radius'] : UAGB_Helper::get_css_value( $border_radius, 'px' ); $gen_border_css['border-color'] = ( isset( $current_css['border-color'] ) && ! empty( $current_css['border-color'] ) ) ? $current_css['border-color'] : $border_color; $gen_border_css['border-style'] = ( isset( $current_css['border-style'] ) && ! empty( $current_css['border-style'] ) ) ? $current_css['border-style'] : $border_style; return $gen_border_css; } /** * For flex-direction: row-reverse, justify-content work opposite. * * @since 2.0.0 * @param string $text_align Alignment value from text-align property. */ public static function flex_alignment_when_direction_is_row_reverse( $text_align ) { switch ( $text_align ) { case 'flex-end': return 'flex-start'; case 'center': return 'center'; case 'space-between': return 'space-between'; default: return 'flex-end'; } } /** * Get a Block's Default Attributes. * * @param string $block_name Name of the block to retrieve defaults. * @return array All default attributes for the specified block. */ private static function get_block_default_attributes( $block_name ) { return require UAGB_DIR . 'includes/blocks/' . $block_name . '/attributes.php'; } /** * Return the Current Attribute or the Default Attribute. * * @param array $current_value The current variable / attribute that is altered by settings. * @param string $key The key of the default attribute for that setting. * @param string $block_name The name of the block. */ public static function get_attribute_fallback( $current_value, $key, $block_name ) { $default = self::get_block_default_attributes( $block_name ); return isset( $current_value ) ? $current_value : $default[ $key ]; } /** * Return the Current Attribute or the Default Attribute for Numeric Data. * * @param array $current_value The current variable / attribute that is altered by settings. * @param string $key The key of the default attribute for that setting. * @param string $block_name The name of the block. */ public static function get_fallback_number( $current_value, $key, $block_name ) { $default = self::get_block_default_attributes( $block_name ); return is_numeric( $current_value ) ? $current_value : $default[ $key ]; } } }