PluginProbe
Elementor Website Builder – more than just a page builder / 3.6.4
Elementor Website Builder – more than just a page builder v3.6.4
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 / base / document.php

document.php in Elementor Website Builder – more than just a page builder 3.6.4, at core/base/document.php

1,703 lines 41.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Base;
3
4 use Elementor\Core\Base\Elements_Iteration_Actions\Assets as Assets_Iteration_Action;
5 use Elementor\Core\Base\Elements_Iteration_Actions\Base as Elements_Iteration_Action;
6 use Elementor\Core\Files\CSS\Post as Post_CSS;
7 use Elementor\Core\Settings\Page\Model as Page_Model;
8 use Elementor\Core\Utils\Exceptions;
9 use Elementor\Includes\Elements\Container;
10 use Elementor\Plugin;
11 use Elementor\Controls_Manager;
12 use Elementor\Controls_Stack;
13 use Elementor\TemplateLibrary\Source_Local;
14 use Elementor\User;
15 use Elementor\Core\Settings\Manager as SettingsManager;
16 use Elementor\Utils;
17 use Elementor\Widget_Base;
18 use Elementor\Core\Settings\Page\Manager as PageManager;
19 use ElementorPro\Modules\Library\Widgets\Template;
20
21 if ( ! defined( 'ABSPATH' ) ) {
22 exit; // Exit if accessed directly
23 }
24
25 /**
26 * Elementor document.
27 *
28 * An abstract class that provides the needed properties and methods to
29 * manage and handle documents in inheriting classes.
30 *
31 * @since 2.0.0
32 * @abstract
33 */
34 abstract class Document extends Controls_Stack {
35
36 /**
37 * Document type meta key.
38 */
39 const TYPE_META_KEY = '_elementor_template_type';
40 const PAGE_META_KEY = '_elementor_page_settings';
41
42 const BUILT_WITH_ELEMENTOR_META_KEY = '_elementor_edit_mode';
43
44 /**
45 * Document publish status.
46 */
47 const STATUS_PUBLISH = 'publish';
48
49 /**
50 * Document draft status.
51 */
52 const STATUS_DRAFT = 'draft';
53
54 /**
55 * Document private status.
56 */
57 const STATUS_PRIVATE = 'private';
58
59 /**
60 * Document autosave status.
61 */
62 const STATUS_AUTOSAVE = 'autosave';
63
64 /**
65 * Document pending status.
66 */
67 const STATUS_PENDING = 'pending';
68
69
70 private $main_id;
71
72 /**
73 * @var bool
74 */
75 private $is_saving = false;
76
77 private static $properties = [];
78
79 /**
80 * @var Elements_Iteration_Action[]
81 */
82 private $elements_iteration_actions = [];
83
84 /**
85 * Document post data.
86 *
87 * Holds the document post data.
88 *
89 * @since 2.0.0
90 * @access protected
91 *
92 * @var \WP_Post WordPress post data.
93 */
94 protected $post;
95
96 /**
97 * @since 2.1.0
98 * @access protected
99 * @static
100 */
101 protected static function get_editor_panel_categories() {
102 return Plugin::$instance->elements_manager->get_categories();
103 }
104
105 /**
106 * Get properties.
107 *
108 * Retrieve the document properties.
109 *
110 * @since 2.0.0
111 * @access public
112 * @static
113 *
114 * @return array Document properties.
115 */
116 public static function get_properties() {
117 return [
118 'has_elements' => true,
119 'is_editable' => true,
120 'edit_capability' => '',
121 'show_in_finder' => true,
122 'show_on_admin_bar' => true,
123 'support_kit' => false,
124 ];
125 }
126
127 /**
128 * @since 2.1.0
129 * @access public
130 * @static
131 */
132 public static function get_editor_panel_config() {
133 $default_route = 'panel/elements/categories';
134
135 if ( ! Plugin::instance()->role_manager->user_can( 'design' ) ) {
136 $default_route = 'panel/page-settings/settings';
137 }
138
139 return [
140 'title' => static::get_title(), // JS Container title.
141 'widgets_settings' => [],
142 'elements_categories' => static::get_editor_panel_categories(),
143 'default_route' => $default_route,
144 'has_elements' => static::get_property( 'has_elements' ),
145 'support_kit' => static::get_property( 'support_kit' ),
146 'messages' => [
147 /* translators: %s: Document title. */
148 'publish_notification' => sprintf( esc_html__( 'Hurray! Your %s is live.', 'elementor' ), static::get_title() ),
149 ],
150 ];
151 }
152
153 /**
154 * Get element title.
155 *
156 * Retrieve the element title.
157 *
158 * @since 2.0.0
159 * @access public
160 * @static
161 *
162 * @return string Element title.
163 */
164 public static function get_title() {
165 return esc_html__( 'Document', 'elementor' );
166 }
167
168 public static function get_plural_title() {
169 return static::get_title();
170 }
171
172 public static function get_add_new_title() {
173 return sprintf( esc_html__( 'Add New %s', 'elementor' ), static::get_title() );
174 }
175
176 /**
177 * Get property.
178 *
179 * Retrieve the document property.
180 *
181 * @since 2.0.0
182 * @access public
183 * @static
184 *
185 * @param string $key The property key.
186 *
187 * @return mixed The property value.
188 */
189 public static function get_property( $key ) {
190 $id = static::get_class_full_name();
191
192 if ( ! isset( self::$properties[ $id ] ) ) {
193 self::$properties[ $id ] = static::get_properties();
194 }
195
196 return self::get_items( self::$properties[ $id ], $key );
197 }
198
199 /**
200 * @since 2.0.0
201 * @access public
202 * @static
203 */
204 public static function get_class_full_name() {
205 return get_called_class();
206 }
207
208 public static function get_create_url() {
209 $properties = static::get_properties();
210
211 // BC Support - Each document should define it own CPT this code is for BC support.
212 $cpt = Source_Local::CPT;
213
214 if ( isset( $properties['cpt'][0] ) ) {
215 $cpt = $properties['cpt'][0];
216 }
217
218 return Plugin::$instance->documents->get_create_new_post_url( $cpt, static::get_type() );
219 }
220
221 public function get_name() {
222 return static::get_type();
223 }
224
225 /**
226 * @since 2.0.0
227 * @access public
228 */
229 public function get_unique_name() {
230 return static::get_type() . '-' . $this->post->ID;
231 }
232
233 /**
234 * @since 2.3.0
235 * @access public
236 */
237 public function get_post_type_title() {
238 $post_type_object = get_post_type_object( $this->post->post_type );
239
240 return $post_type_object->labels->singular_name;
241 }
242
243 /**
244 * @since 2.0.0
245 * @access public
246 */
247 public function get_main_id() {
248 if ( ! $this->main_id ) {
249 $post_id = $this->post->ID;
250
251 $parent_post_id = wp_is_post_revision( $post_id );
252
253 if ( $parent_post_id ) {
254 $post_id = $parent_post_id;
255 }
256
257 $this->main_id = $post_id;
258 }
259
260 return $this->main_id;
261 }
262
263 /**
264 * @since 2.0.0
265 * @access public
266 *
267 * @param $data
268 *
269 * @throws \Exception If the widget was not found.
270 *
271 * @return string
272 */
273 public function render_element( $data ) {
274 // Start buffering
275 ob_start();
276
277 /** @var Widget_Base $widget */
278 $widget = Plugin::$instance->elements_manager->create_element_instance( $data );
279
280 if ( ! $widget ) {
281 throw new \Exception( 'Widget not found.' );
282 }
283
284 $widget->render_content();
285
286 $render_html = ob_get_clean();
287
288 return $render_html;
289 }
290
291 /**
292 * @since 2.0.0
293 * @access public
294 */
295 public function get_main_post() {
296 return get_post( $this->get_main_id() );
297 }
298
299 public function get_container_attributes() {
300 $id = $this->get_main_id();
301
302 $attributes = [
303 'data-elementor-type' => $this->get_name(),
304 'data-elementor-id' => $id,
305 'class' => 'elementor elementor-' . $id,
306 ];
307
308 $version_meta = $this->get_main_meta( '_elementor_version' );
309
310 if ( version_compare( $version_meta, '2.5.0', '<' ) ) {
311 $attributes['class'] .= ' elementor-bc-flex-widget';
312 }
313
314 if ( Plugin::$instance->preview->is_preview() ) {
315 $attributes['data-elementor-title'] = static::get_title();
316 } else {
317 $elementor_settings = $this->get_frontend_settings();
318 if ( ! empty( $elementor_settings ) ) {
319 $attributes['data-elementor-settings'] = wp_json_encode( $elementor_settings );
320 }
321 }
322
323 return $attributes;
324 }
325
326 /**
327 * @since 2.0.0
328 * @access public
329 */
330 public function get_wp_preview_url() {
331 $main_post_id = $this->get_main_id();
332 $document = $this;
333
334 // Ajax request from editor.
335 // PHPCS - only reading the value from $_POST['initial_document_id'].
336 if ( ! empty( $_POST['initial_document_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
337 // PHPCS - only reading the value from $_POST['initial_document_id'].
338 $document = Plugin::$instance->documents->get( $_POST['initial_document_id'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
339 }
340
341 $url = get_preview_post_link(
342 $document->get_main_id(),
343 [
344 'preview_id' => $main_post_id,
345 'preview_nonce' => wp_create_nonce( 'post_preview_' . $main_post_id ),
346 ]
347 );
348
349 /**
350 * Document "WordPress preview" URL.
351 *
352 * Filters the WordPress preview URL.
353 *
354 * @since 2.0.0
355 *
356 * @param string $url WordPress preview URL.
357 * @param Document $this The document instance.
358 */
359 $url = apply_filters( 'elementor/document/urls/wp_preview', $url, $this );
360
361 return $url;
362 }
363
364 /**
365 * @since 2.0.0
366 * @access public
367 */
368 public function get_exit_to_dashboard_url() {
369 $url = get_edit_post_link( $this->get_main_id(), 'raw' );
370
371 /**
372 * Document "exit to dashboard" URL.
373 *
374 * Filters the "Exit To Dashboard" URL.
375 *
376 * @since 2.0.0
377 *
378 * @param string $url The exit URL
379 * @param Document $this The document instance.
380 */
381 $url = apply_filters( 'elementor/document/urls/exit_to_dashboard', $url, $this );
382
383 return $url;
384 }
385
386 /**
387 * Get auto-saved post revision.
388 *
389 * Retrieve the auto-saved post revision that is newer than current post.
390 *
391 * @since 2.0.0
392 * @access public
393 *
394 *
395 * @return bool|Document
396 */
397
398 public function get_newer_autosave() {
399 $autosave = $this->get_autosave();
400
401 // Detect if there exists an autosave newer than the post.
402 if ( $autosave && mysql2date( 'U', $autosave->get_post()->post_modified_gmt, false ) > mysql2date( 'U', $this->post->post_modified_gmt, false ) ) {
403 return $autosave;
404 }
405
406 return false;
407 }
408
409 /**
410 * @since 2.0.0
411 * @access public
412 */
413 public function is_autosave() {
414 return wp_is_post_autosave( $this->post->ID );
415 }
416
417 /**
418 * Check if the current document is a 'revision'
419 *
420 * @return bool
421 */
422 public function is_revision() {
423 return 'revision' === $this->post->post_type;
424 }
425
426 /**
427 * Checks if the current document status is 'trash'.
428 *
429 * @return bool
430 */
431 public function is_trash() {
432 return 'trash' === $this->post->post_status;
433 }
434
435 /**
436 * @since 2.0.0
437 * @access public
438 *
439 * @param int $user_id
440 * @param bool $create
441 *
442 * @return bool|Document
443 */
444 public function get_autosave( $user_id = 0, $create = false ) {
445 if ( ! $user_id ) {
446 $user_id = get_current_user_id();
447 }
448
449 $autosave_id = $this->get_autosave_id( $user_id );
450
451 if ( $autosave_id ) {
452 $document = Plugin::$instance->documents->get( $autosave_id );
453 } elseif ( $create ) {
454 $autosave_id = wp_create_post_autosave( [
455 'post_ID' => $this->post->ID,
456 'post_type' => $this->post->post_type,
457 'post_title' => $this->post->post_title,
458 'post_excerpt' => $this->post->post_excerpt,
459 // Hack to cause $autosave_is_different=true in `wp_create_post_autosave`.
460 'post_content' => '<!-- Created With Elementor -->',
461 'post_modified' => current_time( 'mysql' ),
462 ] );
463
464 Plugin::$instance->db->copy_elementor_meta( $this->post->ID, $autosave_id );
465
466 $document = Plugin::$instance->documents->get( $autosave_id );
467 $document->save_template_type();
468 } else {
469 $document = false;
470 }
471
472 return $document;
473 }
474
475 /**
476 * Add/Remove edit link in dashboard.
477 *
478 * Add or remove an edit link to the post/page action links on the post/pages list table.
479 *
480 * Fired by `post_row_actions` and `page_row_actions` filters.
481 *
482 * @access public
483 *
484 * @param array $actions An array of row action links.
485 *
486 * @return array An updated array of row action links.
487 */
488 public function filter_admin_row_actions( $actions ) {
489 if ( $this->is_built_with_elementor() && $this->is_editable_by_current_user() ) {
490 $actions['edit_with_elementor'] = sprintf(
491 '<a href="%1$s">%2$s</a>',
492 $this->get_edit_url(),
493 __( 'Edit with Elementor', 'elementor' )
494 );
495 }
496
497 return $actions;
498 }
499
500 /**
501 * @since 2.0.0
502 * @access public
503 */
504 public function is_editable_by_current_user() {
505 $edit_capability = static::get_property( 'edit_capability' );
506 if ( $edit_capability && ! current_user_can( $edit_capability ) ) {
507 return false;
508 }
509
510 return self::get_property( 'is_editable' ) && User::is_current_user_can_edit( $this->get_main_id() );
511 }
512
513 /**
514 * @since 2.9.0
515 * @access protected
516 */
517 protected function get_initial_config() {
518 // Get document data *after* the scripts hook - so plugins can run compatibility before get data, but *before* enqueue the editor script - so elements can enqueue their own scripts that depended in editor script.
519
520 $locked_user = Plugin::$instance->editor->get_locked_user( $this->get_main_id() );
521
522 if ( $locked_user ) {
523 $locked_user = $locked_user->display_name;
524 }
525
526 $post_type_object = get_post_type_object( $this->get_main_post()->post_type );
527
528 $settings = SettingsManager::get_settings_managers_config();
529
530 $config = [
531 'id' => $this->get_main_id(),
532 'type' => $this->get_name(),
533 'version' => $this->get_main_meta( '_elementor_version' ),
534 'settings' => $settings['page'],
535 'remoteLibrary' => $this->get_remote_library_config(),
536 'last_edited' => $this->get_last_edited(),
537 'panel' => static::get_editor_panel_config(),
538 'container' => 'body',
539 'post_type_title' => $this->get_post_type_title(),
540 'user' => [
541 'can_publish' => current_user_can( $post_type_object->cap->publish_posts ),
542
543 // Deprecated config since 2.9.0.
544 'locked' => $locked_user,
545 ],
546 'urls' => [
547 'exit_to_dashboard' => $this->get_exit_to_dashboard_url(),
548 'preview' => $this->get_preview_url(),
549 'wp_preview' => $this->get_wp_preview_url(),
550 'permalink' => $this->get_permalink(),
551 'have_a_look' => $this->get_have_a_look_url(),
552 ],
553 ];
554
555 do_action( 'elementor/document/before_get_config', $this );
556
557 if ( static::get_property( 'has_elements' ) ) {
558 $container_config = [];
559 $experiments_manager = Plugin::$instance->experiments;
560
561 if ( $experiments_manager->is_feature_active( 'container' ) ) {
562 $container_config = [
563 'container' => Plugin::$instance->elements_manager->get_element_types( 'container' )->get_config(),
564 ];
565 }
566
567 $config['elements'] = $this->get_elements_raw_data( null, true );
568 $config['widgets'] = $container_config + Plugin::$instance->widgets_manager->get_widget_types_config();
569 }
570
571 $additional_config = [];
572
573 /**
574 * Additional document configuration.
575 *
576 * Filters the document configuration by adding additional configuration.
577 * External developers can use this hook to add custom configuration in
578 * addition to Elementor's initial configuration.
579 *
580 * Use the $post_id to add custom configuration for different pages.
581 *
582 * @param array $additional_config The additional document configuration.
583 * @param int $post_id The post ID of the document.
584 */
585 $additional_config = apply_filters( 'elementor/document/config', $additional_config, $this->get_main_id() );
586
587 if ( ! empty( $additional_config ) ) {
588 $config = array_replace_recursive( $config, $additional_config );
589 }
590
591 return $config;
592 }
593
594 /**
595 * @since 3.1.0
596 * @access protected
597 */
598 protected function register_controls() {
599 $this->register_document_controls();
600
601 /**
602 * Register document controls.
603 *
604 * Fires after Elementor registers the document controls.
605 *
606 * External developers can use this hook to add new controls to the document.
607 *
608 * @since 2.0.0
609 *
610 * @param Document $this The document instance.
611 */
612 do_action( 'elementor/documents/register_controls', $this );
613 }
614
615 /**
616 * @since 2.0.0
617 * @access public
618 *
619 * @param $data
620 *
621 * @return bool
622 */
623 public function save( $data ) {
624 /**
625 * Document save data.
626 *
627 * Filter the document data before saving process starts.
628 *
629 * External developers can use this hook to change the data before
630 * saving it to the database.
631 *
632 * @since 3.3.0
633 *
634 * @param array $data The document data.
635 * @param \Elementor\Core\Base\Document $this The document instance.
636 */
637 $data = apply_filters( 'elementor/document/save/data', $data, $this );
638
639 $this->add_handle_revisions_changed_filter();
640
641 if ( ! $this->is_editable_by_current_user() ) {
642 return false;
643 }
644
645 $this->set_is_saving( true );
646
647 /**
648 * Before document save.
649 *
650 * Fires when document save starts on Elementor.
651 *
652 * @since 2.5.12
653 *
654 * @param \Elementor\Core\Base\Document $this The current document.
655 * @param $data.
656 */
657 do_action( 'elementor/document/before_save', $this, $data );
658
659 if ( ! current_user_can( 'unfiltered_html' ) ) {
660 $data = wp_kses_post_deep( $data );
661 }
662
663 if ( ! empty( $data['settings'] ) ) {
664 if ( isset( $data['settings']['post_status'] ) && self::STATUS_AUTOSAVE === $data['settings']['post_status'] ) {
665 if ( ! defined( 'DOING_AUTOSAVE' ) ) {
666 define( 'DOING_AUTOSAVE', true );
667 }
668 }
669
670 $this->save_settings( $data['settings'] );
671
672 $this->refresh_post();
673 }
674
675 // Don't check is_empty, because an empty array should be saved.
676 if ( isset( $data['elements'] ) && is_array( $data['elements'] ) ) {
677 $this->save_elements( $data['elements'] );
678 }
679
680 $this->save_template_type();
681
682 $this->save_version();
683
684 // Remove Post CSS
685 $post_css = Post_CSS::create( $this->post->ID );
686
687 $post_css->delete();
688
689 /**
690 * After document save.
691 *
692 * Fires when document save is complete.
693 *
694 * @since 2.5.12
695 *
696 * @param \Elementor\Core\Base\Document $this The current document.
697 * @param $data.
698 */
699 do_action( 'elementor/document/after_save', $this, $data );
700
701 $this->set_is_saving( false );
702
703 $this->remove_handle_revisions_changed_filter();
704
705 return true;
706 }
707
708 public function refresh_post() {
709 $this->post = get_post( $this->post->ID );
710 }
711
712 /**
713 * @param array $new_settings
714 *
715 * @return static
716 */
717 public function update_settings( array $new_settings ) {
718 $document_settings = $this->get_meta( PageManager::META_KEY );
719
720 if ( ! $document_settings ) {
721 $document_settings = [];
722 }
723
724 $this->save_settings(
725 array_replace_recursive( $document_settings, $new_settings )
726 );
727
728 return $this;
729 }
730
731 /**
732 * Is built with Elementor.
733 *
734 * Check whether the post was built with Elementor.
735 *
736 * @since 2.0.0
737 * @access public
738 *
739 * @return bool Whether the post was built with Elementor.
740 */
741 public function is_built_with_elementor() {
742 return ! ! $this->get_meta( self::BUILT_WITH_ELEMENTOR_META_KEY );
743 }
744
745 /**
746 * Mark the post as "built with elementor" or not.
747 *
748 * @param bool $is_built_with_elementor
749 *
750 * @return $this
751 */
752 public function set_is_built_with_elementor( $is_built_with_elementor ) {
753 if ( $is_built_with_elementor ) {
754 // Use the string `builder` and not a boolean for rollback compatibility
755 $this->update_meta( self::BUILT_WITH_ELEMENTOR_META_KEY, 'builder' );
756 } else {
757 $this->delete_meta( self::BUILT_WITH_ELEMENTOR_META_KEY );
758 }
759
760 return $this;
761 }
762
763 /**
764 * @since 2.0.0
765 * @access public
766 * @static
767 *
768 * @return mixed
769 */
770 public function get_edit_url() {
771 $url = add_query_arg(
772 [
773 'post' => $this->get_main_id(),
774 'action' => 'elementor',
775 ],
776 admin_url( 'post.php' )
777 );
778
779 /**
780 * Document edit url.
781 *
782 * Filters the document edit url.
783 *
784 * @since 2.0.0
785 *
786 * @param string $url The edit url.
787 * @param Document $this The document instance.
788 */
789 $url = apply_filters( 'elementor/document/urls/edit', $url, $this );
790
791 return $url;
792 }
793
794 /**
795 * @since 2.0.0
796 * @access public
797 */
798 public function get_preview_url() {
799 /**
800 * Use a static var - to avoid change the `ver` parameter on every call.
801 */
802 static $url;
803
804 if ( empty( $url ) ) {
805
806 add_filter( 'pre_option_permalink_structure', '__return_empty_string' );
807
808 $url = set_url_scheme( add_query_arg( [
809 'elementor-preview' => $this->get_main_id(),
810 'ver' => time(),
811 ], $this->get_permalink() ) );
812
813 remove_filter( 'pre_option_permalink_structure', '__return_empty_string' );
814
815 /**
816 * Document preview URL.
817 *
818 * Filters the document preview URL.
819 *
820 * @since 2.0.0
821 *
822 * @param string $url The preview URL.
823 * @param Document $this The document instance.
824 */
825 $url = apply_filters( 'elementor/document/urls/preview', $url, $this );
826 }
827
828 return $url;
829 }
830
831 /**
832 * @since 2.0.0
833 * @access public
834 *
835 * @param string $key
836 *
837 * @return array
838 */
839 public function get_json_meta( $key ) {
840 $meta = get_post_meta( $this->post->ID, $key, true );
841
842 if ( is_string( $meta ) && ! empty( $meta ) ) {
843 $meta = json_decode( $meta, true );
844 }
845
846 if ( empty( $meta ) ) {
847 $meta = [];
848 }
849
850 return $meta;
851 }
852
853 /**
854 * @since 2.0.0
855 * @access public
856 *
857 * @param null $data
858 * @param bool $with_html_content
859 *
860 * @return array
861 */
862 public function get_elements_raw_data( $data = null, $with_html_content = false ) {
863 if ( ! static::get_property( 'has_elements' ) ) {
864 return [];
865 }
866
867 if ( is_null( $data ) ) {
868 $data = $this->get_elements_data();
869 }
870
871 // Change the current documents, so widgets can use `documents->get_current` and other post data
872 Plugin::$instance->documents->switch_to_document( $this );
873
874 $editor_data = [];
875
876 foreach ( $data as $element_data ) {
877 if ( ! is_array( $element_data ) ) {
878 throw new \Exception( 'Invalid data: ' . wp_json_encode( [
879 'data' => $data,
880 'element' => $element_data,
881 ] ) );
882 }
883
884 $element = Plugin::$instance->elements_manager->create_element_instance( $element_data );
885
886 if ( ! $element ) {
887 continue;
888 }
889
890 $editor_data[] = $element->get_raw_data( $with_html_content );
891 } // End foreach().
892
893 Plugin::$instance->documents->restore_document();
894
895 return $editor_data;
896 }
897
898 /**
899 * @since 2.0.0
900 * @access public
901 *
902 * @param string $status
903 *
904 * @return array
905 */
906 public function get_elements_data( $status = self::STATUS_PUBLISH ) {
907 $elements = $this->get_json_meta( '_elementor_data' );
908
909 if ( self::STATUS_DRAFT === $status ) {
910 $autosave = $this->get_newer_autosave();
911
912 if ( is_object( $autosave ) ) {
913 $autosave_elements = Plugin::$instance->documents
914 ->get( $autosave->get_post()->ID )
915 ->get_json_meta( '_elementor_data' );
916 }
917 }
918
919 if ( Plugin::$instance->editor->is_edit_mode() ) {
920 if ( empty( $elements ) && empty( $autosave_elements ) ) {
921 // Convert to Elementor.
922 $elements = $this->convert_to_elementor();
923 if ( $this->is_autosave() ) {
924 Plugin::$instance->db->copy_elementor_meta( $this->post->post_parent, $this->post->ID );
925 }
926 }
927 }
928
929 if ( ! empty( $autosave_elements ) ) {
930 $elements = $autosave_elements;
931 }
932
933 return $elements;
934 }
935
936 /**
937 * Get document setting from DB.
938 *
939 * @return array
940 */
941 public function get_db_document_settings() {
942 return $this->get_meta( static::PAGE_META_KEY );
943 }
944
945 /**
946 * @since 2.3.0
947 * @access public
948 */
949 public function convert_to_elementor() {
950 $this->save( [] );
951
952 if ( empty( $this->post->post_content ) ) {
953 return [];
954 }
955
956 // Check if it's only a shortcode.
957 preg_match_all( '/' . get_shortcode_regex() . '/', $this->post->post_content, $matches, PREG_SET_ORDER );
958 if ( ! empty( $matches ) ) {
959 foreach ( $matches as $shortcode ) {
960 if ( trim( $this->post->post_content ) === $shortcode[0] ) {
961 $widget_type = Plugin::$instance->widgets_manager->get_widget_types( 'shortcode' );
962 $settings = [
963 'shortcode' => $this->post->post_content,
964 ];
965 break;
966 }
967 }
968 }
969
970 if ( empty( $widget_type ) ) {
971 $widget_type = Plugin::$instance->widgets_manager->get_widget_types( 'text-editor' );
972 $settings = [
973 'editor' => $this->post->post_content,
974 ];
975 }
976
977 // TODO: Better coding to start template for editor
978 return [
979 [
980 'id' => Utils::generate_random_string(),
981 'elType' => 'section',
982 'elements' => [
983 [
984 'id' => Utils::generate_random_string(),
985 'elType' => 'column',
986 'elements' => [
987 [
988 'id' => Utils::generate_random_string(),
989 'elType' => $widget_type::get_type(),
990 'widgetType' => $widget_type->get_name(),
991 'settings' => $settings,
992 ],
993 ],
994 ],
995 ],
996 ],
997 ];
998 }
999
1000 /**
1001 * @since 2.1.3
1002 * @access public
1003 */
1004 public function print_elements_with_wrapper( $elements_data = null ) {
1005 if ( ! $elements_data ) {
1006 $elements_data = $this->get_elements_data();
1007 }
1008
1009 $is_dom_optimization_active = Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' );
1010 ?>
1011 <div <?php Utils::print_html_attributes( $this->get_container_attributes() ); ?>>
1012 <?php if ( ! $is_dom_optimization_active ) : ?>
1013 <div class="elementor-inner">
1014 <div class="elementor-section-wrap">
1015 <?php endif; ?>
1016 <?php $this->print_elements( $elements_data ); ?>
1017 <?php if ( ! $is_dom_optimization_active ) : ?>
1018 </div>
1019 </div>
1020 <?php endif; ?>
1021 </div>
1022 <?php
1023 }
1024
1025 /**
1026 * @since 2.0.0
1027 * @access public
1028 */
1029 public function get_css_wrapper_selector() {
1030 return '';
1031 }
1032
1033 /**
1034 * @since 2.0.0
1035 * @access public
1036 */
1037 public function get_panel_page_settings() {
1038 return [
1039 /* translators: %s: Document title. */
1040 'title' => sprintf( esc_html__( '%s Settings', 'elementor' ), static::get_title() ),
1041 ];
1042 }
1043
1044 /**
1045 * @since 2.0.0
1046 * @access public
1047 */
1048 public function get_post() {
1049 return $this->post;
1050 }
1051
1052 /**
1053 * @since 2.0.0
1054 * @access public
1055 */
1056 public function get_permalink() {
1057 return get_permalink( $this->get_main_id() );
1058 }
1059
1060 /**
1061 * @since 2.0.8
1062 * @access public
1063 */
1064 public function get_content( $with_css = false ) {
1065 return Plugin::$instance->frontend->get_builder_content( $this->post->ID, $with_css );
1066 }
1067
1068 /**
1069 * @since 2.0.0
1070 * @access public
1071 */
1072 public function delete() {
1073 if ( 'revision' === $this->post->post_type ) {
1074 $deleted = wp_delete_post_revision( $this->post );
1075 } else {
1076 $deleted = wp_delete_post( $this->post->ID );
1077 }
1078
1079 return $deleted && ! is_wp_error( $deleted );
1080 }
1081
1082 /**
1083 *
1084 * @since 3.6.0
1085 *
1086 * @param array $config
1087 *
1088 * @param array $map_old_new_post_ids
1089 */
1090 public static function on_import_replace_dynamic_content( $config, $map_old_new_post_ids ) {
1091 foreach ( $config as &$element_config ) {
1092 $element_instance = Plugin::$instance->elements_manager->create_element_instance( $element_config );
1093
1094 if ( $element_instance ) {
1095 $element_config = $element_instance::on_import_replace_dynamic_content( $element_config, $map_old_new_post_ids );
1096
1097 $element_config['elements'] = static::on_import_replace_dynamic_content( $element_config['elements'], $map_old_new_post_ids );
1098 }
1099 }
1100
1101 return $config;
1102 }
1103
1104 /**
1105 * Save editor elements.
1106 *
1107 * Save data from the editor to the database.
1108 *
1109 * @since 2.0.0
1110 * @access protected
1111 *
1112 * @param array $elements
1113 */
1114 protected function save_elements( $elements ) {
1115 $editor_data = $this->get_elements_raw_data( $elements );
1116
1117 // We need the `wp_slash` in order to avoid the unslashing during the `update_post_meta`
1118 $json_value = wp_slash( wp_json_encode( $editor_data ) );
1119
1120 // Don't use `update_post_meta` that can't handle `revision` post type
1121 $is_meta_updated = update_metadata( 'post', $this->post->ID, '_elementor_data', $json_value );
1122
1123 /**
1124 * Before saving data.
1125 *
1126 * Fires before Elementor saves data to the database.
1127 *
1128 * @since 1.0.0
1129 *
1130 * @param string $status Post status.
1131 * @param int|bool $is_meta_updated Meta ID if the key didn't exist, true on successful update, false on failure.
1132 */
1133 do_action( 'elementor/db/before_save', $this->post->post_status, $is_meta_updated );
1134
1135 Plugin::$instance->db->save_plain_text( $this->post->ID );
1136
1137 $elements_iteration_actions = $this->get_elements_iteration_actions();
1138
1139 if ( $elements_iteration_actions ) {
1140 $this->iterate_elements( $elements, $elements_iteration_actions, 'save' );
1141 }
1142
1143 /**
1144 * After saving data.
1145 *
1146 * Fires after Elementor saves data to the database.
1147 *
1148 * @since 1.0.0
1149 *
1150 * @param int $post_id The ID of the post.
1151 * @param array $editor_data Sanitize posted data.
1152 */
1153 do_action( 'elementor/editor/after_save', $this->post->ID, $editor_data );
1154 }
1155
1156 /**
1157 * @since 2.0.0
1158 * @access public
1159 *
1160 * @param int $user_id Optional. User ID. Default value is `0`.
1161 *
1162 * @return bool|int
1163 */
1164 public function get_autosave_id( $user_id = 0 ) {
1165 if ( ! $user_id ) {
1166 $user_id = get_current_user_id();
1167 }
1168
1169 $autosave = Utils::get_post_autosave( $this->post->ID, $user_id );
1170 if ( $autosave ) {
1171 return $autosave->ID;
1172 }
1173
1174 return false;
1175 }
1176
1177 public function save_version() {
1178 if ( ! defined( 'IS_ELEMENTOR_UPGRADE' ) ) {
1179 // Save per revision.
1180 $this->update_meta( '_elementor_version', ELEMENTOR_VERSION );
1181
1182 /**
1183 * Document version save.
1184 *
1185 * Fires when document version is saved on Elementor.
1186 * Will not fire during Elementor Upgrade.
1187 *
1188 * @since 2.5.12
1189 *
1190 * @param \Elementor\Core\Base\Document $this The current document.
1191 *
1192 */
1193 do_action( 'elementor/document/save_version', $this );
1194 }
1195 }
1196
1197 /**
1198 * @since 2.3.0
1199 * @access public
1200 */
1201 public function save_template_type() {
1202 return $this->update_main_meta( self::TYPE_META_KEY, $this->get_name() );
1203 }
1204
1205 /**
1206 * @since 2.3.0
1207 * @access public
1208 */
1209 public function get_template_type() {
1210 return $this->get_main_meta( self::TYPE_META_KEY );
1211 }
1212
1213 /**
1214 * @since 2.0.0
1215 * @access public
1216 *
1217 * @param string $key Meta data key.
1218 *
1219 * @return mixed
1220 */
1221 public function get_main_meta( $key ) {
1222 return get_post_meta( $this->get_main_id(), $key, true );
1223 }
1224
1225 /**
1226 * @since 2.0.4
1227 * @access public
1228 *
1229 * @param string $key Meta data key.
1230 * @param string $value Meta data value.
1231 *
1232 * @return bool|int
1233 */
1234 public function update_main_meta( $key, $value ) {
1235 return update_post_meta( $this->get_main_id(), $key, $value );
1236 }
1237
1238 /**
1239 * @since 2.0.4
1240 * @access public
1241 *
1242 * @param string $key Meta data key.
1243 * @param string $value Optional. Meta data value. Default is an empty string.
1244 *
1245 * @return bool
1246 */
1247 public function delete_main_meta( $key, $value = '' ) {
1248 return delete_post_meta( $this->get_main_id(), $key, $value );
1249 }
1250
1251 /**
1252 * @since 2.0.0
1253 * @access public
1254 *
1255 * @param string $key Meta data key.
1256 *
1257 * @return mixed
1258 */
1259 public function get_meta( $key ) {
1260 return get_post_meta( $this->post->ID, $key, true );
1261 }
1262
1263 /**
1264 * @since 2.0.0
1265 * @access public
1266 *
1267 * @param string $key Meta data key.
1268 * @param mixed $value Meta data value.
1269 *
1270 * @return bool|int
1271 */
1272 public function update_meta( $key, $value ) {
1273 // Use `update_metadata` in order to work also with revisions.
1274 return update_metadata( 'post', $this->post->ID, $key, $value );
1275 }
1276
1277 /**
1278 * @since 2.0.3
1279 * @access public
1280 *
1281 * @param string $key Meta data key.
1282 * @param string $value Meta data value.
1283 *
1284 * @return bool
1285 */
1286 public function delete_meta( $key, $value = '' ) {
1287 // Use `delete_metadata` in order to work also with revisions.
1288 return delete_metadata( 'post', $this->post->ID, $key, $value );
1289 }
1290
1291 /**
1292 * @since 2.0.0
1293 * @access public
1294 */
1295 public function get_last_edited() {
1296 $post = $this->post;
1297 $autosave_post = $this->get_autosave();
1298
1299 if ( $autosave_post ) {
1300 $post = $autosave_post->get_post();
1301 }
1302
1303 $date = date_i18n( _x( 'M j, H:i', 'revision date format', 'elementor' ), strtotime( $post->post_modified ) );
1304 $display_name = get_the_author_meta( 'display_name', $post->post_author );
1305
1306 if ( $autosave_post || 'revision' === $post->post_type ) {
1307 /* translators: 1: Saving date, 2: Author display name. */
1308 $last_edited = sprintf( esc_html__( 'Draft saved on %1$s by %2$s', 'elementor' ), '<time>' . $date . '</time>', $display_name );
1309 } else {
1310 /* translators: 1: Editing date, 2: Author display name. */
1311 $last_edited = sprintf( esc_html__( 'Last edited on %1$s by %2$s', 'elementor' ), '<time>' . $date . '</time>', $display_name );
1312 }
1313
1314 return $last_edited;
1315 }
1316
1317
1318 /**
1319 * @return bool
1320 */
1321 public function is_saving() {
1322 return $this->is_saving;
1323 }
1324
1325 /**
1326 * @param $is_saving
1327 *
1328 * @return $this
1329 */
1330 public function set_is_saving( $is_saving ) {
1331 $this->is_saving = $is_saving;
1332
1333 return $this;
1334 }
1335
1336 /**
1337 * @since 2.0.0
1338 * @access public
1339 *
1340 * @param array $data
1341 *
1342 * @throws \Exception If the post does not exist.
1343 */
1344 public function __construct( array $data = [] ) {
1345 if ( $data ) {
1346 if ( empty( $data['post_id'] ) ) {
1347 $this->post = new \WP_Post( (object) [] );
1348 } else {
1349 $this->post = get_post( $data['post_id'] );
1350
1351 if ( ! $this->post ) {
1352 throw new \Exception( sprintf( 'Post ID #%s does not exist.', $data['post_id'] ), Exceptions::NOT_FOUND );
1353 }
1354 }
1355
1356 // Each Control_Stack is based on a unique ID.
1357 $data['id'] = $data['post_id'];
1358
1359 if ( ! isset( $data['settings'] ) ) {
1360 $data['settings'] = [];
1361 }
1362
1363 $saved_settings = get_post_meta( $this->post->ID, '_elementor_page_settings', true );
1364 if ( ! empty( $saved_settings ) && is_array( $saved_settings ) ) {
1365 $data['settings'] += $saved_settings;
1366 }
1367 }
1368
1369 parent::__construct( $data );
1370 }
1371
1372 /*
1373 * Get Export Data
1374 *
1375 * Filters a document's data on export
1376 *
1377 * @since 3.2.0
1378 * @access public
1379 *
1380 * @return array The data to export
1381 */
1382 public function get_export_data() {
1383 $content = Plugin::$instance->db->iterate_data( $this->get_elements_data(), function( $element_data ) {
1384 $element_data['id'] = Utils::generate_random_string();
1385
1386 $element = Plugin::$instance->elements_manager->create_element_instance( $element_data );
1387
1388 // If the widget/element isn't exist, like a plugin that creates a widget but deactivated
1389 if ( ! $element ) {
1390 return null;
1391 }
1392
1393 return $this->process_element_import_export( $element, 'on_export' );
1394 } );
1395
1396 return [
1397 'content' => $content,
1398 'settings' => $this->get_data( 'settings' ),
1399 'metadata' => $this->get_export_metadata(),
1400 ];
1401 }
1402
1403 public function get_export_summary() {
1404 return [
1405 'title' => $this->post->post_title,
1406 'doc_type' => $this->get_name(),
1407 'thumbnail' => get_the_post_thumbnail_url( $this->post ),
1408 ];
1409 }
1410
1411 /*
1412 * Get Import Data
1413 *
1414 * Filters a document's data on import
1415 *
1416 * @since 3.2.0
1417 * @access public
1418 *
1419 * @return array The data to import
1420 */
1421 public function get_import_data( array $data ) {
1422 $data['content'] = Plugin::$instance->db->iterate_data( $data['content'], function( $element_data ) {
1423 $element = Plugin::$instance->elements_manager->create_element_instance( $element_data );
1424
1425 // If the widget/element isn't exist, like a plugin that creates a widget but deactivated
1426 if ( ! $element ) {
1427 return null;
1428 }
1429
1430 return $this->process_element_import_export( $element, 'on_import' );
1431 } );
1432
1433 if ( ! empty( $data['settings'] ) ) {
1434 $template_model = new Page_Model( [
1435 'id' => 0,
1436 'settings' => $data['settings'],
1437 ] );
1438
1439 $page_data = $this->process_element_import_export( $template_model, 'on_import' );
1440
1441 $data['settings'] = $page_data['settings'];
1442 }
1443
1444 return $data;
1445 }
1446
1447 /**
1448 * Import
1449 *
1450 * Allows to import an external data to a document
1451 *
1452 * @since 3.2.0
1453 * @access public
1454 *
1455 * @param array $data
1456 */
1457 public function import( array $data ) {
1458 $data = $this->get_import_data( $data );
1459
1460 $this->save( [
1461 'elements' => $data['content'],
1462 'settings' => $data['settings'],
1463 ] );
1464
1465 if ( $data['import_settings']['thumbnail'] ) {
1466 $attachment = Plugin::$instance->templates_manager->get_import_images_instance()->import( [ 'url' => $data['import_settings']['thumbnail'] ] );
1467
1468 set_post_thumbnail( $this->get_main_post(), $attachment['id'] );
1469 }
1470
1471 if ( ! empty( $data['metadata'] ) ) {
1472 foreach ( $data['metadata'] as $key => $value ) {
1473 $this->update_meta( $key, $value );
1474 }
1475 }
1476 }
1477
1478 private function process_element_import_export( Controls_Stack $element, $method ) {
1479 $element_data = $element->get_data();
1480
1481 if ( method_exists( $element, $method ) ) {
1482 // TODO: Use the internal element data without parameters.
1483 $element_data = $element->{$method}( $element_data );
1484 }
1485
1486 foreach ( $element->get_controls() as $control ) {
1487 $control_class = Plugin::$instance->controls_manager->get_control( $control['type'] );
1488
1489 // If the control isn't exist, like a plugin that creates the control but deactivated.
1490 if ( ! $control_class ) {
1491 return $element_data;
1492 }
1493
1494 if ( method_exists( $control_class, $method ) ) {
1495 $element_data['settings'][ $control['name'] ] = $control_class->{$method}( $element->get_settings( $control['name'] ), $control );
1496 }
1497
1498 // On Export, check if the control has an argument 'export' => false.
1499 if ( 'on_export' === $method && isset( $control['export'] ) && false === $control['export'] ) {
1500 unset( $element_data['settings'][ $control['name'] ] );
1501 }
1502 }
1503
1504 return $element_data;
1505 }
1506
1507 protected function get_export_metadata() {
1508 $metadata = get_post_meta( $this->get_main_id() );
1509
1510 foreach ( $metadata as $meta_key => $meta_value ) {
1511 if ( is_protected_meta( $meta_key, 'post' ) ) {
1512 unset( $metadata[ $meta_key ] );
1513
1514 continue;
1515 }
1516
1517 $metadata[ $meta_key ] = $meta_value[0];
1518 }
1519
1520 return $metadata;
1521 }
1522
1523 protected function get_remote_library_config() {
1524 $config = [
1525 'type' => 'block',
1526 'default_route' => 'templates/blocks',
1527 'category' => $this->get_name(),
1528 'autoImportSettings' => false,
1529 ];
1530
1531 return $config;
1532 }
1533
1534 /**
1535 * @since 2.0.4
1536 * @access protected
1537 *
1538 * @param $settings
1539 */
1540 protected function save_settings( $settings ) {
1541 $page_settings_manager = SettingsManager::get_settings_managers( 'page' );
1542 $page_settings_manager->ajax_before_save_settings( $settings, $this->post->ID );
1543 $page_settings_manager->save_settings( $settings, $this->post->ID );
1544 }
1545
1546 /**
1547 * @since 2.1.3
1548 * @access protected
1549 */
1550 protected function print_elements( $elements_data ) {
1551 // Collect all data updaters that should be updated on runtime.
1552 $runtime_elements_iteration_actions = $this->get_runtime_elements_iteration_actions();
1553
1554 if ( $runtime_elements_iteration_actions ) {
1555 $this->iterate_elements( $elements_data, $runtime_elements_iteration_actions, 'render' );
1556 }
1557
1558 foreach ( $elements_data as $element_data ) {
1559 $element = Plugin::$instance->elements_manager->create_element_instance( $element_data );
1560
1561 if ( ! $element ) {
1562 continue;
1563 }
1564
1565 $element->print_element();
1566 }
1567 }
1568
1569 protected function register_document_controls() {
1570 $this->start_controls_section(
1571 'document_settings',
1572 [
1573 'label' => esc_html__( 'General Settings', 'elementor' ),
1574 'tab' => Controls_Manager::TAB_SETTINGS,
1575 ]
1576 );
1577
1578 $this->add_control(
1579 'post_title',
1580 [
1581 'label' => esc_html__( 'Title', 'elementor' ),
1582 'type' => Controls_Manager::TEXT,
1583 'default' => $this->post->post_title,
1584 'label_block' => true,
1585 ]
1586 );
1587
1588 $post_type_object = get_post_type_object( $this->post->post_type );
1589
1590 $can_publish = $post_type_object && current_user_can( $post_type_object->cap->publish_posts );
1591 $is_published = self::STATUS_PUBLISH === $this->post->post_status || self::STATUS_PRIVATE === $this->post->post_status;
1592
1593 if ( $is_published || $can_publish || ! Plugin::$instance->editor->is_edit_mode() ) {
1594
1595 $statuses = $this->get_post_statuses();
1596 if ( 'future' === $this->get_main_post()->post_status ) {
1597 $statuses['future'] = esc_html__( 'Future', 'elementor' );
1598 }
1599
1600 $this->add_control(
1601 'post_status',
1602 [
1603 'label' => esc_html__( 'Status', 'elementor' ),
1604 'type' => Controls_Manager::SELECT,
1605 'default' => $this->get_main_post()->post_status,
1606 'options' => $statuses,
1607 ]
1608 );
1609 }
1610
1611 $this->end_controls_section();
1612 }
1613
1614 protected function get_post_statuses() {
1615 return get_post_statuses();
1616 }
1617
1618 protected function get_have_a_look_url() {
1619 return $this->get_permalink();
1620 }
1621
1622 public function handle_revisions_changed( $post_has_changed, $last_revision, $post ) {
1623 // In case default, didn't determine the changes.
1624 if ( ! $post_has_changed ) {
1625 $last_revision_id = $last_revision->ID;
1626 $last_revision_document = Plugin::instance()->documents->get( $last_revision_id );
1627 $post_document = Plugin::instance()->documents->get( $post->ID );
1628
1629 $last_revision_settings = $last_revision_document->get_settings();
1630 $post_settings = $post_document->get_settings();
1631
1632 // TODO: Its better to add crc32 signature for each revision and then only compare one part of the checksum.
1633 $post_has_changed = $last_revision_settings !== $post_settings;
1634 }
1635
1636 return $post_has_changed;
1637 }
1638
1639 private function add_handle_revisions_changed_filter() {
1640 add_filter( 'wp_save_post_revision_post_has_changed', [ $this, 'handle_revisions_changed' ], 10, 3 );
1641 }
1642
1643 private function remove_handle_revisions_changed_filter() {
1644 remove_filter( 'wp_save_post_revision_post_has_changed', [ $this, 'handle_revisions_changed' ] );
1645 }
1646
1647 private function get_runtime_elements_iteration_actions() {
1648 $runtime_elements_iteration_actions = [];
1649
1650 $elements_iteration_actions = $this->get_elements_iteration_actions();
1651
1652 foreach ( $elements_iteration_actions as $elements_iteration_action ) {
1653 if ( $elements_iteration_action->is_action_needed() ) {
1654 $runtime_elements_iteration_actions[] = $elements_iteration_action;
1655 }
1656 }
1657
1658 return $runtime_elements_iteration_actions;
1659 }
1660
1661 private function iterate_elements( $elements, $elements_iteration_actions, $mode ) {
1662 $unique_page_elements = [];
1663
1664 foreach ( $elements_iteration_actions as $elements_iteration_action ) {
1665 $elements_iteration_action->set_mode( $mode );
1666 }
1667
1668 Plugin::$instance->db->iterate_data( $elements, function( array $element_data ) use ( &$unique_page_elements, $elements_iteration_actions ) {
1669 $element_type = 'widget' === $element_data['elType'] ? $element_data['widgetType'] : $element_data['elType'];
1670
1671 $element = Plugin::$instance->elements_manager->create_element_instance( $element_data );
1672
1673 if ( $element ) {
1674 if ( ! in_array( $element_type, $unique_page_elements, true ) ) {
1675 $unique_page_elements[] = $element_type;
1676
1677 foreach ( $elements_iteration_actions as $elements_iteration_action ) {
1678 $elements_iteration_action->unique_element_action( $element );
1679 }
1680 }
1681
1682 foreach ( $elements_iteration_actions as $elements_iteration_action ) {
1683 $elements_iteration_action->element_action( $element );
1684 }
1685 }
1686
1687 return $element_data;
1688 } );
1689
1690 foreach ( $elements_iteration_actions as $elements_iteration_action ) {
1691 $elements_iteration_action->after_elements_iteration();
1692 }
1693 }
1694
1695 private function get_elements_iteration_actions() {
1696 if ( ! $this->elements_iteration_actions ) {
1697 $this->elements_iteration_actions[] = new Assets_Iteration_Action( $this );
1698 }
1699
1700 return $this->elements_iteration_actions;
1701 }
1702 }
1703