← All changes
|
modules/atomic-widgets/elements/atomic-heading/atomic-heading.php
+41
-72
4.0.9
→
3.29.0-beta4
View file →
| @@ -1,23 +1,20 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Heading; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 5 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control; | |
| 6 | 5 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 7 | 6 | use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control; |
| 8 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; | |
| 9 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base; | |
| 10 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template; | |
| 11 | -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; | |
| 7 | +use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control; | |
| 8 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; | |
| 9 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 12 | 10 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 13 | -use Elementor\Modules\AtomicWidgets\PropTypes\Html_V3_Prop_Type; | |
| 11 | +use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type; | |
| 14 | 12 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 15 | 13 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 16 | 14 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 17 | 15 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 18 | 16 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 19 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 20 | 17 | |
| 21 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 22 | 19 | exit; // Exit if accessed directly. |
| 23 | 20 | } |
| @@ -26,10 +23,8 @@ | ||
| 26 | 23 | use Has_Template; |
| 27 | 24 | |
| 28 | 25 | const LINK_BASE_STYLE_KEY = 'link-base'; |
| 29 | 26 | |
| 30 | - public static $widget_description = 'Display a heading with customizable tag, styles, and link options.'; | |
| 31 | - | |
| 32 | 27 | public static function get_element_type(): string { |
| 33 | 28 | return 'e-heading'; |
| 34 | 29 | } |
| 35 | 30 | |
| @@ -51,81 +46,55 @@ | ||
| 51 | 46 | ->default( [] ), |
| 52 | 47 | |
| 53 | 48 | 'tag' => String_Prop_Type::make() |
| 54 | 49 | ->enum( [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] ) |
| 55 | - ->default( 'h2' ) | |
| 56 | - ->description( 'The HTML tag for the heading element. Could be h1, h2, up to h6' ), | |
| 50 | + ->default( 'h2' ), | |
| 57 | 51 | |
| 58 | - 'title' => Html_V3_Prop_Type::make() | |
| 59 | - ->default( [ | |
| 60 | - 'content' => String_Prop_Type::generate( __( 'This is a title', 'elementor' ) ), | |
| 61 | - 'children' => [], | |
| 62 | - ] ) | |
| 63 | - ->description( 'The text content of the heading.' ), | |
| 52 | + 'title' => String_Prop_Type::make() | |
| 53 | + ->default( __( 'This is a title', 'elementor' ) ), | |
| 64 | 54 | |
| 65 | 55 | 'link' => Link_Prop_Type::make(), |
| 66 | - | |
| 67 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 68 | 56 | ]; |
| 69 | 57 | } |
| 70 | 58 | |
| 71 | 59 | protected function define_atomic_controls(): array { |
| 72 | - $content_section = Section::make() | |
| 73 | - ->set_label( __( 'Content', 'elementor' ) ) | |
| 74 | - ->set_items( [ | |
| 75 | - Inline_Editing_Control::bind_to( 'title' ) | |
| 76 | - ->set_placeholder( __( 'Type your title here', 'elementor' ) ) | |
| 77 | - ->set_label( __( 'Title', 'elementor' ) ), | |
| 78 | - ] ); | |
| 79 | - | |
| 80 | 60 | return [ |
| 81 | - $content_section, | |
| 82 | 61 | Section::make() |
| 83 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 84 | - ->set_id( 'settings' ) | |
| 85 | - ->set_items( $this->get_settings_controls() ), | |
| 86 | - ]; | |
| 87 | - } | |
| 88 | - | |
| 89 | - protected function get_settings_controls(): array { | |
| 90 | - return [ | |
| 91 | - Select_Control::bind_to( 'tag' ) | |
| 92 | - ->set_options([ | |
| 93 | - [ | |
| 94 | - 'value' => 'h1', | |
| 95 | - 'label' => 'H1', | |
| 96 | - ], | |
| 97 | - [ | |
| 98 | - 'value' => 'h2', | |
| 99 | - 'label' => 'H2', | |
| 100 | - ], | |
| 101 | - [ | |
| 102 | - 'value' => 'h3', | |
| 103 | - 'label' => 'H3', | |
| 104 | - ], | |
| 105 | - [ | |
| 106 | - 'value' => 'h4', | |
| 107 | - 'label' => 'H4', | |
| 108 | - ], | |
| 109 | - [ | |
| 110 | - 'value' => 'h5', | |
| 111 | - 'label' => 'H5', | |
| 112 | - ], | |
| 113 | - [ | |
| 114 | - 'value' => 'h6', | |
| 115 | - 'label' => 'H6', | |
| 116 | - ], | |
| 117 | - ]) | |
| 118 | - ->set_label( __( 'Tag', 'elementor' ) ), | |
| 119 | - Link_Control::bind_to( 'link' ) | |
| 120 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 121 | - ->set_label( __( 'Link', 'elementor' ) ) | |
| 122 | - ->set_meta( [ | |
| 123 | - 'topDivider' => true, | |
| 62 | + ->set_label( __( 'Content', 'elementor' ) ) | |
| 63 | + ->set_items( [ | |
| 64 | + Textarea_Control::bind_to( 'title' ) | |
| 65 | + ->set_label( __( 'Title', 'elementor' ) ) | |
| 66 | + ->set_placeholder( __( 'Type your title here', 'elementor' ) ), | |
| 67 | + Select_Control::bind_to( 'tag' ) | |
| 68 | + ->set_label( esc_html__( 'Tag', 'elementor' ) ) | |
| 69 | + ->set_options( [ | |
| 70 | + [ | |
| 71 | + 'value' => 'h1', | |
| 72 | + 'label' => 'H1', | |
| 73 | + ], | |
| 74 | + [ | |
| 75 | + 'value' => 'h2', | |
| 76 | + 'label' => 'H2', | |
| 77 | + ], | |
| 78 | + [ | |
| 79 | + 'value' => 'h3', | |
| 80 | + 'label' => 'H3', | |
| 81 | + ], | |
| 82 | + [ | |
| 83 | + 'value' => 'h4', | |
| 84 | + 'label' => 'H4', | |
| 85 | + ], | |
| 86 | + [ | |
| 87 | + 'value' => 'h5', | |
| 88 | + 'label' => 'H5', | |
| 89 | + ], | |
| 90 | + [ | |
| 91 | + 'value' => 'h6', | |
| 92 | + 'label' => 'H6', | |
| 93 | + ], | |
| 94 | + ]), | |
| 95 | + Link_Control::bind_to( 'link' ), | |
| 124 | 96 | ] ), |
| 125 | - Text_Control::bind_to( '_cssid' ) | |
| 126 | - ->set_label( __( 'ID', 'elementor' ) ) | |
| 127 | - ->set_meta( $this->get_css_id_control_meta() ), | |
| 128 | 97 | ]; |
| 129 | 98 | } |
| 130 | 99 | |
| 131 | 100 | protected function define_base_styles(): array { |