PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / libs / framework / classes / install-tracker.php
elementskit-lite / libs / framework / classes Last commit date
ajax.php 3 weeks ago install-notice.php 3 weeks ago install-tracker.php 3 weeks ago onboard-status.php 3 weeks ago plugin-data-sender.php 1 year ago plugin-installer.php 3 weeks ago plugin-skin.php 1 year ago plugin-status.php 4 years ago utils.php 1 year ago
install-tracker.php
188 lines
1 <?php
2
3 namespace ElementsKit_Lite\Libs\Framework\Classes;
4
5 defined( 'ABSPATH' ) || exit;
6
7 /**
8 * Tracks plugins installed during a WPMet onboarding flow.
9 *
10 * @since 3.9.5
11 */
12 class Install_Tracker {
13
14 /**
15 * Option name used to store the shared WPMet onboarding registry.
16 *
17 * @since 3.9.5
18 * @var string
19 */
20 const OPTION_KEY = 'wpmet_onboarded_plugins';
21
22 /**
23 * Onboarding status options used by known Wpmet plugins.
24 *
25 * @since 3.9.5
26 * @var array<string, array{option: string, value: mixed, crm_slug?: string}>
27 */
28 const ONBOARD_STATUS_MAP = array(
29 'elementskit-lite/elementskit-lite.php' => array( 'option' => 'elements_kit_onboard_status', 'value' => 'onboarded', 'crm_slug' => 'elementskit-lite' ),
30 'emailkit/EmailKit.php' => array( 'option' => 'emailkit_onboard_status', 'value' => 'onboarded', 'crm_slug' => 'emailkit' ),
31 'shopengine/shopengine.php' => array( 'option' => 'shopengine_onboard_status', 'value' => 'onboarded', 'crm_slug' => 'shopengine' ),
32 'metform/metform.php' => array( 'option' => 'met_form_onboard_status', 'value' => 'onboarded', 'crm_slug' => 'metform' ),
33 'gutenkit-blocks-addon/gutenkit-blocks-addon.php' => array( 'option' => 'gutenkit_onboard_status', 'value' => 'onboarded', 'crm_slug' => 'gutenkit-blocks-addon' ),
34 'getgenie/getgenie.php' => array( 'option' => 'getgenie_onboard_status', 'value' => 'onboarded', 'crm_slug' => 'getgenie' ),
35 'popup-builder-block/popup-builder-block.php' => array( 'option' => 'popupkit_onboard_status', 'value' => 'onboarded', 'crm_slug' => 'popupkit' ),
36 );
37
38 /**
39 * Return the filterable plugin onboarding map.
40 *
41 * @since 3.9.5
42 *
43 * @return array
44 */
45 public static function get_onboard_status_map(): array {
46 return (array) apply_filters( 'wpmet_onboard_status_map', self::ONBOARD_STATUS_MAP );
47 }
48
49 /**
50 * Record an auto-installed plugin and complete its onboarding.
51 *
52 * @since 3.9.5
53 *
54 * @param string $plugin_file Plugin basename.
55 * @param string $installed_by Plugin that initiated the installation.
56 * @return void
57 */
58 public static function mark( string $plugin_file, string $installed_by = 'elementskit-lite' ): void {
59 $registry = self::get_registry();
60
61 if ( ! isset( $registry[ $plugin_file ] ) ) {
62 $registry[ $plugin_file ] = array(
63 'installed_by' => $installed_by,
64 'installed_at' => time(),
65 );
66 update_option( self::OPTION_KEY, $registry, false );
67 }
68
69 $map = self::get_onboard_status_map();
70
71 if ( isset( $map[ $plugin_file ] ) && ! get_option( $map[ $plugin_file ]['option'] ) ) {
72 update_option( $map[ $plugin_file ]['option'], $map[ $plugin_file ]['value'], false );
73 }
74 }
75
76 /**
77 * Check whether a plugin was installed by a Wpmet onboarding flow.
78 *
79 * @since 3.9.5
80 *
81 * @param string $plugin_file Plugin basename.
82 * @return bool
83 */
84 public static function was_auto_installed( string $plugin_file ): bool {
85 return isset( self::get_registry()[ $plugin_file ] );
86 }
87
88 /**
89 * Get the auto-install registry.
90 *
91 * @since 3.9.5
92 *
93 * @return array Shared onboarding registry.
94 */
95 public static function get_registry(): array {
96 return (array) get_option( self::OPTION_KEY, array() );
97 }
98
99 /**
100 * Store the collected onboarding email in the shared registry.
101 *
102 * @since 3.9.5
103 *
104 * @param string $email Email address collected during onboarding.
105 * @return void
106 */
107 public static function store_collected_email( string $email ): void {
108 if ( ! is_email( $email ) ) {
109 return;
110 }
111
112 $registry = self::get_registry();
113 $registry['_shared']['email'] = sanitize_email( $email );
114 $registry['_shared']['email_collected'] = true;
115 $registry['_shared']['updated_at'] = time();
116 self::save_registry( $registry );
117 }
118
119 /**
120 * Get the email address stored in the shared onboarding registry.
121 *
122 * @since 3.9.5
123 *
124 * @return string Sanitized email address, or an empty string when unavailable.
125 */
126 public static function get_collected_email(): string {
127 $registry = self::get_registry();
128 $email = isset( $registry['_shared']['email'] ) ? $registry['_shared']['email'] : '';
129
130 return is_email( $email ) ? sanitize_email( $email ) : '';
131 }
132
133 /**
134 * Determine whether an email address has been collected.
135 *
136 * @since 3.9.5
137 *
138 * @return bool True when an email address has been collected.
139 */
140 public static function has_collected_email(): bool {
141 $registry = self::get_registry();
142
143 return ! empty( $registry['_shared']['email_collected'] );
144 }
145
146 /**
147 * Determine whether the install notice was dismissed for a plugin.
148 *
149 * @since 3.9.5
150 *
151 * @param string $plugin_file Plugin basename.
152 * @return bool True when the notice was dismissed.
153 */
154 public static function is_notice_dismissed( string $plugin_file ): bool {
155 $registry = self::get_registry();
156
157 return ! empty( $registry['_shared']['dismissed'][ $plugin_file ] );
158 }
159
160 /**
161 * Mark the install notice as dismissed for a plugin.
162 *
163 * @since 3.9.5
164 *
165 * @param string $plugin_file Plugin basename.
166 * @return void
167 */
168 public static function dismiss_notice( string $plugin_file ): void {
169 $registry = self::get_registry();
170 $registry['_shared']['dismissed'][ $plugin_file ] = true;
171 $registry['_shared']['notice_resolved_at'][ $plugin_file ] = time();
172 $registry['_shared']['updated_at'] = time();
173 self::save_registry( $registry );
174 }
175
176 /**
177 * Save the shared onboarding registry.
178 *
179 * @since 3.9.5
180 *
181 * @param array $registry Shared onboarding registry.
182 * @return void
183 */
184 private static function save_registry( array $registry ): void {
185 update_option( self::OPTION_KEY, $registry, false );
186 }
187 }
188