PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.5.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.5.3
3.8.0 3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 All 112 releases
← All changes | includes/Core/Importer/Runners/ExtraContent.php +21 -17 3.0.3 → 3.5.3 View file →
@@ -7,8 +7,10 @@
7 7 use Templately\Core\Importer\Runners\BaseRunner;
8 8
9 9 class ExtraContent extends BaseRunner {
10 10
11 + protected static $imported_form = [];
12 +
11 13 public function get_name(): string {
12 14 return 'extra-content';
13 15 }
14 16
@@ -32,27 +34,22 @@
32 34 return ! empty( $this->manifest['extra-content'] ) && !empty($data['import_demo_content']);
33 35 }
34 36
35 37 public function import( $data, $imported_data ): array {
36 - $extra_content = [];
37 - $contents = $this->manifest['extra-content'];
38 + $contents = $this->manifest['extra-content'] ?? [];
38 39
39 - if( ! empty( $contents ) ) {
40 - foreach( $contents as $type => $content ) {
41 - switch ( $type ) {
42 - case 'form':
43 - $import = $this->import_form( $content );
44 - $extra_content['form'] = $import;
45 - break;
46 - case 'data':
47 - break;
48 - }
40 + $extra_content = $this->loop( $contents, function($type, $content, $extra_content ) {
41 + switch ( $type ) {
42 + case 'form':
43 + $import = $this->import_form( $content );
44 + $extra_content['form'] = $import;
45 + break;
46 + case 'data':
47 + break;
49 48 }
49 + return $extra_content;
50 + });
50 51
51 - // $imported_data = array_merge( $imported_data, [ 'extra-content' => $this->extra_content ] );
52 - }
53 -
54 -
55 52 return [ 'extra-content' => $extra_content ];
56 53 }
57 54
58 55 private function import_form( $contents ): array {
@@ -75,13 +72,20 @@
75 72 }
76 73
77 74 foreach ( $form_list as $form ) {
78 75 try {
76 + $form_id = isset( $form['identifier'] ) ? $form['settings'][$form['identifier']] : $form['settings']['form_list'];
77 + if(isset(self::$imported_form[ $plugin_name ][ $form_id ])){
78 + $result[$json_id][ $plugin_name ][ $form['id'] ] = self::$imported_form[ $plugin_name ][ $form_id ];
79 + continue;
80 + }
81 +
79 82 $file_path = $root_path . wp_unslash( $form['file_path'] );
80 83 $import = new Form( $plugin_name, $file_path, $form );
81 84 $data = $import->run();
82 85
83 - $result[$json_id][ $plugin_name ][ $form['id'] ] = $data;
86 + self::$imported_form[ $plugin_name ][ $form_id ] = (string) $data;
87 + $result[$json_id][ $plugin_name ][ $form['id'] ] = (string) $data;
84 88 } catch ( Exception $e ) {
85 89 continue;
86 90 }
87 91 }