PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.7.5
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.7.5
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 +51 -6 3.0.73.7.5 View file →
@@ -1,10 +1,14 @@
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;
5 7 use Templately\Core\Platform\Elementor;
6 8 use Templately\Core\Platform\Gutenberg;
9 +use Templately\Core\Importer\Utils\Utils;
10 +use Templately\Utils\Helper;
7 11
8 12 /**
9 13 * @method Elementor|Gutenberg platform( $id );
10 14 */
@@ -21,13 +25,26 @@
21 25 $platform = $this->get_param( 'platform', 'elementor' );
22 26 $origin = $this->get_param( 'origin', 'remote' );
23 27 $id = $this->get_param( 'id', 0, 'intval' );
24 28 $postId = $this->get_param( 'postId', 0, 'intval' );
29 + $settings = $this->get_param( 'settings', [], null );
25 30
26 31 if( $id <= 0 || $id == null ) {
27 32 return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'get_content', 404 );
28 33 }
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 + }
29 43
44 + @set_time_limit( 0 ); // Unlimited execution time for this request.
45 + Utils::add_gd_editor_filter();
46 +
30 47 switch ( $origin ) {
31 48 case 'cloud':
32 49 $template_data = $this->get_cloud_content( $id, $platform );
33 50 break;
@@ -57,9 +74,9 @@
57 74 'insert', 404
58 75 );
59 76 }
60 77
61 - return $this->platform( $platform )->insert( $template_data, $postId );
78 + return $this->platform( $platform )->insert( $template_data, $postId, $settings );
62 79 }
63 80
64 81 private function get_cloud_content( $id = null, $platform = 'elementor' ){
65 82 $response = $this->http()->query(
@@ -142,16 +159,31 @@
142 159 return $template_data;
143 160 }
144 161
145 162 public function import_in_library(){
146 - $platform = $this->get_param( 'platform', 'elementor' );
147 - $id = $this->get_param( 'id', 0, 'intval' );
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' );
148 168
149 169 if( $id == 0 ) {
150 170 return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 );
151 171 }
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 + }
152 181
153 - return $this->platform( $platform )->import_in_library( $id, $this );
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 );
154 186 }
155 187
156 188 public function import_as_page(){
157 189 $platform = $this->get_param( 'platform', 'elementor' );
@@ -156,12 +188,25 @@
156 188 public function import_as_page(){
157 189 $platform = $this->get_param( 'platform', 'elementor' );
158 190 $id = $this->get_param( 'id', 0, 'intval' );
159 191 $title = $this->get_param( 'title' );
192 + $settings = $this->get_param( 'settings', [], null );
160 193
161 194 if( $id == 0 ) {
162 195 return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 );
163 196 }
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 + }
164 206
165 - return $this->platform( $platform )->create_page( $id, $title, $this );
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 );
166 211 }
167 -}
212 +}