| @@ -542,8 +542,28 @@ | ||
| 542 | 542 | 'isInner' => $data['isInner'], |
| 543 | 543 | ]; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | + public function get_data_for_save() { | |
| 547 | + $data = $this->get_raw_data(); | |
| 548 | + | |
| 549 | + $elements = []; | |
| 550 | + | |
| 551 | + foreach ( $this->get_children() as $child ) { | |
| 552 | + $elements[] = $child->get_data_for_save(); | |
| 553 | + } | |
| 554 | + | |
| 555 | + if ( ! empty( $elements ) ) { | |
| 556 | + $data['elements'] = $elements; | |
| 557 | + } | |
| 558 | + | |
| 559 | + if ( ! empty( $data['settings'] ) ) { | |
| 560 | + $data['settings'] = $this->on_save( $data['settings'] ); | |
| 561 | + } | |
| 562 | + | |
| 563 | + return $data; | |
| 564 | + } | |
| 565 | + | |
| 546 | 566 | /** |
| 547 | 567 | * Get unique selector. |
| 548 | 568 | * |
| 549 | 569 | * Retrieve the unique selector of the element. Used to set a unique HTML |
| @@ -800,8 +820,16 @@ | ||
| 800 | 820 | $config['editable'] = false; |
| 801 | 821 | } |
| 802 | 822 | |
| 803 | 823 | return $config; |
| 824 | + } | |
| 825 | + | |
| 826 | + /** | |
| 827 | + * A Base method for sanitizing the settings before save. | |
| 828 | + * This method is meant to be overridden by the element. | |
| 829 | + */ | |
| 830 | + protected function on_save( array $settings ) { | |
| 831 | + return $settings; | |
| 804 | 832 | } |
| 805 | 833 | |
| 806 | 834 | /** |
| 807 | 835 | * Get child type. |