| 1 |
<?php |
| 2 |
namespace ABlocks\Blocks\AcademyEnrollContent; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
use ABlocks\Classes\BlockBaseAbstract; |
| 8 |
use ABlocks\Classes\CssGenerator; |
| 9 |
use ABlocks\Classes\CssGeneratorV2; |
| 10 |
use ABlocks\Helper; |
| 11 |
use ABlocks\Controls\Typography; |
| 12 |
use ABlocks\Controls\Background; |
| 13 |
use ABlocks\Controls\Border; |
| 14 |
use ABlocks\Controls\Dimensions; |
| 15 |
use ABlocks\Controls\Range; |
| 16 |
use ABlocks\Controls\BoxShadow; |
| 17 |
use ABlocks\Controls\Color; |
| 18 |
class Block extends BlockBaseAbstract { |
| 19 |
protected $block_name = 'academy-enroll-content'; |
| 20 |
|
| 21 |
public function build_css( $attributes ) { |
| 22 |
$css_generator = new CssGeneratorV2( $attributes, $this->block_name ); |
| 23 |
|
| 24 |
$css_generator->add_class_styles( |
| 25 |
'{{WRAPPER}} .academy-widget-enroll__content-lists', |
| 26 |
$this->get_content_css( $attributes, '' ), |
| 27 |
$this->get_content_css( $attributes, 'Tablet' ), |
| 28 |
$this->get_content_css( $attributes, 'Mobile' ) |
| 29 |
); |
| 30 |
$css_generator->add_class_styles( |
| 31 |
'{{WRAPPER}} .academy-widget-enroll__content-lists:hover', |
| 32 |
$this->get_content_hover_css( $attributes, '' ), |
| 33 |
$this->get_content_hover_css( $attributes, 'Tablet' ), |
| 34 |
$this->get_content_hover_css( $attributes, 'Mobile' ) |
| 35 |
); |
| 36 |
$css_generator->add_class_styles( |
| 37 |
'{{WRAPPER}} .academy-widget-enroll__content-lists li .academy-icon, |
| 38 |
{{WRAPPER}} .academy-icon--level:before, |
| 39 |
{{WRAPPER}} .academy-icon--video-lesson:before', |
| 40 |
$this->get_content_icon_css( $attributes, '' ), |
| 41 |
$this->get_content_icon_css( $attributes, 'Tablet' ), |
| 42 |
$this->get_content_icon_css( $attributes, 'Mobile' ) |
| 43 |
); |
| 44 |
$css_generator->add_class_styles( |
| 45 |
'{{WRAPPER}} .academy-widget-enroll__content-lists li .academy-icon:hover, |
| 46 |
{{WRAPPER}} .academy-icon--level:hover::before, |
| 47 |
{{WRAPPER}} .academy-icon--video-lesson:hover::before', |
| 48 |
$this->get_content_icon_hover_css( $attributes, '' ), |
| 49 |
$this->get_content_icon_hover_css( $attributes, 'Tablet' ), |
| 50 |
$this->get_content_icon_hover_css( $attributes, 'Mobile' ) |
| 51 |
); |
| 52 |
$css_generator->add_class_styles( |
| 53 |
'{{WRAPPER}} .academy-widget-enroll__content-lists li', |
| 54 |
$this->get_content_list_css( $attributes, '' ), |
| 55 |
$this->get_content_list_css( $attributes, 'Tablet' ), |
| 56 |
$this->get_content_list_css( $attributes, 'Mobile' ) |
| 57 |
); |
| 58 |
$css_generator->add_class_styles( |
| 59 |
'{{WRAPPER}} .academy-widget-enroll__content-lists li:hover', |
| 60 |
$this->get_content_list_hover_css( $attributes, '' ), |
| 61 |
$this->get_content_list_hover_css( $attributes, 'Tablet' ), |
| 62 |
$this->get_content_list_hover_css( $attributes, 'Mobile' ) |
| 63 |
); |
| 64 |
$css_generator->add_class_styles( |
| 65 |
'{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-btn', |
| 66 |
$this->get_share_button_css( $attributes, '' ), |
| 67 |
$this->get_share_button_css( $attributes, 'Tablet' ), |
| 68 |
$this->get_share_button_css( $attributes, 'Mobile' ) |
| 69 |
); |
| 70 |
$css_generator->add_class_styles( |
| 71 |
'{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-btn:hover', |
| 72 |
$this->get_share_button_hover_css( $attributes, '' ), |
| 73 |
$this->get_share_button_hover_css( $attributes, 'Tablet' ), |
| 74 |
$this->get_share_button_hover_css( $attributes, 'Mobile' ) |
| 75 |
); |
| 76 |
$css_generator->add_class_styles( |
| 77 |
'{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-course__wishlist', |
| 78 |
$this->get_wishlist_button_css( $attributes, '' ), |
| 79 |
$this->get_wishlist_button_css( $attributes, 'Tablet' ), |
| 80 |
$this->get_wishlist_button_css( $attributes, 'Mobile' ) |
| 81 |
); |
| 82 |
$css_generator->add_class_styles( |
| 83 |
'{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-course__wishlist:hover', |
| 84 |
$this->get_wishlist_button_hover_css( $attributes, '' ), |
| 85 |
$this->get_wishlist_button_hover_css( $attributes, 'Tablet' ), |
| 86 |
$this->get_wishlist_button_hover_css( $attributes, 'Mobile' ) |
| 87 |
); |
| 88 |
$css_generator->add_class_styles( |
| 89 |
'{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-btn i.academy-icon', |
| 90 |
$this->get_button_icon_css( $attributes, '' ), |
| 91 |
$this->get_button_icon_css( $attributes, 'Tablet' ), |
| 92 |
$this->get_button_icon_css( $attributes, 'Mobile' ) |
| 93 |
); |
| 94 |
|
| 95 |
return $css_generator->generate_css(); |
| 96 |
} |
| 97 |
|
| 98 |
public function get_content_css( $attributes, $device = '' ) { |
| 99 |
return [ 'background' => Color::get_css( isset( $attributes['contentBg'] ) ? $attributes['contentBg'] : '#fff' ) ]; |
| 100 |
} |
| 101 |
|
| 102 |
public function get_content_hover_css( $attributes, $device = '' ) { |
| 103 |
return array_merge( |
| 104 |
[ 'background' => Color::get_css( isset( $attributes['contentBgH'] ) ? $attributes['contentBgH'] : '#fff' ) ], |
| 105 |
Range::get_css([ |
| 106 |
'attributeValue' => $attributes['contentTransition'], |
| 107 |
'attribute_object_key' => 'value', |
| 108 |
'isResponsive' => false, |
| 109 |
'defaultValue' => 0, |
| 110 |
'hasUnit' => false, |
| 111 |
'unitDefaultValue' => 's', |
| 112 |
'property' => 'transition-duration', |
| 113 |
'device' => $device, |
| 114 |
]), |
| 115 |
); |
| 116 |
|
| 117 |
} |
| 118 |
|
| 119 |
public function get_content_icon_css( $attributes, $device = '' ) { |
| 120 |
return array_merge( |
| 121 |
[ 'color' => Color::get_css( isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '#595959' ) ], |
| 122 |
Range::get_css([ |
| 123 |
'attributeValue' => $attributes['iconSize'], |
| 124 |
'attribute_object_key' => 'value', |
| 125 |
'isResponsive' => true, |
| 126 |
'defaultValue' => 14, |
| 127 |
'hasUnit' => true, |
| 128 |
'unitDefaultValue' => 'px', |
| 129 |
'property' => 'font-size', |
| 130 |
'device' => $device, |
| 131 |
]), |
| 132 |
); |
| 133 |
} |
| 134 |
|
| 135 |
public function get_content_icon_hover_css( $attributes, $device = '' ) { |
| 136 |
return [ 'color' => Color::get_css( isset( $attributes['iconColorH'] ) ? $attributes['iconColorH'] : '#595959' ) ]; |
| 137 |
} |
| 138 |
|
| 139 |
public function get_content_list_css( $attributes, $device = '' ) { |
| 140 |
$typographyValueGlobal = ! empty( $attributes['listTypographyGlobal'] ) ? $attributes['listTypographyGlobal'] : ''; |
| 141 |
$typography_value = ! empty( $attributes['listTypography'] ) ? |
| 142 |
Typography::get_css( $attributes['listTypography'], '', $device, $typographyValueGlobal ) |
| 143 |
: array(); |
| 144 |
|
| 145 |
return array_merge( |
| 146 |
[ 'color' => Color::get_css( isset( $attributes['listColor'] ) ? $attributes['listColor'] : '#111' ) ], |
| 147 |
$typography_value |
| 148 |
); |
| 149 |
|
| 150 |
} |
| 151 |
|
| 152 |
public function get_content_list_hover_css( $attributes, $device = '' ) { |
| 153 |
return [ 'color' => Color::get_css( isset( $attributes['listColorH'] ) ? $attributes['listColorH'] : '#111' ) ]; |
| 154 |
} |
| 155 |
|
| 156 |
public function get_share_button_css( $attributes, $device = '' ) { |
| 157 |
$typographyValueGlobal = ! empty( $attributes['shareTypographyGlobal'] ) ? $attributes['shareTypographyGlobal'] : ''; |
| 158 |
$typography_value = ! empty( $attributes['shareTypography'] ) ? |
| 159 |
Typography::get_css( $attributes['shareTypography'], '', $device, $typographyValueGlobal ) |
| 160 |
: array(); |
| 161 |
|
| 162 |
return array_merge( |
| 163 |
[ 'color' => Color::get_css( isset( $attributes['shareColor'] ) ? $attributes['shareColor'] : '#444' ) ], |
| 164 |
[ 'background' => Color::get_css( isset( $attributes['shareBg'] ) ? $attributes['shareBg'] : '#fff' ) ], |
| 165 |
$typography_value, |
| 166 |
Dimensions::get_css( $attributes['sharePadding'], 'padding', $device ), |
| 167 |
Border::get_css( $attributes['shareBorder'], '', $device ), |
| 168 |
); |
| 169 |
} |
| 170 |
|
| 171 |
public function get_share_button_hover_css( $attributes, $device = '' ) { |
| 172 |
return array_merge( |
| 173 |
[ 'color' => Color::get_css( isset( $attributes['shareColorH'] ) ? $attributes['shareColorH'] : '#444' ) ], |
| 174 |
[ 'background' => Color::get_css( isset( $attributes['shareBgH'] ) ? $attributes['shareBgH'] : '#fff' ) ], |
| 175 |
Border::get_hover_css( $attributes['shareBorder'], '', $device ) |
| 176 |
); |
| 177 |
} |
| 178 |
|
| 179 |
public function get_wishlist_button_css( $attributes, $device = '' ) { |
| 180 |
return array_merge( |
| 181 |
[ 'color' => Color::get_css( isset( $attributes['wishlistColor'] ) ? $attributes['wishlistColor'] : '#fff' ) ], |
| 182 |
[ 'background' => Color::get_css( isset( $attributes['wishlistBg'] ) ? $attributes['wishlistBg'] : '#7b68ee' ) ], |
| 183 |
); |
| 184 |
} |
| 185 |
|
| 186 |
public function get_wishlist_button_hover_css( $attributes, $device = '' ) { |
| 187 |
return array_merge( |
| 188 |
[ 'color' => Color::get_css( isset( $attributes['wishlistColorH'] ) ? $attributes['wishlistColorH'] : '#fff' ) ], |
| 189 |
[ 'background' => Color::get_css( isset( $attributes['wishlistBgH'] ) ? $attributes['wishlistBgH'] : '#7b68ee' ) ], |
| 190 |
); |
| 191 |
|
| 192 |
} |
| 193 |
|
| 194 |
public function get_button_icon_css( $attributes, $device = '' ) { |
| 195 |
return array_merge( |
| 196 |
Range::get_css([ |
| 197 |
'attributeValue' => $attributes['buttonIconSize'], |
| 198 |
'attribute_object_key' => 'value', |
| 199 |
'isResponsive' => true, |
| 200 |
'defaultValue' => 14, |
| 201 |
'hasUnit' => true, |
| 202 |
'unitDefaultValue' => 'px', |
| 203 |
'property' => 'font-size', |
| 204 |
'device' => $device, |
| 205 |
]), |
| 206 |
); |
| 207 |
} |
| 208 |
|
| 209 |
public function render_block_content( $attributes, $content, $block_instance ) { |
| 210 |
$attr_array = []; |
| 211 |
|
| 212 |
$shortcode = '[academy_course_enroll_widget_content ' . Helper::attr_shortcode( $attr_array ) . ']'; |
| 213 |
echo do_shortcode( $shortcode ); |
| 214 |
} |
| 215 |
} |
| 216 |
|