PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 4.0.7
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v4.0.7
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 trunk 1.0.0 2.0.0 2.0.1 2.0.2 2.0.3 3.0 3.0.1 3.0.2 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1
superb-blocks / src / data / utils / class-engagement.php
superb-blocks / src / data / utils Last commit date
wizard 4 days ago class-addons-template-util.php 4 days ago class-allowed-template-html-util.php 4 days ago class-base-exception.php 4 days ago class-cache-constants.php 4 days ago class-cache-exception.php 4 days ago class-engagement.php 4 days ago class-key-exception.php 4 days ago class-keytypes.php 4 days ago class-option-exception.php 4 days ago class-quiet-skin.php 4 days ago class-request-exception.php 4 days ago class-script-translations.php 4 days ago class-settings-exception.php 4 days ago class-theme-installer-exception.php 4 days ago class-theme-installer.php 4 days ago class-third-party-compatibility-util.php 4 days ago
class-engagement.php
64 lines
1 <?php
2
3 namespace SuperbAddons\Data\Utils;
4
5 defined('ABSPATH') || exit();
6
7 /**
8 * Centralized, per-site engagement marker.
9 *
10 * Records the first time each meaningful "used the product" action occurs so
11 * features like the review prompt can gate on whether the site has actually
12 * engaged with the plugin. Each feature is written at most once (the first time
13 * it is used), so repeat calls cost a single cached option read and never write.
14 */
15 class Engagement
16 {
17 const OPTION_KEY = 'superbaddons_engagement';
18
19 const FEATURE_PATTERN = 'pattern';
20 const FEATURE_FORM = 'form';
21 const FEATURE_POPUP = 'popup';
22 const FEATURE_DESIGNER = 'designer';
23 const FEATURE_CSS = 'css';
24 const FEATURE_ENHANCEMENT = 'enhancement';
25
26 /**
27 * Record that a feature has been used. Writes only on the first use of each
28 * feature, so subsequent calls are a no-op after a single option read.
29 *
30 * @param string $feature One of the FEATURE_* constants.
31 * @return void
32 */
33 public static function MarkUsed($feature)
34 {
35 if (empty($feature)) {
36 return;
37 }
38
39 $engagement = get_option(self::OPTION_KEY, array());
40 if (!is_array($engagement)) {
41 $engagement = array();
42 }
43
44 // Already recorded — nothing to write.
45 if (isset($engagement[$feature])) {
46 return;
47 }
48
49 $engagement[$feature] = time();
50 update_option(self::OPTION_KEY, $engagement, false);
51 }
52
53 /**
54 * Whether the site has engaged with at least one plugin feature.
55 *
56 * @return bool
57 */
58 public static function HasEngaged()
59 {
60 $engagement = get_option(self::OPTION_KEY, array());
61 return is_array($engagement) && !empty($engagement);
62 }
63 }
64