PluginProbe
Elementor Website Builder – more than just a page builder / 3.3.0
Elementor Website Builder – more than just a page builder v3.3.0
4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 All 453 releases
← All changes | includes/template-library/manager.php +8 -11 3.2.53.3.0 View file →
@@ -458,22 +458,19 @@
458 458 *
459 459 * @return mixed Whether the export succeeded or failed.
460 460 */
461 461 public function import_template( array $data ) {
462 - /** @var Source_Local $source */
463 - $file_content = base64_decode( $data['fileData'] );
462 + // Imported templates can be either JSON files, or Zip files containing multiple JSON files
463 + $upload_result = Plugin::$instance->uploads_manager->handle_elementor_upload( $data, [ 'zip', 'json' ] );
464 464
465 - $tmp_file = tmpfile();
465 + if ( is_wp_error( $upload_result ) ) {
466 + return $upload_result;
467 + }
466 468
467 - fwrite( $tmp_file, $file_content );
469 + /** @var Source_Local $source_local */
470 + $source_local = $this->get_source( 'local' );
468 471
469 - $source = $this->get_source( 'local' );
470 -
471 - $result = $source->import_template( $data['fileName'], stream_get_meta_data( $tmp_file )['uri'] );
472 -
473 - fclose( $tmp_file );
474 -
475 - return $result;
472 + return $source_local->import_template( $upload_result['name'], $upload_result['tmp_name'] );
476 473 }
477 474
478 475 /**
479 476 * Mark template as favorite.