PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
← All changes | app/PartnerData.php +61 -7 3.2.0 → 3.2.2 View file →
@@ -64,8 +64,11 @@
64 64 'domainSearchURL' => '',
65 65 'showDraft' => false,
66 66 'showChat' => false,
67 67 'showAIPageCreation' => false,
68 + 'mcpConfig' => [],
69 + 'mcpWriteList' => [],
70 + 'mcpReadList' => [],
68 71 'enableImageImports-1-14-6' => false,
69 72 'disableLibraryAutoOpen' => false,
70 73 'enableApexDomain' => false,
71 74 'showLaunch' => false,
@@ -98,8 +101,9 @@
98 101 'useAutoUpdate' => false,
99 102 'showLaunchUpdate' => false,
100 103 'activeTests' => [],
101 104 'showExtendifyCode' => false,
105 + 'useComingSoon' => false,
102 106 'extendifyCodeData' => [
103 107 'link' => '',
104 108 'title' => '',
105 109 'message' => '',
@@ -116,8 +120,16 @@
116 120 * @return void
117 121 */
118 122 public function __construct()
119 123 {
124 + self::load();
125 + }
126 +
127 + /**
128 + * @return void
129 + */
130 + public static function load()
131 + {
120 132 self::$id = defined('EXTENDIFY_PARTNER_ID') ? constant('EXTENDIFY_PARTNER_ID') : null;
121 133 $data = self::getPartnerData();
122 134 self::$config['showDomainBanner'] = ($data['showDomainBanner'] ?? self::$config['showDomainBanner']);
123 135 self::$config['showDomainTask'] = ($data['showDomainTask'] ?? self::$config['showDomainTask']);
@@ -152,8 +164,11 @@
152 164 'secondaryColor' => ($data['secondaryColor'] ?? ($data['backgroundColor'] ?? null)),
153 165 'secondaryColorText' => '#ffffff',
154 166 ];
155 167 self::$config['showAIPageCreation'] = ($data['showAIPageCreation'] ?? self::$config['showAIPageCreation']);
168 + self::$config['mcpConfig'] = ($data['mcpConfig'] ?? self::$config['mcpConfig']);
169 + self::$config['mcpWriteList'] = ($data['mcpWriteList'] ?? self::$config['mcpWriteList']);
170 + self::$config['mcpReadList'] = ($data['mcpReadList'] ?? self::$config['mcpReadList']);
156 171 self::$config['showLaunch'] = ($data['showLaunch'] ?? self::$config['showLaunch']);
157 172 self::$config['showLaunchTitle'] = ($data['showLaunchTitle'] ?? self::$config['showLaunchTitle']);
158 173 self::$config['deactivated'] = ($data['deactivated'] ?? self::$config['deactivated']);
159 174 self::$config['launchRedirectWebsite'] = ($data['launchRedirectWebsite']
@@ -189,8 +204,9 @@
189 204 self::$config['useAutoUpdate'] = ($data['useAutoUpdate'] ?? self::$config['useAutoUpdate']);
190 205 self::$config['showLaunchUpdate'] = ($data['showLaunchUpdate'] ?? self::$config['showLaunchUpdate']);
191 206 self::$config['activeTests'] = ($data['activeTests'] ?? self::$config['activeTests']);
192 207 self::$config['showExtendifyCode'] = ($data['showExtendifyCode'] ?? self::$config['showExtendifyCode']);
208 + self::$config['useComingSoon'] = ($data['useComingSoon'] ?? self::$config['useComingSoon']);
193 209 self::$config['extendifyCodeData'] = ($data['extendifyCodeData'] ?? self::$config['extendifyCodeData']);
194 210 self::$config['customDesign'] = ($data['customDesign'] ?? self::$config['customDesign']);
195 211 self::$config['strings'] = ($data['strings'] ?? self::$config['strings']);
196 212
@@ -213,15 +229,12 @@
213 229 $partnerData = \get_option('extendify_partner_data_v2', 'empty');
214 230 if ($partnerData !== 'empty') {
215 231 // We have data, but if it's been 10 minutes, check for new data.
216 232 $partnerRefresh = \get_transient('extendify_partner_data_cache_check');
217 - if (!$partnerRefresh && \is_admin()) {
218 - \add_action('init', function () {
219 - if (!\wp_next_scheduled('extendify_fetch_partner_data')) {
220 - \wp_schedule_single_event(time(), 'extendify_fetch_partner_data');
221 - \spawn_cron();
222 - }
223 - });
233 + if (!$partnerRefresh && \is_user_logged_in()) {
234 + \did_action('init')
235 + ? self::scheduleRefresh()
236 + : \add_action('init', [self::class, 'scheduleRefresh']);
224 237 }
225 238
226 239 return array_merge(self::$config, $partnerData);
227 240 }
@@ -230,8 +243,49 @@
230 243 $mergedData = array_merge(self::$config, $freshData);
231 244 // Cache here even if empty [] to prevent multiple requests.
232 245 \update_option('extendify_partner_data_v2', $mergedData);
233 246 return $mergedData;
247 + }
248 +
249 + /**
250 + * A token request may be the only visitor a site gets, so it fetches a stale config itself.
251 + *
252 + * @return void
253 + */
254 + public static function refreshIfStale()
255 + {
256 + if (\get_transient('extendify_partner_data_cache_check')) {
257 + return;
258 + }
259 +
260 + // The 45s timeout the plugin gives its hosts is longer than a waiting MCP client allows.
261 + $brief = function ($args) {
262 + $args['timeout'] = 5;
263 + return $args;
264 + };
265 + \add_filter('http_request_args', $brief, 101);
266 + try {
267 + $fetched = self::fetchPartnerData();
268 + } finally {
269 + \remove_filter('http_request_args', $brief, 101);
270 + }
271 +
272 + if ($fetched) {
273 + self::load();
274 + }
275 + }
276 +
277 + /**
278 + * @return void
279 + */
280 + public static function scheduleRefresh()
281 + {
282 + if (\wp_next_scheduled('extendify_fetch_partner_data')) {
283 + return;
284 + }
285 +
286 + \wp_schedule_single_event(time(), 'extendify_fetch_partner_data');
287 + \spawn_cron();
234 288 }
235 289
236 290 /**
237 291 * Fetch or refresh the partner data