PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev1
Elementor Website Builder – more than just a page builder v3.35.0-dev1
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.35.0-dev1, at modules/announcements/classes/announcement.php

78 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\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 is_active
41 *
42 * @return bool
43 */
44 public function is_active(): bool {
45 $triggers = $this->get_triggers();
46
47 if ( empty( $triggers ) ) {
48 return true;
49 }
50
51 foreach ( $triggers as $trigger ) {
52 if ( ! $trigger->is_active() ) {
53 return false;
54 }
55 }
56
57 return true;
58 }
59
60 public function after_triggered() {
61 foreach ( $this->get_triggers() as $trigger ) {
62 if ( $trigger->is_active() ) {
63 $trigger->after_triggered();
64 }
65 }
66 }
67
68 /**
69 * @return array
70 */
71 public function get_prepared_data(): array {
72 $raw_data = $this->raw_data;
73 unset( $raw_data['triggers'] );
74
75 return $raw_data;
76 }
77 }
78