PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 2.0.0
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v2.0.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 3.1.10 All 111 releases
← All changes | includes/API/Import.php +7 -58 3.7.42.0.0 View file →
@@ -1,14 +1,10 @@
1 1 <?php
2 2
3 3 namespace Templately\API;
4 4
5 -use Elementor\Plugin;
6 -use Elementor\Core\Experiments\Manager as Experiments_Manager;
7 5 use Templately\Core\Platform\Elementor;
8 6 use Templately\Core\Platform\Gutenberg;
9 -use Templately\Core\Importer\Utils\Utils;
10 -use Templately\Utils\Helper;
11 7
12 8 /**
13 9 * @method Elementor|Gutenberg platform( $id );
14 10 */
@@ -24,33 +20,19 @@
24 20 public function insert_template() {
25 21 $platform = $this->get_param( 'platform', 'elementor' );
26 22 $origin = $this->get_param( 'origin', 'remote' );
27 23 $id = $this->get_param( 'id', 0, 'intval' );
28 - $postId = $this->get_param( 'postId', 0, 'intval' );
29 - $settings = $this->get_param( 'settings', [], null );
30 24
31 25 if( $id <= 0 || $id == null ) {
32 26 return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'get_content', 404 );
33 27 }
34 - if($platform === 'elementor') {
35 - if(Helper::enable_elementor_container()) {
36 - return $this->error(
37 - 'retry_again',
38 - __( 'Please try again we enabled container.', 'templately' ),
39 - 'insert', 404
40 - );
41 - }
42 - }
43 28
44 - @set_time_limit( 0 ); // Unlimited execution time for this request.
45 - Utils::add_gd_editor_filter();
46 -
47 29 switch ( $origin ) {
48 30 case 'cloud':
49 31 $template_data = $this->get_cloud_content( $id, $platform );
50 32 break;
51 33 case 'remote':
52 - $template_data = $this->get_remote_content( $id );
34 + $template_data = $this->get_remote_content( $id, $platform, $origin );
53 35 break;
54 36 case 'local':
55 37 default:
56 38 $template_data = $this->get_local_content( $id, $platform );
@@ -57,13 +39,8 @@
57 39 $template_data = isset( $template_data['data'] ) ? $template_data['data'] : [];
58 40 break;
59 41 }
60 42
61 - /**
62 - * A fallback for old cloud items.
63 - */
64 - $template_data = is_string( $template_data ) ? json_decode( wp_unslash($template_data), true ) : $template_data;
65 -
66 43 if( is_wp_error( $template_data ) ) {
67 44 return $template_data;
68 45 }
69 46
@@ -74,9 +51,9 @@
74 51 'insert', 404
75 52 );
76 53 }
77 54
78 - return $this->platform( $platform )->insert( $template_data, $postId, $settings );
55 + return $this->platform( $platform )->insert( $template_data );
79 56 }
80 57
81 58 private function get_cloud_content( $id = null, $platform = 'elementor' ){
82 59 $response = $this->http()->query(
@@ -159,31 +136,16 @@
159 136 return $template_data;
160 137 }
161 138
162 139 public function import_in_library(){
163 - $platform = $this->get_param( 'platform', 'elementor' );
164 - $id = $this->get_param( 'id', 0, 'intval' );
165 - $settings = $this->get_param( 'settings', [], null );
166 - $template_type = $this->get_param( 'template_type', '', 'sanitize_text_field' );
167 - $type = $this->get_param( 'type', '', 'sanitize_text_field' );
140 + $platform = $this->get_param( 'platform', 'elementor' );
141 + $id = $this->get_param( 'id', 0, 'intval' );
168 142
169 143 if( $id == 0 ) {
170 144 return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 );
171 145 }
172 - if($platform === 'elementor') {
173 - if(Helper::enable_elementor_container()) {
174 - return $this->error(
175 - 'retry_again',
176 - __( 'Please try again we enabled container.', 'templately' ),
177 - 'insert', 404
178 - );
179 - }
180 - }
181 146
182 - @set_time_limit( 0 ); // Unlimited execution time for this request.
183 - Utils::add_gd_editor_filter();
184 -
185 - return $this->platform( $platform )->import_in_library( $id, $this, $settings, $template_type, $type );
147 + return $this->platform( $platform )->import_in_library( $id, $this );
186 148 }
187 149
188 150 public function import_as_page(){
189 151 $platform = $this->get_param( 'platform', 'elementor' );
@@ -188,25 +150,12 @@
188 150 public function import_as_page(){
189 151 $platform = $this->get_param( 'platform', 'elementor' );
190 152 $id = $this->get_param( 'id', 0, 'intval' );
191 153 $title = $this->get_param( 'title' );
192 - $settings = $this->get_param( 'settings', [], null );
193 154
194 155 if( $id == 0 ) {
195 156 return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 );
196 157 }
197 - if($platform === 'elementor') {
198 - if(Helper::enable_elementor_container()) {
199 - return $this->error(
200 - 'retry_again',
201 - __( 'Please try again we enabled container.', 'templately' ),
202 - 'insert', 404
203 - );
204 - }
205 - }
206 158
207 - @set_time_limit( 0 ); // Unlimited execution time for this request.
208 - Utils::add_gd_editor_filter();
209 -
210 - return $this->platform( $platform )->create_page( $id, $title, $this, $settings );
159 + return $this->platform( $platform )->create_page( $id, $title, $this );
211 160 }
212 -}
161 +}