← All changes
|
modules/atomic-widgets/elements/atomic-image/atomic-image.php
+11
-48
4.1.3
→
3.29.0-beta4
View file →
| @@ -1,21 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Image; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 5 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template; | |
| 5 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 6 | 6 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 7 | 7 | use Elementor\Modules\AtomicWidgets\PropTypes\Image_Prop_Type; |
| 8 | 8 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 9 | 9 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 10 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base; | |
| 11 | -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; | |
| 10 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; | |
| 12 | 11 | use Elementor\Modules\AtomicWidgets\Controls\Types\Image_Control; |
| 13 | -use Elementor\Modules\AtomicWidgets\Utils\Image\Placeholder_Image; | |
| 12 | +use Elementor\Modules\AtomicWidgets\Image\Placeholder_Image; | |
| 14 | 13 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 15 | 14 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 16 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; | |
| 17 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 18 | 15 | |
| 19 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 20 | 17 | exit; // Exit if accessed directly. |
| 21 | 18 | } |
| @@ -22,10 +19,8 @@ | ||
| 22 | 19 | |
| 23 | 20 | class Atomic_Image extends Atomic_Widget_Base { |
| 24 | 21 | use Has_Template; |
| 25 | 22 | |
| 26 | - public static $widget_description = 'Display an image with customizable styles and link options.'; | |
| 27 | - | |
| 28 | 23 | const LINK_BASE_STYLE_KEY = 'link-base'; |
| 29 | 24 | const BASE_STYLE_KEY = 'base'; |
| 30 | 25 | |
| 31 | 26 | public static function get_element_type(): string { |
| @@ -44,9 +39,9 @@ | ||
| 44 | 39 | return 'eicon-e-image'; |
| 45 | 40 | } |
| 46 | 41 | |
| 47 | 42 | protected static function define_props_schema(): array { |
| 48 | - $props = [ | |
| 43 | + return [ | |
| 49 | 44 | 'classes' => Classes_Prop_Type::make() |
| 50 | 45 | ->default( [] ), |
| 51 | 46 | |
| 52 | 47 | 'image' => Image_Prop_Type::make() |
| @@ -53,38 +48,21 @@ | ||
| 53 | 48 | ->default_url( Placeholder_Image::get_placeholder_image() ) |
| 54 | 49 | ->default_size( 'full' ), |
| 55 | 50 | |
| 56 | 51 | 'link' => Link_Prop_Type::make(), |
| 57 | - | |
| 58 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 59 | 52 | ]; |
| 60 | - | |
| 61 | - return $props; | |
| 62 | 53 | } |
| 63 | 54 | |
| 64 | 55 | protected function define_atomic_controls(): array { |
| 65 | - return [ | |
| 66 | - Section::make() | |
| 67 | - ->set_label( esc_html__( 'Content', 'elementor' ) ) | |
| 68 | - ->set_items( [ | |
| 69 | - Image_Control::bind_to( 'image' ) | |
| 70 | - ->set_label( __( 'Image', 'elementor' ) ), | |
| 71 | - ] ), | |
| 72 | - Section::make() | |
| 73 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 74 | - ->set_id( 'settings' ) | |
| 75 | - ->set_items( $this->get_settings_controls() ), | |
| 76 | - ]; | |
| 77 | - } | |
| 56 | + $content_section = Section::make() | |
| 57 | + ->set_label( esc_html__( 'Content', 'elementor' ) ) | |
| 58 | + ->set_items( [ | |
| 59 | + Image_Control::bind_to( 'image' ), | |
| 60 | + Link_Control::bind_to( 'link' ), | |
| 61 | + ] ); | |
| 78 | 62 | |
| 79 | - protected function get_settings_controls(): array { | |
| 80 | 63 | return [ |
| 81 | - Link_Control::bind_to( 'link' ) | |
| 82 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 83 | - ->set_label( __( 'Link', 'elementor' ) ), | |
| 84 | - Text_Control::bind_to( '_cssid' ) | |
| 85 | - ->set_label( __( 'ID', 'elementor' ) ) | |
| 86 | - ->set_meta( $this->get_css_id_control_meta() ), | |
| 64 | + $content_section, | |
| 87 | 65 | ]; |
| 88 | 66 | } |
| 89 | 67 | |
| 90 | 68 | protected function define_base_styles(): array { |
| @@ -91,12 +69,10 @@ | ||
| 91 | 69 | return [ |
| 92 | 70 | self::LINK_BASE_STYLE_KEY => Style_Definition::make() |
| 93 | 71 | ->add_variant( |
| 94 | 72 | Style_Variant::make() |
| 95 | - ->add_prop( 'all', 'unset' ) | |
| 96 | 73 | ->add_prop( 'display', 'inherit' ) |
| 97 | 74 | ->add_prop( 'width', 'fit-content' ) |
| 98 | - ->add_prop( 'cursor', 'pointer' ) | |
| 99 | 75 | ), |
| 100 | 76 | self::BASE_STYLE_KEY => Style_Definition::make() |
| 101 | 77 | ->add_variant( |
| 102 | 78 | Style_Variant::make() |
| @@ -108,19 +84,6 @@ | ||
| 108 | 84 | protected function get_templates(): array { |
| 109 | 85 | return [ |
| 110 | 86 | 'elementor/elements/atomic-image' => __DIR__ . '/atomic-image.html.twig', |
| 111 | 87 | ]; |
| 112 | - } | |
| 113 | - | |
| 114 | - public function render_markdown(): string { | |
| 115 | - $settings = $this->get_atomic_settings(); | |
| 116 | - $src = $settings['image']['src'] ?? ''; | |
| 117 | - | |
| 118 | - if ( empty( $src ) ) { | |
| 119 | - return ''; | |
| 120 | - } | |
| 121 | - | |
| 122 | - $alt = $settings['image']['alt'] ?? ''; | |
| 123 | - | |
| 124 | - return ' . ')'; | |
| 125 | 88 | } |
| 126 | 89 | } |