PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.1
Elementor Website Builder – more than just a page builder v4.2.1
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 4.1.0-dev1 All 452 releases
← All changes | includes/template-library/manager.php +18 -1 4.0.94.2.1 View file →
@@ -26,8 +26,9 @@
26 26 class Manager {
27 27
28 28 const ERROR_TEMPLATE_SOURCE_NOT_FOUND = 'Template source not found.';
29 29 const ERROR_TEMPLATE_IDS_MISSING = 'Template IDs are missing.';
30 + const ERROR_JSON_UPLOAD_NOT_ALLOWED = 'Uploading JSON files is not allowed for this user.';
30 31
31 32 /**
32 33 * Registered template sources.
33 34 *
@@ -599,8 +600,12 @@
599 600 *
600 601 * @return mixed Whether the export succeeded or failed.
601 602 */
602 603 public function import_template( array $data ) {
604 + if ( ! User::is_current_user_can_upload_json() ) {
605 + return new \WP_Error( 'template_error', self::ERROR_JSON_UPLOAD_NOT_ALLOWED );
606 + }
607 +
603 608 // If the template is a JSON file, allow uploading it.
604 609 add_filter( 'elementor/files/allow-file-type/json', [ $this, 'enable_json_template_upload' ] );
605 610 add_filter( 'elementor/files/allow_unfiltered_upload', [ $this, 'enable_json_template_upload' ] );
606 611
@@ -678,9 +683,17 @@
678 683 }
679 684
680 685 $import_data = $document->get_import_data( [ 'content' => $elements ] );
681 686
682 - return $import_data['content'];
687 + $content = $document::on_import_update_dynamic_content(
688 + $import_data['content'],
689 + [ 'post_ids' => [] ]
690 + );
691 +
692 + return Plugin::$instance->db->iterate_data( $content, function( $element_data ) {
693 + unset( $element_data['htmlCache'] );
694 + return $element_data;
695 + } );
683 696 }
684 697
685 698 public function process_global_styles( array $args ) {
686 699 $validate_args = $this->ensure_args( [ 'content', 'import_mode' ], $args );
@@ -888,8 +901,12 @@
888 901 * @throws \Exception If current user has no permission or the post is not found.
889 902 */
890 903 private function handle_ajax_request( $ajax_request, array $data ) {
891 904 if ( ! User::is_current_user_can_edit_post_type( Source_Local::CPT ) ) {
905 + throw new \Exception( 'Access denied.' );
906 + }
907 +
908 + if ( 'import_template' === $ajax_request && ! User::is_current_user_can_upload_json() ) {
892 909 throw new \Exception( 'Access denied.' );
893 910 }
894 911
895 912 if ( ! empty( $data['editor_post_id'] ) ) {