| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -namespace Easyel\EasyElements\Widgets; | |
| 3 | 2 | use Elementor\Controls_Manager; |
| 4 | 3 | use Elementor\Group_Control_Image_Size; |
| 5 | 4 | use Elementor\Utils; |
| 6 | 5 | |
| @@ -28,15 +27,31 @@ | ||
| 28 | 27 | return [ 'gallery', 'image', 'photo', 'portfolio' ]; |
| 29 | 28 | } |
| 30 | 29 | |
| 31 | 30 | public function get_style_depends() { |
| 32 | - | |
| 33 | - return [ 'eel-gallery' ]; | |
| 31 | + $handle = 'eel-gallery-style'; | |
| 32 | + $css_path = plugin_dir_path( __FILE__ ) . 'css/gallery.css'; | |
| 33 | + if ( ! wp_style_is( $handle, 'registered' ) && file_exists( $css_path ) ) { | |
| 34 | + wp_register_style( | |
| 35 | + $handle, | |
| 36 | + plugins_url( 'css/gallery.css', __FILE__ ), | |
| 37 | + [], | |
| 38 | + defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $css_path ) : '1.0.0' | |
| 39 | + ); | |
| 40 | + } | |
| 41 | + return [ $handle ]; | |
| 34 | 42 | } |
| 35 | 43 | |
| 36 | 44 | public function get_script_depends() { |
| 37 | - | |
| 38 | - return [ 'eel-gallery' ]; | |
| 45 | + $handle = 'eel-simple-gallery-script'; | |
| 46 | + $js_path = plugin_dir_path( __FILE__ ) . 'js/simple-gallery.js'; | |
| 47 | + | |
| 48 | + // Normal script loading | |
| 49 | + if ( ! wp_script_is( $handle, 'registered' ) && file_exists( $js_path ) ) { | |
| 50 | + wp_register_script( $handle, plugins_url( 'js/simple-gallery.js', __FILE__ ), [], defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $js_path ) : '1.0.0', true ); | |
| 51 | + } | |
| 52 | + | |
| 53 | + return [ $handle ]; | |
| 39 | 54 | } |
| 40 | 55 | |
| 41 | 56 | protected function register_controls() { |
| 42 | 57 | |
| @@ -181,15 +196,15 @@ | ||
| 181 | 196 | 'hover_style' => 'icon', |
| 182 | 197 | ], |
| 183 | 198 | ] |
| 184 | 199 | ); |
| 185 | - | |
| 200 | + | |
| 186 | 201 | $this->end_controls_section(); |
| 187 | 202 | |
| 188 | 203 | $this->start_controls_section( |
| 189 | - 'section_item_style', | |
| 204 | + 'section_image_style', | |
| 190 | 205 | [ |
| 191 | - 'label' => esc_html__('Items', 'easy-elements'), | |
| 206 | + 'label' => esc_html__('Images', 'easy-elements'), | |
| 192 | 207 | 'tab' => Controls_Manager::TAB_STYLE, |
| 193 | 208 | ] |
| 194 | 209 | ); |
| 195 | 210 | |
| @@ -208,18 +223,8 @@ | ||
| 208 | 223 | ], |
| 209 | 224 | ] |
| 210 | 225 | ); |
| 211 | 226 | |
| 212 | - $this->end_controls_section(); | |
| 213 | - | |
| 214 | - $this->start_controls_section( | |
| 215 | - 'section_image_style', | |
| 216 | - [ | |
| 217 | - 'label' => esc_html__('Images', 'easy-elements'), | |
| 218 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 219 | - ] | |
| 220 | - ); | |
| 221 | - | |
| 222 | 227 | $this->add_responsive_control( |
| 223 | 228 | 'image_height', |
| 224 | 229 | [ |
| 225 | 230 | 'label' => esc_html__( 'Height', 'easy-elements' ), |
| @@ -256,8 +261,20 @@ | ||
| 256 | 261 | ], |
| 257 | 262 | ] |
| 258 | 263 | ); |
| 259 | 264 | |
| 265 | + $this->add_responsive_control( | |
| 266 | + 'image_border_padding', | |
| 267 | + [ | |
| 268 | + 'label' => esc_html__( 'Padding', 'easy-elements' ), | |
| 269 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 270 | + 'size_units' => [ 'px', '%' ], | |
| 271 | + 'selectors' => [ | |
| 272 | + '{{WRAPPER}} .eel-gallery-item img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 273 | + ], | |
| 274 | + ] | |
| 275 | + ); | |
| 276 | + | |
| 260 | 277 | $this->end_controls_section(); |
| 261 | 278 | |
| 262 | 279 | $this->start_controls_section( |
| 263 | 280 | 'section_caption_style', |
| @@ -339,9 +356,9 @@ | ||
| 339 | 356 | 'hover_style' => 'icon', |
| 340 | 357 | ], |
| 341 | 358 | ] |
| 342 | 359 | ); |
| 343 | - $this->add_responsive_control( | |
| 360 | + $this->add_control( | |
| 344 | 361 | 'hover_icon_size', |
| 345 | 362 | [ |
| 346 | 363 | 'label' => esc_html__( 'Icon Size', 'easy-elements' ), |
| 347 | 364 | 'type' => \Elementor\Controls_Manager::SLIDER, |
| @@ -484,9 +501,9 @@ | ||
| 484 | 501 | |
| 485 | 502 | // === Lightbox === |
| 486 | 503 | if ( $popup_enabled ) : |
| 487 | 504 | ?> |
| 488 | - <div class="eel-lightbox-gallery"> | |
| 505 | + <div class="eel-lightbox"> | |
| 489 | 506 | <span class="eel-close">×</span> |
| 490 | 507 | <img class="eel-lightbox-image" src="" alt=""> |
| 491 | 508 | <button class="eel-prev">❮</button> |
| 492 | 509 | <button class="eel-next">❯</button> |
| @@ -495,5 +512,5 @@ | ||
| 495 | 512 | endif; |
| 496 | 513 | } |
| 497 | 514 | |
| 498 | 515 | |
| 499 | -} | |
| 516 | +} ?> | |