| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Templately\API; |
| 4 | 4 | |
| 5 | -use Templately\Core\Platform; | |
| 5 | +use Templately\Utils\Database; | |
| 6 | 6 | use WP_REST_Request; |
| 7 | 7 | |
| 8 | 8 | use function wp_slash; |
| 9 | 9 | use function json_encode; |
| @@ -72,10 +72,9 @@ | ||
| 72 | 72 | |
| 73 | 73 | if( is_wp_error( $response ) ) { |
| 74 | 74 | return $this->error( |
| 75 | 75 | 'invalid_response', $response->get_error_message(), |
| 76 | - 'clouds/usage', 404, | |
| 77 | - $response->get_error_data() | |
| 76 | + 'clouds/usage', 404 | |
| 78 | 77 | ); |
| 79 | 78 | } |
| 80 | 79 | |
| 81 | 80 | return $response; |
| @@ -108,12 +107,8 @@ | ||
| 108 | 107 | $file_type = $this->get_param( 'platform', 'elementor' ); |
| 109 | 108 | $id = $this->get_param( 'id', 0, 'intval' ); |
| 110 | 109 | $workspace_id = $this->get_param( 'workspace_id', 0, 'intval' ); |
| 111 | 110 | |
| 112 | - if( $file_type === 'elementor' && ! class_exists('Elementor\TemplateLibrary\Source_Local') ) { | |
| 113 | - return $this->error( 'required_elementor', __("Missing required dependency Elementor, please install before trying again.", "templately"), 'clouds/upload', 400 ); | |
| 114 | - } | |
| 115 | - | |
| 116 | 111 | if( empty( $file_content ) ) { |
| 117 | 112 | /** |
| 118 | 113 | * @var Platform $platform |
| 119 | 114 | */ |
| @@ -208,11 +203,11 @@ | ||
| 208 | 203 | $file_content['version'] = ! empty( $file_content['version'] ) ? $file_content['version'] : ''; |
| 209 | 204 | $file_content['type'] = ! empty( $file_content['type'] ) ? $file_content['type'] : 'section'; |
| 210 | 205 | $file_content['title'] = ! empty( $file_content['title'] ) ? $file_content['title'] : \basename( $response['file_name'], '.json' ); |
| 211 | 206 | } |
| 207 | + | |
| 208 | + $file_content = json_encode( $file_content ); | |
| 212 | 209 | } |
| 213 | - | |
| 214 | - $file_content = is_array( $file_content ) ? json_encode( $file_content ) : $file_content; | |
| 215 | 210 | |
| 216 | 211 | $file_name = 'templately-tmp.json'; |
| 217 | 212 | $_temp_file_name = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . $file_name; |
| 218 | 213 | $_temp_file_url = $upload_dir['baseurl'] . DIRECTORY_SEPARATOR . $file_name; |