| @@ -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; |
| @@ -144,14 +160,27 @@ | ||
| 144 | 160 | |
| 145 | 161 | public function import_in_library(){ |
| 146 | 162 | $platform = $this->get_param( 'platform', 'elementor' ); |
| 147 | 163 | $id = $this->get_param( 'id', 0, 'intval' ); |
| 164 | + $settings = $this->get_param( 'settings', [], null ); | |
| 148 | 165 | |
| 149 | 166 | if( $id == 0 ) { |
| 150 | 167 | return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 ); |
| 151 | 168 | } |
| 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 | + } | |
| 152 | 178 | |
| 153 | - return $this->platform( $platform )->import_in_library( $id, $this ); | |
| 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 ); | |
| 154 | 183 | } |
| 155 | 184 | |
| 156 | 185 | public function import_as_page(){ |
| 157 | 186 | $platform = $this->get_param( 'platform', 'elementor' ); |
| @@ -156,12 +185,25 @@ | ||
| 156 | 185 | public function import_as_page(){ |
| 157 | 186 | $platform = $this->get_param( 'platform', 'elementor' ); |
| 158 | 187 | $id = $this->get_param( 'id', 0, 'intval' ); |
| 159 | 188 | $title = $this->get_param( 'title' ); |
| 189 | + $settings = $this->get_param( 'settings', [] ); | |
| 160 | 190 | |
| 161 | 191 | if( $id == 0 ) { |
| 162 | 192 | return $this->error('invalid_item_id', __( 'Invalid ID is provided.', 'templately' ), 'import/page', 404 ); |
| 163 | 193 | } |
| 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 | + } | |
| 164 | 203 | |
| 165 | - return $this->platform( $platform )->create_page( $id, $title, $this ); | |
| 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 ); | |
| 166 | 208 | } |
| 167 | 209 | } |