PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.4.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.4.0
2.4.0 2.3.0 2.2.0 2.1.0 2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 All 65 releases
← All changes | includes/Admin/Integrations.php +193 -68 1.10.2 → 2.4.0 View file →
@@ -89,9 +89,10 @@
89 89 if ( ! $screen || false === strpos( $screen->id, 'wp-subscription-integrations' ) ) {
90 90 return;
91 91 }
92 92
93 - wp_enqueue_script( 'subscrpt-integrations', SUBSCRPT_ASSETS . '/js/integration_settings.js', [], SUBSCRPT_VERSION, true );
93 + wp_enqueue_script( 'subscrpt-integrations', SUBSCRPT_ASSETS . '/js/integration_settings.js', [ 'wp-i18n' ], SUBSCRPT_VERSION, true );
94 + wp_set_script_translations( 'subscrpt-integrations', 'subscription', SUBSCRPT_PATH . '/languages' );
94 95
95 96 wp_localize_script(
96 97 'subscrpt-integrations',
97 98 'subscrptIntegrations',
@@ -99,8 +100,12 @@
99 100 'nonce' => wp_create_nonce( 'subscrpt_integration_install_nonce' ),
100 101 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
101 102 )
102 103 );
104 +
105 + // Browser-side filter rail. Enqueued on this hook, not in the render
106 + // callback, so it always loads.
107 + wp_enqueue_script( 'subscrpt-integrations-filter', SUBSCRPT_ASSETS . '/js/admin/integrations-filter.js', [], SUBSCRPT_VERSION, true );
103 108 }
104 109
105 110 /**
106 111 * Handle AJAX request for integrations.
@@ -188,8 +193,55 @@
188 193 return is_plugin_active( $plugin_file );
189 194 }
190 195
191 196 /**
197 + * Find the basename of an installed plugin from its wp.org slug.
198 + *
199 + * @param string $slug The wp.org plugin slug, which is also its directory.
200 + * @return string The plugin basename, or an empty string when not installed.
201 + */
202 + protected function find_plugin_file( $slug ) {
203 + if ( ! function_exists( 'get_plugins' ) ) {
204 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
205 + }
206 + foreach ( array_keys( get_plugins() ) as $plugin_file ) {
207 + if ( 0 === strpos( $plugin_file, $slug . '/' ) ) {
208 + return $plugin_file;
209 + }
210 + }
211 + return '';
212 + }
213 +
214 + /**
215 + * Mark a gateway card installed when its plugin is on disk, and give it an
216 + * Activate action for when that plugin is inactive.
217 + *
218 + * Gateway cards otherwise detect installation by a class the plugin declares,
219 + * which only exists while it is active, so an installed-but-inactive gateway
220 + * offered "Install Now" and the install failed on the existing folder.
221 + *
222 + * @param array $integration The integration card.
223 + * @param string $slug The wp.org plugin slug.
224 + * @return array
225 + */
226 + protected function with_gateway_plugin_state( array $integration, $slug ) {
227 + $plugin_file = $this->find_plugin_file( $slug );
228 + if ( '' === $plugin_file ) {
229 + return $integration;
230 + }
231 +
232 + $integration['is_installed'] = true;
233 + $integration['plugin_file'] = $plugin_file;
234 + $integration['actions'][] = [
235 + 'action' => 'activate',
236 + 'label' => __( 'Activate', 'subscription' ),
237 + 'type' => 'function',
238 + 'function' => "subscrptActivatePlugin(this, '" . esc_js( $plugin_file ) . "')",
239 + ];
240 + return $integration;
241 + }
242 +
243 + /**
192 244 * Check if a payment gateway is enabled.
193 245 *
194 246 * @param string $gateway_id Gateway ID.
195 247 */
@@ -206,9 +258,9 @@
206 258 protected function get_integrations(): array {
207 259 $integrations = [
208 260 'paypal' => [
209 261 'title' => 'PayPal',
210 - 'description' => 'Accept recurring subscription payments directly through PayPal.',
262 + 'description' => __( 'Accept recurring subscription payments directly through PayPal.', 'subscription' ),
211 263 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/paypal.svg',
212 264 'type' => 'payment_gateway',
213 265 'is_installed' => 'on' === get_option( 'wp_subs_paypal_integration_enabled', 'off' ),
214 266 'is_active' => self::is_gateway_enabled( 'wp_subscription_paypal' ),
@@ -221,9 +273,9 @@
221 273 // 'function' => 'wpSubsInstallPaypalIntegration()',
222 274 // ],
223 275 [
224 276 'action' => 'settings',
225 - 'label' => 'Settings',
277 + 'label' => __( 'Settings', 'subscription' ),
226 278 'type' => 'link',
227 279 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=wp_subscription_paypal' ),
228 280 ],
229 281 // [
@@ -236,10 +288,10 @@
236 288 ],
237 289 ],
238 290 'stripe' => [
239 291 'title' => 'Stripe',
240 - 'description' => 'Process subscription payments securely with Stripe.',
241 - 'icon_url' => 'https://ps.w.org/woocommerce-gateway-stripe/assets/icon-256x256.png',
292 + 'description' => __( 'Process subscription payments securely with Stripe.', 'subscription' ),
293 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/stripe.png',
242 294 'type' => 'payment_gateway',
243 295 'is_installed' => class_exists( 'WC_Stripe' ),
244 296 'is_active' => self::is_gateway_enabled( 'stripe' ),
245 297 'supports_recurring' => true,
@@ -245,15 +297,15 @@
245 297 'supports_recurring' => true,
246 298 'actions' => [
247 299 [
248 300 'action' => 'install',
249 - 'label' => 'Install Now',
301 + 'label' => __( 'Install Now', 'subscription' ),
250 302 'type' => 'function',
251 303 'function' => "subscrptInstallPlugin(this, 'woocommerce-gateway-stripe')",
252 304 ],
253 305 [
254 306 'action' => 'settings',
255 - 'label' => 'Settings',
307 + 'label' => __( 'Settings', 'subscription' ),
256 308 'type' => 'link',
257 309 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe&panel=settings' ),
258 310 ],
259 311 ],
@@ -259,9 +311,9 @@
259 311 ],
260 312 ],
261 313 'paddle' => [
262 314 'title' => 'Paddle',
263 - 'description' => 'Process subscription payments securely with Paddle.',
315 + 'description' => __( 'Process subscription payments securely with Paddle.', 'subscription' ),
264 316 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/paddle.svg',
265 317 'type' => 'payment_gateway',
266 318 'is_installed' => class_exists( 'SmartPayWoo\Gateways\Paddle\SmartPay_Paddle' ),
267 319 'is_active' => self::is_gateway_enabled( 'smartpay_paddle' ),
@@ -268,15 +320,15 @@
268 320 'supports_recurring' => true,
269 321 'actions' => [
270 322 [
271 323 'action' => 'install',
272 - 'label' => 'Get Paddle',
324 + 'label' => __( 'Get Paddle', 'subscription' ),
273 325 'type' => 'external_link',
274 326 'url' => 'https://wpsmartpay.com/paddle-for-woocommerce/',
275 327 ],
276 328 [
277 329 'action' => 'enable',
278 - 'label' => 'Enable Gateway',
330 + 'label' => __( 'Enable Gateway', 'subscription' ),
279 331 'type' => 'toggle_option',
280 332 'option_key' => 'woocommerce_enable_paddle_gateway',
281 333 'value' => true,
282 334 ],
@@ -281,14 +333,14 @@
281 333 'value' => true,
282 334 ],
283 335 [
284 336 'action' => 'settings',
285 - 'label' => 'Settings',
337 + 'label' => __( 'Settings', 'subscription' ),
286 338 'type' => 'link',
287 339 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=smartpay_paddle&from=WCADMIN_PAYMENT_SETTINGS' ),
288 340 ],
289 341 [
290 - 'label' => 'More Details',
342 + 'label' => __( 'More Details', 'subscription' ),
291 343 'type' => 'external_link',
292 344 'url' => 'https://wpsmartpay.com/paddle-for-woocommerce/',
293 345 ],
294 346 ],
@@ -294,13 +346,12 @@
294 346 ],
295 347 ],
296 348 'mollie' => [
297 349 'title' => 'Mollie',
298 - 'description' => 'Pay for subscriptions with Mollie Payments for WooCommerce.',
350 + 'description' => __( 'Pay for subscriptions with Mollie Payments for WooCommerce.', 'subscription' ),
299 351 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/mollie.png',
300 352 'type' => 'payment_gateway',
301 353 'is_pro' => true,
302 - 'is_beta' => true,
303 354 'is_installed' => class_exists( 'Mollie\WooCommerce\Activation\ActivationModule' ),
304 355 'is_active' => self::is_gateway_enabled( 'mollie_wc_gateway', true ),
305 356 'supports_recurring' => true,
306 357 'actions' => [
@@ -305,28 +356,28 @@
305 356 'supports_recurring' => true,
306 357 'actions' => [
307 358 [
308 359 'action' => 'install',
309 - 'label' => 'Install Now',
360 + 'label' => __( 'Install Now', 'subscription' ),
310 361 'type' => 'function',
311 362 'function' => "subscrptInstallPlugin(this, 'mollie-payments-for-woocommerce')",
312 363 ],
313 364 [
314 365 'action' => 'settings',
315 - 'label' => 'Settings',
366 + 'label' => __( 'Settings', 'subscription' ),
316 367 'type' => 'link',
317 368 'url' => admin_url( 'admin.php?page=wc-settings&tab=mollie_settings' ),
318 369 ],
319 370 [
320 - 'label' => 'More Details',
371 + 'label' => __( 'More Details', 'subscription' ),
321 372 'type' => 'external_link',
322 - 'url' => 'https://docs.converslabs.com/en/wpsubscription-payment-with-mollie',
373 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-payment-with-mollie?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
323 374 ],
324 375 ],
325 376 ],
326 377 'razorpay' => [
327 378 'title' => 'Razorpay',
328 - 'description' => 'Pay for subscriptions securely with Razorpay for WooCommerce.',
379 + 'description' => __( 'Pay for subscriptions securely with Razorpay for WooCommerce.', 'subscription' ),
329 380 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/razorpay.png',
330 381 'type' => 'payment_gateway',
331 382 'is_pro' => true,
332 383 'is_beta' => true,
@@ -335,28 +386,28 @@
335 386 'supports_recurring' => true,
336 387 'actions' => [
337 388 [
338 389 'action' => 'install',
339 - 'label' => 'Install Now',
390 + 'label' => __( 'Install Now', 'subscription' ),
340 391 'type' => 'function',
341 392 'function' => "subscrptInstallPlugin(this, 'woo-razorpay')",
342 393 ],
343 394 [
344 395 'action' => 'settings',
345 - 'label' => 'Settings',
396 + 'label' => __( 'Settings', 'subscription' ),
346 397 'type' => 'link',
347 398 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=razorpay' ),
348 399 ],
349 400 [
350 - 'label' => 'More Details',
401 + 'label' => __( 'More Details', 'subscription' ),
351 402 'type' => 'external_link',
352 - 'url' => 'https://docs.converslabs.com/en/wpsubscription-payment-with-razorpay',
403 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-payment-with-razorpay?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
353 404 ],
354 405 ],
355 406 ],
356 407 'xendit' => [
357 408 'title' => 'Xendit',
358 - 'description' => 'Pay for subscriptions securely with Xendit for WooCommerce.',
409 + 'description' => __( 'Pay for subscriptions securely with Xendit for WooCommerce.', 'subscription' ),
359 410 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/xendit.png',
360 411 'type' => 'payment_gateway',
361 412 'is_pro' => true,
362 413 'is_beta' => true,
@@ -365,38 +416,43 @@
365 416 'supports_recurring' => true,
366 417 'actions' => [
367 418 [
368 419 'action' => 'install',
369 - 'label' => 'Install Now',
420 + 'label' => __( 'Install Now', 'subscription' ),
370 421 'type' => 'function',
371 422 'function' => "subscrptInstallPlugin(this, 'woo-xendit-virtual-accounts')",
372 423 ],
373 424 [
374 425 'action' => 'settings',
375 - 'label' => 'Settings',
426 + 'label' => __( 'Settings', 'subscription' ),
376 427 'type' => 'link',
377 428 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=xendit_gateway' ),
378 429 ],
379 430 [
380 - 'label' => 'More Details',
431 + 'label' => __( 'More Details', 'subscription' ),
381 432 'type' => 'external_link',
382 - 'url' => 'https://docs.converslabs.com/en/wpsubscription-payment-with-xendit',
433 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-payment-with-xendit?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
383 434 ],
384 435 ],
385 436 ],
386 437 ];
387 438
439 + $integrations['stripe'] = $this->with_gateway_plugin_state( $integrations['stripe'], 'woocommerce-gateway-stripe' );
440 + $integrations['mollie'] = $this->with_gateway_plugin_state( $integrations['mollie'], 'mollie-payments-for-woocommerce' );
441 + $integrations['razorpay'] = $this->with_gateway_plugin_state( $integrations['razorpay'], 'woo-razorpay' );
442 + $integrations['xendit'] = $this->with_gateway_plugin_state( $integrations['xendit'], 'woo-xendit-virtual-accounts' );
443 +
388 444 // Third-party integrations (requires Pro plugin to function).
389 445 $third_party = [
390 446 // LMS.
391 447 'tutor_lms' => [
392 448 'title' => 'Tutor LMS',
393 - 'description' => 'Restrict course access based on subscription status. Enroll and unenroll students automatically.',
394 - 'icon_url' => 'https://ps.w.org/tutor/assets/icon-256x256.gif',
449 + 'description' => __( 'Restrict course access based on subscription status. Enroll and unenroll students automatically.', 'subscription' ),
450 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/tutor-lms.jpeg',
395 451 'type' => 'third_party',
396 452 'is_pro' => true,
397 453 'category' => 'lms',
398 - 'is_installed' => is_plugin_active( 'tutor/tutor.php' ) && class_exists( 'TUTOR\Tutor' ),
454 + 'is_installed' => $this->is_plugin_installed( 'tutor/tutor.php' ),
399 455 'is_active' => is_plugin_active( 'tutor/tutor.php' ) && class_exists( 'TUTOR\Tutor' ),
400 456 'actions' => [
401 457 [
402 458 'action' => 'install',
@@ -404,22 +460,28 @@
404 460 'type' => 'function',
405 461 'function' => "subscrptInstallPlugin(this, 'tutor')",
406 462 ],
407 463 [
464 + 'action' => 'activate',
465 + 'label' => __( 'Activate', 'subscription' ),
466 + 'type' => 'function',
467 + 'function' => "subscrptActivatePlugin(this, 'tutor/tutor.php')",
468 + ],
469 + [
408 470 'label' => __( 'Learn More', 'subscription' ),
409 471 'type' => 'external_link',
410 - 'url' => 'https://docs.converslabs.com/en/wpsubscription-tutor-lms',
472 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-tutor-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
411 473 ],
412 474 ],
413 475 ],
414 476 'learnpress' => [
415 477 'title' => 'LearnPress',
416 - 'description' => 'Connect subscriptions with LearnPress courses. Enroll users automatically when subscriptions are active.',
417 - 'icon_url' => 'https://ps.w.org/learnpress/assets/icon-256x256.gif',
478 + 'description' => __( 'Connect subscriptions with LearnPress courses. Enroll users automatically when subscriptions are active.', 'subscription' ),
479 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/learnpress.png',
418 480 'type' => 'third_party',
419 481 'is_pro' => true,
420 482 'category' => 'lms',
421 - 'is_installed' => is_plugin_active( 'learnpress/learnpress.php' ) && class_exists( 'LearnPress' ),
483 + 'is_installed' => $this->is_plugin_installed( 'learnpress/learnpress.php' ),
422 484 'is_active' => is_plugin_active( 'learnpress/learnpress.php' ) && class_exists( 'LearnPress' ),
423 485 'actions' => [
424 486 [
425 487 'action' => 'install',
@@ -427,22 +489,28 @@
427 489 'type' => 'function',
428 490 'function' => "subscrptInstallPlugin(this, 'learnpress')",
429 491 ],
430 492 [
493 + 'action' => 'activate',
494 + 'label' => __( 'Activate', 'subscription' ),
495 + 'type' => 'function',
496 + 'function' => "subscrptActivatePlugin(this, 'learnpress/learnpress.php')",
497 + ],
498 + [
431 499 'label' => __( 'Learn More', 'subscription' ),
432 500 'type' => 'external_link',
433 - 'url' => 'https://docs.converslabs.com/en/wpsubscription-learnpress-lms',
501 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-learnpress-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
434 502 ],
435 503 ],
436 504 ],
437 505 'learndash' => [
438 506 'title' => 'LearnDash',
439 - 'description' => 'Sync subscription status with LearnDash group enrollment and course access.',
507 + 'description' => __( 'Sync subscription status with LearnDash group enrollment and course access.', 'subscription' ),
440 508 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/learndash.jpeg',
441 509 'type' => 'third_party',
442 510 'is_pro' => true,
443 511 'category' => 'lms',
444 - 'is_installed' => is_plugin_active( 'sfwd-lms/sfwd_lms.php' ) && class_exists( 'LearnDash\Core\App' ),
512 + 'is_installed' => $this->is_plugin_installed( 'sfwd-lms/sfwd_lms.php' ),
445 513 'is_active' => is_plugin_active( 'sfwd-lms/sfwd_lms.php' ) && class_exists( 'LearnDash\Core\App' ),
446 514 'actions' => [
447 515 [
448 516 'action' => 'install',
@@ -450,11 +518,17 @@
450 518 'type' => 'external_link',
451 519 'url' => 'https://www.learndash.com/',
452 520 ],
453 521 [
522 + 'action' => 'activate',
523 + 'label' => __( 'Activate', 'subscription' ),
524 + 'type' => 'function',
525 + 'function' => "subscrptActivatePlugin(this, 'sfwd-lms/sfwd_lms.php')",
526 + ],
527 + [
454 528 'label' => __( 'Learn More', 'subscription' ),
455 529 'type' => 'external_link',
456 - 'url' => 'https://docs.converslabs.com/en/wpsubscription-learndash-lms',
530 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-learndash-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
457 531 ],
458 532 ],
459 533 ],
460 534 // CRM.
@@ -459,14 +533,14 @@
459 533 ],
460 534 // CRM.
461 535 'fluentcrm' => [
462 536 'title' => 'FluentCRM',
463 - 'description' => 'Trigger email sequences and manage contacts based on subscription events and status changes.',
464 - 'icon_url' => 'https://ps.w.org/fluent-crm/assets/icon-256x256.png',
537 + 'description' => __( 'Trigger email sequences and manage contacts based on subscription events and status changes.', 'subscription' ),
538 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/fluentcrm.png',
465 539 'type' => 'third_party',
466 540 'is_pro' => true,
467 541 'category' => 'crm',
468 - 'is_installed' => class_exists( 'FluentCrm\App\Services\Funnel\BaseTrigger' ),
542 + 'is_installed' => $this->is_plugin_installed( 'fluent-crm/fluent-crm.php' ),
469 543 'is_active' => class_exists( 'FluentCrm\App\Services\Funnel\BaseTrigger' ),
470 544 'actions' => [
471 545 [
472 546 'action' => 'install',
@@ -474,11 +548,17 @@
474 548 'type' => 'function',
475 549 'function' => "subscrptInstallPlugin(this, 'fluent-crm')",
476 550 ],
477 551 [
552 + 'action' => 'activate',
553 + 'label' => __( 'Activate', 'subscription' ),
554 + 'type' => 'function',
555 + 'function' => "subscrptActivatePlugin(this, 'fluent-crm/fluent-crm.php')",
556 + ],
557 + [
478 558 'label' => __( 'Learn More', 'subscription' ),
479 559 'type' => 'external_link',
480 - 'url' => 'https://docs.converslabs.com/en/wpsubscription-fluent-crm',
560 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-fluent-crm?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
481 561 ],
482 562 ],
483 563 ],
484 564 // Automation.
@@ -483,14 +563,14 @@
483 563 ],
484 564 // Automation.
485 565 'automatorwp' => [
486 566 'title' => 'AutomatorWP',
487 - 'description' => 'Build powerful automations triggered by subscription events without writing any code.',
488 - 'icon_url' => 'https://ps.w.org/automatorwp/assets/icon-256x256.png',
567 + 'description' => __( 'Build powerful automations triggered by subscription events without writing any code.', 'subscription' ),
568 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/automatorwp.png',
489 569 'type' => 'third_party',
490 570 'is_pro' => true,
491 571 'category' => 'automation',
492 - 'is_installed' => is_plugin_active( 'automatorwp/automatorwp.php' ) && class_exists( 'AutomatorWP' ),
572 + 'is_installed' => $this->is_plugin_installed( 'automatorwp/automatorwp.php' ),
493 573 'is_active' => is_plugin_active( 'automatorwp/automatorwp.php' ) && class_exists( 'AutomatorWP' ),
494 574 'actions' => [
495 575 [
496 576 'action' => 'install',
@@ -497,23 +577,29 @@
497 577 'label' => __( 'Install Now', 'subscription' ),
498 578 'type' => 'function',
499 579 'function' => "subscrptInstallPlugin(this, 'automatorwp')",
500 580 ],
581 + [
582 + 'action' => 'activate',
583 + 'label' => __( 'Activate', 'subscription' ),
584 + 'type' => 'function',
585 + 'function' => "subscrptActivatePlugin(this, 'automatorwp/automatorwp.php')",
586 + ],
501 587 // [
502 588 // 'label' => __( 'Learn More', 'subscription' ),
503 589 // 'type' => 'external_link',
504 - // 'url' => 'https://docs.converslabs.com/en/',
590 + // 'url' => 'https://docs.wpsubscription.co/en/',
505 591 // ],
506 592 ],
507 593 ],
508 594 'wpfusion' => [
509 595 'title' => 'WP Fusion',
510 - 'description' => 'Sync subscription data with your CRM and marketing platforms through WP Fusion.',
511 - 'icon_url' => 'https://ps.w.org/wp-fusion-lite/assets/icon-256x256.png',
596 + 'description' => __( 'Sync subscription data with your CRM and marketing platforms through WP Fusion.', 'subscription' ),
597 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/wp-fusion.png',
512 598 'type' => 'third_party',
513 599 'is_pro' => true,
514 600 'category' => 'automation',
515 - 'is_installed' => class_exists( 'WPF_Integrations_Base' ),
601 + 'is_installed' => $this->is_plugin_installed( 'wp-fusion/wp-fusion.php' ) || class_exists( 'WPF_Integrations_Base' ),
516 602 'is_active' => class_exists( 'WPF_Integrations_Base' ),
517 603 'actions' => [
518 604 [
519 605 'action' => 'install',
@@ -520,12 +606,18 @@
520 606 'label' => __( 'Get WP Fusion', 'subscription' ),
521 607 'type' => 'external_link',
522 608 'url' => 'https://wpfusion.com/',
523 609 ],
610 + [
611 + 'action' => 'activate',
612 + 'label' => __( 'Activate', 'subscription' ),
613 + 'type' => 'function',
614 + 'function' => "subscrptActivatePlugin(this, 'wp-fusion/wp-fusion.php')",
615 + ],
524 616 // [
525 617 // 'label' => __( 'Learn More', 'subscription' ),
526 618 // 'type' => 'external_link',
527 - // 'url' => 'https://docs.converslabs.com/en/',
619 + // 'url' => 'https://docs.wpsubscription.co/en/',
528 620 // ],
529 621 ],
530 622 ],
531 623 // Email Marketing.
@@ -530,14 +622,14 @@
530 622 ],
531 623 // Email Marketing.
532 624 'mailpoet' => [
533 625 'title' => 'MailPoet',
534 - 'description' => 'Add subscribers to MailPoet lists and trigger email automations based on subscription lifecycle events.',
535 - 'icon_url' => 'https://ps.w.org/mailpoet/assets/icon-256x256.png',
626 + 'description' => __( 'Add subscribers to MailPoet lists and trigger email automations based on subscription lifecycle events.', 'subscription' ),
627 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/mailpoet.png',
536 628 'type' => 'third_party',
537 629 'is_pro' => true,
538 630 'category' => 'email',
539 - 'is_installed' => is_plugin_active( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
631 + 'is_installed' => $this->is_plugin_installed( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
540 632 'is_active' => is_plugin_active( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
541 633 'actions' => [
542 634 [
543 635 'action' => 'install',
@@ -545,11 +637,17 @@
545 637 'type' => 'function',
546 638 'function' => "subscrptInstallPlugin(this, 'mailpoet')",
547 639 ],
548 640 [
641 + 'action' => 'activate',
642 + 'label' => __( 'Activate', 'subscription' ),
643 + 'type' => 'function',
644 + 'function' => "subscrptActivatePlugin(this, 'mailpoet/mailpoet.php')",
645 + ],
646 + [
549 647 'label' => __( 'Learn More', 'subscription' ),
550 648 'type' => 'external_link',
551 - 'url' => 'https://docs.converslabs.com/en/wpsubscription-mailpoet',
649 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-mailpoet?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
552 650 ],
553 651 ],
554 652 ],
555 653 // License Management.
@@ -554,14 +652,14 @@
554 652 ],
555 653 // License Management.
556 654 'wp_soft_lic' => [
557 655 'title' => 'WP Software License',
558 - 'description' => 'Issue and validate software licenses for subscription-based digital products.',
656 + 'description' => __( 'Issue and validate software licenses for subscription-based digital products.', 'subscription' ),
559 657 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/wp-software-license.png',
560 658 'type' => 'third_party',
561 659 'is_pro' => true,
562 660 'category' => 'license',
563 - 'is_installed' => is_plugin_active( 'software-license/software-license.php' ) && class_exists( 'WOO_SL' ),
661 + 'is_installed' => $this->is_plugin_installed( 'software-license/software-license.php' ),
564 662 'is_active' => is_plugin_active( 'software-license/software-license.php' ) && class_exists( 'WOO_SL' ),
565 663 'actions' => [
566 664 [
567 665 'action' => 'install',
@@ -568,23 +666,29 @@
568 666 'label' => __( 'Get Plugin', 'subscription' ),
569 667 'type' => 'external_link',
570 668 'url' => 'https://wpsoftwarelicense.com/',
571 669 ],
670 + [
671 + 'action' => 'activate',
672 + 'label' => __( 'Activate', 'subscription' ),
673 + 'type' => 'function',
674 + 'function' => "subscrptActivatePlugin(this, 'software-license/software-license.php')",
675 + ],
572 676 // [
573 677 // 'label' => __( 'Learn More', 'subscription' ),
574 678 // 'type' => 'external_link',
575 - // 'url' => 'https://docs.converslabs.com/en/',
679 + // 'url' => 'https://docs.wpsubscription.co/en/',
576 680 // ],
577 681 ],
578 682 ],
579 683 'license_mgr' => [
580 684 'title' => 'License Manager for WooCommerce',
581 - 'description' => 'Generate and manage software license keys that are automatically tied to active subscriptions.',
582 - 'icon_url' => 'https://ps.w.org/license-manager-for-woocommerce/assets/icon-256x256.gif',
685 + 'description' => __( 'Generate and manage software license keys that are automatically tied to active subscriptions.', 'subscription' ),
686 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/license-manager.png',
583 687 'type' => 'third_party',
584 688 'is_pro' => true,
585 689 'category' => 'license',
586 - 'is_installed' => is_plugin_active( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ) && class_exists( 'LicenseManagerForWooCommerce\Models\Resources\License' ),
690 + 'is_installed' => $this->is_plugin_installed( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ),
587 691 'is_active' => is_plugin_active( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ) && class_exists( 'LicenseManagerForWooCommerce\Models\Resources\License' ),
588 692 'actions' => [
589 693 [
590 694 'action' => 'install',
@@ -591,12 +695,18 @@
591 695 'label' => __( 'Install Now', 'subscription' ),
592 696 'type' => 'function',
593 697 'function' => "subscrptInstallPlugin(this, 'license-manager-for-woocommerce')",
594 698 ],
699 + [
700 + 'action' => 'activate',
701 + 'label' => __( 'Activate', 'subscription' ),
702 + 'type' => 'function',
703 + 'function' => "subscrptActivatePlugin(this, 'license-manager-for-woocommerce/license-manager-for-woocommerce.php')",
704 + ],
595 705 // [
596 706 // 'label' => __( 'Learn More', 'subscription' ),
597 707 // 'type' => 'external_link',
598 - // 'url' => 'https://docs.converslabs.com/en/',
708 + // 'url' => 'https://docs.wpsubscription.co/en/',
599 709 // ],
600 710 ],
601 711 ],
602 712 ];
@@ -619,10 +729,16 @@
619 729 foreach ( $integrations as $integration ) {
620 730 $is_installed = $integration['is_installed'] ?? false;
621 731 $is_active = $integration['is_active'] ?? false;
622 732
623 - $cleaned_actions = [];
733 + // A gateway card is "active" when its gateway is enabled, which is not
734 + // the same as its plugin being active; read the plugin itself.
735 + $plugin_file = $integration['plugin_file'] ?? '';
736 + $plugin_active = '' !== $plugin_file ? is_plugin_active( $plugin_file ) : $is_active;
624 737
738 + $cleaned_actions = [];
739 + $shown_install_url = null;
740 +
625 741 foreach ( $integration['actions'] as $integration_action ) {
626 742 $action_tag = $integration_action['action'] ?? null;
627 743
628 744 if ( 'install' === $action_tag ) {
@@ -627,8 +743,9 @@
627 743
628 744 if ( 'install' === $action_tag ) {
629 745 if ( ! $is_installed ) {
630 746 $cleaned_actions[] = $integration_action;
747 + $shown_install_url = $integration_action['url'] ?? null;
631 748 }
632 749 continue;
633 750 }
634 751 if ( 'uninstall' === $action_tag ) {
@@ -636,8 +753,14 @@
636 753 $cleaned_actions[] = $integration_action;
637 754 }
638 755 continue;
639 756 }
757 + if ( 'activate' === $action_tag ) {
758 + if ( $is_installed && ! $plugin_active ) {
759 + $cleaned_actions[] = $integration_action;
760 + }
761 + continue;
762 + }
640 763 if ( 'enable' === $action_tag ) {
641 764 if ( $is_installed && ! $is_active ) {
642 765 $cleaned_actions[] = $integration_action;
643 766 }
@@ -643,15 +766,20 @@
643 766 }
644 767 continue;
645 768 }
646 769 if ( 'settings' === $action_tag ) {
647 - if ( $is_installed ) {
770 + if ( $is_installed && ( '' === $plugin_file || $plugin_active ) ) {
648 771 $cleaned_actions[] = $integration_action;
649 772 }
650 773 continue;
651 774 }
652 775
653 - // Default.
776 + // Default. Skip a "More Details"-style link that just repeats the
777 + // install/"Get X" link already shown (e.g. Paddle), so the card
778 + // does not carry the same URL twice.
779 + if ( null !== $shown_install_url && ( $integration_action['url'] ?? null ) === $shown_install_url ) {
780 + continue;
781 + }
654 782 $cleaned_actions[] = $integration_action;
655 783 }
656 784
657 785 // Overwrite.
@@ -667,11 +795,8 @@
667 795 */
668 796 public function render_integrations_page() {
669 797 $integrations = $this->integrations;
670 798 $integrations = $this->filter_integration_actions( $integrations );
671 -
672 - // Integrations styles.
673 - // wp_enqueue_style( 'wp-subs-integration-settings', SUBSCRPT_ASSETS . '/css/integration_settings.css', [], SUBSCRPT_VERSION, 'all' );
674 799
675 800 $menu = new \SpringDevs\Subscription\Admin\Menu();
676 801 $menu->render_admin_header( __( 'Integrations', 'subscription' ) );
677 802 include 'views/integrations.php';