PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.0-dev3
Elementor Website Builder – more than just a page builder v3.17.0-dev3
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 +13 -50 4.2.03.17.0-dev3 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 }
@@ -91,10 +90,10 @@
91 90 * @since 1.0.0
92 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 ) {
@@ -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
@@ -330,9 +298,9 @@
330 298 if ( ! $from_document || ! $from_document->is_built_with_elementor() ) {
331 299 return;
332 300 }
333 301
334 - // It's an exited Elementor auto-save.
302 + // It's an exited Elementor auto-save
335 303 if ( get_post_meta( $to_post_id, '_elementor_data', true ) ) {
336 304 return;
337 305 }
338 306 }
@@ -349,13 +317,12 @@
349 317 *
350 318 * @since 1.1.0
351 319 * @access public
352 320 *
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.
321 + * @param int $from_post_id Original post ID.
322 + * @param int $to_post_id Target post ID.
356 323 */
357 - public function copy_elementor_meta( $from_post_id, $to_post_id, $specific_meta_keys = null ) {
324 + public function copy_elementor_meta( $from_post_id, $to_post_id ) {
358 325 $from_post_meta = get_post_meta( $from_post_id );
359 326 $core_meta = [
360 327 '_wp_page_template',
361 328 '_thumbnail_id',
@@ -361,17 +328,13 @@
361 328 '_thumbnail_id',
362 329 ];
363 330
364 331 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.
332 + // Copy only meta with the `_elementor` prefix
370 333 if ( 0 === strpos( $meta_key, '_elementor' ) || in_array( $meta_key, $core_meta, true ) ) {
371 334 $value = $values[0];
372 335
373 - // The elementor JSON needs slashes before saving.
336 + // The elementor JSON needs slashes before saving
374 337 if ( '_elementor_data' === $meta_key ) {
375 338 $value = wp_slash( $value );
376 339 } else {
377 340 $value = maybe_unserialize( $value );
@@ -376,9 +339,9 @@
376 339 } else {
377 340 $value = maybe_unserialize( $value );
378 341 }
379 342
380 - // Don't use `update_post_meta` that can't handle `revision` post type.
343 + // Don't use `update_post_meta` that can't handle `revision` post type
381 344 update_metadata( 'post', $to_post_id, $meta_key, $value );
382 345 }
383 346 }
384 347 }
@@ -434,9 +397,9 @@
434 397 }
435 398
436 399 $this->switched_post_data[] = [
437 400 'switched_id' => $post_id,
438 - 'original_id' => get_the_ID(), // Note, it can be false if the global isn't set.
401 + 'original_id' => get_the_ID(), // Note, it can be false if the global isn't set
439 402 ];
440 403
441 404 $GLOBALS['post'] = get_post( $post_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
442 405
@@ -458,9 +421,9 @@
458 421 if ( ! $data ) {
459 422 return;
460 423 }
461 424
462 - // It was switched from an empty global post, restore this state and unset the global post.
425 + // It was switched from an empty global post, restore this state and unset the global post
463 426 if ( false === $data['original_id'] ) {
464 427 unset( $GLOBALS['post'] );
465 428 return;
466 429 }
@@ -507,9 +470,9 @@
507 470 $this->switched_data[] = $switched_data;
508 471
509 472 $wp_query = $new_query; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
510 473
511 - // Ensure the global post is set only if needed.
474 + // Ensure the global post is set only if needed
512 475 unset( $GLOBALS['post'] );
513 476
514 477 if ( isset( $new_query->posts[0] ) ) {
515 478 if ( $force_global_post || $new_query->is_singular() ) {