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