| @@ -326,8 +326,28 @@ | ||
| 326 | 326 | |
| 327 | 327 | return $this->children; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | + public function render_markdown(): string { | |
| 331 | + $children = $this->get_children(); | |
| 332 | + | |
| 333 | + if ( empty( $children ) ) { | |
| 334 | + return ''; | |
| 335 | + } | |
| 336 | + | |
| 337 | + $parts = []; | |
| 338 | + | |
| 339 | + foreach ( $children as $child ) { | |
| 340 | + $md = $child->render_markdown(); | |
| 341 | + | |
| 342 | + if ( ! empty( trim( $md ) ) ) { | |
| 343 | + $parts[] = $md; | |
| 344 | + } | |
| 345 | + } | |
| 346 | + | |
| 347 | + return implode( "\n\n", $parts ); | |
| 348 | + } | |
| 349 | + | |
| 330 | 350 | /** |
| 331 | 351 | * Get default arguments. |
| 332 | 352 | * |
| 333 | 353 | * Retrieve the element default arguments. Used to return all the default |
| @@ -439,8 +459,16 @@ | ||
| 439 | 459 | $this->add_render_attribute( $element, $attributes, null, $overwrite ); |
| 440 | 460 | } |
| 441 | 461 | |
| 442 | 462 | return $this; |
| 463 | + } | |
| 464 | + | |
| 465 | + public function reset_descendant_render_state(): void { | |
| 466 | + $this->reset_render_state(); | |
| 467 | + | |
| 468 | + foreach ( $this->get_children() as $child ) { | |
| 469 | + $child->reset_descendant_render_state(); | |
| 470 | + } | |
| 443 | 471 | } |
| 444 | 472 | |
| 445 | 473 | /** |
| 446 | 474 | * Print element. |