PluginProbe
Elementor Website Builder – more than just a page builder / 3.6.7
Elementor Website Builder – more than just a page builder v3.6.7
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 4.0.7 All 451 releases
← All changes | core/upgrade/upgrades.php +194 -204 4.1.0-dev23.6.7 View file →
@@ -3,16 +3,16 @@
3 3
4 4 use Elementor\Api;
5 5 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
6 6 use Elementor\Core\Experiments\Manager as Experiments_Manager;
7 +use Elementor\Core\Schemes\Base;
7 8 use Elementor\Core\Settings\Manager as SettingsManager;
8 9 use Elementor\Core\Settings\Page\Manager as SettingsPageManager;
9 10 use Elementor\Icons_Manager;
10 -use Elementor\Includes\Elements\Container;
11 11 use Elementor\Modules\Usage\Module;
12 12 use Elementor\Plugin;
13 13 use Elementor\Tracker;
14 -use Elementor\App\Modules\ImportExport\Utils;
14 +use Elementor\Utils;
15 15
16 16 if ( ! defined( 'ABSPATH' ) ) {
17 17 exit; // Exit if accessed directly.
18 18 }
@@ -404,9 +404,9 @@
404 404 update_metadata( 'post', $post_id, '_elementor_data', $json_value );
405 405
406 406 // Clear WP cache for next step.
407 407 wp_cache_flush();
408 - }
408 + } // End foreach().
409 409 }
410 410
411 411 /**
412 412 * @param Updater $updater
@@ -479,9 +479,9 @@
479 479 // We need the `wp_slash` in order to avoid the unslashing during the `update_post_meta`
480 480 $json_value = wp_slash( wp_json_encode( $data ) );
481 481
482 482 update_metadata( 'post', $post_id, '_elementor_data', $json_value );
483 - }
483 + } // End foreach().
484 484
485 485 return $updater->should_run_again( $post_ids );
486 486 }
487 487
@@ -515,9 +515,9 @@
515 515 continue;
516 516 }
517 517
518 518 $document->save_template_type();
519 - }
519 + } // End foreach().
520 520
521 521 return $updater->should_run_again( $post_ids );
522 522 }
523 523
@@ -529,9 +529,9 @@
529 529 add_option( 'elementor_load_fa4_shim', 'yes' );
530 530 }
531 531
532 532 /**
533 - * Migrate Icon control string value to Icons control array value
533 + * migrate Icon control string value to Icons control array value
534 534 *
535 535 * @param array $element
536 536 * @param array $args
537 537 *
@@ -581,10 +581,11 @@
581 581 /**
582 582 * Update database to separate page from post.
583 583 *
584 584 * @param Updater $updater
585 - * @param string $type
586 585 *
586 + * @param string $type
587 + *
587 588 * @return bool
588 589 */
589 590 public static function rename_document_base_to_wp( $updater, $type ) {
590 591 global $wpdb;
@@ -608,8 +609,26 @@
608 609 return $updater->should_run_again( $post_ids );
609 610 }
610 611
611 612 /**
613 + * Update database to separate page from post.
614 + *
615 + * @param Updater $updater
616 + *
617 + * @return bool
618 + */
619 + // Because the query is slow on large sites, temporary don't upgrade.
620 + /* public static function _v_2_7_0_rename_document_types_to_wp( $updater ) {
621 + return self::rename_document_base_to_wp( $updater, 'post' ) || self::rename_document_base_to_wp( $updater, 'page' );
622 + }*/
623 +
624 + // Upgrade code was fixed & moved to _v_2_7_1_remove_old_usage_data.
625 + /* public static function _v_2_7_0_remove_old_usage_data() {} */
626 +
627 + // Upgrade code moved to _v_2_7_1_recalc_usage_data.
628 + /* public static function _v_2_7_0_recalc_usage_data( $updater ) {} */
629 +
630 + /**
612 631 * Don't use the old data anymore.
613 632 * Since 2.7.1 the key was changed from `elementor_elements_usage` to `elementor_controls_usage`.
614 633 */
615 634 public static function _v_2_7_1_remove_old_usage_data() {
@@ -709,8 +728,174 @@
709 728
710 729 return self::move_settings_to_kit( $callback, $updater );
711 730 }
712 731
732 + /**
733 + * Move default colors settings to active kit and all it's revisions.
734 + *
735 + * @param Updater $updater
736 + *
737 + * @return bool
738 + */
739 + public static function _v_3_0_0_move_default_colors_to_kit( $updater, $include_revisions = true ) {
740 + $callback = function( $kit_id ) {
741 + if ( ! Plugin::$instance->kits_manager->is_custom_colors_enabled() ) {
742 + self::notice( 'System colors are disabled. nothing to do.' );
743 + return;
744 + }
745 +
746 + $kit = Plugin::$instance->documents->get( $kit_id );
747 +
748 + // Already exist. use raw settings that doesn't have default values.
749 + $meta_key = SettingsPageManager::META_KEY;
750 + $kit_raw_settings = $kit->get_meta( $meta_key );
751 + if ( isset( $kit_raw_settings['system_colors'] ) ) {
752 + self::notice( 'System colors already exist. nothing to do.' );
753 + return;
754 + }
755 +
756 + $scheme_obj = Plugin::$instance->schemes_manager->get_scheme( 'color' );
757 +
758 + $default_colors = $scheme_obj->get_scheme();
759 +
760 + $new_ids = [
761 + 'primary',
762 + 'secondary',
763 + 'text',
764 + 'accent',
765 + ];
766 +
767 + foreach ( $default_colors as $index => $color ) {
768 + $kit->add_repeater_row( 'system_colors', [
769 + '_id' => $new_ids[ $index - 1 ], // $default_colors starts from 1.
770 + 'title' => $color['title'],
771 + 'color' => strtoupper( $color['value'] ),
772 + ] );
773 + }
774 + };
775 +
776 + return self::move_settings_to_kit( $callback, $updater, $include_revisions );
777 + }
778 +
779 + /**
780 + * Move saved colors settings to active kit and all it's revisions.
781 + *
782 + * @param Updater $updater
783 + *
784 + * @return bool
785 + */
786 + public static function _v_3_0_0_move_saved_colors_to_kit( $updater, $include_revisions = true ) {
787 + $callback = function( $kit_id ) {
788 + $kit = Plugin::$instance->documents->get( $kit_id );
789 +
790 + // Already exist. use raw settings that doesn't have default values.
791 + $meta_key = SettingsPageManager::META_KEY;
792 + $kit_raw_settings = $kit->get_meta( $meta_key );
793 + if ( isset( $kit_raw_settings['custom_colors'] ) ) {
794 + self::notice( 'Custom colors already exist. nothing to do.' );
795 + return;
796 + }
797 +
798 + $system_colors_rows = $kit->get_settings( 'system_colors' );
799 +
800 + if ( ! $system_colors_rows ) {
801 + $system_colors_rows = [];
802 + }
803 +
804 + $system_colors = [];
805 +
806 + foreach ( $system_colors_rows as $color_row ) {
807 + $system_colors[] = strtoupper( $color_row['color'] );
808 + }
809 +
810 + $saved_scheme_obj = Plugin::$instance->schemes_manager->get_scheme( 'color-picker' );
811 +
812 + $current_saved_colors_rows = $saved_scheme_obj->get_scheme();
813 +
814 + $current_saved_colors = [];
815 +
816 + foreach ( $current_saved_colors_rows as $color_row ) {
817 + $current_saved_colors[] = strtoupper( $color_row['value'] );
818 + }
819 +
820 + $colors_to_save = array_diff( $current_saved_colors, $system_colors );
821 +
822 + if ( empty( $colors_to_save ) ) {
823 + self::notice( 'Saved colors not found. nothing to do.' );
824 + return;
825 + }
826 +
827 + foreach ( $colors_to_save as $index => $color ) {
828 + $kit->add_repeater_row( 'custom_colors', [
829 + '_id' => Utils::generate_random_string(),
830 + 'title' => esc_html__( 'Saved Color', 'elementor' ) . ' #' . ( $index + 1 ),
831 + 'color' => $color,
832 + ] );
833 + }
834 + };
835 +
836 + return self::move_settings_to_kit( $callback, $updater, $include_revisions );
837 + }
838 +
839 + /**
840 + * Move default typography settings to active kit and all it's revisions.
841 + *
842 + * @param Updater $updater
843 + *
844 + * @return bool
845 + */
846 + public static function _v_3_0_0_move_default_typography_to_kit( $updater, $include_revisions = true ) {
847 + $callback = function( $kit_id ) {
848 + if ( ! Plugin::$instance->kits_manager->is_custom_typography_enabled() ) {
849 + self::notice( 'System typography is disabled. nothing to do.' );
850 + return;
851 + }
852 +
853 + $kit = Plugin::$instance->documents->get( $kit_id );
854 +
855 + // Already exist. use raw settings that doesn't have default values.
856 + $meta_key = SettingsPageManager::META_KEY;
857 + $kit_raw_settings = $kit->get_meta( $meta_key );
858 + if ( isset( $kit_raw_settings['system_typography'] ) ) {
859 + self::notice( 'System typography already exist. nothing to do.' );
860 + return;
861 + }
862 +
863 + $scheme_obj = Plugin::$instance->schemes_manager->get_scheme( 'typography' );
864 +
865 + $default_typography = $scheme_obj->get_scheme();
866 +
867 + $new_ids = [
868 + 'primary',
869 + 'secondary',
870 + 'text',
871 + 'accent',
872 + ];
873 +
874 + foreach ( $default_typography as $index => $typography ) {
875 + $kit->add_repeater_row( 'system_typography', [
876 + '_id' => $new_ids[ $index - 1 ], // $default_typography starts from 1.
877 + 'title' => $typography['title'],
878 + 'typography_typography' => 'custom',
879 + 'typography_font_family' => $typography['value']['font_family'],
880 + 'typography_font_weight' => $typography['value']['font_weight'],
881 + ] );
882 + }
883 + };
884 +
885 + return self::move_settings_to_kit( $callback, $updater, $include_revisions );
886 + }
887 +
888 + public static function v_3_1_0_move_optimized_dom_output_to_experiments() {
889 + $saved_option = get_option( 'elementor_optimized_dom_output' );
890 +
891 + if ( $saved_option ) {
892 + $new_option = 'enabled' === $saved_option ? Experiments_Manager::STATE_ACTIVE : Experiments_Manager::STATE_INACTIVE;
893 +
894 + add_option( 'elementor_experiment-e_dom_optimization', $new_option );
895 + }
896 + }
897 +
713 898 public static function _v_3_2_0_migrate_breakpoints_to_new_system( $updater, $include_revisions = true ) {
714 899 $callback = function( $kit_id ) {
715 900 $kit = Plugin::$instance->documents->get( $kit_id );
716 901
@@ -762,134 +947,13 @@
762 947
763 948 public static function _v_3_5_0_remove_old_elementor_scheme() {
764 949 global $wpdb;
765 950
766 - $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'elementor_scheme_%';" );
767 - }
951 + $key = Base::SCHEME_OPTION_PREFIX;
768 952
769 - public static function _v_3_8_0_fix_php8_image_custom_size() {
770 - global $wpdb;
771 -
772 - $attachment_ids = $wpdb->get_col(
773 - 'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
774 - WHERE `meta_key` = "_wp_attachment_metadata"
775 - AND (
776 - `meta_value` LIKE \'%elementor_custom_%\'
777 - );'
778 - );
779 -
780 - foreach ( $attachment_ids as $attachment_id ) {
781 - $attachment_metadata = wp_get_attachment_metadata( $attachment_id );
782 - if ( empty( $attachment_metadata['sizes'] ) || ! is_array( $attachment_metadata['sizes'] ) ) {
783 - continue;
784 - }
785 -
786 - $old_attachment_metadata = $attachment_metadata;
787 - foreach ( $attachment_metadata['sizes'] as $size_key => $size_value ) {
788 - if ( 0 !== strpos( $size_key, 'elementor_custom_' ) ) {
789 - continue;
790 - }
791 -
792 - if ( absint( $size_value['width'] ) !== $size_value['width'] ) {
793 - $attachment_metadata['sizes'][ $size_key ]['width'] = (int) $size_value['width'];
794 - }
795 -
796 - if ( absint( $size_value['height'] ) !== $size_value['height'] ) {
797 - $attachment_metadata['sizes'][ $size_key ]['height'] = (int) $size_value['height'];
798 - }
799 - }
800 -
801 - if ( $old_attachment_metadata['sizes'] === $attachment_metadata['sizes'] ) {
802 - continue;
803 - }
804 -
805 - wp_update_attachment_metadata( $attachment_id, $attachment_metadata );
806 - }
953 + $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '{$key}%';" ); // phpcs:ignore
807 954 }
808 955
809 - public static function _v_3_16_0_container_updates( $updater ) {
810 - $post_ids = self::get_post_ids_by_element_type( $updater, 'container' );
811 -
812 - if ( empty( $post_ids ) ) {
813 - return false;
814 - }
815 -
816 - foreach ( $post_ids as $post_id ) {
817 - $document = Plugin::$instance->documents->get( $post_id );
818 -
819 - if ( $document ) {
820 - $data = $document->get_elements_data();
821 - }
822 -
823 - if ( empty( $data ) ) {
824 - continue;
825 - }
826 -
827 - $data = self::iterate_containers( $data );
828 -
829 - self::save_updated_document( $post_id, $data );
830 - }
831 - }
832 -
833 - public static function _v_3_17_0_site_settings_updates() {
834 - $options = [ 'elementor_active_kit', 'elementor_previous_kit' ];
835 -
836 - foreach ( $options as $option_name ) {
837 - self::maybe_add_gap_control_data( $option_name );
838 - }
839 - }
840 -
841 - /**
842 - * Upgrade Elementor 3.26.0 - Delete old experiments from the DB.
843 - *
844 - * @since 3.26.0
845 - * @static
846 - * @access public
847 - */
848 - public static function _v_3_26_0() {
849 - delete_option( 'elementor_experiment-ai-layout' );
850 - delete_option( 'elementor_experiment-block_editor_assets_optimize' );
851 - delete_option( 'elementor_experiment-container_grid' );
852 - delete_option( 'elementor_experiment-display-conditions' );
853 - delete_option( 'elementor_experiment-e_dom_optimization' );
854 - delete_option( 'elementor_experiment-e_global_styleguide' );
855 - delete_option( 'elementor_experiment-e_image_loading_optimization' );
856 - delete_option( 'elementor_experiment-e_lazyload' );
857 - delete_option( 'elementor_experiment-e_optimized_assets_loading' );
858 - delete_option( 'elementor_experiment-e_optimized_css_loading' );
859 - delete_option( 'elementor_experiment-e_scroll_snap' );
860 - delete_option( 'elementor_experiment-floating-buttons' );
861 - delete_option( 'elementor_experiment-form-submissions' );
862 - delete_option( 'elementor_experiment-link-in-bio' );
863 - delete_option( 'elementor_experiment-loop' );
864 - delete_option( 'elementor_experiment-notes' );
865 - delete_option( 'elementor_experiment-off-canvas' );
866 - delete_option( 'elementor_experiment-page-transitions' );
867 - delete_option( 'elementor_experiment-search' );
868 - delete_option( 'elementor_experiment-taxonomy-filter' );
869 - }
870 -
871 - private static function maybe_add_gap_control_data( $option_name ) {
872 - $kit_id = get_option( $option_name );
873 -
874 - if ( ! $kit_id ) {
875 - return;
876 - }
877 -
878 - $kit_data_array = get_post_meta( (int) $kit_id, '_elementor_page_settings', true );
879 -
880 - $setting_not_exist = ! isset( $kit_data_array['space_between_widgets'] );
881 - $already_processed = isset( $kit_data_array['space_between_widgets']['column'] );
882 -
883 - if ( $setting_not_exist || $already_processed ) {
884 - return;
885 - }
886 -
887 - $kit_data_array['space_between_widgets'] = Utils::update_space_between_widgets_values( $kit_data_array['space_between_widgets'] );
888 -
889 - update_post_meta( (int) $kit_id, '_elementor_page_settings', $kit_data_array );
890 - }
891 -
892 956 public static function remove_remote_info_api_data() {
893 957 global $wpdb;
894 958
895 959 $key = Api::TRANSIENT_KEY_PREFIX;
@@ -939,80 +1003,6 @@
939 1003
940 1004 private static function notice( $message ) {
941 1005 $logger = Plugin::$instance->logger->get_logger();
942 1006 $logger->notice( $message );
943 - }
944 -
945 - public static function get_post_ids_by_element_type( $updater, string $element_type ): array {
946 - global $wpdb;
947 -
948 - return $updater->query_col(
949 - 'SELECT `post_id`
950 - FROM `' . $wpdb->postmeta . '`
951 - WHERE `meta_key` = "_elementor_data"
952 - AND `meta_value` LIKE \'%"elType":"' . $element_type . '"%\';'
953 - );
954 - }
955 - /**
956 - * @param $data
957 - *
958 - * @return array|mixed
959 - */
960 - private static function iterate_containers( $data ) {
961 - return Plugin::$instance->db->iterate_data(
962 - $data, function ( $element ) {
963 -
964 - if ( 'container' !== $element['elType'] || ! isset( $element['elements'] ) ) {
965 - return $element;
966 - }
967 -
968 - $element = self::maybe_convert_to_inner_container( $element );
969 - $element = self::maybe_convert_to_grid_container( $element );
970 - return Container::slider_to_gaps_converter( $element );
971 - }
972 - );
973 - }
974 -
975 - /**
976 - * @param $element
977 - *
978 - * @return array
979 - */
980 - private static function maybe_convert_to_inner_container( $element ) {
981 - foreach ( $element['elements'] as &$inner_element ) {
982 - if ( 'container' === $inner_element['elType'] && ! $inner_element['isInner'] ) {
983 - $inner_element['isInner'] = true;
984 - }
985 - }
986 -
987 - return $element;
988 - }
989 -
990 - /**
991 - * @param $element
992 - *
993 - * @return array
994 - */
995 - private static function maybe_convert_to_grid_container( $element ) {
996 - $is_grid_container = isset( $element['settings']['container_type'] ) && 'grid' === $element['settings']['container_type'];
997 - if ( 'container' !== $element['elType'] || empty( $element['settings'] ) || ! $is_grid_container ) {
998 - return $element;
999 - }
1000 -
1001 - $element['settings']['presetTitle'] = 'Grid';
1002 - $element['settings']['presetIcon'] = 'eicon-container-grid';
1003 -
1004 - return $element;
1005 - }
1006 -
1007 - /**
1008 - * @param $post_id
1009 - * @param $data
1010 - *
1011 - * @return void
1012 - */
1013 - private static function save_updated_document( $post_id, $data ) {
1014 - $json_value = wp_slash( wp_json_encode( $data ) );
1015 -
1016 - update_metadata( 'post', $post_id, '_elementor_data', $json_value );
1017 1007 }
1018 1008 }