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 +4 -52 3.6.12.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,32 +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 24
30 25 if( $id <= 0 || $id == null ) {
31 26 return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'get_content', 404 );
32 27 }
33 - if($platform === 'elementor') {
34 - if(Helper::enable_elementor_container()) {
35 - return $this->error(
36 - 'retry_again',
37 - __( 'Please try again we enabled container.', 'templately' ),
38 - 'insert', 404
39 - );
40 - }
41 - }
42 28
43 - @set_time_limit( 0 ); // Unlimited execution time for this request.
44 - Utils::add_gd_editor_filter();
45 -
46 29 switch ( $origin ) {
47 30 case 'cloud':
48 31 $template_data = $this->get_cloud_content( $id, $platform );
49 32 break;
50 33 case 'remote':
51 - $template_data = $this->get_remote_content( $id );
34 + $template_data = $this->get_remote_content( $id, $platform, $origin );
52 35 break;
53 36 case 'local':
54 37 default:
55 38 $template_data = $this->get_local_content( $id, $platform );
@@ -56,13 +39,8 @@
56 39 $template_data = isset( $template_data['data'] ) ? $template_data['data'] : [];
57 40 break;
58 41 }
59 42
60 - /**
61 - * A fallback for old cloud items.
62 - */
63 - $template_data = is_string( $template_data ) ? json_decode( wp_unslash($template_data), true ) : $template_data;
64 -
65 43 if( is_wp_error( $template_data ) ) {
66 44 return $template_data;
67 45 }
68 46
@@ -73,9 +51,9 @@
73 51 'insert', 404
74 52 );
75 53 }
76 54
77 - return $this->platform( $platform )->insert( $template_data, $postId );
55 + return $this->platform( $platform )->insert( $template_data );
78 56 }
79 57
80 58 private function get_cloud_content( $id = null, $platform = 'elementor' ){
81 59 $response = $this->http()->query(
@@ -160,27 +138,14 @@
160 138
161 139 public function import_in_library(){
162 140 $platform = $this->get_param( 'platform', 'elementor' );
163 141 $id = $this->get_param( 'id', 0, 'intval' );
164 - $settings = $this->get_param( 'settings', [], null );
165 142
166 143 if( $id == 0 ) {
167 144 return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 );
168 145 }
169 - if($platform === 'elementor') {
170 - if(Helper::enable_elementor_container()) {
171 - return $this->error(
172 - 'retry_again',
173 - __( 'Please try again we enabled container.', 'templately' ),
174 - 'insert', 404
175 - );
176 - }
177 - }
178 146
179 - @set_time_limit( 0 ); // Unlimited execution time for this request.
180 - Utils::add_gd_editor_filter();
181 -
182 - return $this->platform( $platform )->import_in_library( $id, $this, $settings );
147 + return $this->platform( $platform )->import_in_library( $id, $this );
183 148 }
184 149
185 150 public function import_as_page(){
186 151 $platform = $this->get_param( 'platform', 'elementor' );
@@ -185,25 +150,12 @@
185 150 public function import_as_page(){
186 151 $platform = $this->get_param( 'platform', 'elementor' );
187 152 $id = $this->get_param( 'id', 0, 'intval' );
188 153 $title = $this->get_param( 'title' );
189 - $settings = $this->get_param( 'settings', [] );
190 154
191 155 if( $id == 0 ) {
192 156 return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 );
193 157 }
194 - if($platform === 'elementor') {
195 - if(Helper::enable_elementor_container()) {
196 - return $this->error(
197 - 'retry_again',
198 - __( 'Please try again we enabled container.', 'templately' ),
199 - 'insert', 404
200 - );
201 - }
202 - }
203 158
204 - @set_time_limit( 0 ); // Unlimited execution time for this request.
205 - Utils::add_gd_editor_filter();
206 -
207 - return $this->platform( $platform )->create_page( $id, $title, $this, $settings );
159 + return $this->platform( $platform )->create_page( $id, $title, $this );
208 160 }
209 161 }