PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.0-dev5
Elementor Website Builder – more than just a page builder v3.26.0-dev5
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
← All changes | modules/checklist/module.php +48 -33 4.3.0-beta23.26.0-dev5 View file →
@@ -2,9 +2,9 @@
2 2
3 3 namespace Elementor\Modules\Checklist;
4 4
5 5 use Elementor\Core\Base\Module as BaseModule;
6 -use Elementor\Core\Experiments\Manager as Experiments_Manager;
6 +use Elementor\Core\Experiments\Manager;
7 7 use Elementor\Modules\ElementorCounter\Module as Elementor_Counter;
8 8 use Elementor\Core\Isolation\Wordpress_Adapter;
9 9 use Elementor\Core\Isolation\Wordpress_Adapter_Interface;
10 10 use Elementor\Core\Isolation\Elementor_Adapter;
@@ -12,8 +12,10 @@
12 12 use Elementor\Core\Isolation\Elementor_Counter_Adapter_Interface;
13 13 use Elementor\Plugin;
14 14 use Elementor\Utils;
15 15 use Elementor\Modules\Checklist\Data\Controller;
16 +use Elementor\Core\Utils\Isolation_Manager;
17 +use Elementor\Modules\EditorAppBar\Module as AppBarModule;
16 18
17 19 if ( ! defined( 'ABSPATH' ) ) {
18 20 exit; // Exit if accessed directly.
19 21 }
@@ -18,9 +20,9 @@
18 20 exit; // Exit if accessed directly.
19 21 }
20 22
21 23 class Module extends BaseModule implements Checklist_Module_Interface {
22 - const EXPERIMENT_NAME = 'launchpad-checklist';
24 + const EXPERIMENT_ID = 'launchpad-checklist';
23 25 const DB_OPTION_KEY = 'elementor_checklist';
24 26 const VISIBILITY_SWITCH_ID = 'show_launchpad_checklist';
25 27 const FIRST_CLOSED_CHECKLIST_IN_EDITOR = 'first_closed_checklist_in_editor';
26 28 const LAST_OPENED_TIMESTAMP = 'last_opened_timestamp';
@@ -42,19 +44,19 @@
42 44 public function __construct(
43 45 ?Wordpress_Adapter_Interface $wordpress_adapter = null,
44 46 ?Elementor_Adapter_Interface $elementor_adapter = null
45 47 ) {
46 - $this->wordpress_adapter = $wordpress_adapter ?? new Wordpress_Adapter();
47 - $this->elementor_adapter = $elementor_adapter ?? new Elementor_Adapter();
48 + $this->wordpress_adapter = $wordpress_adapter ?? Isolation_Manager::get_adapter( Wordpress_Adapter::class );
49 + $this->elementor_adapter = $elementor_adapter ?? Isolation_Manager::get_adapter( Elementor_Adapter::class );
48 50
49 51 parent::__construct();
52 + $this->register_experiment();
53 + $this->init_user_progress();
50 54
51 - if ( ! Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) ) {
55 + if ( ! $this->is_experiment_active() ) {
52 56 return;
53 57 }
54 58
55 - $this->init_user_progress();
56 -
57 59 Plugin::$instance->data_manager_v2->register_controller( new Controller() );
58 60 $this->user_progress = $this->user_progress ?? $this->get_user_progress_from_db();
59 61 $this->handle_checklist_visibility_with_kit();
60 62 $this->steps_manager = new Steps_Manager( $this );
@@ -70,21 +72,19 @@
70 72 * Get the module name.
71 73 *
72 74 * @return string
73 75 */
74 - public function get_name(): string {
76 + public function get_name() : string {
75 77 return 'e-checklist';
76 78 }
77 79
78 - public static function get_experimental_data(): array {
79 - return [
80 - 'name' => self::EXPERIMENT_NAME,
81 - 'title' => esc_html__( 'Launchpad Checklist', 'elementor' ),
82 - 'description' => esc_html__( 'Launchpad Checklist feature to boost productivity and deliver your site faster', 'elementor' ),
83 - 'hidden' => true,
84 - 'default' => Experiments_Manager::STATE_INACTIVE,
85 - 'release_status' => Experiments_Manager::RELEASE_STATUS_STABLE,
86 - ];
80 + /**
81 + * Checks if the experiment is active
82 + *
83 + * @return bool
84 + */
85 + public function is_experiment_active() : bool {
86 + return Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_ID );
87 87 }
88 88
89 89 /**
90 90 * Gets user's progress from db
@@ -100,9 +100,9 @@
100 100 * }
101 101 * }
102 102 * }
103 103 */
104 - public function get_user_progress_from_db(): array {
104 + public function get_user_progress_from_db() : array {
105 105 $db_progress = json_decode( $this->wordpress_adapter->get_option( self::DB_OPTION_KEY ), true );
106 106 $db_progress = is_array( $db_progress ) ? $db_progress : [];
107 107
108 108 $progress = array_merge( $this->get_default_user_progress(), $db_progress );
@@ -122,9 +122,9 @@
122 122 * @type bool $is_marked_completed
123 123 * @type bool $is_completed
124 124 * }
125 125 */
126 - public function get_step_progress( $step_id ): ?array {
126 + public function get_step_progress( $step_id ) : ?array {
127 127 return $this->user_progress['steps'][ $step_id ] ?? null;
128 128 }
129 129
130 130 /**
@@ -134,14 +134,14 @@
134 134 * @param $step_progress
135 135 *
136 136 * @return void
137 137 */
138 - public function set_step_progress( $step_id, $step_progress ): void {
138 + public function set_step_progress( $step_id, $step_progress ) : void {
139 139 $this->user_progress['steps'][ $step_id ] = $step_progress;
140 140 $this->update_user_progress_in_db();
141 141 }
142 142
143 - public function update_user_progress( $new_data ): void {
143 + public function update_user_progress( $new_data ) : void {
144 144 $allowed_properties = [
145 145 self::FIRST_CLOSED_CHECKLIST_IN_EDITOR => $new_data[ self::FIRST_CLOSED_CHECKLIST_IN_EDITOR ] ?? null,
146 146 self::LAST_OPENED_TIMESTAMP => $new_data[ self::LAST_OPENED_TIMESTAMP ] ?? null,
147 147 self::IS_POPUP_MINIMIZED_KEY => $new_data[ self::IS_POPUP_MINIMIZED_KEY ] ?? null,
@@ -162,9 +162,9 @@
162 162
163 163 /**
164 164 * @return Steps_Manager
165 165 */
166 - public function get_steps_manager(): Steps_Manager {
166 + public function get_steps_manager() : Steps_Manager {
167 167 return $this->steps_manager;
168 168 }
169 169
170 170 /**
@@ -169,9 +169,9 @@
169 169
170 170 /**
171 171 * @return Wordpress_Adapter
172 172 */
173 - public function get_wordpress_adapter(): Wordpress_Adapter {
173 + public function get_wordpress_adapter() : Wordpress_Adapter {
174 174 return $this->wordpress_adapter;
175 175 }
176 176
177 177 /**
@@ -176,13 +176,13 @@
176 176
177 177 /**
178 178 * @return Elementor_Adapter
179 179 */
180 - public function get_elementor_adapter(): Elementor_Adapter {
180 + public function get_elementor_adapter() : Elementor_Adapter {
181 181 return $this->elementor_adapter;
182 182 }
183 183
184 - public function enqueue_editor_scripts(): void {
184 + public function enqueue_editor_scripts() : void {
185 185 add_action( 'elementor/editor/before_enqueue_scripts', function () {
186 186 $min_suffix = Utils::is_script_debug() ? '' : '.min';
187 187
188 188 wp_enqueue_script(
@@ -204,9 +204,9 @@
204 204 wp_set_script_translations( $this->get_name(), 'elementor' );
205 205 } );
206 206 }
207 207
208 - public function is_preference_switch_on(): bool {
208 + public function is_preference_switch_on() : bool {
209 209 if ( $this->should_switch_preferences_off() ) {
210 210 return false;
211 211 }
212 212
@@ -214,19 +214,33 @@
214 214
215 215 return 'yes' === $user_preferences || $this->wordpress_adapter->is_new_installation();
216 216 }
217 217
218 - public function should_switch_preferences_off(): bool {
218 + public function should_switch_preferences_off() : bool {
219 219 return ! $this->elementor_adapter->is_active_kit_default() && ! $this->user_progress[ self::LAST_OPENED_TIMESTAMP ] && ! $this->elementor_adapter->get_count( Elementor_Counter::EDITOR_COUNTER_KEY );
220 220 }
221 221
222 - private function init_user_progress(): void {
222 + private function register_experiment() : void {
223 + Plugin::$instance->experiments->add_feature( [
224 + 'name' => self::EXPERIMENT_ID,
225 + 'title' => esc_html__( 'Launchpad Checklist', 'elementor' ),
226 + 'description' => esc_html__( 'Launchpad Checklist feature to boost productivity and deliver your site faster', 'elementor' ),
227 + 'release_status' => Manager::RELEASE_STATUS_ALPHA,
228 + 'hidden' => true,
229 + 'new_site' => [
230 + 'default_active' => true,
231 + 'minimum_installation_version' => '3.25.0',
232 + ],
233 + ] );
234 + }
235 +
236 + private function init_user_progress() : void {
223 237 $default_settings = $this->get_default_user_progress();
224 238
225 239 $this->wordpress_adapter->add_option( self::DB_OPTION_KEY, wp_json_encode( $default_settings ) );
226 240 }
227 241
228 - private function get_default_user_progress(): array {
242 + private function get_default_user_progress() : array {
229 243 return [
230 244 self::LAST_OPENED_TIMESTAMP => null,
231 245 self::FIRST_CLOSED_CHECKLIST_IN_EDITOR => false,
232 246 self::IS_POPUP_MINIMIZED_KEY => false,
@@ -233,9 +247,9 @@
233 247 'steps' => [],
234 248 ];
235 249 }
236 250
237 - private function update_user_progress_in_db(): void {
251 + private function update_user_progress_in_db() : void {
238 252 $this->wordpress_adapter->update_option( self::DB_OPTION_KEY, wp_json_encode( $this->user_progress ) );
239 253 }
240 254
241 255 private function get_formatted_value( $key, $value ) {
@@ -255,9 +269,10 @@
255 269 $this->wordpress_adapter->set_user_preferences( self::VISIBILITY_SWITCH_ID, '' );
256 270 }, 11 );
257 271 }
258 272
259 - public static function should_display_checklist_toggle_control(): bool {
260 - return Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME )
261 - && current_user_can( 'manage_options' );
273 + public static function should_display_checklist_toggle_control() : bool {
274 + return Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_ID ) &&
275 + Plugin::$instance->experiments->is_feature_active( AppBarModule::EXPERIMENT_NAME ) &&
276 + current_user_can( 'manage_options' );
262 277 }
263 278 }