← All changes
|
modules/atomic-widgets/elements/atomic-button/atomic-button.php
+10
-56
4.2.0-dev2
→
3.29.0-dev4
View file →
| @@ -2,17 +2,14 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Button; |
| 4 | 4 | |
| 5 | 5 | use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; |
| 6 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control; | |
| 7 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base; | |
| 6 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; | |
| 8 | 7 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 9 | 8 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 10 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template; | |
| 9 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 11 | 10 | use Elementor\Modules\AtomicWidgets\PropTypes\Background_Prop_Type; |
| 12 | -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; | |
| 13 | 11 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 14 | -use Elementor\Modules\AtomicWidgets\PropTypes\Html_V3_Prop_Type; | |
| 15 | 12 | use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type; |
| 16 | 13 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 17 | 14 | use Elementor\Modules\AtomicWidgets\PropTypes\Dimensions_Prop_Type; |
| 18 | 15 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| @@ -18,9 +15,8 @@ | ||
| 18 | 15 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 19 | 16 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 20 | 17 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 21 | 18 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 22 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 23 | 19 | |
| 24 | 20 | if ( ! defined( 'ABSPATH' ) ) { |
| 25 | 21 | exit; |
| 26 | 22 | } |
| @@ -44,30 +40,17 @@ | ||
| 44 | 40 | return 'eicon-e-button'; |
| 45 | 41 | } |
| 46 | 42 | |
| 47 | 43 | protected static function define_props_schema(): array { |
| 48 | - $props = [ | |
| 44 | + return [ | |
| 49 | 45 | 'classes' => Classes_Prop_Type::make() |
| 50 | 46 | ->default( [] ), |
| 51 | 47 | |
| 52 | - 'text' => Html_V3_Prop_Type::make() | |
| 53 | - ->default( [ | |
| 54 | - 'content' => String_Prop_Type::generate( __( 'Click here', 'elementor' ) ), | |
| 55 | - 'children' => [], | |
| 56 | - ] ) | |
| 57 | - ->description( 'The text displayed on the button.' ) | |
| 58 | - ->alias( 'content', 'label' ), | |
| 48 | + 'text' => String_Prop_Type::make() | |
| 49 | + ->default( __( 'Click here', 'elementor' ) ), | |
| 59 | 50 | |
| 60 | 51 | 'link' => Link_Prop_Type::make(), |
| 61 | - | |
| 62 | - 'tag' => String_Prop_Type::make() | |
| 63 | - ->default( 'button' ) | |
| 64 | - ->description( 'The HTML tag for the button element.' ), | |
| 65 | - | |
| 66 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 67 | 52 | ]; |
| 68 | - | |
| 69 | - return $props; | |
| 70 | 53 | } |
| 71 | 54 | |
| 72 | 55 | protected function define_atomic_controls(): array { |
| 73 | 56 | return [ |
| @@ -72,32 +55,18 @@ | ||
| 72 | 55 | protected function define_atomic_controls(): array { |
| 73 | 56 | return [ |
| 74 | 57 | Section::make() |
| 75 | 58 | ->set_label( __( 'Content', 'elementor' ) ) |
| 76 | - ->set_id( 'content' ) | |
| 77 | 59 | ->set_items( [ |
| 78 | - Inline_Editing_Control::bind_to( 'text' ) | |
| 79 | - ->set_placeholder( __( 'Type your button text here', 'elementor' ) ) | |
| 80 | - ->set_label( __( 'Button text', 'elementor' ) ), | |
| 60 | + Text_Control::bind_to( 'text' ) | |
| 61 | + ->set_label( __( 'Button text', 'elementor' ) ) | |
| 62 | + ->set_placeholder( __( 'Type your button text here', 'elementor' ) ), | |
| 63 | + | |
| 64 | + Link_Control::bind_to( 'link' ), | |
| 81 | 65 | ] ), |
| 82 | - Section::make() | |
| 83 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 84 | - ->set_id( 'settings' ) | |
| 85 | - ->set_items( $this->get_settings_controls() ), | |
| 86 | 66 | ]; |
| 87 | 67 | } |
| 88 | 68 | |
| 89 | - protected function get_settings_controls(): array { | |
| 90 | - return [ | |
| 91 | - Link_Control::bind_to( 'link' ) | |
| 92 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 93 | - ->set_label( __( 'Link', 'elementor' ) ), | |
| 94 | - Text_Control::bind_to( '_cssid' ) | |
| 95 | - ->set_label( __( 'ID', 'elementor' ) ) | |
| 96 | - ->set_meta( $this->get_css_id_control_meta() ), | |
| 97 | - ]; | |
| 98 | - } | |
| 99 | - | |
| 100 | 69 | protected function define_base_styles(): array { |
| 101 | 70 | $background_color_value = Background_Prop_Type::generate( [ |
| 102 | 71 | 'color' => Color_Prop_Type::generate( '#375EFB' ), |
| 103 | 72 | ] ); |
| @@ -147,21 +116,6 @@ | ||
| 147 | 116 | protected function get_templates(): array { |
| 148 | 117 | return [ |
| 149 | 118 | 'elementor/elements/atomic-button' => __DIR__ . '/atomic-button.html.twig', |
| 150 | 119 | ]; |
| 151 | - } | |
| 152 | - | |
| 153 | - public function render_markdown(): string { | |
| 154 | - $settings = $this->get_atomic_settings(); | |
| 155 | - $text = wp_strip_all_tags( $settings['text'] ?? '' ); | |
| 156 | - | |
| 157 | - if ( empty( $text ) ) { | |
| 158 | - return ''; | |
| 159 | - } | |
| 160 | - | |
| 161 | - if ( ! empty( $settings['link']['href'] ) ) { | |
| 162 | - return '[' . $text . '](' . esc_url( $settings['link']['href'] ) . ')'; | |
| 163 | - } | |
| 164 | - | |
| 165 | - return '**' . $text . '**'; | |
| 166 | 120 | } |
| 167 | 121 | } |