| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace UiCoreElements\Utils; |
| 3 | 4 | |
| 4 | 5 | use Elementor\Controls_Manager; |
| 5 | 6 | use Elementor\Utils; |
| @@ -8,12 +9,14 @@ | ||
| 8 | 9 | use Elementor\Group_Control_Box_Shadow; |
| 9 | 10 | use Elementor\Group_Control_Css_Filter; |
| 10 | 11 | |
| 11 | 12 | use UiCoreElements\Utils\Carousel_Trait; |
| 13 | +use UiCoreElements\Helper; | |
| 12 | 14 | |
| 13 | 15 | defined('ABSPATH') || exit(); |
| 14 | 16 | |
| 15 | -trait Logo_Trait { | |
| 17 | +trait Logo_Trait | |
| 18 | +{ | |
| 16 | 19 | |
| 17 | 20 | use Carousel_Trait; |
| 18 | 21 | |
| 19 | 22 | // Settings |
| @@ -22,83 +25,83 @@ | ||
| 22 | 25 | $this->start_controls_section( |
| 23 | 26 | 'section_logo', |
| 24 | 27 | [ |
| 25 | 28 | /* translators: %s: logo name */ |
| 26 | - 'label' => esc_html( sprintf('%s', $logo), 'uicore-elements'), | |
| 29 | + 'label' => esc_html(sprintf('%s', $logo), 'uicore-elements'), | |
| 27 | 30 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 28 | 31 | ] |
| 29 | 32 | ); |
| 30 | 33 | |
| 31 | - $repeater = new Repeater(); | |
| 32 | - $repeater->add_control( | |
| 33 | - 'title', | |
| 34 | - [ | |
| 35 | - 'label' => esc_html__( 'Title', 'uicore-elements' ), | |
| 36 | - 'type' => Controls_Manager::TEXT, | |
| 37 | - ] | |
| 38 | - ); | |
| 39 | - $repeater->add_control( | |
| 40 | - 'image', | |
| 41 | - [ | |
| 42 | - 'label' => esc_html__( 'Logo Image', 'uicore-elements' ), | |
| 43 | - 'type' => Controls_Manager::MEDIA, | |
| 44 | - 'default' => [ | |
| 45 | - 'url' => Utils::get_placeholder_image_src(), | |
| 34 | + $repeater = new Repeater(); | |
| 35 | + $repeater->add_control( | |
| 36 | + 'title', | |
| 37 | + [ | |
| 38 | + 'label' => esc_html__('Title', 'uicore-elements'), | |
| 39 | + 'type' => Controls_Manager::TEXT, | |
| 40 | + ] | |
| 41 | + ); | |
| 42 | + $repeater->add_control( | |
| 43 | + 'image', | |
| 44 | + [ | |
| 45 | + 'label' => esc_html__('Logo Image', 'uicore-elements'), | |
| 46 | + 'type' => Controls_Manager::MEDIA, | |
| 47 | + 'default' => [ | |
| 48 | + 'url' => Utils::get_placeholder_image_src(), | |
| 49 | + ], | |
| 50 | + ] | |
| 51 | + ); | |
| 52 | + $repeater->add_control( | |
| 53 | + 'link', | |
| 54 | + [ | |
| 55 | + 'label' => esc_html__('Website URL', 'uicore-elements'), | |
| 56 | + 'type' => Controls_Manager::URL, | |
| 57 | + 'show_external' => false, | |
| 58 | + 'label_block' => false, | |
| 59 | + ] | |
| 60 | + ); | |
| 61 | + $this->add_control( | |
| 62 | + 'logo_list', | |
| 63 | + [ | |
| 64 | + 'show_label' => false, | |
| 65 | + 'type' => Controls_Manager::REPEATER, | |
| 66 | + 'fields' => $repeater->get_controls(), | |
| 67 | + 'title_field' => "{{{ title }}}", | |
| 68 | + 'default' => [ | |
| 69 | + [ | |
| 70 | + 'title' => esc_html__('Item 1', 'uicore-elements'), | |
| 71 | + 'image' => ['url' => Utils::get_placeholder_image_src()] | |
| 46 | 72 | ], |
| 73 | + [ | |
| 74 | + 'title' => esc_html__('Item 2', 'uicore-elements'), | |
| 75 | + 'image' => ['url' => Utils::get_placeholder_image_src()] | |
| 76 | + ], | |
| 77 | + [ | |
| 78 | + 'title' => esc_html__('Item 3', 'uicore-elements'), | |
| 79 | + 'image' => ['url' => Utils::get_placeholder_image_src()] | |
| 80 | + ], | |
| 81 | + [ | |
| 82 | + 'title' => esc_html__('Item 4', 'uicore-elements'), | |
| 83 | + 'image' => ['url' => Utils::get_placeholder_image_src()] | |
| 84 | + ], | |
| 85 | + [ | |
| 86 | + 'title' => esc_html__('Item 5', 'uicore-elements'), | |
| 87 | + 'image' => ['url' => Utils::get_placeholder_image_src()] | |
| 88 | + ], | |
| 89 | + [ | |
| 90 | + 'title' => esc_html__('Item 6', 'uicore-elements'), | |
| 91 | + 'image' => ['url' => Utils::get_placeholder_image_src()] | |
| 92 | + ], | |
| 93 | + [ | |
| 94 | + 'title' => esc_html__('Item 7', 'uicore-elements'), | |
| 95 | + 'image' => ['url' => Utils::get_placeholder_image_src()] | |
| 96 | + ], | |
| 97 | + [ | |
| 98 | + 'title' => esc_html__('Item 8', 'uicore-elements'), | |
| 99 | + 'image' => ['url' => Utils::get_placeholder_image_src()] | |
| 100 | + ], | |
| 47 | 101 | ] |
| 48 | - ); | |
| 49 | - $repeater->add_control( | |
| 50 | - 'link', | |
| 51 | - [ | |
| 52 | - 'label' => esc_html__( 'Website URL', 'uicore-elements' ), | |
| 53 | - 'type' => Controls_Manager::URL, | |
| 54 | - 'show_external' => false, | |
| 55 | - 'label_block' => false, | |
| 56 | - ] | |
| 57 | - ); | |
| 58 | - $this->add_control( | |
| 59 | - 'logo_list', | |
| 60 | - [ | |
| 61 | - 'show_label' => false, | |
| 62 | - 'type' => Controls_Manager::REPEATER, | |
| 63 | - 'fields' => $repeater->get_controls(), | |
| 64 | - 'title_field' => "{{{ title }}}", | |
| 65 | - 'default' => [ | |
| 66 | - [ | |
| 67 | - 'title' => esc_html__( 'Item 1', 'uicore-elements' ), | |
| 68 | - 'image' => [ 'url' => Utils::get_placeholder_image_src() ] | |
| 69 | - ], | |
| 70 | - [ | |
| 71 | - 'title' => esc_html__( 'Item 2', 'uicore-elements' ), | |
| 72 | - 'image' => [ 'url' => Utils::get_placeholder_image_src() ] | |
| 73 | - ], | |
| 74 | - [ | |
| 75 | - 'title' => esc_html__( 'Item 3', 'uicore-elements' ), | |
| 76 | - 'image' => [ 'url' => Utils::get_placeholder_image_src() ] | |
| 77 | - ], | |
| 78 | - [ | |
| 79 | - 'title' => esc_html__( 'Item 4', 'uicore-elements' ), | |
| 80 | - 'image' => [ 'url' => Utils::get_placeholder_image_src() ] | |
| 81 | - ], | |
| 82 | - [ | |
| 83 | - 'title' => esc_html__( 'Item 5', 'uicore-elements' ), | |
| 84 | - 'image' => [ 'url' => Utils::get_placeholder_image_src() ] | |
| 85 | - ], | |
| 86 | - [ | |
| 87 | - 'title' => esc_html__( 'Item 6', 'uicore-elements' ), | |
| 88 | - 'image' => [ 'url' => Utils::get_placeholder_image_src() ] | |
| 89 | - ], | |
| 90 | - [ | |
| 91 | - 'title' => esc_html__( 'Item 7', 'uicore-elements' ), | |
| 92 | - 'image' => [ 'url' => Utils::get_placeholder_image_src() ] | |
| 93 | - ], | |
| 94 | - [ | |
| 95 | - 'title' => esc_html__( 'Item 8', 'uicore-elements' ), | |
| 96 | - 'image' => [ 'url' => Utils::get_placeholder_image_src() ] | |
| 97 | - ], | |
| 98 | - ] | |
| 99 | - ] | |
| 100 | - ); | |
| 102 | + ] | |
| 103 | + ); | |
| 101 | 104 | $this->end_controls_section(); |
| 102 | 105 | } |
| 103 | 106 | protected function TRAIT_register_logo_adittional_controls() |
| 104 | 107 | { |
| @@ -115,11 +118,11 @@ | ||
| 115 | 118 | ); |
| 116 | 119 | $this->add_responsive_control( |
| 117 | 120 | 'height', |
| 118 | 121 | [ |
| 119 | - 'label' => esc_html__( 'Item Height', 'uicore-elements' ), | |
| 122 | + 'label' => esc_html__('Item Height', 'uicore-elements'), | |
| 120 | 123 | 'type' => Controls_Manager::SLIDER, |
| 121 | - 'size_units' => [ 'px' ], | |
| 124 | + 'size_units' => ['px'], | |
| 122 | 125 | 'range' => [ |
| 123 | 126 | 'px' => [ |
| 124 | 127 | 'max' => 500, |
| 125 | 128 | 'min' => 100, |
| @@ -134,193 +137,193 @@ | ||
| 134 | 137 | |
| 135 | 138 | // Grid Styles |
| 136 | 139 | protected function TRAIT_register_logos_grid_style_controls() |
| 137 | 140 | { |
| 138 | - $this->start_controls_tabs( 'logos_style' ); | |
| 141 | + $this->start_controls_tabs('logos_style'); | |
| 139 | 142 | |
| 140 | - $this->start_controls_tab( | |
| 141 | - 'tab_logos_style_normal', | |
| 142 | - [ | |
| 143 | - 'label' => esc_html__( 'Normal', 'uicore-elements' ), | |
| 143 | + $this->start_controls_tab( | |
| 144 | + 'tab_logos_style_normal', | |
| 145 | + [ | |
| 146 | + 'label' => esc_html__('Normal', 'uicore-elements'), | |
| 147 | + ] | |
| 148 | + ); | |
| 149 | + | |
| 150 | + $this->add_control( | |
| 151 | + 'item_bg_color', | |
| 152 | + [ | |
| 153 | + 'label' => esc_html__('Background Color', 'uicore-elements'), | |
| 154 | + 'type' => Controls_Manager::COLOR, | |
| 155 | + 'selectors' => [ | |
| 156 | + '{{WRAPPER}} figure' => 'background-color: {{VALUE}};', | |
| 157 | + ], | |
| 158 | + ] | |
| 159 | + ); | |
| 160 | + // Using Group Control Border overlays script border styling | |
| 161 | + $this->add_control( | |
| 162 | + 'item_border_type', | |
| 163 | + [ | |
| 164 | + 'label' => esc_html__('Border Type', 'uicore-elements'), | |
| 165 | + 'type' => Controls_Manager::SELECT, | |
| 166 | + 'options' => [ | |
| 167 | + 'none' => esc_html__('None', 'uicore-elements'), | |
| 168 | + 'solid' => esc_html__('Solid', 'uicore-elements'), | |
| 169 | + 'double' => esc_html__('Double', 'uicore-elements'), | |
| 170 | + 'dotted' => esc_html__('Dotted', 'uicore-elements'), | |
| 171 | + 'dashed' => esc_html__('Dashed', 'uicore-elements'), | |
| 172 | + 'groove' => esc_html__('Groove', 'uicore-elements'), | |
| 173 | + ], | |
| 174 | + 'default' => 'solid', | |
| 175 | + 'selectors' => [ | |
| 176 | + '{{WRAPPER}} .ui-e-item' => 'border-style: {{VALUE}};', | |
| 177 | + ], | |
| 178 | + ] | |
| 179 | + ); | |
| 180 | + $this->add_responsive_control( | |
| 181 | + 'item_border_width', | |
| 182 | + [ | |
| 183 | + 'label' => esc_html__('Border Width', 'uicore-elements'), | |
| 184 | + 'type' => Controls_Manager::SLIDER, | |
| 185 | + 'default' => [ | |
| 186 | + 'size' => 2, | |
| 187 | + ], | |
| 188 | + 'tablet_default' => [ | |
| 189 | + 'size' => 2, | |
| 190 | + ], | |
| 191 | + 'mobile_default' => [ | |
| 192 | + 'size' => 2, | |
| 193 | + ], | |
| 194 | + 'range' => [ | |
| 195 | + 'px' => [ | |
| 196 | + 'min' => 0, | |
| 197 | + 'max' => 50, | |
| 198 | + ], | |
| 199 | + ], | |
| 200 | + 'selectors' => [ | |
| 201 | + '{{WRAPPER}}' => '--ui-e-border-width: {{SIZE}}{{UNIT}};' | |
| 202 | + ], | |
| 203 | + 'condition' => [ | |
| 204 | + 'item_border_type!' => 'none', | |
| 144 | 205 | ] |
| 145 | - ); | |
| 146 | - | |
| 147 | - $this->add_control( | |
| 148 | - 'item_bg_color', | |
| 149 | - [ | |
| 150 | - 'label' => esc_html__( 'Background Color', 'uicore-elements' ), | |
| 151 | - 'type' => Controls_Manager::COLOR, | |
| 152 | - 'selectors' => [ | |
| 153 | - '{{WRAPPER}} figure' => 'background-color: {{VALUE}};', | |
| 154 | - ], | |
| 155 | - ] | |
| 156 | - ); | |
| 157 | - // Using Group Control Border overlays script border styling | |
| 158 | - $this->add_control( | |
| 159 | - 'item_border_type', | |
| 160 | - [ | |
| 161 | - 'label' => esc_html__( 'Border Type', 'uicore-elements' ), | |
| 162 | - 'type' => Controls_Manager::SELECT, | |
| 163 | - 'options' => [ | |
| 164 | - 'none' => esc_html__( 'None', 'uicore-elements' ), | |
| 165 | - 'solid' => esc_html__( 'Solid', 'uicore-elements' ), | |
| 166 | - 'double' => esc_html__( 'Double', 'uicore-elements' ), | |
| 167 | - 'dotted' => esc_html__( 'Dotted', 'uicore-elements' ), | |
| 168 | - 'dashed' => esc_html__( 'Dashed', 'uicore-elements' ), | |
| 169 | - 'groove' => esc_html__( 'Groove', 'uicore-elements' ), | |
| 170 | - ], | |
| 171 | - 'default' => 'solid', | |
| 172 | - 'selectors' => [ | |
| 173 | - '{{WRAPPER}} .ui-e-item' => 'border-style: {{VALUE}};', | |
| 174 | - ], | |
| 175 | - ] | |
| 176 | - ); | |
| 177 | - $this->add_responsive_control( | |
| 178 | - 'item_border_width', | |
| 179 | - [ | |
| 180 | - 'label' => esc_html__( 'Border Width', 'uicore-elements' ), | |
| 181 | - 'type' => Controls_Manager::SLIDER, | |
| 182 | - 'default' => [ | |
| 183 | - 'size' => 2, | |
| 184 | - ], | |
| 185 | - 'tablet_default' => [ | |
| 186 | - 'size' => 2, | |
| 187 | - ], | |
| 188 | - 'mobile_default' => [ | |
| 189 | - 'size' => 2, | |
| 190 | - ], | |
| 191 | - 'range' => [ | |
| 192 | - 'px' => [ | |
| 193 | - 'min' => 0, | |
| 194 | - 'max' => 50, | |
| 195 | - ], | |
| 196 | - ], | |
| 197 | - 'selectors' => [ | |
| 198 | - '{{WRAPPER}}' => '--ui-e-border-width: {{SIZE}}{{UNIT}};' | |
| 199 | - ], | |
| 200 | - 'condition' => [ | |
| 201 | - 'item_border_type!' => 'none', | |
| 202 | - ] | |
| 203 | - ] | |
| 204 | - ); | |
| 205 | - $this->add_control( | |
| 206 | - 'item_border_color', | |
| 207 | - [ | |
| 208 | - 'label' => esc_html__( 'Border Color', 'uicore-elements' ), | |
| 209 | - 'type' => Controls_Manager::COLOR, | |
| 210 | - 'selectors' => [ | |
| 211 | - '{{WRAPPER}} .ui-e-item' => 'border-color: {{VALUE}};', | |
| 212 | - ], | |
| 213 | - 'default' => '#EEE', | |
| 214 | - 'condition' => [ | |
| 215 | - 'item_border_type!' => 'none', | |
| 216 | - ] | |
| 217 | - ] | |
| 218 | - ); | |
| 219 | - $this->add_responsive_control( | |
| 220 | - 'item_border_radius', | |
| 221 | - [ | |
| 222 | - 'label' => esc_html__( 'Border Radius', 'uicore-elements' ), | |
| 223 | - 'type' => Controls_Manager::DIMENSIONS, | |
| 224 | - 'size_units' => [ 'px', '%' ], | |
| 225 | - 'default' => [ | |
| 226 | - 'top' => 5, | |
| 227 | - 'right' => 5, | |
| 228 | - 'bottom' => 5, | |
| 229 | - 'left' => 5, | |
| 230 | - 'unit' => 'px', | |
| 231 | - 'isLinked' => true, | |
| 232 | - ], | |
| 233 | - 'selectors' => [ | |
| 234 | - // each side is used separately by logo-grid script | |
| 235 | - '{{WRAPPER}}' => '--ui-e-top-radius: {{TOP}}{{UNIT}}; | |
| 206 | + ] | |
| 207 | + ); | |
| 208 | + $this->add_control( | |
| 209 | + 'item_border_color', | |
| 210 | + [ | |
| 211 | + 'label' => esc_html__('Border Color', 'uicore-elements'), | |
| 212 | + 'type' => Controls_Manager::COLOR, | |
| 213 | + 'selectors' => [ | |
| 214 | + '{{WRAPPER}} .ui-e-item' => 'border-color: {{VALUE}};', | |
| 215 | + ], | |
| 216 | + 'default' => '#EEE', | |
| 217 | + 'condition' => [ | |
| 218 | + 'item_border_type!' => 'none', | |
| 219 | + ] | |
| 220 | + ] | |
| 221 | + ); | |
| 222 | + $this->add_responsive_control( | |
| 223 | + 'item_border_radius', | |
| 224 | + [ | |
| 225 | + 'label' => esc_html__('Border Radius', 'uicore-elements'), | |
| 226 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 227 | + 'size_units' => ['px', '%'], | |
| 228 | + 'default' => [ | |
| 229 | + 'top' => 5, | |
| 230 | + 'right' => 5, | |
| 231 | + 'bottom' => 5, | |
| 232 | + 'left' => 5, | |
| 233 | + 'unit' => 'px', | |
| 234 | + 'isLinked' => true, | |
| 235 | + ], | |
| 236 | + 'selectors' => [ | |
| 237 | + // each side is used separately by logo-grid script | |
| 238 | + '{{WRAPPER}}' => '--ui-e-top-radius: {{TOP}}{{UNIT}}; | |
| 236 | 239 | --ui-e-right-radius: {{RIGHT}}{{UNIT}}; |
| 237 | 240 | --ui-e-left-radius: {{LEFT}}{{UNIT}}; |
| 238 | 241 | --ui-e-bottom-radius: {{BOTTOM}}{{UNIT}}; |
| 239 | 242 | --ui-e-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 240 | - ], | |
| 241 | - ] | |
| 242 | - ); | |
| 243 | - $this->add_responsive_control( | |
| 244 | - 'item_padding', | |
| 245 | - [ | |
| 246 | - 'label' => esc_html__( 'Padding', 'uicore-elements' ), | |
| 247 | - 'type' => Controls_Manager::DIMENSIONS, | |
| 248 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 249 | - 'default' => [ | |
| 250 | - 'top' => 20, | |
| 251 | - 'right' => 20, | |
| 252 | - 'bottom' => 20, | |
| 253 | - 'left' => 20, | |
| 254 | - 'unit' => 'px', | |
| 255 | - 'isLinked' => true, | |
| 256 | - ], | |
| 257 | - 'selectors' => [ | |
| 258 | - '{{WRAPPER}} figure' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 259 | - ], | |
| 260 | - ] | |
| 261 | - ); | |
| 262 | - $this->add_group_control( | |
| 263 | - Group_Control_Box_Shadow::get_type(), | |
| 264 | - [ | |
| 265 | - 'name' => 'logos_box_shadow_item', | |
| 266 | - 'exclude' => [ | |
| 267 | - 'box_shadow_position', | |
| 268 | - ], | |
| 269 | - 'selector' => '{{WRAPPER}} .ui-e-item', | |
| 270 | - 'condition' => [ | |
| 271 | - 'layout' => 'inner-border' | |
| 272 | - ], | |
| 273 | - ] | |
| 274 | - ); | |
| 275 | - $this->add_group_control( | |
| 276 | - Group_Control_Box_Shadow::get_type(), | |
| 277 | - [ | |
| 278 | - 'name' => 'logos_box_shadow_wrapper', | |
| 279 | - 'exclude' => [ | |
| 280 | - 'box_shadow_position', | |
| 281 | - ], | |
| 282 | - 'selector' => '{{WRAPPER}} .ui-e-grid', | |
| 283 | - 'condition' => [ | |
| 284 | - 'layout!' => 'inner-border' | |
| 285 | - ], | |
| 286 | - ] | |
| 287 | - ); | |
| 288 | - $this->TRAIT_register_logos_image_style_controls('normal'); | |
| 289 | - $this->end_controls_tab(); | |
| 243 | + ], | |
| 244 | + ] | |
| 245 | + ); | |
| 246 | + $this->add_responsive_control( | |
| 247 | + 'item_padding', | |
| 248 | + [ | |
| 249 | + 'label' => esc_html__('Padding', 'uicore-elements'), | |
| 250 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 251 | + 'size_units' => ['px', 'em', '%'], | |
| 252 | + 'default' => [ | |
| 253 | + 'top' => 20, | |
| 254 | + 'right' => 20, | |
| 255 | + 'bottom' => 20, | |
| 256 | + 'left' => 20, | |
| 257 | + 'unit' => 'px', | |
| 258 | + 'isLinked' => true, | |
| 259 | + ], | |
| 260 | + 'selectors' => [ | |
| 261 | + '{{WRAPPER}} figure' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 262 | + ], | |
| 263 | + ] | |
| 264 | + ); | |
| 265 | + $this->add_group_control( | |
| 266 | + Group_Control_Box_Shadow::get_type(), | |
| 267 | + [ | |
| 268 | + 'name' => 'logos_box_shadow_item', | |
| 269 | + 'exclude' => [ | |
| 270 | + 'box_shadow_position', | |
| 271 | + ], | |
| 272 | + 'selector' => '{{WRAPPER}} .ui-e-item', | |
| 273 | + 'condition' => [ | |
| 274 | + 'layout' => 'inner-border' | |
| 275 | + ], | |
| 276 | + ] | |
| 277 | + ); | |
| 278 | + $this->add_group_control( | |
| 279 | + Group_Control_Box_Shadow::get_type(), | |
| 280 | + [ | |
| 281 | + 'name' => 'logos_box_shadow_wrapper', | |
| 282 | + 'exclude' => [ | |
| 283 | + 'box_shadow_position', | |
| 284 | + ], | |
| 285 | + 'selector' => '{{WRAPPER}} .ui-e-grid', | |
| 286 | + 'condition' => [ | |
| 287 | + 'layout!' => 'inner-border' | |
| 288 | + ], | |
| 289 | + ] | |
| 290 | + ); | |
| 291 | + $this->TRAIT_register_logos_image_style_controls('normal'); | |
| 292 | + $this->end_controls_tab(); | |
| 290 | 293 | |
| 291 | - $this->start_controls_tab( | |
| 292 | - 'tab_logos_style_hover', | |
| 293 | - [ | |
| 294 | - 'label' => esc_html__( 'Hover', 'uicore-elements' ), | |
| 294 | + $this->start_controls_tab( | |
| 295 | + 'tab_logos_style_hover', | |
| 296 | + [ | |
| 297 | + 'label' => esc_html__('Hover', 'uicore-elements'), | |
| 298 | + ] | |
| 299 | + ); | |
| 300 | + $this->add_control( | |
| 301 | + 'item_bg_hover_color', | |
| 302 | + [ | |
| 303 | + 'label' => esc_html__('Background Color', 'uicore-elements'), | |
| 304 | + 'type' => Controls_Manager::COLOR, | |
| 305 | + 'selectors' => [ | |
| 306 | + '{{WRAPPER}} .ui-e-item:hover figure' => 'background-color: {{VALUE}};', | |
| 307 | + ], | |
| 308 | + ] | |
| 309 | + ); | |
| 310 | + $this->add_control( | |
| 311 | + 'grid_border_hover_color', | |
| 312 | + [ | |
| 313 | + 'label' => esc_html__('Border Color', 'uicore-elements'), | |
| 314 | + 'type' => Controls_Manager::COLOR, | |
| 315 | + 'selectors' => [ | |
| 316 | + '{{WRAPPER}} .ui-e-item:hover' => 'border-color: {{VALUE}};', | |
| 317 | + ], | |
| 318 | + 'condition' => [ | |
| 319 | + 'item_border_type!' => 'none', | |
| 320 | + 'layout' => 'inner-border', | |
| 295 | 321 | ] |
| 296 | - ); | |
| 297 | - $this->add_control( | |
| 298 | - 'item_bg_hover_color', | |
| 299 | - [ | |
| 300 | - 'label' => esc_html__( 'Background Color', 'uicore-elements' ), | |
| 301 | - 'type' => Controls_Manager::COLOR, | |
| 302 | - 'selectors' => [ | |
| 303 | - '{{WRAPPER}} .ui-e-item:hover figure' => 'background-color: {{VALUE}};', | |
| 304 | - ], | |
| 305 | - ] | |
| 306 | - ); | |
| 307 | - $this->add_control( | |
| 308 | - 'grid_border_hover_color', | |
| 309 | - [ | |
| 310 | - 'label' => esc_html__( 'Border Color', 'uicore-elements' ), | |
| 311 | - 'type' => Controls_Manager::COLOR, | |
| 312 | - 'selectors' => [ | |
| 313 | - '{{WRAPPER}} .ui-e-item:hover' => 'border-color: {{VALUE}};', | |
| 314 | - ], | |
| 315 | - 'condition' => [ | |
| 316 | - 'item_border_type!' => 'none', | |
| 317 | - 'layout' => 'inner-border', | |
| 318 | - ] | |
| 319 | - ] | |
| 320 | - ); | |
| 321 | - $this->TRAIT_register_logos_image_style_controls('hover'); | |
| 322 | - $this->end_controls_tab(); | |
| 322 | + ] | |
| 323 | + ); | |
| 324 | + $this->TRAIT_register_logos_image_style_controls('hover'); | |
| 325 | + $this->end_controls_tab(); | |
| 323 | 326 | |
| 324 | 327 | $this->end_controls_tabs(); |
| 325 | 328 | } |
| 326 | 329 | // Logo Image Styles |
| @@ -325,9 +328,9 @@ | ||
| 325 | 328 | } |
| 326 | 329 | // Logo Image Styles |
| 327 | 330 | protected function TRAIT_register_logos_image_style_controls($state) |
| 328 | 331 | { |
| 329 | - if($state == 'normal'){ | |
| 332 | + if ($state == 'normal') { | |
| 330 | 333 | $this->add_group_control( |
| 331 | 334 | Group_Control_Css_Filter::get_type(), |
| 332 | 335 | [ |
| 333 | 336 | 'name' => 'image_css_filters', |
| @@ -336,11 +339,11 @@ | ||
| 336 | 339 | ); |
| 337 | 340 | $this->add_responsive_control( |
| 338 | 341 | 'image_size', |
| 339 | 342 | [ |
| 340 | - 'label' => esc_html__( 'Image Size', 'uicore-elements' ), | |
| 343 | + 'label' => esc_html__('Image Size', 'uicore-elements'), | |
| 341 | 344 | 'type' => Controls_Manager::SLIDER, |
| 342 | - 'size_units' => [ 'px', '%' ], | |
| 345 | + 'size_units' => ['px', '%'], | |
| 343 | 346 | 'range' => [ |
| 344 | 347 | 'px' => [ |
| 345 | 348 | 'min' => 10, |
| 346 | 349 | 'max' => 500, |
| @@ -354,9 +357,9 @@ | ||
| 354 | 357 | '{{WRAPPER}} img' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; object-fit: contain;' |
| 355 | 358 | ], |
| 356 | 359 | ] |
| 357 | 360 | ); |
| 358 | - } else if ($state == 'hover'){ | |
| 361 | + } else if ($state == 'hover') { | |
| 359 | 362 | $this->add_group_control( |
| 360 | 363 | Group_Control_Css_Filter::get_type(), |
| 361 | 364 | [ |
| 362 | 365 | 'name' => 'image_css_filters_hover', |
| @@ -365,9 +368,9 @@ | ||
| 365 | 368 | ); |
| 366 | 369 | $this->add_control( |
| 367 | 370 | 'image_bg_hover_transition', |
| 368 | 371 | [ |
| 369 | - 'label' => esc_html__( 'Transition Duration', 'uicore-elements' ), | |
| 372 | + 'label' => esc_html__('Transition Duration', 'uicore-elements'), | |
| 370 | 373 | 'type' => Controls_Manager::SLIDER, |
| 371 | 374 | 'range' => [ |
| 372 | 375 | 'px' => [ |
| 373 | 376 | 'max' => 3, |
| @@ -378,9 +381,9 @@ | ||
| 378 | 381 | '{{WRAPPER}} figure img' => 'transition-duration: {{SIZE}}s;', |
| 379 | 382 | ], |
| 380 | 383 | ] |
| 381 | 384 | ); |
| 382 | - } else if($state == 'active'){ | |
| 385 | + } else if ($state == 'active') { | |
| 383 | 386 | $this->add_group_control( |
| 384 | 387 | Group_Control_Css_Filter::get_type(), |
| 385 | 388 | [ |
| 386 | 389 | 'name' => 'image_css_filters_active', |
| @@ -396,28 +399,28 @@ | ||
| 396 | 399 | $image = wp_get_attachment_image_url($data['id'], $size); |
| 397 | 400 | $name = isset($data['name']) ? $data['name'] : ''; |
| 398 | 401 | $desc = isset($data['description']) ? $data['description'] : ''; |
| 399 | 402 | $alt = $name . ' : ' . $desc; |
| 400 | - ?> | |
| 401 | - <figure class="<?php echo esc_attr($this->get_settings_for_display('logo_hover_animation'));?>"> | |
| 403 | +?> | |
| 404 | + <figure class="<?php echo esc_attr($this->get_settings_for_display('logo_hover_animation')); ?>"> | |
| 402 | 405 | <?php |
| 403 | - if($image) { | |
| 404 | - echo wp_get_attachment_image( | |
| 405 | - $data['id'], | |
| 406 | - $size, | |
| 407 | - false, | |
| 408 | - ['alt' => esc_attr( $alt )] | |
| 409 | - ); | |
| 410 | - } else { | |
| 411 | - printf( | |
| 412 | - '<img src="%s" alt="%s">', | |
| 413 | - esc_url( Utils::get_placeholder_image_src()), | |
| 414 | - esc_attr( $alt ) | |
| 415 | - ); | |
| 416 | - } | |
| 417 | - ?> | |
| 406 | + if ($image) { | |
| 407 | + echo wp_get_attachment_image( | |
| 408 | + $data['id'], | |
| 409 | + $size, | |
| 410 | + false, | |
| 411 | + ['alt' => esc_attr($alt)] | |
| 412 | + ); | |
| 413 | + } else { | |
| 414 | + printf( | |
| 415 | + '<img src="%s" alt="%s">', | |
| 416 | + esc_url(Utils::get_placeholder_image_src()), | |
| 417 | + esc_attr($alt) | |
| 418 | + ); | |
| 419 | + } | |
| 420 | + ?> | |
| 418 | 421 | </figure> |
| 419 | - <?php | |
| 422 | + <?php | |
| 420 | 423 | } |
| 421 | 424 | protected function TRAIT_render_logo_item() |
| 422 | 425 | { |
| 423 | 426 | $settings = $this->get_settings_for_display(); |
| @@ -422,9 +425,9 @@ | ||
| 422 | 425 | { |
| 423 | 426 | $settings = $this->get_settings_for_display(); |
| 424 | 427 | |
| 425 | 428 | // Get entrance and item hover animation classes |
| 426 | - $entrance = (isset($settings['animate_items']) && $settings['animate_items'] == 'ui-e-grid-animate') ? 'elementor-invisible' : ''; | |
| 429 | + $entrance = $this->is_option('animate_items', 'ui-e-grid-animate') ? 'elementor-invisible' : ''; | |
| 427 | 430 | $hover = isset($settings['item_hover_animation']) ? $settings['item_hover_animation'] : null; |
| 428 | 431 | $animations = sprintf('%s %s', $entrance, $hover); |
| 429 | 432 | |
| 430 | 433 | // Check if any animation that relies on the animation wrapper is set |
| @@ -437,49 +440,36 @@ | ||
| 437 | 440 | 'class' => $is_carousel ? 'ui-e-wrp swiper-slide' : 'ui-e-wrp', |
| 438 | 441 | ], |
| 439 | 442 | ]); |
| 440 | 443 | |
| 441 | - foreach ( $settings['logo_list'] as $index => $item ) { | |
| 444 | + foreach ($settings['logo_list'] as $index => $item) { | |
| 442 | 445 | $this->render_logo($index, $item, $settings, $has_animation, $animations); |
| 443 | 446 | } |
| 444 | - | |
| 445 | - if( $is_carousel ){ | |
| 446 | - | |
| 447 | - $total_slides = count($settings['logo_list']); | |
| 448 | - | |
| 449 | - // Most recent swiper versions requires, if loop, at least one extra slide compared to visible slides | |
| 450 | - if( $this->TRAIT_should_duplicate_slides($total_slides)) { | |
| 451 | - $diff = $this->TRAIT_get_duplication_diff($total_slides); | |
| 452 | - for($i = 0; $i <= $diff; $i++){ | |
| 453 | - $this->render_logo($index, $item, $settings, $has_animation, $animations); | |
| 454 | - } | |
| 455 | - } | |
| 456 | - } | |
| 457 | 447 | } |
| 458 | 448 | |
| 459 | 449 | protected function render_logo($index, $item, $settings, $has_animation, $animations) |
| 460 | 450 | { |
| 461 | 451 | // Params |
| 462 | - $key = 'logo_'.$index; | |
| 463 | - $tag = 'div '; | |
| 464 | - $this->add_render_attribute($key, 'class', 'ui-e-item' ); | |
| 452 | + $key = 'logo_' . $index; | |
| 453 | + $tag = 'div'; | |
| 454 | + $this->add_render_attribute($key, 'class', 'ui-e-item'); | |
| 465 | 455 | |
| 466 | 456 | // Build URL |
| 467 | 457 | if (!empty($item['link']['url'])) { |
| 468 | - $tag = 'a '; | |
| 469 | - $this->add_link_attributes($key, $item['link'] ); | |
| 458 | + $tag = 'a'; | |
| 459 | + $this->add_link_attributes($key, $item['link']); | |
| 470 | 460 | } |
| 471 | - ?> | |
| 461 | + ?> | |
| 472 | 462 | <div <?php $this->print_render_attribute_string('wrapper'); ?>> |
| 473 | - <?php if($has_animation) : ?> | |
| 474 | - <div class='ui-e-animations-wrp <?php echo esc_attr($animations);?>'> | |
| 475 | - <?php endif; ?> | |
| 476 | - <<?php echo esc_html($tag);?> <?php $this->print_render_attribute_string($key); ?>> | |
| 463 | + <?php if ($has_animation) : ?> | |
| 464 | + <div class='ui-e-animations-wrp <?php echo esc_attr($animations); ?>'> | |
| 465 | + <?php endif; ?> | |
| 466 | + <<?php echo Helper::esc_tag($tag); ?> <?php $this->print_render_attribute_string($key); ?>> | |
| 477 | 467 | <?php $this->render_logo_figure($item['image'], $settings['thumbnail_size']); ?> |
| 478 | - </<?php echo esc_html($tag);?>> | |
| 479 | - <?php if($has_animation) : ?> | |
| 468 | + </<?php echo Helper::esc_tag($tag); ?>> | |
| 469 | + <?php if ($has_animation) : ?> | |
| 480 | 470 | </div> |
| 481 | 471 | <?php endif; ?> |
| 482 | 472 | </div> |
| 483 | - <?php | |
| 473 | +<?php | |
| 484 | 474 | } |
| 485 | -} | |
| 475 | +} | |