| @@ -1,7 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace ABlocks\Blocks\PriceMenuItem; |
| 3 | 3 | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | + | |
| 4 | 8 | use ABlocks\Classes\BlockBaseAbstract; |
| 5 | 9 | use ABlocks\Classes\CssGenerator; |
| 6 | 10 | use ABlocks\Controls\Icon; |
| 7 | 11 | use ABlocks\Controls\Alignment; |
| @@ -8,8 +12,9 @@ | ||
| 8 | 12 | use ABlocks\Controls\Typography; |
| 9 | 13 | use ABlocks\Controls\TextShadow; |
| 10 | 14 | use ABlocks\Controls\TextStroke; |
| 11 | 15 | use ABlocks\Controls\Range; |
| 16 | +use ABlocks\Controls\Color; | |
| 12 | 17 | |
| 13 | 18 | class Block extends BlockBaseAbstract { |
| 14 | 19 | protected $parent_block_name = 'price-menu'; |
| 15 | 20 | protected $block_name = 'price-menu-item'; |
| @@ -21,11 +26,19 @@ | ||
| 21 | 26 | $css_generator->add_class_styles( |
| 22 | 27 | '{{WRAPPER}} .ablocks-icon-wrap', |
| 23 | 28 | Icon::get_wrapper_css( $attributes ), |
| 24 | 29 | Icon::get_wrapper_css( $attributes, 'Tablet' ), |
| 25 | - Icon::get_wrapper_css( $attributes, 'Mobile' ) | |
| 30 | + Icon::get_wrapper_css( $attributes, 'Mobile' ), | |
| 31 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_css( $attributes, $device ); } ) | |
| 26 | 32 | ); |
| 27 | 33 | $css_generator->add_class_styles( |
| 34 | + '{{WRAPPER}} .ablocks-icon-wrap:hover', | |
| 35 | + Icon::get_wrapper_hover_css( $attributes ), | |
| 36 | + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ), | |
| 37 | + Icon::get_wrapper_hover_css( $attributes, 'Mobile' ), | |
| 38 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_hover_css( $attributes, $device ); } ) | |
| 39 | + ); | |
| 40 | + $css_generator->add_class_styles( | |
| 28 | 41 | '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon', |
| 29 | 42 | Icon::get_element_image_css( $attributes ), |
| 30 | 43 | Icon::get_element_image_css( $attributes, 'Tablet' ), |
| 31 | 44 | Icon::get_element_image_css( $attributes, 'Mobile' ), |
| @@ -80,18 +93,12 @@ | ||
| 80 | 93 | return $css_generator->generate_css(); |
| 81 | 94 | } |
| 82 | 95 | |
| 83 | 96 | public function get_title_text_css( $attributes, $device = '' ) { |
| 84 | - $css = []; | |
| 85 | - $title_color = isset( $attributes['titleColor'] ) ? $attributes['titleColor'] : ''; | |
| 86 | - | |
| 87 | - if ( isset( $attributes['titleColor'] ) ) { | |
| 88 | - $css['color'] = $title_color; | |
| 89 | - } | |
| 90 | - | |
| 97 | + $typographyValueGlobal = ! empty( $attributes['titleTypographyGlobal'] ) ? $attributes['titleTypographyGlobal'] : array(); | |
| 91 | 98 | return array_merge( |
| 92 | - $css, | |
| 93 | - isset( $attributes['titleTypography'] ) ? Typography::get_css( $attributes['titleTypography'], '', $device ) : [], | |
| 99 | + [ 'color' => Color::get_css( isset( $attributes['titleColor'] ) ? $attributes['titleColor'] : '' ) ], | |
| 100 | + isset( $attributes['titleTypography'] ) ? Typography::get_css( $attributes['titleTypography'], '', $device, $typographyValueGlobal ) : [], | |
| 94 | 101 | isset( $attributes['titleTextStroke'] ) ? TextStroke::get_css( $attributes['titleTextStroke'], '', $device ) : [], |
| 95 | 102 | isset( $attributes['titleTextShadow'] ) ? TextShadow::get_css( $attributes['titleTextShadow'], '', $device ) : [], |
| 96 | 103 | isset( $attributes['titleAlignment'] ) ? Alignment::get_css( $attributes['titleAlignment'], 'text-align', $device ) : [], |
| 97 | 104 | ); |
| @@ -96,18 +103,13 @@ | ||
| 96 | 103 | isset( $attributes['titleAlignment'] ) ? Alignment::get_css( $attributes['titleAlignment'], 'text-align', $device ) : [], |
| 97 | 104 | ); |
| 98 | 105 | } |
| 99 | 106 | public function get_description_text_css( $attributes, $device = '' ) { |
| 100 | - $css = []; | |
| 101 | - $description_color = isset( $attributes['descriptionColor'] ) ? $attributes['descriptionColor'] : ''; | |
| 107 | + $typographyValueGlobal = ! empty( $attributes['descriptionTypographyGlobal'] ) ? $attributes['descriptionTypographyGlobal'] : array(); | |
| 102 | 108 | |
| 103 | - if ( isset( $attributes['descriptionColor'] ) ) { | |
| 104 | - $css['color'] = $description_color; | |
| 105 | - } | |
| 106 | - | |
| 107 | 109 | return array_merge( |
| 108 | - $css, | |
| 109 | - isset( $attributes['descriptionTypography'] ) ? Typography::get_css( $attributes['descriptionTypography'], '', $device ) : [], | |
| 110 | + [ 'color' => Color::get_css( isset( $attributes['descriptionColor'] ) ? $attributes['descriptionColor'] : '' ) ], | |
| 111 | + isset( $attributes['descriptionTypography'] ) ? Typography::get_css( $attributes['descriptionTypography'], '', $device, $typographyValueGlobal ) : [], | |
| 110 | 112 | isset( $attributes['descriptionTextStroke'] ) ? TextStroke::get_css( $attributes['descriptionTextStroke'], '', $device ) : [], |
| 111 | 113 | isset( $attributes['descriptionTextShadow'] ) ? TextShadow::get_css( $attributes['descriptionTextShadow'], '', $device ) : [], |
| 112 | 114 | isset( $attributes['descriptionAlignment'] ) ? Alignment::get_css( $attributes['descriptionAlignment'], 'text-align', $device ) : [], |
| 113 | 115 | ); |
| @@ -114,13 +116,14 @@ | ||
| 114 | 116 | } |
| 115 | 117 | public function get_divider_css( $attributes, $device = '' ) { |
| 116 | 118 | $css = []; |
| 117 | 119 | $divider_width = isset( $attributes['width'][ 'value' . $device ] ) ? $attributes['width'][ 'value' . $device ] : 60; |
| 118 | - $divider_color = isset( $attributes['color'] ) ? $attributes['color'] : '#000000'; | |
| 119 | 120 | $default_Unit = $attributes['allowDescription'] === true ? '%' : 'px'; |
| 120 | 121 | |
| 121 | 122 | if ( ! empty( $attributes['color'] ) ) { |
| 122 | - $css['--ablocks-divider-pattern-color'] = $divider_color; | |
| 123 | + $css['--ablocks-divider-pattern-color'] = Color::get_css( | |
| 124 | + isset( $attributes['color'] ) ? $attributes['color'] : '#000000'); | |
| 125 | + | |
| 123 | 126 | } |
| 124 | 127 | |
| 125 | 128 | $moreRangeCSS = []; |
| 126 | 129 | if ( isset( $attributes['dividerType'] ) && $attributes['dividerType'] === 'mask-style' && isset( $attributes['size'] ) && ! empty( $attributes['size'] ) ) { |
| @@ -168,18 +171,12 @@ | ||
| 168 | 171 | $moreRangeCSS, |
| 169 | 172 | ); |
| 170 | 173 | } |
| 171 | 174 | public function get_price_text_css( $attributes, $device = '' ) { |
| 172 | - $css = []; | |
| 173 | - $price_color = isset( $attributes['priceColor'] ) ? $attributes['priceColor'] : ''; | |
| 174 | - | |
| 175 | - if ( isset( $attributes['priceColor'] ) ) { | |
| 176 | - $css['color'] = $price_color; | |
| 177 | - } | |
| 178 | - | |
| 175 | + $typographyValueGlobal = ! empty( $attributes['priceTypographyGlobal'] ) ? $attributes['priceTypographyGlobal'] : array(); | |
| 179 | 176 | return array_merge( |
| 180 | - $css, | |
| 181 | - isset( $attributes['priceTypography'] ) ? Typography::get_css( $attributes['priceTypography'], '', $device ) : [], | |
| 177 | + [ 'color' => Color::get_css( isset( $attributes['priceColor'] ) ? $attributes['priceColor'] : '' ) ], | |
| 178 | + isset( $attributes['priceTypography'] ) ? Typography::get_css( $attributes['priceTypography'], '', $device, $typographyValueGlobal ) : [], | |
| 182 | 179 | isset( $attributes['priceTextStroke'] ) ? TextStroke::get_css( $attributes['priceTextStroke'], '', $device ) : [], |
| 183 | 180 | isset( $attributes['priceTextShadow'] ) ? TextShadow::get_css( $attributes['priceTextShadow'], '', $device ) : [], |
| 184 | 181 | isset( $attributes['priceAlignment'] ) ? Alignment::get_css( $attributes['priceAlignment'], 'text-align', $device ) : [], |
| 185 | 182 | ); |