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 +59 -7 3.2.1 → 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,
@@ -117,8 +120,16 @@
117 120 * @return void
118 121 */
119 122 public function __construct()
120 123 {
124 + self::load();
125 + }
126 +
127 + /**
128 + * @return void
129 + */
130 + public static function load()
131 + {
121 132 self::$id = defined('EXTENDIFY_PARTNER_ID') ? constant('EXTENDIFY_PARTNER_ID') : null;
122 133 $data = self::getPartnerData();
123 134 self::$config['showDomainBanner'] = ($data['showDomainBanner'] ?? self::$config['showDomainBanner']);
124 135 self::$config['showDomainTask'] = ($data['showDomainTask'] ?? self::$config['showDomainTask']);
@@ -153,8 +164,11 @@
153 164 'secondaryColor' => ($data['secondaryColor'] ?? ($data['backgroundColor'] ?? null)),
154 165 'secondaryColorText' => '#ffffff',
155 166 ];
156 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']);
157 171 self::$config['showLaunch'] = ($data['showLaunch'] ?? self::$config['showLaunch']);
158 172 self::$config['showLaunchTitle'] = ($data['showLaunchTitle'] ?? self::$config['showLaunchTitle']);
159 173 self::$config['deactivated'] = ($data['deactivated'] ?? self::$config['deactivated']);
160 174 self::$config['launchRedirectWebsite'] = ($data['launchRedirectWebsite']
@@ -215,15 +229,12 @@
215 229 $partnerData = \get_option('extendify_partner_data_v2', 'empty');
216 230 if ($partnerData !== 'empty') {
217 231 // We have data, but if it's been 10 minutes, check for new data.
218 232 $partnerRefresh = \get_transient('extendify_partner_data_cache_check');
219 - if (!$partnerRefresh && \is_admin()) {
220 - \add_action('init', function () {
221 - if (!\wp_next_scheduled('extendify_fetch_partner_data')) {
222 - \wp_schedule_single_event(time(), 'extendify_fetch_partner_data');
223 - \spawn_cron();
224 - }
225 - });
233 + if (!$partnerRefresh && \is_user_logged_in()) {
234 + \did_action('init')
235 + ? self::scheduleRefresh()
236 + : \add_action('init', [self::class, 'scheduleRefresh']);
226 237 }
227 238
228 239 return array_merge(self::$config, $partnerData);
229 240 }
@@ -232,8 +243,49 @@
232 243 $mergedData = array_merge(self::$config, $freshData);
233 244 // Cache here even if empty [] to prevent multiple requests.
234 245 \update_option('extendify_partner_data_v2', $mergedData);
235 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();
236 288 }
237 289
238 290 /**
239 291 * Fetch or refresh the partner data