← All changes
|
modules/atomic-widgets/elements/atomic-image/atomic-image.php
+36
-57
4.3.1
→
3.30.1
View file →
| @@ -1,22 +1,22 @@ | ||
| 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\Controls\Types\Text_Control; | |
| 6 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 7 | +use Elementor\Modules\AtomicWidgets\Module; | |
| 6 | 8 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 7 | 9 | use Elementor\Modules\AtomicWidgets\PropTypes\Image_Prop_Type; |
| 8 | 10 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 9 | 11 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 10 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base; | |
| 11 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer; | |
| 12 | -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; | |
| 12 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; | |
| 13 | 13 | use Elementor\Modules\AtomicWidgets\Controls\Types\Image_Control; |
| 14 | -use Elementor\Modules\AtomicWidgets\Utils\Image\Placeholder_Image; | |
| 14 | +use Elementor\Modules\AtomicWidgets\Image\Placeholder_Image; | |
| 15 | +use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; | |
| 15 | 16 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 16 | 17 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 17 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; | |
| 18 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 18 | +use Elementor\Plugin; | |
| 19 | 19 | |
| 20 | 20 | if ( ! defined( 'ABSPATH' ) ) { |
| 21 | 21 | exit; // Exit if accessed directly. |
| 22 | 22 | } |
| @@ -23,10 +23,8 @@ | ||
| 23 | 23 | |
| 24 | 24 | class Atomic_Image extends Atomic_Widget_Base { |
| 25 | 25 | use Has_Template; |
| 26 | 26 | |
| 27 | - public static $widget_description = 'Display an image with customizable styles and link options.'; | |
| 28 | - | |
| 29 | 27 | const LINK_BASE_STYLE_KEY = 'link-base'; |
| 30 | 28 | const BASE_STYLE_KEY = 'base'; |
| 31 | 29 | |
| 32 | 30 | public static function get_element_type(): string { |
| @@ -37,9 +35,9 @@ | ||
| 37 | 35 | return esc_html__( 'Image', 'elementor' ); |
| 38 | 36 | } |
| 39 | 37 | |
| 40 | 38 | public function get_keywords() { |
| 41 | - return [ 'ato', 'atom', 'atoms', 'atomic', 'image', 'photo', 'picture' ]; | |
| 39 | + return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 42 | 40 | } |
| 43 | 41 | |
| 44 | 42 | public function get_icon() { |
| 45 | 43 | return 'eicon-e-image'; |
| @@ -44,18 +42,8 @@ | ||
| 44 | 42 | public function get_icon() { |
| 45 | 43 | return 'eicon-e-image'; |
| 46 | 44 | } |
| 47 | 45 | |
| 48 | - public static function html_tag_follows_link(): bool { | |
| 49 | - return false; | |
| 50 | - } | |
| 51 | - | |
| 52 | - public static function get_computed_html_tag( array $settings ): string { | |
| 53 | - return Html_Tag_Computer::compute( $settings, 'img', [ | |
| 54 | - Html_Tag_Computer::FOLLOW_LINK_OPTION => static::html_tag_follows_link(), | |
| 55 | - ] ); | |
| 56 | - } | |
| 57 | - | |
| 58 | 46 | protected static function define_props_schema(): array { |
| 59 | 47 | $props = [ |
| 60 | 48 | 'classes' => Classes_Prop_Type::make() |
| 61 | 49 | ->default( [] ), |
| @@ -64,39 +52,45 @@ | ||
| 64 | 52 | ->default_url( Placeholder_Image::get_placeholder_image() ) |
| 65 | 53 | ->default_size( 'full' ), |
| 66 | 54 | |
| 67 | 55 | 'link' => Link_Prop_Type::make(), |
| 56 | + ]; | |
| 68 | 57 | |
| 69 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 70 | - ]; | |
| 58 | + if ( Plugin::$instance->experiments->is_feature_active( Module::EXPERIMENT_VERSION_3_30 ) ) { | |
| 59 | + $props['_cssid'] = String_Prop_Type::make(); | |
| 60 | + } | |
| 71 | 61 | |
| 72 | 62 | return $props; |
| 73 | 63 | } |
| 74 | 64 | |
| 75 | 65 | protected function define_atomic_controls(): array { |
| 76 | - return [ | |
| 77 | - Section::make() | |
| 78 | - ->set_label( esc_html__( 'Content', 'elementor' ) ) | |
| 79 | - ->set_id( 'content' ) | |
| 80 | - ->set_items( [ | |
| 81 | - Image_Control::bind_to( 'image' ) | |
| 82 | - ->set_label( __( 'Image', 'elementor' ) ), | |
| 83 | - ] ), | |
| 84 | - Section::make() | |
| 85 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 86 | - ->set_id( 'settings' ) | |
| 87 | - ->set_items( $this->get_settings_controls() ), | |
| 66 | + $content_section = Section::make() | |
| 67 | + ->set_label( esc_html__( 'Content', 'elementor' ) ) | |
| 68 | + ->set_items( [ | |
| 69 | + Image_Control::bind_to( 'image' ) | |
| 70 | + ->set_show_mode( 'media' ), | |
| 71 | + ] ); | |
| 72 | + | |
| 73 | + $settings_section_items = [ | |
| 74 | + Image_Control::bind_to( 'image' ) | |
| 75 | + ->set_show_mode( 'sizes' ), | |
| 76 | + Link_Control::bind_to( 'link' )->set_meta( [ | |
| 77 | + 'topDivider' => true, | |
| 78 | + ] ), | |
| 88 | 79 | ]; |
| 89 | - } | |
| 90 | 80 | |
| 91 | - protected function get_settings_controls(): array { | |
| 81 | + if ( Plugin::$instance->experiments->is_feature_active( Module::EXPERIMENT_VERSION_3_30 ) ) { | |
| 82 | + $settings_section_items[] = Text_Control::bind_to( '_cssid' )->set_label( __( 'ID', 'elementor' ) )->set_meta( [ | |
| 83 | + 'layout' => 'two-columns', | |
| 84 | + 'topDivider' => true, | |
| 85 | + ] ); | |
| 86 | + } | |
| 87 | + | |
| 92 | 88 | return [ |
| 93 | - Link_Control::bind_to( 'link' ) | |
| 94 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 95 | - ->set_label( __( 'Link', 'elementor' ) ), | |
| 96 | - Text_Control::bind_to( '_cssid' ) | |
| 97 | - ->set_label( __( 'ID', 'elementor' ) ) | |
| 98 | - ->set_meta( $this->get_css_id_control_meta() ), | |
| 89 | + $content_section, | |
| 90 | + Section::make() | |
| 91 | + ->set_label( esc_html__( 'Settings', 'elementor' ) ) | |
| 92 | + ->set_items( $settings_section_items ), | |
| 99 | 93 | ]; |
| 100 | 94 | } |
| 101 | 95 | |
| 102 | 96 | protected function define_base_styles(): array { |
| @@ -103,12 +97,10 @@ | ||
| 103 | 97 | return [ |
| 104 | 98 | self::LINK_BASE_STYLE_KEY => Style_Definition::make() |
| 105 | 99 | ->add_variant( |
| 106 | 100 | Style_Variant::make() |
| 107 | - ->add_prop( 'all', 'unset' ) | |
| 108 | 101 | ->add_prop( 'display', 'inherit' ) |
| 109 | 102 | ->add_prop( 'width', 'fit-content' ) |
| 110 | - ->add_prop( 'cursor', 'pointer' ) | |
| 111 | 103 | ), |
| 112 | 104 | self::BASE_STYLE_KEY => Style_Definition::make() |
| 113 | 105 | ->add_variant( |
| 114 | 106 | Style_Variant::make() |
| @@ -120,19 +112,6 @@ | ||
| 120 | 112 | protected function get_templates(): array { |
| 121 | 113 | return [ |
| 122 | 114 | 'elementor/elements/atomic-image' => __DIR__ . '/atomic-image.html.twig', |
| 123 | 115 | ]; |
| 124 | - } | |
| 125 | - | |
| 126 | - public function render_markdown(): string { | |
| 127 | - $settings = $this->get_atomic_settings(); | |
| 128 | - $src = $settings['image']['src'] ?? ''; | |
| 129 | - | |
| 130 | - if ( empty( $src ) ) { | |
| 131 | - return ''; | |
| 132 | - } | |
| 133 | - | |
| 134 | - $alt = $settings['image']['alt'] ?? ''; | |
| 135 | - | |
| 136 | - return ' . ')'; | |
| 137 | 116 | } |
| 138 | 117 | } |