← All changes
|
modules/atomic-widgets/elements/atomic-heading/atomic-heading.php
+28
-0
4.0.9
→
4.1.0-beta1
View file →
| @@ -153,5 +153,33 @@ | ||
| 153 | 153 | return [ |
| 154 | 154 | 'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig', |
| 155 | 155 | ]; |
| 156 | 156 | } |
| 157 | + | |
| 158 | + public function render_markdown(): string { | |
| 159 | + $settings = $this->get_atomic_settings(); | |
| 160 | + $title = wp_strip_all_tags( $settings['title'] ?? '' ); | |
| 161 | + | |
| 162 | + if ( empty( $title ) ) { | |
| 163 | + return ''; | |
| 164 | + } | |
| 165 | + | |
| 166 | + $tag = $settings['tag'] ?? 'h2'; | |
| 167 | + $level_map = [ | |
| 168 | + 'h1' => 1, | |
| 169 | + 'h2' => 2, | |
| 170 | + 'h3' => 3, | |
| 171 | + 'h4' => 4, | |
| 172 | + 'h5' => 5, | |
| 173 | + 'h6' => 6, | |
| 174 | + ]; | |
| 175 | + $level = $level_map[ $tag ] ?? 2; | |
| 176 | + | |
| 177 | + $md = str_repeat( '#', $level ) . ' ' . $title; | |
| 178 | + | |
| 179 | + if ( ! empty( $settings['link']['href'] ) ) { | |
| 180 | + $md = str_repeat( '#', $level ) . ' [' . $title . '](' . esc_url( $settings['link']['href'] ) . ')'; | |
| 181 | + } | |
| 182 | + | |
| 183 | + return $md; | |
| 184 | + } | |
| 157 | 185 | } |