'', 'tablet' => '', 'mobile' => '', ); foreach ( $variables as $device => $data ) { $css = implode( ';', $data ); if ( ! empty( $css ) ) { $device_css[ $device ] .= $selector . '{' . $css . '}'; } } $result = ''; foreach ( $device_css as $device => $css ) { if ( ! in_array( $device, brandy_get_devices(), true ) ) { continue; } if ( 'tablet' === $device ) { $css = DynamicCss::wrap_tablet_responsive( $css ); } if ( 'mobile' === $device ) { $css = DynamicCss::wrap_mobile_responsive( $css ); } $result .= $css; } return $result; } /** * Generates CSS properties for different directions based on the given name and spacing values. * * @param string $name The name to be used as a prefix for the CSS properties. * @param array $spacing An associative array containing spacing values for each direction (top, right, bottom, left). * @return array An associative array containing CSS properties for each direction. */ public static function get_directions_spacing_css_variables( $name, $spacing ) { if ( ! self::is_spacing_data( $spacing ) ) { return array(); } $directions = array( 'top', 'right', 'bottom', 'left' ); $result = array(); foreach ( $directions as $direction ) { if ( 'wp' === $spacing['unit'] ) { $result[] = "$name-$direction:" . $spacing[ $direction ]; } else { $result[] = "$name-$direction:" . $spacing[ $direction ] . $spacing['unit']; } } return $result; } /** * Generates CSS properties for different directions based on the given name and spacing values. * * @param string $name The name to be used as a prefix for the CSS properties. * @param array $spacing An associative array containing spacing values for each direction (top, right, bottom, left). * @return array An associative array containing CSS properties for each direction. */ public static function get_directions_css_variables( $name, $css_value ) { $directions = array( 'top', 'right', 'bottom', 'left' ); $result = array(); foreach ( $directions as $direction ) { $result[] = "$name-$direction:$css_value"; } return $result; } public static function get_css_variable( $name, $value ) { if ( empty( $value ) ) { return ''; } return "$name:$value"; } public static function get_spacing_css_variable( $name, $data ) { return self::get_css_variable( $name, self::get_spacing_css( $data ) ); } public static function get_dimension_css_variable( $name, $data ) { return self::get_css_variable( $name, self::get_dimension_css( $data ) ); } public static function get_box_shadow_css_variable( $name, $data ) { return self::get_css_variable( $name, self::get_box_shadow_css( $data ) ); } public static function get_typography_css_variables( $data, $prefix = null ) { $result = array( 'desktop' => array(), 'tablet' => array(), 'mobile' => array(), ); if ( empty( $prefix ) ) { return $result; } if ( empty( $data ) ) { return $result; } foreach ( $data as $typo_type => $typo_value ) { foreach ( $typo_value as $device => $variable_value ) { if ( ! in_array( $device, brandy_get_devices(), true ) ) { continue; } $variable_value = Helpers::get_device_value( $typo_value, $device ); if ( 'font_style' === $typo_type ) { $result[ $device ][] = self::get_css_variable( $prefix . '-font_weight', $variable_value['weight'] ); $result[ $device ][] = self::get_css_variable( $prefix . '-font_style', $variable_value['italic'] ? 'italic' : 'normal' ); continue; } if ( in_array( $typo_type, array( 'font_size', 'line_height', 'letter_spacing' ), true ) ) { $result[ $device ][] = self::get_css_variable( $prefix . '-' . $typo_type, self::get_dimension_css( $variable_value ) ); continue; } $result[ $device ][] = self::get_css_variable( $prefix . '-' . $typo_type, $variable_value ); } } return $result; } }