PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.0
Elementor Website Builder – more than just a page builder v4.2.0
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 / interactions-collector.php

interactions-collector.php in Elementor Website Builder – more than just a page builder 4.2.0, at modules/interactions/interactions-collector.php

77 lines 1.6 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;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 /**
10 * Collects interaction data from all rendered documents and provides centralized access.
11 */
12 class Interactions_Collector {
13 /**
14 * @var Interactions_Collector
15 */
16 private static $instance = null;
17
18 /**
19 * @var array Stores interaction data keyed by element ID
20 * Format: [ 'element_id' => [ interaction_items... ] ]
21 */
22 private $interactions_data = [];
23
24 /**
25 * Get singleton instance.
26 *
27 * @return Interactions_Collector
28 */
29 public static function instance() {
30 if ( null === self::$instance ) {
31 self::$instance = new self();
32 }
33
34 return self::$instance;
35 }
36
37 /**
38 * Register interaction data for an element.
39 *
40 * @param string $element_id The element ID (data-id attribute value)
41 * @param array $interactions The full interactions array from the element
42 */
43 public function register( $element_id, $interactions ) {
44 if ( empty( $element_id ) || empty( $interactions ) ) {
45 return;
46 }
47
48 $this->interactions_data[ $element_id ] = $interactions;
49 }
50
51 /**
52 * Get all collected interaction data.
53 *
54 * @return array Format: [ 'element_id' => interactions_array ]
55 */
56 public function get_all() {
57 return $this->interactions_data;
58 }
59
60 /**
61 * Get interaction data for a specific element.
62 *
63 * @param string $element_id The element ID
64 * @return array|null
65 */
66 public function get( $element_id ) {
67 return $this->interactions_data[ $element_id ] ?? null;
68 }
69
70 /**
71 * Reset collected data (useful for testing or page reloads).
72 */
73 public function reset() {
74 $this->interactions_data = [];
75 }
76 }
77