| @@ -80,17 +80,8 @@ | ||
| 80 | 80 | if ( ! empty( $args['with_page_settings'] ) ) { |
| 81 | 81 | $data['page_settings'] = $decoded_data['page_settings']; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $snapshots = apply_filters( | |
| 85 | - 'elementor/template_library/get_data/extract_snapshots', | |
| 86 | - [], | |
| 87 | - $decoded_data, | |
| 88 | - $data | |
| 89 | - ); | |
| 90 | - | |
| 91 | - static::attach_global_styles_to_data_static( $data, $snapshots ); | |
| 92 | - | |
| 93 | 84 | // After the upload complete, set the elementor upload state back to false |
| 94 | 85 | Plugin::$instance->uploads_manager->set_elementor_upload_state( false ); |
| 95 | 86 | |
| 96 | 87 | return $data; |
| @@ -110,23 +101,17 @@ | ||
| 110 | 101 | return (int) $response['id']; |
| 111 | 102 | } |
| 112 | 103 | |
| 113 | 104 | private function format_resource_item_for_create( $template_data ) { |
| 114 | - $content_payload = [ | |
| 115 | - 'content' => $template_data['content'], | |
| 116 | - 'page_settings' => $template_data['page_settings'], | |
| 117 | - ]; | |
| 118 | - | |
| 119 | - if ( is_array( $template_data['content'] ?? null ) ) { | |
| 120 | - $this->attach_global_styles_to_data( $content_payload, $template_data['content'], 0 ); | |
| 121 | - } | |
| 122 | - | |
| 123 | 105 | return [ |
| 124 | 106 | 'title' => $template_data['title'] ?? esc_html__( '(no title)', 'elementor' ), |
| 125 | 107 | 'type' => self::TEMPLATE_RESOURCE_TYPE, |
| 126 | 108 | 'templateType' => $template_data['type'], |
| 127 | 109 | 'parentId' => ! empty( $template_data['parentId'] ) ? (int) $template_data['parentId'] : null, |
| 128 | - 'content' => wp_json_encode( $content_payload ), | |
| 110 | + 'content' => wp_json_encode( [ | |
| 111 | + 'content' => $template_data['content'], | |
| 112 | + 'page_settings' => $template_data['page_settings'], | |
| 113 | + ] ), | |
| 129 | 114 | 'hasPageSettings' => ! empty( $template_data['page_settings'] ), |
| 130 | 115 | ]; |
| 131 | 116 | } |
| 132 | 117 | |
| @@ -156,9 +141,9 @@ | ||
| 156 | 141 | public function export_template( $id ) { |
| 157 | 142 | $data = $this->get_app()->get_resource( [ 'id' => $id ] ); |
| 158 | 143 | |
| 159 | 144 | if ( is_wp_error( $data ) ) { |
| 160 | - return new \WP_Error( 'export_template_error', 'An error has occurred' ); | |
| 145 | + return new \WP_Error( 'export_template_error', 'An error has occured' ); | |
| 161 | 146 | } |
| 162 | 147 | |
| 163 | 148 | if ( static::TEMPLATE_RESOURCE_TYPE === $data['type'] ) { |
| 164 | 149 | $this->handle_export_file( $data ); |
| @@ -211,18 +196,8 @@ | ||
| 211 | 196 | 'title' => $data['title'], |
| 212 | 197 | 'type' => $data['templateType'], |
| 213 | 198 | ]; |
| 214 | 199 | |
| 215 | - $this->attach_global_styles_to_data( | |
| 216 | - $export_data, | |
| 217 | - $export_data['content'], | |
| 218 | - (int) ( $data['id'] ?? 0 ), | |
| 219 | - [ | |
| 220 | - 'global_classes' => $data['content']['global_classes'] ?? null, | |
| 221 | - 'global_variables' => $data['content']['global_variables'] ?? null, | |
| 222 | - ] | |
| 223 | - ); | |
| 224 | - | |
| 225 | 200 | return [ |
| 226 | 201 | 'name' => 'elementor-' . $data['id'] . '-' . gmdate( 'Y-m-d' ) . '.json', |
| 227 | 202 | 'content' => wp_json_encode( $export_data ), |
| 228 | 203 | ]; |
| @@ -406,9 +381,9 @@ | ||
| 406 | 381 | public function get_quota() { |
| 407 | 382 | return $this->get_app()->get_quota(); |
| 408 | 383 | } |
| 409 | 384 | |
| 410 | - public function import_template( $name, $path, $import_mode = 'match_site' ) { | |
| 385 | + public function import_template( $name, $path ) { | |
| 411 | 386 | if ( empty( $path ) ) { |
| 412 | 387 | return new \WP_Error( 'file_error', 'Please upload a file to import' ); |
| 413 | 388 | } |
| 414 | 389 | |
| @@ -442,9 +417,9 @@ | ||
| 442 | 417 | if ( false !== strpos( $file_path, '__MACOSX' ) || '.' === basename( $file_path )[0] ) { |
| 443 | 418 | continue; |
| 444 | 419 | } |
| 445 | 420 | |
| 446 | - $prepared = $this->prepare_import_template_data( $file_path, $import_mode ); | |
| 421 | + $prepared = $this->prepare_import_template_data( $file_path ); | |
| 447 | 422 | |
| 448 | 423 | if ( is_wp_error( $prepared ) ) { |
| 449 | 424 | // Skip failed templates |
| 450 | 425 | continue; |
| @@ -466,9 +441,9 @@ | ||
| 466 | 441 | $items = $this->get_app()->post_bulk_resources( $items_to_save ); |
| 467 | 442 | |
| 468 | 443 | Plugin::$instance->uploads_manager->remove_file_or_dir( $extracted_files['extraction_directory'] ); |
| 469 | 444 | } else { |
| 470 | - $prepared = $this->prepare_import_template_data( $path, $import_mode ); | |
| 445 | + $prepared = $this->prepare_import_template_data( $path ); | |
| 471 | 446 | |
| 472 | 447 | if ( is_wp_error( $prepared ) ) { |
| 473 | 448 | return $prepared; |
| 474 | 449 | } |