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 / modules / interactions / cache / interactions-postmeta.php

interactions-postmeta.php in Elementor Website Builder – more than just a page builder 4.2.2, at modules/interactions/cache/interactions-postmeta.php

57 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\Interactions\Cache;
4
5 use Elementor\Core\Base\Document;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 class Interactions_Postmeta {
12 const META_KEY = 'elementor-interactions-cache';
13
14 public function load_content( $post_id ) {
15 return get_post_meta( $post_id, self::META_KEY, true );
16 }
17
18 public function process_content( $post_id, $data ) {
19 if ( $this->skip_processing( $data ) ) {
20 return;
21 }
22
23 $elements_interactions = $this->extract_elements_interactions( $data );
24
25 $this->save_postmeta( $post_id, $elements_interactions );
26
27 return $elements_interactions;
28 }
29
30 private function save_postmeta( $post_id, array $interactions ) {
31 if ( empty( $interactions ) ) {
32 delete_post_meta( $post_id, self::META_KEY );
33 return;
34 }
35
36 update_post_meta( $post_id, self::META_KEY, $interactions );
37 }
38
39 private function skip_processing( array $data ) {
40 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
41 return true;
42 }
43
44 if ( isset( $data['settings']['post_status'] ) && Document::STATUS_AUTOSAVE === $data['settings']['post_status'] ) {
45 return true;
46 }
47
48 return false;
49 }
50
51 private function extract_elements_interactions( array $data ) {
52 $parser = new Elements_Interactions();
53 $parser->parse_from( $data );
54 return $parser->all();
55 }
56 }
57