PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.9.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.9.0
2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 All 50 releases
← All changes | includes/core/class-usage-tracker-manager.php +65 -0 2.0.02.9.0 View file →
@@ -40,8 +40,27 @@
40 40 */
41 41 private const ITEM_ID = '08649e95a94ecddfd027';
42 42
43 43 /**
44 + * Days after install before the opt-in notice may be shown.
45 + *
46 + * Activation redirects into the Setup Wizard, which asks for consent
47 + * itself. Asking again on the user's first admin page load is noise, so
48 + * the card is held back for users who skipped the wizard and only appears
49 + * once they have had a chance to use the plugin.
50 + *
51 + * @var int
52 + */
53 + private const NOTICE_DELAY_DAYS = 7;
54 +
55 + /**
56 + * Option holding the install timestamp the delay is measured from.
57 + *
58 + * @var string
59 + */
60 + private const INSTALL_TIME_OPTION = 'thinkrank_usage_notice_since';
61 +
62 + /**
44 63 * Tracker instance.
45 64 *
46 65 * @var Plugin_Usage_Tracker|null
47 66 */
@@ -74,8 +93,16 @@
74 93 'goodbye_form' => true,
75 94 'item_id' => $item_id,
76 95 ]);
77 96
97 + // Only the admin ever renders the notice, and resolving the baseline
98 + // can write an option — neither belongs on a front-end request.
99 + if (is_admin()) {
100 + $this->tracker->set_notice_after(
101 + $this->get_notice_baseline() + (self::NOTICE_DELAY_DAYS * DAY_IN_SECONDS)
102 + );
103 + }
104 +
78 105 $this->tracker->set_notice_options([
79 106 'notice_title' => __('Want to help make ThinkRank even better?', 'thinkrank'),
80 107 'notice' => __('Allow us to collect non-sensitive diagnostic data and usage information.', 'thinkrank'),
81 108 'extra_notice' => __('We collect non-sensitive diagnostic data and plugin usage information — your site URL, WordPress & PHP version, active plugins & theme, and admin email. This lets us keep ThinkRank compatible with the most popular plugins and themes. No spam, we promise.', 'thinkrank'),
@@ -81,8 +108,46 @@
81 108 'extra_notice' => __('We collect non-sensitive diagnostic data and plugin usage information — your site URL, WordPress & PHP version, active plugins & theme, and admin email. This lets us keep ThinkRank compatible with the most popular plugins and themes. No spam, we promise.', 'thinkrank'),
82 109 ]);
83 110
84 111 $this->tracker->init();
112 + }
113 +
114 + /**
115 + * Timestamp the opt-in delay is measured from.
116 + *
117 + * Deliberately not `thinkrank_activation_time`: the activator rewrites
118 + * that on every activation, so deactivating and reactivating would restart
119 + * the grace period and a user who toggles the plugin could never be asked.
120 + * This option is written once and then left alone.
121 + *
122 + * On upgrade the baseline is seeded from `thinkrank_activation_time`, so a
123 + * site that has had ThinkRank for months is not made to wait another week
124 + * before it can be asked — it has been seeing this card on every admin
125 + * screen already, and the screen scoping is the change it needs. Only an
126 + * install with no activation timestamp at all starts its week now.
127 + *
128 + * Autoloaded: it is read on every admin request, so the alternative is an
129 + * extra query per page load.
130 + *
131 + * @since 2.8.1
132 + * @return int Unix timestamp.
133 + */
134 + private function get_notice_baseline(): int {
135 + $since = (int) get_option(self::INSTALL_TIME_OPTION, 0);
136 +
137 + if ($since > 0) {
138 + return $since;
139 + }
140 +
141 + $since = (int) get_option('thinkrank_activation_time', 0);
142 + if ($since <= 0) {
143 + $since = time();
144 + }
145 +
146 + // add_option() so a concurrent request cannot move a recorded baseline.
147 + add_option(self::INSTALL_TIME_OPTION, $since);
148 +
149 + return $since;
85 150 }
86 151
87 152 /**
88 153 * Record explicit user consent for usage tracking.