PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0-dev3
Elementor Website Builder – more than just a page builder v4.0.0-dev3
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
elementor / app / modules / onboarding / storage / entities / user-progress.php

user-progress.php in Elementor Website Builder – more than just a page builder 4.0.0-dev3, at app/modules/onboarding/storage/entities/user-progress.php

130 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\App\Modules\Onboarding\Storage\Entities;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 class User_Progress {
10
11 private int $current_step_index = 0;
12 private ?string $current_step_id = null;
13 private array $completed_steps = [];
14 private ?string $exit_type = null;
15 private ?int $last_active_timestamp = null;
16 private ?int $started_at = null;
17 private bool $starter_dismissed = false;
18
19 public static function from_array( array $data ): self {
20 $instance = new self();
21
22 $instance->current_step_index = $data['current_step_index'] ?? $data['current_step'] ?? 0;
23 $instance->current_step_id = $data['current_step_id'] ?? null;
24 $instance->completed_steps = $data['completed_steps'] ?? [];
25 $instance->exit_type = $data['exit_type'] ?? null;
26 $instance->last_active_timestamp = $data['last_active_timestamp'] ?? null;
27 $instance->started_at = $data['started_at'] ?? null;
28 $instance->starter_dismissed = ! empty( $data['starter_dismissed'] );
29
30 return $instance;
31 }
32
33 public function to_array(): array {
34 return [
35 'current_step' => $this->current_step_index,
36 'current_step_index' => $this->current_step_index,
37 'current_step_id' => $this->current_step_id,
38 'completed_steps' => $this->completed_steps,
39 'exit_type' => $this->exit_type,
40 'last_active_timestamp' => $this->last_active_timestamp,
41 'started_at' => $this->started_at,
42 'starter_dismissed' => $this->starter_dismissed,
43 ];
44 }
45
46 public function get_current_step(): int {
47 return $this->current_step_index;
48 }
49
50 public function get_current_step_index(): int {
51 return $this->current_step_index;
52 }
53
54 public function set_current_step_index( int $index ): void {
55 $this->current_step_index = $index;
56 }
57
58 public function get_current_step_id(): ?string {
59 return $this->current_step_id;
60 }
61
62 public function set_current_step_id( ?string $step_id ): void {
63 $this->current_step_id = $step_id;
64 }
65
66 public function set_current_step( int $step, ?string $step_id = null ): void {
67 $this->current_step_index = $step;
68
69 if ( null !== $step_id ) {
70 $this->current_step_id = $step_id;
71 }
72 }
73
74 public function get_completed_steps(): array {
75 return $this->completed_steps;
76 }
77
78 public function set_completed_steps( array $steps ): void {
79 $this->completed_steps = $steps;
80 }
81
82 public function add_completed_step( $step ): void {
83 if ( ! in_array( $step, $this->completed_steps, true ) ) {
84 $this->completed_steps[] = $step;
85 }
86 }
87
88 public function is_step_completed( $step ): bool {
89 return in_array( $step, $this->completed_steps, true );
90 }
91
92 public function get_exit_type(): ?string {
93 return $this->exit_type;
94 }
95
96 public function set_exit_type( ?string $type ): void {
97 $this->exit_type = $type;
98 }
99
100 public function get_last_active_timestamp(): ?int {
101 return $this->last_active_timestamp;
102 }
103
104 public function set_last_active_timestamp( ?int $timestamp ): void {
105 $this->last_active_timestamp = $timestamp;
106 }
107
108 public function get_started_at(): ?int {
109 return $this->started_at;
110 }
111
112 public function set_started_at( ?int $timestamp ): void {
113 $this->started_at = $timestamp;
114 }
115
116 public function is_starter_dismissed(): bool {
117 return $this->starter_dismissed;
118 }
119
120 public function set_starter_dismissed( bool $dismissed ): void {
121 $this->starter_dismissed = $dismissed;
122 }
123
124 public function had_unexpected_exit( bool $is_completed ): bool {
125 return null === $this->exit_type
126 && $this->current_step_index > 0
127 && ! $is_completed;
128 }
129 }
130