PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.2
Elementor Website Builder – more than just a page builder v3.1.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
← All changes | includes/db.php +22 -76 4.1.53.1.2 View file →
@@ -2,9 +2,8 @@
2 2 namespace Elementor;
3 3
4 4 use Elementor\Core\Base\Document;
5 5 use Elementor\Core\DynamicTags\Manager;
6 -use Elementor\TemplateLibrary\Source_Local;
7 6
8 7 if ( ! defined( 'ABSPATH' ) ) {
9 8 exit; // Exit if accessed directly.
10 9 }
@@ -26,9 +25,9 @@
26 25
27 26 /**
28 27 * Post publish status.
29 28 *
30 - * @deprecated 3.1.0 Use `Document::STATUS_PUBLISH` const instead.
29 + * @deprecated 3.1.0 Use `Document::STATUS_PUBLISH` instead
31 30 */
32 31 const STATUS_PUBLISH = Document::STATUS_PUBLISH;
33 32
34 33 /**
@@ -33,9 +32,9 @@
33 32
34 33 /**
35 34 * Post draft status.
36 35 *
37 - * @deprecated 3.1.0 Use `Document::STATUS_DRAFT` const instead.
36 + * @deprecated 3.1.0 Use `Document::STATUS_DRAFT` instead
38 37 */
39 38 const STATUS_DRAFT = Document::STATUS_DRAFT;
40 39
41 40 /**
@@ -40,9 +39,9 @@
40 39
41 40 /**
42 41 * Post private status.
43 42 *
44 - * @deprecated 3.1.0 Use `Document::STATUS_PRIVATE` const instead.
43 + * @deprecated 3.1.0 Use `Document::STATUS_PRIVATE` instead
45 44 */
46 45 const STATUS_PRIVATE = Document::STATUS_PRIVATE;
47 46
48 47 /**
@@ -47,9 +46,9 @@
47 46
48 47 /**
49 48 * Post autosave status.
50 49 *
51 - * @deprecated 3.1.0 Use `Document::STATUS_AUTOSAVE` const instead.
50 + * @deprecated 3.1.0 Use `Document::STATUS_AUTOSAVE` instead
52 51 */
53 52 const STATUS_AUTOSAVE = Document::STATUS_AUTOSAVE;
54 53
55 54 /**
@@ -54,9 +53,9 @@
54 53
55 54 /**
56 55 * Post pending status.
57 56 *
58 - * @deprecated 3.1.0 Use `Document::STATUS_PENDING` const instead.
57 + * @deprecated 3.1.0 Use `Document::STATUS_PENDING` instead
59 58 */
60 59 const STATUS_PENDING = Document::STATUS_PENDING;
61 60
62 61 /**
@@ -88,13 +87,13 @@
88 87 *
89 88 * Retrieve editor data from the database.
90 89 *
91 90 * @since 1.0.0
92 - * @deprecated 3.1.0 Use `Plugin::$instance->documents->get( $post_id )->get_elements_raw_data( null, true )` OR `Plugin::$instance->documents->get_doc_or_auto_save( $post_id )->get_elements_raw_data( null, true )` instead.
91 + * @deprecated 3.1.0 Use `Plugin::$instance->documents->get( $post_id )->get_elements_raw_data( null, true )` OR `Plugin::$instance->documents->get_doc_or_auto_save( $post_id )->get_elements_raw_data( null, true )` instead
93 92 * @access public
94 93 *
95 - * @param int $post_id Post ID.
96 - * @param string $status Optional. Post status. Default is `publish`.
94 + * @param int $post_id Post ID.
95 + * @param string $status Optional. Post status. Default is `publish`.
97 96 *
98 97 * @return array Editor data.
99 98 */
100 99 public function get_builder( $post_id, $status = Document::STATUS_PUBLISH ) {
@@ -156,9 +155,9 @@
156 155 *
157 156 * Set whether the page is using Elementor or not.
158 157 *
159 158 * @since 1.5.0
160 - * @deprecated 3.1.0 Use `Plugin::$instance->documents->get( $post_id )->set_is_build_with_elementor( $is_elementor )` instead.
159 + * @deprecated 3.1.0 Use `Plugin::$instance->documents->get( $post_id )->set_is_build_with_elementor( $is_elementor )` instead
161 160 * @access public
162 161 *
163 162 * @param int $post_id Post ID.
164 163 * @param bool $is_elementor Optional. Whether the page is elementor page.
@@ -251,9 +250,9 @@
251 250 * @access public
252 251 *
253 252 * @param array $data_container Any type of elementor data.
254 253 * @param callable $callback A function to iterate data by.
255 - * @param array $args Array of args pointers for passing parameters in & out of the callback.
254 + * @param array $args Array of args pointers for passing parameters in & out of the callback
256 255 *
257 256 * @return mixed Iterated data.
258 257 */
259 258 public function iterate_data( $data_container, $callback, $args = [] ) {
@@ -277,39 +276,8 @@
277 276
278 277 return $data_container;
279 278 }
280 279
281 - public static function iterate_elementor_documents( $callback, $batch_size = 100, $additional_post_types = [] ) {
282 - $processed_posts = 0;
283 -
284 - while ( true ) {
285 - $args = wp_parse_args( [
286 - 'post_type' => array_merge( [ Source_Local::CPT, 'post', 'page' ], $additional_post_types ),
287 - 'post_status' => [ 'publish' ],
288 - 'posts_per_page' => $batch_size,
289 - 'meta_key' => Document::BUILT_WITH_ELEMENTOR_META_KEY,
290 - 'meta_value' => 'builder',
291 - 'offset' => $processed_posts,
292 - 'fields' => 'ids',
293 - ] );
294 -
295 - $query = new \WP_Query( $args );
296 -
297 - if ( empty( $query->posts ) ) {
298 - break;
299 - }
300 -
301 - foreach ( $query->posts as $post_id ) {
302 - $document = Plugin::$instance->documents->get( $post_id );
303 - $elements_data = $document->get_json_meta( Document::ELEMENTOR_DATA_META_KEY );
304 -
305 - $callback( $document, $elements_data );
306 -
307 - ++$processed_posts;
308 - }
309 - }
310 - }
311 -
312 280 /**
313 281 * Safely copy Elementor meta.
314 282 *
315 283 * Make sure the original page was built with Elementor and the post is not
@@ -324,15 +292,14 @@
324 292 */
325 293 public function safe_copy_elementor_meta( $from_post_id, $to_post_id ) {
326 294 // It's from WP-Admin & not from Elementor.
327 295 if ( ! did_action( 'elementor/db/before_save' ) ) {
328 - $from_document = Plugin::$instance->documents->get( $from_post_id );
329 296
330 - if ( ! $from_document || ! $from_document->is_built_with_elementor() ) {
297 + if ( ! Plugin::$instance->db->is_built_with_elementor( $from_post_id ) ) {
331 298 return;
332 299 }
333 300
334 - // It's an exited Elementor auto-save.
301 + // It's an exited Elementor auto-save
335 302 if ( get_post_meta( $to_post_id, '_elementor_data', true ) ) {
336 303 return;
337 304 }
338 305 }
@@ -349,13 +316,12 @@
349 316 *
350 317 * @since 1.1.0
351 318 * @access public
352 319 *
353 - * @param int $from_post_id Original post ID.
354 - * @param int $to_post_id Target post ID.
355 - * @param ?array $specific_meta_keys Optional. Specific meta keys to copy. Default is null, which copies all elementor meta keys.
320 + * @param int $from_post_id Original post ID.
321 + * @param int $to_post_id Target post ID.
356 322 */
357 - public function copy_elementor_meta( $from_post_id, $to_post_id, $specific_meta_keys = null ) {
323 + public function copy_elementor_meta( $from_post_id, $to_post_id ) {
358 324 $from_post_meta = get_post_meta( $from_post_id );
359 325 $core_meta = [
360 326 '_wp_page_template',
361 327 '_thumbnail_id',
@@ -361,17 +327,13 @@
361 327 '_thumbnail_id',
362 328 ];
363 329
364 330 foreach ( $from_post_meta as $meta_key => $values ) {
365 - if ( $specific_meta_keys && ! in_array( $meta_key, $specific_meta_keys, true ) ) {
366 - continue;
367 - }
368 -
369 - // Copy only meta with the `_elementor` prefix.
331 + // Copy only meta with the `_elementor` prefix
370 332 if ( 0 === strpos( $meta_key, '_elementor' ) || in_array( $meta_key, $core_meta, true ) ) {
371 333 $value = $values[0];
372 334
373 - // The elementor JSON needs slashes before saving.
335 + // The elementor JSON needs slashes before saving
374 336 if ( '_elementor_data' === $meta_key ) {
375 337 $value = wp_slash( $value );
376 338 } else {
377 339 $value = maybe_unserialize( $value );
@@ -376,9 +338,9 @@
376 338 } else {
377 339 $value = maybe_unserialize( $value );
378 340 }
379 341
380 - // Don't use `update_post_meta` that can't handle `revision` post type.
342 + // Don't use `update_post_meta` that can't handle `revision` post type
381 343 update_metadata( 'post', $to_post_id, $meta_key, $value );
382 344 }
383 345 }
384 346 }
@@ -388,9 +350,8 @@
388 350 *
389 351 * Check whether the post was built with Elementor.
390 352 *
391 353 * @since 1.0.10
392 - * @deprecated 3.2.0 Use `Plugin::$instance->documents->get( $post_id )->is_built_with_elementor()` instead.
393 354 * @access public
394 355 *
395 356 * @param int $post_id Post ID.
396 357 *
@@ -396,24 +357,9 @@
396 357 *
397 358 * @return bool Whether the post was built with Elementor.
398 359 */
399 360 public function is_built_with_elementor( $post_id ) {
400 - Plugin::$instance->modules_manager
401 - ->get_modules( 'dev-tools' )
402 - ->deprecation
403 - ->deprecated_function(
404 - __METHOD__,
405 - '3.2.0',
406 - 'Plugin::$instance->documents->get( $post_id )->is_built_with_elementor()'
407 - );
408 -
409 - $document = Plugin::$instance->documents->get( $post_id );
410 -
411 - if ( ! $document ) {
412 - return false;
413 - }
414 -
415 - return $document->is_built_with_elementor();
361 + return ! ! get_post_meta( $post_id, '_elementor_edit_mode', true );
416 362 }
417 363
418 364 /**
419 365 * Switch to post.
@@ -434,9 +380,9 @@
434 380 }
435 381
436 382 $this->switched_post_data[] = [
437 383 'switched_id' => $post_id,
438 - 'original_id' => get_the_ID(), // Note, it can be false if the global isn't set.
384 + 'original_id' => get_the_ID(), // Note, it can be false if the global isn't set
439 385 ];
440 386
441 387 $GLOBALS['post'] = get_post( $post_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
442 388
@@ -458,9 +404,9 @@
458 404 if ( ! $data ) {
459 405 return;
460 406 }
461 407
462 - // It was switched from an empty global post, restore this state and unset the global post.
408 + // It was switched from an empty global post, restore this state and unset the global post
463 409 if ( false === $data['original_id'] ) {
464 410 unset( $GLOBALS['post'] );
465 411 return;
466 412 }
@@ -507,9 +453,9 @@
507 453 $this->switched_data[] = $switched_data;
508 454
509 455 $wp_query = $new_query; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
510 456
511 - // Ensure the global post is set only if needed.
457 + // Ensure the global post is set only if needed
512 458 unset( $GLOBALS['post'] );
513 459
514 460 if ( isset( $new_query->posts[0] ) ) {
515 461 if ( $force_global_post || $new_query->is_singular() ) {