PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.2
Elementor Website Builder – more than just a page builder v4.2.2
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
elementor / core / upgrade / upgrade-utils.php

upgrade-utils.php in Elementor Website Builder – more than just a page builder 4.2.2, at core/upgrade/upgrade-utils.php

78 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Upgrade;
3
4 use Elementor\Plugin;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly.
8 }
9
10 class Upgrade_Utils {
11
12 /**
13 * _update_widget_settings
14 *
15 * @param string $widget_id widget type id.
16 * @param Updater $updater updater instance.
17 * @param array $changes array containing updating control_ids, callback and other data needed by the callback.
18 *
19 * @return bool
20 */
21 public static function _update_widget_settings( $widget_id, $updater, $changes ) {
22 global $wpdb;
23
24 $post_ids = $updater->query_col(
25 'SELECT `post_id`
26 FROM `' . $wpdb->postmeta . '`
27 WHERE `meta_key` = "_elementor_data"
28 AND `meta_value` LIKE \'%"widgetType":"' . $widget_id . '"%\';'
29 );
30
31 if ( empty( $post_ids ) ) {
32 return false;
33 }
34
35 foreach ( $post_ids as $post_id ) {
36 $do_update = false;
37
38 $document = Plugin::instance()->documents->get( $post_id );
39
40 if ( ! $document ) {
41 continue;
42 }
43
44 $data = $document->get_elements_data();
45
46 if ( empty( $data ) ) {
47 continue;
48 }
49
50 // loop thru callbacks & array
51 foreach ( $changes as $change ) {
52 $args = [
53 'do_update' => &$do_update,
54 'widget_id' => $widget_id,
55 'control_ids' => $change['control_ids'],
56 ];
57
58 if ( isset( $change['prefix'] ) ) {
59 $args['prefix'] = $change['prefix'];
60 $args['new_id'] = $change['new_id'];
61 }
62
63 $data = Plugin::instance()->db->iterate_data( $data, $change['callback'], $args );
64 if ( ! $do_update ) {
65 continue;
66 }
67
68 // We need the `wp_slash` in order to avoid the unslashing during the `update_metadata`
69 $json_value = wp_slash( wp_json_encode( $data ) );
70
71 update_metadata( 'post', $post_id, '_elementor_data', $json_value );
72 }
73 }
74
75 return $updater->should_run_again( $post_ids );
76 }
77 }
78