← All changes
|
includes/blocks/academy-instructor-registration-form/block.php
+37
-54
2.9.1
→
2.14.0
View file →
| @@ -5,14 +5,15 @@ | ||
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | use ABlocks\Classes\BlockBaseAbstract; |
| 9 | -use ABlocks\Classes\CssGenerator; | |
| 9 | +use ABlocks\Classes\CssGeneratorV2; | |
| 10 | 10 | use ABlocks\Helper; |
| 11 | 11 | use ABlocks\Controls\Typography; |
| 12 | 12 | use ABlocks\Controls\Background; |
| 13 | 13 | use ABlocks\Controls\Border; |
| 14 | 14 | use ABlocks\Controls\Dimensions; |
| 15 | +use ABlocks\Controls\Color; | |
| 15 | 16 | |
| 16 | 17 | class Block extends BlockBaseAbstract { |
| 17 | 18 | protected $block_name = 'academy-instructor-registration-form'; |
| 18 | 19 | |
| @@ -31,19 +32,15 @@ | ||
| 31 | 32 | return $flag; |
| 32 | 33 | } |
| 33 | 34 | |
| 34 | 35 | public function build_css( $attributes ) { |
| 35 | - $css_generator = new CssGenerator( $attributes ); | |
| 36 | - | |
| 37 | - $input_field_label_desktop_css = $this->get_form_input_label_css( $attributes ); | |
| 38 | - if ( ! empty( $attributes['input_label_color'] ) ) { | |
| 39 | - $input_field_label_desktop_css['color'] = $attributes['input_label_color']; | |
| 40 | - } | |
| 36 | + $css_generator = new CssGeneratorV2( $attributes ); | |
| 41 | 37 | $css_generator->add_class_styles( |
| 42 | 38 | '{{WRAPPER}} .academy-reg-form--instructor .academy-form-group label', |
| 43 | - $input_field_label_desktop_css, | |
| 39 | + $this->get_form_input_label_css( $attributes ), | |
| 44 | 40 | $this->get_form_input_label_css( $attributes, 'Tablet' ), |
| 45 | - $this->get_form_input_label_css( $attributes, 'Mobile' ) | |
| 41 | + $this->get_form_input_label_css( $attributes, 'Mobile' ), | |
| 42 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_label_css( $attributes, $device ); } ) | |
| 46 | 43 | ); |
| 47 | 44 | |
| 48 | 45 | $css_generator->add_class_styles( |
| 49 | 46 | '{{WRAPPER}} .academy-reg-form--instructor .academy-form-group input', |
| @@ -48,15 +45,17 @@ | ||
| 48 | 45 | $css_generator->add_class_styles( |
| 49 | 46 | '{{WRAPPER}} .academy-reg-form--instructor .academy-form-group input', |
| 50 | 47 | $this->get_form_input_field_css( $attributes ), |
| 51 | 48 | $this->get_form_input_field_css( $attributes, 'Tablet' ), |
| 52 | - $this->get_form_input_field_css( $attributes, 'Mobile' ) | |
| 49 | + $this->get_form_input_field_css( $attributes, 'Mobile' ), | |
| 50 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_field_css( $attributes, $device ); } ) | |
| 53 | 51 | ); |
| 54 | 52 | $css_generator->add_class_styles( |
| 55 | 53 | '{{WRAPPER}} .academy-reg-form--instructor .academy-form-group input:hover', |
| 56 | 54 | $this->get_form_input_field_hover_css( $attributes ), |
| 57 | 55 | $this->get_form_input_field_hover_css( $attributes, 'Tablet' ), |
| 58 | - $this->get_form_input_field_hover_css( $attributes, 'Mobile' ) | |
| 56 | + $this->get_form_input_field_hover_css( $attributes, 'Mobile' ), | |
| 57 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_field_hover_css( $attributes, $device ); } ) | |
| 59 | 58 | ); |
| 60 | 59 | |
| 61 | 60 | $css_generator->add_class_styles( |
| 62 | 61 | '{{WRAPPER}} .academy-reg-form--instructor .academy-form-group input::placeholder', |
| @@ -61,20 +60,17 @@ | ||
| 61 | 60 | $css_generator->add_class_styles( |
| 62 | 61 | '{{WRAPPER}} .academy-reg-form--instructor .academy-form-group input::placeholder', |
| 63 | 62 | $this->get_form_input_field_placeholder_css( $attributes ), |
| 64 | 63 | $this->get_form_input_field_placeholder_css( $attributes, 'Tablet' ), |
| 65 | - $this->get_form_input_field_placeholder_css( $attributes, 'Mobile' ) | |
| 64 | + $this->get_form_input_field_placeholder_css( $attributes, 'Mobile' ), | |
| 65 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_field_placeholder_css( $attributes, $device ); } ) | |
| 66 | 66 | ); |
| 67 | - | |
| 68 | - $form_button_desktop_css = $this->get_form_button_css( $attributes ); | |
| 69 | - if ( ! empty( $attributes['form_button_color'] ) ) { | |
| 70 | - $form_button_desktop_css['color'] = $attributes['form_button_color']; | |
| 71 | - } | |
| 72 | 67 | $css_generator->add_class_styles( |
| 73 | 68 | '{{WRAPPER}} .academy-reg-form--instructor .academy-form-group button', |
| 74 | - $form_button_desktop_css, | |
| 69 | + $this->get_form_button_css( $attributes ), | |
| 75 | 70 | $this->get_form_button_css( $attributes, 'Tablet' ), |
| 76 | - $this->get_form_button_css( $attributes, 'Mobile' ) | |
| 71 | + $this->get_form_button_css( $attributes, 'Mobile' ), | |
| 72 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_button_css( $attributes, $device ); } ) | |
| 77 | 73 | ); |
| 78 | 74 | |
| 79 | 75 | $css_generator->add_class_styles( |
| 80 | 76 | '{{WRAPPER}} .academy-reg-form--instructor .academy-form-group button:hover', |
| @@ -79,9 +75,10 @@ | ||
| 79 | 75 | $css_generator->add_class_styles( |
| 80 | 76 | '{{WRAPPER}} .academy-reg-form--instructor .academy-form-group button:hover', |
| 81 | 77 | $this->get_form_button_hover_css( $attributes ), |
| 82 | 78 | $this->get_form_button_hover_css( $attributes, 'Tablet' ), |
| 83 | - $this->get_form_button_hover_css( $attributes, 'Mobile' ) | |
| 79 | + $this->get_form_button_hover_css( $attributes, 'Mobile' ), | |
| 80 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_button_hover_css( $attributes, $device ); } ) | |
| 84 | 81 | ); |
| 85 | 82 | |
| 86 | 83 | $css_generator->add_class_styles( |
| 87 | 84 | '{{WRAPPER}} .academy-reg-form', |
| @@ -86,9 +83,10 @@ | ||
| 86 | 83 | $css_generator->add_class_styles( |
| 87 | 84 | '{{WRAPPER}} .academy-reg-form', |
| 88 | 85 | $this->get_form_css( $attributes ), |
| 89 | 86 | $this->get_form_css( $attributes, 'Tablet' ), |
| 90 | - $this->get_form_css( $attributes, 'Mobile' ) | |
| 87 | + $this->get_form_css( $attributes, 'Mobile' ), | |
| 88 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_css( $attributes, $device ); } ) | |
| 91 | 89 | ); |
| 92 | 90 | |
| 93 | 91 | $css_generator->add_class_styles( |
| 94 | 92 | '{{WRAPPER}} .academy-reg-form:hover', |
| @@ -93,9 +91,10 @@ | ||
| 93 | 91 | $css_generator->add_class_styles( |
| 94 | 92 | '{{WRAPPER}} .academy-reg-form:hover', |
| 95 | 93 | $this->get_form_hover_css( $attributes ), |
| 96 | 94 | $this->get_form_hover_css( $attributes, 'Tablet' ), |
| 97 | - $this->get_form_hover_css( $attributes, 'Mobile' ) | |
| 95 | + $this->get_form_hover_css( $attributes, 'Mobile' ), | |
| 96 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_hover_css( $attributes, $device ); } ) | |
| 98 | 97 | ); |
| 99 | 98 | |
| 100 | 99 | return $css_generator->generate_css(); |
| 101 | 100 | } |
| @@ -100,25 +99,23 @@ | ||
| 100 | 99 | return $css_generator->generate_css(); |
| 101 | 100 | } |
| 102 | 101 | |
| 103 | 102 | public function get_form_input_label_css( $attributes, $device = '' ) { |
| 104 | - $input_label_typography_css = ! empty( $attributes['input_label_typhography'] ) ? Typography::get_css( $attributes['input_label_typhography'], '', $device ) : array(); | |
| 105 | - return $input_label_typography_css; | |
| 103 | + $typographyValueGlobal = ! empty( $attributes['input_label_typhographyGlobal'] ) ? $attributes['input_label_typhographyGlobal'] : ''; | |
| 104 | + $input_label_typography_css = isset( $attributes['input_label_typhography'] ) ? $attributes['input_label_typhography'] : []; | |
| 105 | + return array_merge( | |
| 106 | + [ 'color' => Color::get_css( isset( $attributes['input_label_color'] ) ? $attributes['input_label_color'] : '' ) ], | |
| 107 | + Typography::get_css( $input_label_typography_css, '', $device, $typographyValueGlobal ), | |
| 108 | + ); | |
| 106 | 109 | } |
| 107 | 110 | |
| 108 | 111 | public function get_form_input_field_css( $attributes, $device = '' ) { |
| 109 | - $css = array(); | |
| 110 | 112 | $input_field_border_css = ! empty( $attributes['form_field_border'] ) ? Border::get_css( $attributes['form_field_border'], '', $device ) : array(); |
| 111 | - if ( ! empty( $attributes['input_field_color'] ) ) { | |
| 112 | - $css['color'] = $attributes['input_field_color']; | |
| 113 | - } | |
| 114 | - if ( ! empty( $attributes['input_field_bg_color'] ) ) { | |
| 115 | - $css['background'] = $attributes['input_field_bg_color']; | |
| 116 | - } | |
| 117 | 113 | |
| 118 | 114 | return array_merge( |
| 119 | 115 | $input_field_border_css, |
| 120 | - $css, | |
| 116 | + [ 'color' => Color::get_css( isset( $attributes['input_field_color'] ) ? $attributes['input_field_color'] : '' ) ], | |
| 117 | + [ 'background' => Color::get_css( isset( $attributes['input_field_bg_color'] ) ? $attributes['input_field_bg_color'] : '' ) ] | |
| 121 | 118 | ); |
| 122 | 119 | } |
| 123 | 120 | public function get_form_input_field_hover_css( $attributes, $device = '' ) { |
| 124 | 121 | $input_field_border_hover_css = ! empty( $attributes['form_field_border'] ) ? Border::get_hover_css( $attributes['form_field_border'], '', $device ) : array(); |
| @@ -125,29 +122,22 @@ | ||
| 125 | 122 | |
| 126 | 123 | return $input_field_border_hover_css; |
| 127 | 124 | } |
| 128 | 125 | public function get_form_input_field_placeholder_css( $attributes, $device = '' ) { |
| 129 | - $css = array(); | |
| 130 | - if ( ! empty( $attributes['input_field_placeholder_color'] ) ) { | |
| 131 | - $css['color'] = $attributes['input_field_placeholder_color']; | |
| 132 | - } | |
| 133 | - | |
| 134 | - return $css; | |
| 126 | + return [ 'color' => Color::get_css( isset( $attributes['input_field_placeholder_color'] ) ? $attributes['input_field_placeholder_color'] : '' ) ]; | |
| 135 | 127 | } |
| 136 | 128 | |
| 137 | 129 | public function get_form_button_css( $attributes, $device = '' ) { |
| 138 | - $css = array(); | |
| 139 | - if ( ! empty( $attributes['form_button_background'] ) ) { | |
| 140 | - $css['background'] = $attributes['form_button_background']; | |
| 141 | - } | |
| 142 | - $form_button_typography_css = ! empty( $attributes['form_button_typhography'] ) ? Typography::get_css( $attributes['form_button_typhography'], '', $device ) : array(); | |
| 130 | + $typographyValueGlobal = ! empty( $attributes['form_button_typhographyGlobal'] ) ? $attributes['form_button_typhographyGlobal'] : ''; | |
| 131 | + $form_button_typography_css = isset( $attributes['form_button_typhography'] ) ? $attributes['form_button_typhography'] : []; | |
| 143 | 132 | $form_button_padding = ! empty( $attributes['form_button_padding'] ) ? Dimensions::get_css( $attributes['form_button_padding'], 'padding', $device ) : array(); |
| 144 | 133 | $form_button_border_css = ! empty( $attributes['form_button_border'] ) ? Border::get_css( $attributes['form_button_border'], '', $device ) : array(); |
| 145 | 134 | return array_merge( |
| 146 | - $form_button_typography_css, | |
| 135 | + Typography::get_css( $form_button_typography_css, '', $device, $typographyValueGlobal ), | |
| 147 | 136 | $form_button_padding, |
| 148 | 137 | $form_button_border_css, |
| 149 | - $css | |
| 138 | + [ 'color' => Color::get_css( isset( $attributes['form_button_color'] ) ? $attributes['form_button_color'] : '' ) ], | |
| 139 | + [ 'background' => Color::get_css( isset( $attributes['form_button_background'] ) ? $attributes['form_button_background'] : '' ) ] | |
| 150 | 140 | ); |
| 151 | 141 | } |
| 152 | 142 | |
| 153 | 143 | public function get_form_css( $attributes, $device = '' ) { |
| @@ -172,20 +162,13 @@ | ||
| 172 | 162 | ); |
| 173 | 163 | } |
| 174 | 164 | |
| 175 | 165 | public function get_form_button_hover_css( $attributes, $device = '' ) { |
| 176 | - $css = array(); | |
| 177 | - if ( ! empty( $attributes['form_button_hover_color'] ) ) { | |
| 178 | - $css['color'] = $attributes['form_button_hover_color']; | |
| 179 | - } | |
| 180 | - if ( ! empty( $attributes['form_button_hover_background'] ) ) { | |
| 181 | - $css['background'] = $attributes['form_button_hover_background']; | |
| 182 | - } | |
| 183 | 166 | $form_btn_hover_border = ! empty( $attributes['form_button_border'] ) ? Border::get_hover_css( $attributes['form_button_border'], 'background', $device ) : array(); |
| 184 | - | |
| 185 | 167 | return array_merge( |
| 168 | + [ 'color' => Color::get_css( isset( $attributes['form_button_hover_color'] ) ? $attributes['form_button_hover_color'] : '' ) ], | |
| 169 | + [ 'background' => Color::get_css( isset( $attributes['form_button_hover_background'] ) ? $attributes['form_button_hover_background'] : '' ) ], | |
| 186 | 170 | $form_btn_hover_border, |
| 187 | - $css | |
| 188 | 171 | ); |
| 189 | 172 | } |
| 190 | 173 | |
| 191 | 174 | |