← All changes
|
modules/atomic-widgets/elements/atomic-heading/atomic-heading.php
+9
-47
4.3.0-beta3
→
4.0.8
View file →
| @@ -7,12 +7,11 @@ | ||
| 7 | 7 | use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control; |
| 8 | 8 | use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; |
| 9 | 9 | use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base; |
| 10 | 10 | use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template; |
| 11 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer; | |
| 12 | 11 | use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; |
| 13 | 12 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 14 | -use Elementor\Modules\AtomicWidgets\PropTypes\Escaped_Html_Prop_Type; | |
| 13 | +use Elementor\Modules\AtomicWidgets\PropTypes\Html_V3_Prop_Type; | |
| 15 | 14 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 16 | 15 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 17 | 16 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 18 | 17 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| @@ -38,9 +37,9 @@ | ||
| 38 | 37 | return esc_html__( 'Heading', 'elementor' ); |
| 39 | 38 | } |
| 40 | 39 | |
| 41 | 40 | public function get_keywords() { |
| 42 | - return [ 'ato', 'atom', 'atoms', 'atomic', 'heading', 'title', 'text', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ]; | |
| 41 | + return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | 44 | public function get_icon() { |
| 46 | 45 | return 'eicon-e-heading'; |
| @@ -45,18 +44,8 @@ | ||
| 45 | 44 | public function get_icon() { |
| 46 | 45 | return 'eicon-e-heading'; |
| 47 | 46 | } |
| 48 | 47 | |
| 49 | - public static function html_tag_follows_link(): bool { | |
| 50 | - return false; | |
| 51 | - } | |
| 52 | - | |
| 53 | - public static function get_computed_html_tag( array $settings ): string { | |
| 54 | - return Html_Tag_Computer::compute( $settings, 'h2', [ | |
| 55 | - Html_Tag_Computer::FOLLOW_LINK_OPTION => static::html_tag_follows_link(), | |
| 56 | - ] ); | |
| 57 | - } | |
| 58 | - | |
| 59 | 48 | protected static function define_props_schema(): array { |
| 60 | 49 | return [ |
| 61 | 50 | 'classes' => Classes_Prop_Type::make() |
| 62 | 51 | ->default( [] ), |
| @@ -63,14 +52,16 @@ | ||
| 63 | 52 | |
| 64 | 53 | 'tag' => String_Prop_Type::make() |
| 65 | 54 | ->enum( [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] ) |
| 66 | 55 | ->default( 'h2' ) |
| 67 | - ->description( 'The HTML tag for the heading element. One of: h1, h2, h3, h4, h5, or h6. Do not use p, span, or div.' ), | |
| 56 | + ->description( 'The HTML tag for the heading element. Could be h1, h2, up to h6' ), | |
| 68 | 57 | |
| 69 | - 'title' => Escaped_Html_Prop_Type::make() | |
| 70 | - ->default( __( 'This is a title', 'elementor' ) ) | |
| 71 | - ->description( 'The text content of the heading.' ) | |
| 72 | - ->alias( 'text', 'content', 'heading' ), | |
| 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.' ), | |
| 73 | 64 | |
| 74 | 65 | 'link' => Link_Prop_Type::make(), |
| 75 | 66 | |
| 76 | 67 | 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), |
| @@ -79,9 +70,8 @@ | ||
| 79 | 70 | |
| 80 | 71 | protected function define_atomic_controls(): array { |
| 81 | 72 | $content_section = Section::make() |
| 82 | 73 | ->set_label( __( 'Content', 'elementor' ) ) |
| 83 | - ->set_id( 'content' ) | |
| 84 | 74 | ->set_items( [ |
| 85 | 75 | Inline_Editing_Control::bind_to( 'title' ) |
| 86 | 76 | ->set_placeholder( __( 'Type your title here', 'elementor' ) ) |
| 87 | 77 | ->set_label( __( 'Title', 'elementor' ) ), |
| @@ -162,34 +152,6 @@ | ||
| 162 | 152 | protected function get_templates(): array { |
| 163 | 153 | return [ |
| 164 | 154 | 'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig', |
| 165 | 155 | ]; |
| 166 | - } | |
| 167 | - | |
| 168 | - public function render_markdown(): string { | |
| 169 | - $settings = $this->get_atomic_settings(); | |
| 170 | - $title = wp_strip_all_tags( $settings['title'] ?? '' ); | |
| 171 | - | |
| 172 | - if ( empty( $title ) ) { | |
| 173 | - return ''; | |
| 174 | - } | |
| 175 | - | |
| 176 | - $tag = $settings['tag'] ?? 'h2'; | |
| 177 | - $level_map = [ | |
| 178 | - 'h1' => 1, | |
| 179 | - 'h2' => 2, | |
| 180 | - 'h3' => 3, | |
| 181 | - 'h4' => 4, | |
| 182 | - 'h5' => 5, | |
| 183 | - 'h6' => 6, | |
| 184 | - ]; | |
| 185 | - $level = $level_map[ $tag ] ?? 2; | |
| 186 | - | |
| 187 | - $md = str_repeat( '#', $level ) . ' ' . $title; | |
| 188 | - | |
| 189 | - if ( ! empty( $settings['link']['href'] ) ) { | |
| 190 | - $md = str_repeat( '#', $level ) . ' [' . $title . '](' . esc_url( $settings['link']['href'] ) . ')'; | |
| 191 | - } | |
| 192 | - | |
| 193 | - return $md; | |
| 194 | 156 | } |
| 195 | 157 | } |