PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.8
Elementor Website Builder – more than just a page builder v3.35.8
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 +9 -96 4.1.0-dev13.35.8 View file →
@@ -5,9 +5,8 @@
5 5 use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
6 6 use Elementor\Core\Settings\Manager as SettingsManager;
7 7 use Elementor\Includes\TemplateLibrary\Data\Controller;
8 8 use Elementor\TemplateLibrary\Classes\Import_Images;
9 -use Elementor\Core\Utils\Template_Library_Import_Export_Utils;
10 9 use Elementor\Plugin;
11 10 use Elementor\User;
12 11 use Elementor\Utils;
13 12
@@ -615,10 +614,9 @@
615 614 }
616 615
617 616 $source = $this->get_source( $data['source'] ?? 'local' );
618 617
619 - $import_mode = $data['import_mode'] ?? 'match_site';
620 - $import_result = $source->import_template( $upload_result['name'], $upload_result['tmp_name'], $import_mode );
618 + $import_result = $source->import_template( $upload_result['name'], $upload_result['tmp_name'] );
621 619
622 620 // Remove the temporary directory generated for the stream-uploaded file.
623 621 Plugin::$instance->uploads_manager->remove_file_or_dir( dirname( $upload_result['tmp_name'] ) );
624 622
@@ -681,92 +679,8 @@
681 679
682 680 return $import_data['content'];
683 681 }
684 682
685 - public function process_global_styles( array $args ) {
686 - $validate_args = $this->ensure_args( [ 'content', 'import_mode' ], $args );
687 -
688 - if ( is_wp_error( $validate_args ) ) {
689 - return $validate_args;
690 - }
691 -
692 - $import_mode = Template_Library_Import_Export_Utils::sanitize_import_mode( $args['import_mode'] );
693 -
694 - $content = $this->get_validated_json_arg( $args, 'content' );
695 - if ( is_wp_error( $content ) ) {
696 - return $content;
697 - }
698 -
699 - $global_classes = $this->get_validated_json_arg( $args, 'global_classes', true );
700 - if ( is_wp_error( $global_classes ) ) {
701 - return $global_classes;
702 - }
703 -
704 - $global_variables = $this->get_validated_json_arg( $args, 'global_variables', true );
705 - if ( is_wp_error( $global_variables ) ) {
706 - return $global_variables;
707 - }
708 -
709 - $data = [
710 - 'global_classes' => $global_classes,
711 - 'global_variables' => $global_variables,
712 - ];
713 -
714 - $result = apply_filters(
715 - 'elementor/template_library/import/process_content',
716 - [ 'content' => $content ],
717 - $import_mode,
718 - $data,
719 - null
720 - );
721 -
722 - $response = [
723 - 'content' => $result['content'],
724 - ];
725 -
726 - if ( ! empty( $result['updated_global_classes'] ) ) {
727 - $response['updated_global_classes'] = $result['updated_global_classes'];
728 - }
729 -
730 - if ( ! empty( $result['updated_global_variables'] ) ) {
731 - $response['updated_global_variables'] = $result['updated_global_variables'];
732 - }
733 -
734 - $classes_to_flatten = $result['classes_to_flatten'] ?? [];
735 - $variables_to_flatten = $result['variables_to_flatten'] ?? [];
736 -
737 - if ( ! empty( $classes_to_flatten ) ) {
738 - $response['flattened_classes_count'] = count( $classes_to_flatten );
739 - }
740 -
741 - if ( ! empty( $variables_to_flatten ) ) {
742 - $response['flattened_variables_count'] = count( $variables_to_flatten );
743 - }
744 -
745 - return $response;
746 - }
747 -
748 - private function get_validated_json_arg( array $args, string $key, bool $is_optional = false ) {
749 - if ( ! array_key_exists( $key, $args ) || null === $args[ $key ] || '' === $args[ $key ] ) {
750 - return $is_optional ? null : new \WP_Error( "invalid_$key", "Invalid $key." );
751 - }
752 -
753 - $value = $args[ $key ];
754 - if ( is_string( $value ) ) {
755 - $decoded = json_decode( $value, true );
756 - if ( JSON_ERROR_NONE !== json_last_error() ) {
757 - return new \WP_Error( "invalid_$key", "Invalid JSON $key." );
758 - }
759 - return $decoded;
760 - }
761 -
762 - if ( ! is_array( $value ) ) {
763 - return new \WP_Error( "invalid_$key", "Invalid $key format." );
764 - }
765 -
766 - return $value;
767 - }
768 -
769 683 public function get_item_children( array $args ) {
770 684 $validate_args = $this->ensure_args( [ 'source', 'template_id' ], $args );
771 685
772 686 if ( is_wp_error( $validate_args ) ) {
@@ -1013,9 +927,8 @@
1013 927 'bulk_copy_templates',
1014 928 'bulk_undo_delete_items',
1015 929 'get_templates_quota',
1016 930 'template_screenshot_failed',
1017 - 'process_global_styles',
1018 931 ];
1019 932
1020 933 foreach ( $library_ajax_requests as $ajax_request ) {
1021 934 $ajax->register_ajax_action( $ajax_request, function( $data ) use ( $ajax_request ) {
@@ -1148,15 +1061,15 @@
1148 1061
1149 1062 $bulk_args = $from_source->format_args_for_bulk_action( $args );
1150 1063
1151 1064 if ( $source->supports_quota() && ! $this->is_action_to_same_source( $args ) ) {
1152 - $quota_validation = $source->validate_quota( $bulk_args );
1065 + $is_quota_valid = $source->validate_quota( $bulk_args );
1153 1066
1154 - if ( is_wp_error( $quota_validation ) ) {
1155 - return $quota_validation;
1067 + if ( is_wp_error( $is_quota_valid ) ) {
1068 + return $is_quota_valid;
1156 1069 }
1157 1070
1158 - if ( false === $quota_validation ) {
1071 + if ( ! $is_quota_valid ) {
1159 1072 return new \WP_Error( 'quota_error', 'The moving failed because it will pass the maximum templates you can save.' );
1160 1073 }
1161 1074 }
1162 1075
@@ -1199,15 +1112,15 @@
1199 1112
1200 1113 $bulk_args = $from_source->format_args_for_bulk_action( $args );
1201 1114
1202 1115 if ( $source->supports_quota() && ! $this->is_action_to_same_source( $args ) ) {
1203 - $quota_validation = $source->validate_quota( $bulk_args );
1116 + $is_quota_valid = $source->validate_quota( $bulk_args );
1204 1117
1205 - if ( is_wp_error( $quota_validation ) ) {
1206 - return $quota_validation;
1118 + if ( is_wp_error( $is_quota_valid ) ) {
1119 + return $is_quota_valid;
1207 1120 }
1208 1121
1209 - if ( false === $quota_validation ) {
1122 + if ( ! $is_quota_valid ) {
1210 1123 return new \WP_Error( 'quota_error', 'The copying failed because it will pass the maximum templates you can save.' );
1211 1124 }
1212 1125 }
1213 1126