| @@ -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 | */ |
| @@ -25,9 +29,21 @@ | ||
| 25 | 29 | |
| 26 | 30 | if( $id <= 0 || $id == null ) { |
| 27 | 31 | return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'get_content', 404 ); |
| 28 | 32 | } |
| 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 | + } | |
| 29 | 42 | |
| 43 | + @set_time_limit( 0 ); // Unlimited execution time for this request. | |
| 44 | + Utils::add_gd_editor_filter(); | |
| 45 | + | |
| 30 | 46 | switch ( $origin ) { |
| 31 | 47 | case 'cloud': |
| 32 | 48 | $template_data = $this->get_cloud_content( $id, $platform ); |
| 33 | 49 | break; |
| @@ -142,16 +158,31 @@ | ||
| 142 | 158 | return $template_data; |
| 143 | 159 | } |
| 144 | 160 | |
| 145 | 161 | public function import_in_library(){ |
| 146 | - $platform = $this->get_param( 'platform', 'elementor' ); | |
| 147 | - $id = $this->get_param( 'id', 0, 'intval' ); | |
| 162 | + $platform = $this->get_param( 'platform', 'elementor' ); | |
| 163 | + $id = $this->get_param( 'id', 0, 'intval' ); | |
| 164 | + $settings = $this->get_param( 'settings', [], null ); | |
| 165 | + $template_type = $this->get_param( 'template_type', '', 'sanitize_text_field' ); | |
| 166 | + $type = $this->get_param( 'type', '', 'sanitize_text_field' ); | |
| 148 | 167 | |
| 149 | 168 | if( $id == 0 ) { |
| 150 | 169 | return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 ); |
| 151 | 170 | } |
| 171 | + if($platform === 'elementor') { | |
| 172 | + if(Helper::enable_elementor_container()) { | |
| 173 | + return $this->error( | |
| 174 | + 'retry_again', | |
| 175 | + __( 'Please try again we enabled container.', 'templately' ), | |
| 176 | + 'insert', 404 | |
| 177 | + ); | |
| 178 | + } | |
| 179 | + } | |
| 152 | 180 | |
| 153 | - return $this->platform( $platform )->import_in_library( $id, $this ); | |
| 181 | + @set_time_limit( 0 ); // Unlimited execution time for this request. | |
| 182 | + Utils::add_gd_editor_filter(); | |
| 183 | + | |
| 184 | + return $this->platform( $platform )->import_in_library( $id, $this, $settings, $template_type, $type ); | |
| 154 | 185 | } |
| 155 | 186 | |
| 156 | 187 | public function import_as_page(){ |
| 157 | 188 | $platform = $this->get_param( 'platform', 'elementor' ); |
| @@ -156,12 +187,25 @@ | ||
| 156 | 187 | public function import_as_page(){ |
| 157 | 188 | $platform = $this->get_param( 'platform', 'elementor' ); |
| 158 | 189 | $id = $this->get_param( 'id', 0, 'intval' ); |
| 159 | 190 | $title = $this->get_param( 'title' ); |
| 191 | + $settings = $this->get_param( 'settings', [], null ); | |
| 160 | 192 | |
| 161 | 193 | if( $id == 0 ) { |
| 162 | 194 | return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 ); |
| 163 | 195 | } |
| 196 | + if($platform === 'elementor') { | |
| 197 | + if(Helper::enable_elementor_container()) { | |
| 198 | + return $this->error( | |
| 199 | + 'retry_again', | |
| 200 | + __( 'Please try again we enabled container.', 'templately' ), | |
| 201 | + 'insert', 404 | |
| 202 | + ); | |
| 203 | + } | |
| 204 | + } | |
| 164 | 205 | |
| 165 | - return $this->platform( $platform )->create_page( $id, $title, $this ); | |
| 206 | + @set_time_limit( 0 ); // Unlimited execution time for this request. | |
| 207 | + Utils::add_gd_editor_filter(); | |
| 208 | + | |
| 209 | + return $this->platform( $platform )->create_page( $id, $title, $this, $settings ); | |
| 166 | 210 | } |
| 167 | 211 | } |