PluginProbe
Elementor Website Builder – more than just a page builder / 3.24.4
Elementor Website Builder – more than just a page builder v3.24.4
4.3.0-beta3 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 All 452 releases
← All changes | modules/checklist/steps/step-base.php +29 -74 4.1.0-dev23.24.4 View file →
@@ -3,10 +3,8 @@
3 3 namespace Elementor\Modules\Checklist\Steps;
4 4
5 5 use Elementor\Core\Isolation\Wordpress_Adapter;
6 6 use Elementor\Core\Isolation\Wordpress_Adapter_Interface;
7 -use Elementor\Core\Isolation\Elementor_Adapter;
8 -use Elementor\Core\Isolation\Elementor_Adapter_Interface;
9 7 use Elementor\Modules\Checklist\Module as Checklist_Module;
10 8
11 9 if ( ! defined( 'ABSPATH' ) ) {
12 10 exit; // Exit if accessed directly.
@@ -12,8 +10,9 @@
12 10 exit; // Exit if accessed directly.
13 11 }
14 12
15 13 abstract class Step_Base {
14 +
16 15 /**
17 16 * @var string
18 17 * This is the key to be set to true if the step can be completed, and still be considered completed even if the user later did something to the should have it marked as not completed
19 18 */
@@ -18,15 +17,12 @@
18 17 * This is the key to be set to true if the step can be completed, and still be considered completed even if the user later did something to the should have it marked as not completed
19 18 */
20 19 const IS_COMPLETION_IMMUTABLE = 'is_completion_immutable';
21 20 const MARKED_AS_COMPLETED_KEY = 'is_marked_completed';
22 - const IMMUTABLE_COMPLETION_KEY = 'is_immutable_completed';
23 - const ABSOLUTE_COMPLETION_KEY = 'is_absolute_completed';
21 + const IMMUTABLE_COMPLETION_KEY = 'is_completed';
24 22
25 - private array $user_progress;
23 + protected array $user_progress;
26 24 protected Wordpress_Adapter_Interface $wordpress_adapter;
27 - protected Elementor_Adapter_Interface $elementor_adapter;
28 - protected ?array $promotion_data;
29 25 protected Checklist_Module $module;
30 26
31 27 /**
32 28 * Returns a steps current completion status
@@ -32,104 +28,71 @@
32 28 * Returns a steps current completion status
33 29 *
34 30 * @return bool
35 31 */
36 - abstract protected function is_absolute_completed(): bool;
32 + abstract protected function is_absolute_completed() : bool;
37 33
38 34 /**
39 35 * @return string
40 36 */
41 - abstract public function get_id(): string;
37 + abstract public function get_id() : string;
42 38
43 39 /**
44 40 * @return string
45 41 */
46 - abstract public function get_title(): string;
42 + abstract public function get_title() : string;
47 43
48 44 /**
49 45 * @return string
50 46 */
51 - abstract public function get_description(): string;
47 + abstract public function get_description() : string;
52 48
53 49 /**
54 50 * For instance; 'Create 3 pages'
55 - *
56 51 * @return string
57 52 */
58 - abstract public function get_cta_text(): string;
53 + abstract public function get_cta_text() : string;
59 54
60 55 /**
61 56 * @return string
62 57 */
63 - abstract public function get_cta_url(): string;
58 + abstract public function get_cta_url() : string;
64 59
65 60 /**
66 61 * @return bool
67 62 */
68 - abstract public function get_is_completion_immutable(): bool;
63 + abstract public function get_is_completion_immutable() : bool;
69 64
70 65 /**
71 - * @return string
72 - */
73 - abstract public function get_image_src(): string;
74 -
75 - /**
76 66 * Step_Base constructor.
77 67 *
78 - * @param Checklist_Module $module
68 + * @param Checklist_Module $module
79 69 * @param ?Wordpress_Adapter_Interface $wordpress_adapter
80 - * @param ?Elementor_Adapter_Interface $elementor_adapter
70 +
81 71 * @return void
82 72 */
83 - public function __construct( Checklist_Module $module, ?Wordpress_Adapter_Interface $wordpress_adapter = null, ?Elementor_Adapter_Interface $elementor_adapter = null, $promotion_data = null ) {
73 + public function __construct( Checklist_Module $module, ?Wordpress_Adapter_Interface $wordpress_adapter = null ) {
84 74 $this->module = $module;
85 75 $this->wordpress_adapter = $wordpress_adapter ?? new Wordpress_Adapter();
86 - $this->elementor_adapter = $elementor_adapter ?? new Elementor_Adapter();
87 - $this->promotion_data = $promotion_data;
88 -
89 76 $this->user_progress = $module->get_step_progress( $this->get_id() ) ?? $this->get_step_initial_progress();
90 77 }
91 78
92 - /**
93 - * Returns step visibility (by-default step is visible)
94 - *
95 - * @return bool
96 - */
97 - public function is_visible(): bool {
98 - return true;
99 - }
100 -
101 - public function get_learn_more_text(): string {
79 + public function get_learn_more_text() : string {
102 80 return esc_html__( 'Learn more', 'elementor' );
103 81 }
104 82
105 - public function get_learn_more_url(): string {
83 + public function get_learn_more_url() : string {
106 84 return 'https://go.elementor.com/getting-started-with-elementor/';
107 85 }
108 86
109 - public function update_step( array $step_data ): void {
110 - $allowed_properties = [
111 - self::MARKED_AS_COMPLETED_KEY => $step_data[ self::MARKED_AS_COMPLETED_KEY ] ?? null,
112 - self::IMMUTABLE_COMPLETION_KEY => $step_data[ self::IMMUTABLE_COMPLETION_KEY ] ?? null,
113 - self::ABSOLUTE_COMPLETION_KEY => $step_data[ self::ABSOLUTE_COMPLETION_KEY ] ?? null,
114 - ];
115 -
116 - foreach ( $allowed_properties as $key => $value ) {
117 - if ( null !== $value ) {
118 - $this->user_progress[ $key ] = $value;
119 - }
120 - }
121 -
122 - $this->set_step_progress();
123 - }
124 -
125 87 /**
126 88 * Marking a step as completed based on user's desire
127 89 *
128 90 * @return void
129 91 */
130 - public function mark_as_completed(): void {
131 - $this->update_step( [ self::MARKED_AS_COMPLETED_KEY => true ] );
92 + public function mark_as_completed() : void {
93 + $this->user_progress[ self::MARKED_AS_COMPLETED_KEY ] = true;
94 + $this->set_step_progress();
132 95 }
133 96
134 97 /**
135 98 * Unmarking a step as completed based on user's desire
@@ -135,10 +98,11 @@
135 98 * Unmarking a step as completed based on user's desire
136 99 *
137 100 * @return void
138 101 */
139 - public function unmark_as_completed(): void {
140 - $this->update_step( [ self::MARKED_AS_COMPLETED_KEY => false ] );
102 + public function unmark_as_completed() : void {
103 + $this->user_progress[ self::MARKED_AS_COMPLETED_KEY ] = false;
104 + $this->set_step_progress();
141 105 }
142 106
143 107 /**
144 108 * Marking a step as completed if it was completed once, and it's suffice to marketing's requirements
@@ -144,16 +108,14 @@
144 108 * Marking a step as completed if it was completed once, and it's suffice to marketing's requirements
145 109 *
146 110 * @return void
147 111 */
148 - public function maybe_immutably_mark_as_completed(): void {
112 + public function maybe_mark_as_completed() : void {
149 113 $is_immutable_completed = $this->user_progress[ self::IMMUTABLE_COMPLETION_KEY ] ?? false;
150 114
151 115 if ( ! $is_immutable_completed && $this->get_is_completion_immutable() && $this->is_absolute_completed() ) {
152 - $this->update_step( [
153 - self::MARKED_AS_COMPLETED_KEY => false,
154 - self::IMMUTABLE_COMPLETION_KEY => true,
155 - ] );
116 + $this->user_progress[ self::IMMUTABLE_COMPLETION_KEY ] = true;
117 + $this->set_step_progress();
156 118 }
157 119 }
158 120
159 121 /**
@@ -160,9 +122,9 @@
160 122 * Returns the step marked as completed value
161 123 *
162 124 * @return bool
163 125 */
164 - public function is_marked_as_completed(): bool {
126 + public function is_marked_as_completed() : bool {
165 127 return $this->user_progress[ self::MARKED_AS_COMPLETED_KEY ];
166 128 }
167 129
168 130 /**
@@ -169,10 +131,10 @@
169 131 * Returns the step completed value
170 132 *
171 133 * @return bool
172 134 */
173 - public function is_immutable_completed(): bool {
174 - return $this->get_is_completion_immutable() && $this->user_progress[ self::IMMUTABLE_COMPLETION_KEY ] ?? false;
135 + public function is_immutable_completed() : bool {
136 + return $this->user_progress[ self::IMMUTABLE_COMPLETION_KEY ];
175 137 }
176 138
177 139 /**
178 140 * Sets and returns the initial progress of the step
@@ -178,9 +140,9 @@
178 140 * Sets and returns the initial progress of the step
179 141 *
180 142 * @return array
181 143 */
182 - public function get_step_initial_progress(): array {
144 + public function get_step_initial_progress() : array {
183 145 $initial_progress = [
184 146 self::MARKED_AS_COMPLETED_KEY => false,
185 147 self::IMMUTABLE_COMPLETION_KEY => false,
186 148 ];
@@ -190,19 +152,12 @@
190 152 return $initial_progress;
191 153 }
192 154
193 155 /**
194 - * @return ?array
195 - */
196 - public function get_promotion_data(): ?array {
197 - return $this->promotion_data;
198 - }
199 -
200 - /**
201 156 * Sets the step progress
202 157 *
203 158 * @return void
204 159 */
205 - private function set_step_progress(): void {
160 + private function set_step_progress() : void {
206 161 $this->module->set_step_progress( $this->get_id(), $this->user_progress );
207 162 }
208 163 }