PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev2
Elementor Website Builder – more than just a page builder v3.23.0-dev2
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 / announcements / classes / announcement.php

announcement.php in Elementor Website Builder – more than just a page builder 3.23.0-dev2, at modules/announcements/classes/announcement.php

77 lines 1.2 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\Announcements\Classes;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 class Announcement {
10
11 /**
12 * @var array
13 */
14 protected $raw_data;
15 /**
16 * @var array
17 */
18 protected $triggers;
19
20 public function __construct( array $data ) {
21 $this->raw_data = $data;
22 $this->set_triggers();
23 }
24
25 /**
26 * @return array
27 */
28 protected function get_triggers(): array {
29 return $this->triggers;
30 }
31
32 protected function set_triggers() {
33 $triggers = $this->raw_data['triggers'] ?? [];
34 foreach ( $triggers as $trigger ) {
35 $this->triggers[] = Utils::get_trigger_object( $trigger );
36 }
37 }
38
39 /**
40 * is_active
41 * @return bool
42 */
43 public function is_active(): bool {
44 $triggers = $this->get_triggers();
45
46 if ( empty( $triggers ) ) {
47 return true;
48 }
49
50 foreach ( $triggers as $trigger ) {
51 if ( ! $trigger->is_active() ) {
52 return false;
53 }
54 }
55
56 return true;
57 }
58
59 public function after_triggered() {
60 foreach ( $this->get_triggers() as $trigger ) {
61 if ( $trigger->is_active() ) {
62 $trigger->after_triggered();
63 }
64 }
65 }
66
67 /**
68 * @return array
69 */
70 public function get_prepared_data(): array {
71 $raw_data = $this->raw_data;
72 unset( $raw_data['triggers'] );
73
74 return $raw_data;
75 }
76 }
77