PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.1.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.1.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 +10 -127 2.3.0 → 2.1.0 View file →
@@ -192,55 +192,8 @@
192 192 return is_plugin_active( $plugin_file );
193 193 }
194 194
195 195 /**
196 - * Find the basename of an installed plugin from its wp.org slug.
197 - *
198 - * @param string $slug The wp.org plugin slug, which is also its directory.
199 - * @return string The plugin basename, or an empty string when not installed.
200 - */
201 - protected function find_plugin_file( $slug ) {
202 - if ( ! function_exists( 'get_plugins' ) ) {
203 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
204 - }
205 - foreach ( array_keys( get_plugins() ) as $plugin_file ) {
206 - if ( 0 === strpos( $plugin_file, $slug . '/' ) ) {
207 - return $plugin_file;
208 - }
209 - }
210 - return '';
211 - }
212 -
213 - /**
214 - * Mark a gateway card installed when its plugin is on disk, and give it an
215 - * Activate action for when that plugin is inactive.
216 - *
217 - * Gateway cards otherwise detect installation by a class the plugin declares,
218 - * which only exists while it is active, so an installed-but-inactive gateway
219 - * offered "Install Now" and the install failed on the existing folder.
220 - *
221 - * @param array $integration The integration card.
222 - * @param string $slug The wp.org plugin slug.
223 - * @return array
224 - */
225 - protected function with_gateway_plugin_state( array $integration, $slug ) {
226 - $plugin_file = $this->find_plugin_file( $slug );
227 - if ( '' === $plugin_file ) {
228 - return $integration;
229 - }
230 -
231 - $integration['is_installed'] = true;
232 - $integration['plugin_file'] = $plugin_file;
233 - $integration['actions'][] = [
234 - 'action' => 'activate',
235 - 'label' => __( 'Activate', 'subscription' ),
236 - 'type' => 'function',
237 - 'function' => "subscrptActivatePlugin(this, '" . esc_js( $plugin_file ) . "')",
238 - ];
239 - return $integration;
240 - }
241 -
242 - /**
243 196 * Check if a payment gateway is enabled.
244 197 *
245 198 * @param string $gateway_id Gateway ID.
246 199 */
@@ -434,13 +387,8 @@
434 387 ],
435 388 ],
436 389 ];
437 390
438 - $integrations['stripe'] = $this->with_gateway_plugin_state( $integrations['stripe'], 'woocommerce-gateway-stripe' );
439 - $integrations['mollie'] = $this->with_gateway_plugin_state( $integrations['mollie'], 'mollie-payments-for-woocommerce' );
440 - $integrations['razorpay'] = $this->with_gateway_plugin_state( $integrations['razorpay'], 'woo-razorpay' );
441 - $integrations['xendit'] = $this->with_gateway_plugin_state( $integrations['xendit'], 'woo-xendit-virtual-accounts' );
442 -
443 391 // Third-party integrations (requires Pro plugin to function).
444 392 $third_party = [
445 393 // LMS.
446 394 'tutor_lms' => [
@@ -449,9 +397,9 @@
449 397 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/tutor-lms.jpeg',
450 398 'type' => 'third_party',
451 399 'is_pro' => true,
452 400 'category' => 'lms',
453 - 'is_installed' => $this->is_plugin_installed( 'tutor/tutor.php' ),
401 + 'is_installed' => is_plugin_active( 'tutor/tutor.php' ) && class_exists( 'TUTOR\Tutor' ),
454 402 'is_active' => is_plugin_active( 'tutor/tutor.php' ) && class_exists( 'TUTOR\Tutor' ),
455 403 'actions' => [
456 404 [
457 405 'action' => 'install',
@@ -459,14 +407,8 @@
459 407 'type' => 'function',
460 408 'function' => "subscrptInstallPlugin(this, 'tutor')",
461 409 ],
462 410 [
463 - 'action' => 'activate',
464 - 'label' => __( 'Activate', 'subscription' ),
465 - 'type' => 'function',
466 - 'function' => "subscrptActivatePlugin(this, 'tutor/tutor.php')",
467 - ],
468 - [
469 411 'label' => __( 'Learn More', 'subscription' ),
470 412 'type' => 'external_link',
471 413 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-tutor-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
472 414 ],
@@ -478,9 +420,9 @@
478 420 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/learnpress.png',
479 421 'type' => 'third_party',
480 422 'is_pro' => true,
481 423 'category' => 'lms',
482 - 'is_installed' => $this->is_plugin_installed( 'learnpress/learnpress.php' ),
424 + 'is_installed' => is_plugin_active( 'learnpress/learnpress.php' ) && class_exists( 'LearnPress' ),
483 425 'is_active' => is_plugin_active( 'learnpress/learnpress.php' ) && class_exists( 'LearnPress' ),
484 426 'actions' => [
485 427 [
486 428 'action' => 'install',
@@ -488,14 +430,8 @@
488 430 'type' => 'function',
489 431 'function' => "subscrptInstallPlugin(this, 'learnpress')",
490 432 ],
491 433 [
492 - 'action' => 'activate',
493 - 'label' => __( 'Activate', 'subscription' ),
494 - 'type' => 'function',
495 - 'function' => "subscrptActivatePlugin(this, 'learnpress/learnpress.php')",
496 - ],
497 - [
498 434 'label' => __( 'Learn More', 'subscription' ),
499 435 'type' => 'external_link',
500 436 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-learnpress-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
501 437 ],
@@ -507,9 +443,9 @@
507 443 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/learndash.jpeg',
508 444 'type' => 'third_party',
509 445 'is_pro' => true,
510 446 'category' => 'lms',
511 - 'is_installed' => $this->is_plugin_installed( 'sfwd-lms/sfwd_lms.php' ),
447 + 'is_installed' => is_plugin_active( 'sfwd-lms/sfwd_lms.php' ) && class_exists( 'LearnDash\Core\App' ),
512 448 'is_active' => is_plugin_active( 'sfwd-lms/sfwd_lms.php' ) && class_exists( 'LearnDash\Core\App' ),
513 449 'actions' => [
514 450 [
515 451 'action' => 'install',
@@ -517,14 +453,8 @@
517 453 'type' => 'external_link',
518 454 'url' => 'https://www.learndash.com/',
519 455 ],
520 456 [
521 - 'action' => 'activate',
522 - 'label' => __( 'Activate', 'subscription' ),
523 - 'type' => 'function',
524 - 'function' => "subscrptActivatePlugin(this, 'sfwd-lms/sfwd_lms.php')",
525 - ],
526 - [
527 457 'label' => __( 'Learn More', 'subscription' ),
528 458 'type' => 'external_link',
529 459 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-learndash-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
530 460 ],
@@ -537,9 +467,9 @@
537 467 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/fluentcrm.png',
538 468 'type' => 'third_party',
539 469 'is_pro' => true,
540 470 'category' => 'crm',
541 - 'is_installed' => $this->is_plugin_installed( 'fluent-crm/fluent-crm.php' ),
471 + 'is_installed' => class_exists( 'FluentCrm\App\Services\Funnel\BaseTrigger' ),
542 472 'is_active' => class_exists( 'FluentCrm\App\Services\Funnel\BaseTrigger' ),
543 473 'actions' => [
544 474 [
545 475 'action' => 'install',
@@ -547,14 +477,8 @@
547 477 'type' => 'function',
548 478 'function' => "subscrptInstallPlugin(this, 'fluent-crm')",
549 479 ],
550 480 [
551 - 'action' => 'activate',
552 - 'label' => __( 'Activate', 'subscription' ),
553 - 'type' => 'function',
554 - 'function' => "subscrptActivatePlugin(this, 'fluent-crm/fluent-crm.php')",
555 - ],
556 - [
557 481 'label' => __( 'Learn More', 'subscription' ),
558 482 'type' => 'external_link',
559 483 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-fluent-crm?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
560 484 ],
@@ -567,9 +491,9 @@
567 491 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/automatorwp.png',
568 492 'type' => 'third_party',
569 493 'is_pro' => true,
570 494 'category' => 'automation',
571 - 'is_installed' => $this->is_plugin_installed( 'automatorwp/automatorwp.php' ),
495 + 'is_installed' => is_plugin_active( 'automatorwp/automatorwp.php' ) && class_exists( 'AutomatorWP' ),
572 496 'is_active' => is_plugin_active( 'automatorwp/automatorwp.php' ) && class_exists( 'AutomatorWP' ),
573 497 'actions' => [
574 498 [
575 499 'action' => 'install',
@@ -576,14 +500,8 @@
576 500 'label' => __( 'Install Now', 'subscription' ),
577 501 'type' => 'function',
578 502 'function' => "subscrptInstallPlugin(this, 'automatorwp')",
579 503 ],
580 - [
581 - 'action' => 'activate',
582 - 'label' => __( 'Activate', 'subscription' ),
583 - 'type' => 'function',
584 - 'function' => "subscrptActivatePlugin(this, 'automatorwp/automatorwp.php')",
585 - ],
586 504 // [
587 505 // 'label' => __( 'Learn More', 'subscription' ),
588 506 // 'type' => 'external_link',
589 507 // 'url' => 'https://docs.wpsubscription.co/en/',
@@ -596,9 +514,9 @@
596 514 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/wp-fusion.png',
597 515 'type' => 'third_party',
598 516 'is_pro' => true,
599 517 'category' => 'automation',
600 - 'is_installed' => $this->is_plugin_installed( 'wp-fusion/wp-fusion.php' ) || class_exists( 'WPF_Integrations_Base' ),
518 + 'is_installed' => class_exists( 'WPF_Integrations_Base' ),
601 519 'is_active' => class_exists( 'WPF_Integrations_Base' ),
602 520 'actions' => [
603 521 [
604 522 'action' => 'install',
@@ -605,14 +523,8 @@
605 523 'label' => __( 'Get WP Fusion', 'subscription' ),
606 524 'type' => 'external_link',
607 525 'url' => 'https://wpfusion.com/',
608 526 ],
609 - [
610 - 'action' => 'activate',
611 - 'label' => __( 'Activate', 'subscription' ),
612 - 'type' => 'function',
613 - 'function' => "subscrptActivatePlugin(this, 'wp-fusion/wp-fusion.php')",
614 - ],
615 527 // [
616 528 // 'label' => __( 'Learn More', 'subscription' ),
617 529 // 'type' => 'external_link',
618 530 // 'url' => 'https://docs.wpsubscription.co/en/',
@@ -626,9 +538,9 @@
626 538 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/mailpoet.png',
627 539 'type' => 'third_party',
628 540 'is_pro' => true,
629 541 'category' => 'email',
630 - 'is_installed' => $this->is_plugin_installed( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
542 + 'is_installed' => is_plugin_active( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
631 543 'is_active' => is_plugin_active( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
632 544 'actions' => [
633 545 [
634 546 'action' => 'install',
@@ -636,14 +548,8 @@
636 548 'type' => 'function',
637 549 'function' => "subscrptInstallPlugin(this, 'mailpoet')",
638 550 ],
639 551 [
640 - 'action' => 'activate',
641 - 'label' => __( 'Activate', 'subscription' ),
642 - 'type' => 'function',
643 - 'function' => "subscrptActivatePlugin(this, 'mailpoet/mailpoet.php')",
644 - ],
645 - [
646 552 'label' => __( 'Learn More', 'subscription' ),
647 553 'type' => 'external_link',
648 554 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-mailpoet?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
649 555 ],
@@ -656,9 +562,9 @@
656 562 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/wp-software-license.png',
657 563 'type' => 'third_party',
658 564 'is_pro' => true,
659 565 'category' => 'license',
660 - 'is_installed' => $this->is_plugin_installed( 'software-license/software-license.php' ),
566 + 'is_installed' => is_plugin_active( 'software-license/software-license.php' ) && class_exists( 'WOO_SL' ),
661 567 'is_active' => is_plugin_active( 'software-license/software-license.php' ) && class_exists( 'WOO_SL' ),
662 568 'actions' => [
663 569 [
664 570 'action' => 'install',
@@ -665,14 +571,8 @@
665 571 'label' => __( 'Get Plugin', 'subscription' ),
666 572 'type' => 'external_link',
667 573 'url' => 'https://wpsoftwarelicense.com/',
668 574 ],
669 - [
670 - 'action' => 'activate',
671 - 'label' => __( 'Activate', 'subscription' ),
672 - 'type' => 'function',
673 - 'function' => "subscrptActivatePlugin(this, 'software-license/software-license.php')",
674 - ],
675 575 // [
676 576 // 'label' => __( 'Learn More', 'subscription' ),
677 577 // 'type' => 'external_link',
678 578 // 'url' => 'https://docs.wpsubscription.co/en/',
@@ -685,9 +585,9 @@
685 585 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/license-manager.png',
686 586 'type' => 'third_party',
687 587 'is_pro' => true,
688 588 'category' => 'license',
689 - 'is_installed' => $this->is_plugin_installed( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ),
589 + 'is_installed' => is_plugin_active( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ) && class_exists( 'LicenseManagerForWooCommerce\Models\Resources\License' ),
690 590 'is_active' => is_plugin_active( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ) && class_exists( 'LicenseManagerForWooCommerce\Models\Resources\License' ),
691 591 'actions' => [
692 592 [
693 593 'action' => 'install',
@@ -694,14 +594,8 @@
694 594 'label' => __( 'Install Now', 'subscription' ),
695 595 'type' => 'function',
696 596 'function' => "subscrptInstallPlugin(this, 'license-manager-for-woocommerce')",
697 597 ],
698 - [
699 - 'action' => 'activate',
700 - 'label' => __( 'Activate', 'subscription' ),
701 - 'type' => 'function',
702 - 'function' => "subscrptActivatePlugin(this, 'license-manager-for-woocommerce/license-manager-for-woocommerce.php')",
703 - ],
704 598 // [
705 599 // 'label' => __( 'Learn More', 'subscription' ),
706 600 // 'type' => 'external_link',
707 601 // 'url' => 'https://docs.wpsubscription.co/en/',
@@ -728,13 +622,8 @@
728 622 foreach ( $integrations as $integration ) {
729 623 $is_installed = $integration['is_installed'] ?? false;
730 624 $is_active = $integration['is_active'] ?? false;
731 625
732 - // A gateway card is "active" when its gateway is enabled, which is not
733 - // the same as its plugin being active; read the plugin itself.
734 - $plugin_file = $integration['plugin_file'] ?? '';
735 - $plugin_active = '' !== $plugin_file ? is_plugin_active( $plugin_file ) : $is_active;
736 -
737 626 $cleaned_actions = [];
738 627 $shown_install_url = null;
739 628
740 629 foreach ( $integration['actions'] as $integration_action ) {
@@ -752,14 +641,8 @@
752 641 $cleaned_actions[] = $integration_action;
753 642 }
754 643 continue;
755 644 }
756 - if ( 'activate' === $action_tag ) {
757 - if ( $is_installed && ! $plugin_active ) {
758 - $cleaned_actions[] = $integration_action;
759 - }
760 - continue;
761 - }
762 645 if ( 'enable' === $action_tag ) {
763 646 if ( $is_installed && ! $is_active ) {
764 647 $cleaned_actions[] = $integration_action;
765 648 }
@@ -765,9 +648,9 @@
765 648 }
766 649 continue;
767 650 }
768 651 if ( 'settings' === $action_tag ) {
769 - if ( $is_installed && ( '' === $plugin_file || $plugin_active ) ) {
652 + if ( $is_installed ) {
770 653 $cleaned_actions[] = $integration_action;
771 654 }
772 655 continue;
773 656 }