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 +458 -28 1.10.0 → 2.4.0 View file →
@@ -62,9 +62,8 @@
62 62 __( 'Integrations', 'subscription' ),
63 63 'manage_options',
64 64 'wp-subscription-integrations',
65 65 [ $this, 'render_integrations_page' ],
66 - 40
67 66 );
68 67 }
69 68
70 69 /**
@@ -90,9 +89,10 @@
90 89 if ( ! $screen || false === strpos( $screen->id, 'wp-subscription-integrations' ) ) {
91 90 return;
92 91 }
93 92
94 - 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' );
95 95
96 96 wp_localize_script(
97 97 'subscrpt-integrations',
98 98 'subscrptIntegrations',
@@ -100,8 +100,12 @@
100 100 'nonce' => wp_create_nonce( 'subscrpt_integration_install_nonce' ),
101 101 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
102 102 )
103 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 );
104 108 }
105 109
106 110 /**
107 111 * Handle AJAX request for integrations.
@@ -189,8 +193,55 @@
189 193 return is_plugin_active( $plugin_file );
190 194 }
191 195
192 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 + /**
193 244 * Check if a payment gateway is enabled.
194 245 *
195 246 * @param string $gateway_id Gateway ID.
196 247 */
@@ -205,12 +256,13 @@
205 256 * @return array
206 257 */
207 258 protected function get_integrations(): array {
208 259 $integrations = [
209 - [
260 + 'paypal' => [
210 261 'title' => 'PayPal',
211 - 'description' => 'Accept subscription payments via PayPal.',
212 - 'icon_url' => SUBSCRPT_ASSETS . '/images/paypal.svg',
262 + 'description' => __( 'Accept recurring subscription payments directly through PayPal.', 'subscription' ),
263 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/paypal.svg',
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' ),
215 267 'supports_recurring' => true,
216 268 'actions' => [
@@ -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 // [
@@ -234,12 +286,13 @@
234 286 // 'class' => 'button button-primary wp-subs-button-danger',
235 287 // ],
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',
294 + 'type' => 'payment_gateway',
242 295 'is_installed' => class_exists( 'WC_Stripe' ),
243 296 'is_active' => self::is_gateway_enabled( 'stripe' ),
244 297 'supports_recurring' => true,
245 298 'actions' => [
@@ -244,24 +297,25 @@
244 297 'supports_recurring' => true,
245 298 'actions' => [
246 299 [
247 300 'action' => 'install',
248 - 'label' => 'Install Now',
301 + 'label' => __( 'Install Now', 'subscription' ),
249 302 'type' => 'function',
250 303 'function' => "subscrptInstallPlugin(this, 'woocommerce-gateway-stripe')",
251 304 ],
252 305 [
253 306 'action' => 'settings',
254 - 'label' => 'Settings',
307 + 'label' => __( 'Settings', 'subscription' ),
255 308 'type' => 'link',
256 309 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe&panel=settings' ),
257 310 ],
258 311 ],
259 312 ],
260 - [
313 + 'paddle' => [
261 314 'title' => 'Paddle',
262 - 'description' => 'Process subscription payments securely with Paddle.',
263 - 'icon_url' => SUBSCRPT_ASSETS . '/images/paddle.svg',
315 + 'description' => __( 'Process subscription payments securely with Paddle.', 'subscription' ),
316 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/paddle.svg',
317 + 'type' => 'payment_gateway',
264 318 'is_installed' => class_exists( 'SmartPayWoo\Gateways\Paddle\SmartPay_Paddle' ),
265 319 'is_active' => self::is_gateway_enabled( 'smartpay_paddle' ),
266 320 'supports_recurring' => true,
267 321 'actions' => [
@@ -266,15 +320,15 @@
266 320 'supports_recurring' => true,
267 321 'actions' => [
268 322 [
269 323 'action' => 'install',
270 - 'label' => 'Get Paddle',
324 + 'label' => __( 'Get Paddle', 'subscription' ),
271 325 'type' => 'external_link',
272 326 'url' => 'https://wpsmartpay.com/paddle-for-woocommerce/',
273 327 ],
274 328 [
275 329 'action' => 'enable',
276 - 'label' => 'Enable Gateway',
330 + 'label' => __( 'Enable Gateway', 'subscription' ),
277 331 'type' => 'toggle_option',
278 332 'option_key' => 'woocommerce_enable_paddle_gateway',
279 333 'value' => true,
280 334 ],
@@ -279,21 +333,386 @@
279 333 'value' => true,
280 334 ],
281 335 [
282 336 'action' => 'settings',
283 - 'label' => 'Settings',
337 + 'label' => __( 'Settings', 'subscription' ),
284 338 'type' => 'link',
285 339 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=smartpay_paddle&from=WCADMIN_PAYMENT_SETTINGS' ),
286 340 ],
287 341 [
288 - 'label' => 'More Details',
342 + 'label' => __( 'More Details', 'subscription' ),
289 343 'type' => 'external_link',
290 344 'url' => 'https://wpsmartpay.com/paddle-for-woocommerce/',
291 345 ],
292 346 ],
293 347 ],
348 + 'mollie' => [
349 + 'title' => 'Mollie',
350 + 'description' => __( 'Pay for subscriptions with Mollie Payments for WooCommerce.', 'subscription' ),
351 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/mollie.png',
352 + 'type' => 'payment_gateway',
353 + 'is_pro' => true,
354 + 'is_installed' => class_exists( 'Mollie\WooCommerce\Activation\ActivationModule' ),
355 + 'is_active' => self::is_gateway_enabled( 'mollie_wc_gateway', true ),
356 + 'supports_recurring' => true,
357 + 'actions' => [
358 + [
359 + 'action' => 'install',
360 + 'label' => __( 'Install Now', 'subscription' ),
361 + 'type' => 'function',
362 + 'function' => "subscrptInstallPlugin(this, 'mollie-payments-for-woocommerce')",
363 + ],
364 + [
365 + 'action' => 'settings',
366 + 'label' => __( 'Settings', 'subscription' ),
367 + 'type' => 'link',
368 + 'url' => admin_url( 'admin.php?page=wc-settings&tab=mollie_settings' ),
369 + ],
370 + [
371 + 'label' => __( 'More Details', 'subscription' ),
372 + 'type' => 'external_link',
373 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-payment-with-mollie?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
374 + ],
375 + ],
376 + ],
377 + 'razorpay' => [
378 + 'title' => 'Razorpay',
379 + 'description' => __( 'Pay for subscriptions securely with Razorpay for WooCommerce.', 'subscription' ),
380 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/razorpay.png',
381 + 'type' => 'payment_gateway',
382 + 'is_pro' => true,
383 + 'is_beta' => true,
384 + 'is_installed' => class_exists( 'WC_Razorpay' ),
385 + 'is_active' => self::is_gateway_enabled( 'razorpay' ),
386 + 'supports_recurring' => true,
387 + 'actions' => [
388 + [
389 + 'action' => 'install',
390 + 'label' => __( 'Install Now', 'subscription' ),
391 + 'type' => 'function',
392 + 'function' => "subscrptInstallPlugin(this, 'woo-razorpay')",
393 + ],
394 + [
395 + 'action' => 'settings',
396 + 'label' => __( 'Settings', 'subscription' ),
397 + 'type' => 'link',
398 + 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=razorpay' ),
399 + ],
400 + [
401 + 'label' => __( 'More Details', 'subscription' ),
402 + 'type' => 'external_link',
403 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-payment-with-razorpay?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
404 + ],
405 + ],
406 + ],
407 + 'xendit' => [
408 + 'title' => 'Xendit',
409 + 'description' => __( 'Pay for subscriptions securely with Xendit for WooCommerce.', 'subscription' ),
410 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/xendit.png',
411 + 'type' => 'payment_gateway',
412 + 'is_pro' => true,
413 + 'is_beta' => true,
414 + 'is_installed' => class_exists( 'WC_Xendit_CC' ),
415 + 'is_active' => self::is_gateway_enabled( 'xendit' ),
416 + 'supports_recurring' => true,
417 + 'actions' => [
418 + [
419 + 'action' => 'install',
420 + 'label' => __( 'Install Now', 'subscription' ),
421 + 'type' => 'function',
422 + 'function' => "subscrptInstallPlugin(this, 'woo-xendit-virtual-accounts')",
423 + ],
424 + [
425 + 'action' => 'settings',
426 + 'label' => __( 'Settings', 'subscription' ),
427 + 'type' => 'link',
428 + 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=xendit_gateway' ),
429 + ],
430 + [
431 + 'label' => __( 'More Details', 'subscription' ),
432 + 'type' => 'external_link',
433 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-payment-with-xendit?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
434 + ],
435 + ],
436 + ],
294 437 ];
295 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 +
444 + // Third-party integrations (requires Pro plugin to function).
445 + $third_party = [
446 + // LMS.
447 + 'tutor_lms' => [
448 + 'title' => 'Tutor LMS',
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',
451 + 'type' => 'third_party',
452 + 'is_pro' => true,
453 + 'category' => 'lms',
454 + 'is_installed' => $this->is_plugin_installed( 'tutor/tutor.php' ),
455 + 'is_active' => is_plugin_active( 'tutor/tutor.php' ) && class_exists( 'TUTOR\Tutor' ),
456 + 'actions' => [
457 + [
458 + 'action' => 'install',
459 + 'label' => __( 'Install Now', 'subscription' ),
460 + 'type' => 'function',
461 + 'function' => "subscrptInstallPlugin(this, 'tutor')",
462 + ],
463 + [
464 + 'action' => 'activate',
465 + 'label' => __( 'Activate', 'subscription' ),
466 + 'type' => 'function',
467 + 'function' => "subscrptActivatePlugin(this, 'tutor/tutor.php')",
468 + ],
469 + [
470 + 'label' => __( 'Learn More', 'subscription' ),
471 + 'type' => 'external_link',
472 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-tutor-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
473 + ],
474 + ],
475 + ],
476 + 'learnpress' => [
477 + 'title' => 'LearnPress',
478 + 'description' => __( 'Connect subscriptions with LearnPress courses. Enroll users automatically when subscriptions are active.', 'subscription' ),
479 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/learnpress.png',
480 + 'type' => 'third_party',
481 + 'is_pro' => true,
482 + 'category' => 'lms',
483 + 'is_installed' => $this->is_plugin_installed( 'learnpress/learnpress.php' ),
484 + 'is_active' => is_plugin_active( 'learnpress/learnpress.php' ) && class_exists( 'LearnPress' ),
485 + 'actions' => [
486 + [
487 + 'action' => 'install',
488 + 'label' => __( 'Install Now', 'subscription' ),
489 + 'type' => 'function',
490 + 'function' => "subscrptInstallPlugin(this, 'learnpress')",
491 + ],
492 + [
493 + 'action' => 'activate',
494 + 'label' => __( 'Activate', 'subscription' ),
495 + 'type' => 'function',
496 + 'function' => "subscrptActivatePlugin(this, 'learnpress/learnpress.php')",
497 + ],
498 + [
499 + 'label' => __( 'Learn More', 'subscription' ),
500 + 'type' => 'external_link',
501 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-learnpress-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
502 + ],
503 + ],
504 + ],
505 + 'learndash' => [
506 + 'title' => 'LearnDash',
507 + 'description' => __( 'Sync subscription status with LearnDash group enrollment and course access.', 'subscription' ),
508 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/learndash.jpeg',
509 + 'type' => 'third_party',
510 + 'is_pro' => true,
511 + 'category' => 'lms',
512 + 'is_installed' => $this->is_plugin_installed( 'sfwd-lms/sfwd_lms.php' ),
513 + 'is_active' => is_plugin_active( 'sfwd-lms/sfwd_lms.php' ) && class_exists( 'LearnDash\Core\App' ),
514 + 'actions' => [
515 + [
516 + 'action' => 'install',
517 + 'label' => __( 'Get LearnDash', 'subscription' ),
518 + 'type' => 'external_link',
519 + 'url' => 'https://www.learndash.com/',
520 + ],
521 + [
522 + 'action' => 'activate',
523 + 'label' => __( 'Activate', 'subscription' ),
524 + 'type' => 'function',
525 + 'function' => "subscrptActivatePlugin(this, 'sfwd-lms/sfwd_lms.php')",
526 + ],
527 + [
528 + 'label' => __( 'Learn More', 'subscription' ),
529 + 'type' => 'external_link',
530 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-learndash-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
531 + ],
532 + ],
533 + ],
534 + // CRM.
535 + 'fluentcrm' => [
536 + 'title' => 'FluentCRM',
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',
539 + 'type' => 'third_party',
540 + 'is_pro' => true,
541 + 'category' => 'crm',
542 + 'is_installed' => $this->is_plugin_installed( 'fluent-crm/fluent-crm.php' ),
543 + 'is_active' => class_exists( 'FluentCrm\App\Services\Funnel\BaseTrigger' ),
544 + 'actions' => [
545 + [
546 + 'action' => 'install',
547 + 'label' => __( 'Install Now', 'subscription' ),
548 + 'type' => 'function',
549 + 'function' => "subscrptInstallPlugin(this, 'fluent-crm')",
550 + ],
551 + [
552 + 'action' => 'activate',
553 + 'label' => __( 'Activate', 'subscription' ),
554 + 'type' => 'function',
555 + 'function' => "subscrptActivatePlugin(this, 'fluent-crm/fluent-crm.php')",
556 + ],
557 + [
558 + 'label' => __( 'Learn More', 'subscription' ),
559 + 'type' => 'external_link',
560 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-fluent-crm?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
561 + ],
562 + ],
563 + ],
564 + // Automation.
565 + 'automatorwp' => [
566 + 'title' => 'AutomatorWP',
567 + 'description' => __( 'Build powerful automations triggered by subscription events without writing any code.', 'subscription' ),
568 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/automatorwp.png',
569 + 'type' => 'third_party',
570 + 'is_pro' => true,
571 + 'category' => 'automation',
572 + 'is_installed' => $this->is_plugin_installed( 'automatorwp/automatorwp.php' ),
573 + 'is_active' => is_plugin_active( 'automatorwp/automatorwp.php' ) && class_exists( 'AutomatorWP' ),
574 + 'actions' => [
575 + [
576 + 'action' => 'install',
577 + 'label' => __( 'Install Now', 'subscription' ),
578 + 'type' => 'function',
579 + 'function' => "subscrptInstallPlugin(this, 'automatorwp')",
580 + ],
581 + [
582 + 'action' => 'activate',
583 + 'label' => __( 'Activate', 'subscription' ),
584 + 'type' => 'function',
585 + 'function' => "subscrptActivatePlugin(this, 'automatorwp/automatorwp.php')",
586 + ],
587 + // [
588 + // 'label' => __( 'Learn More', 'subscription' ),
589 + // 'type' => 'external_link',
590 + // 'url' => 'https://docs.wpsubscription.co/en/',
591 + // ],
592 + ],
593 + ],
594 + 'wpfusion' => [
595 + 'title' => 'WP Fusion',
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',
598 + 'type' => 'third_party',
599 + 'is_pro' => true,
600 + 'category' => 'automation',
601 + 'is_installed' => $this->is_plugin_installed( 'wp-fusion/wp-fusion.php' ) || class_exists( 'WPF_Integrations_Base' ),
602 + 'is_active' => class_exists( 'WPF_Integrations_Base' ),
603 + 'actions' => [
604 + [
605 + 'action' => 'install',
606 + 'label' => __( 'Get WP Fusion', 'subscription' ),
607 + 'type' => 'external_link',
608 + 'url' => 'https://wpfusion.com/',
609 + ],
610 + [
611 + 'action' => 'activate',
612 + 'label' => __( 'Activate', 'subscription' ),
613 + 'type' => 'function',
614 + 'function' => "subscrptActivatePlugin(this, 'wp-fusion/wp-fusion.php')",
615 + ],
616 + // [
617 + // 'label' => __( 'Learn More', 'subscription' ),
618 + // 'type' => 'external_link',
619 + // 'url' => 'https://docs.wpsubscription.co/en/',
620 + // ],
621 + ],
622 + ],
623 + // Email Marketing.
624 + 'mailpoet' => [
625 + 'title' => 'MailPoet',
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',
628 + 'type' => 'third_party',
629 + 'is_pro' => true,
630 + 'category' => 'email',
631 + 'is_installed' => $this->is_plugin_installed( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
632 + 'is_active' => is_plugin_active( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
633 + 'actions' => [
634 + [
635 + 'action' => 'install',
636 + 'label' => __( 'Install Now', 'subscription' ),
637 + 'type' => 'function',
638 + 'function' => "subscrptInstallPlugin(this, 'mailpoet')",
639 + ],
640 + [
641 + 'action' => 'activate',
642 + 'label' => __( 'Activate', 'subscription' ),
643 + 'type' => 'function',
644 + 'function' => "subscrptActivatePlugin(this, 'mailpoet/mailpoet.php')",
645 + ],
646 + [
647 + 'label' => __( 'Learn More', 'subscription' ),
648 + 'type' => 'external_link',
649 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-mailpoet?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
650 + ],
651 + ],
652 + ],
653 + // License Management.
654 + 'wp_soft_lic' => [
655 + 'title' => 'WP Software License',
656 + 'description' => __( 'Issue and validate software licenses for subscription-based digital products.', 'subscription' ),
657 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/wp-software-license.png',
658 + 'type' => 'third_party',
659 + 'is_pro' => true,
660 + 'category' => 'license',
661 + 'is_installed' => $this->is_plugin_installed( 'software-license/software-license.php' ),
662 + 'is_active' => is_plugin_active( 'software-license/software-license.php' ) && class_exists( 'WOO_SL' ),
663 + 'actions' => [
664 + [
665 + 'action' => 'install',
666 + 'label' => __( 'Get Plugin', 'subscription' ),
667 + 'type' => 'external_link',
668 + 'url' => 'https://wpsoftwarelicense.com/',
669 + ],
670 + [
671 + 'action' => 'activate',
672 + 'label' => __( 'Activate', 'subscription' ),
673 + 'type' => 'function',
674 + 'function' => "subscrptActivatePlugin(this, 'software-license/software-license.php')",
675 + ],
676 + // [
677 + // 'label' => __( 'Learn More', 'subscription' ),
678 + // 'type' => 'external_link',
679 + // 'url' => 'https://docs.wpsubscription.co/en/',
680 + // ],
681 + ],
682 + ],
683 + 'license_mgr' => [
684 + 'title' => 'License Manager for WooCommerce',
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',
687 + 'type' => 'third_party',
688 + 'is_pro' => true,
689 + 'category' => 'license',
690 + 'is_installed' => $this->is_plugin_installed( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ),
691 + 'is_active' => is_plugin_active( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ) && class_exists( 'LicenseManagerForWooCommerce\Models\Resources\License' ),
692 + 'actions' => [
693 + [
694 + 'action' => 'install',
695 + 'label' => __( 'Install Now', 'subscription' ),
696 + 'type' => 'function',
697 + 'function' => "subscrptInstallPlugin(this, 'license-manager-for-woocommerce')",
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 + ],
705 + // [
706 + // 'label' => __( 'Learn More', 'subscription' ),
707 + // 'type' => 'external_link',
708 + // 'url' => 'https://docs.wpsubscription.co/en/',
709 + // ],
710 + ],
711 + ],
712 + ];
713 + $integrations = array_merge( $integrations, $third_party );
714 +
296 715 // Add more integrations as needed.
297 716 $integrations = apply_filters( 'wpsubs_integrations', $integrations );
298 717
299 718 return $integrations;
@@ -310,10 +729,16 @@
310 729 foreach ( $integrations as $integration ) {
311 730 $is_installed = $integration['is_installed'] ?? false;
312 731 $is_active = $integration['is_active'] ?? false;
313 732
314 - $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;
315 737
738 + $cleaned_actions = [];
739 + $shown_install_url = null;
740 +
316 741 foreach ( $integration['actions'] as $integration_action ) {
317 742 $action_tag = $integration_action['action'] ?? null;
318 743
319 744 if ( 'install' === $action_tag ) {
@@ -318,8 +743,9 @@
318 743
319 744 if ( 'install' === $action_tag ) {
320 745 if ( ! $is_installed ) {
321 746 $cleaned_actions[] = $integration_action;
747 + $shown_install_url = $integration_action['url'] ?? null;
322 748 }
323 749 continue;
324 750 }
325 751 if ( 'uninstall' === $action_tag ) {
@@ -327,8 +753,14 @@
327 753 $cleaned_actions[] = $integration_action;
328 754 }
329 755 continue;
330 756 }
757 + if ( 'activate' === $action_tag ) {
758 + if ( $is_installed && ! $plugin_active ) {
759 + $cleaned_actions[] = $integration_action;
760 + }
761 + continue;
762 + }
331 763 if ( 'enable' === $action_tag ) {
332 764 if ( $is_installed && ! $is_active ) {
333 765 $cleaned_actions[] = $integration_action;
334 766 }
@@ -334,15 +766,20 @@
334 766 }
335 767 continue;
336 768 }
337 769 if ( 'settings' === $action_tag ) {
338 - if ( $is_installed ) {
770 + if ( $is_installed && ( '' === $plugin_file || $plugin_active ) ) {
339 771 $cleaned_actions[] = $integration_action;
340 772 }
341 773 continue;
342 774 }
343 775
344 - // 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 + }
345 782 $cleaned_actions[] = $integration_action;
346 783 }
347 784
348 785 // Overwrite.
@@ -356,17 +793,10 @@
356 793 /**
357 794 * Render the Integrations admin page.
358 795 */
359 796 public function render_integrations_page() {
360 - if ( ! empty( $_GET['subscrpt_installed'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
361 - echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'Plugin installed and activated successfully.', 'subscription' ) . '</p></div>';
362 - }
363 -
364 797 $integrations = $this->integrations;
365 798 $integrations = $this->filter_integration_actions( $integrations );
366 -
367 - // Integrations styles.
368 - // wp_enqueue_style( 'wp-subs-integration-settings', SUBSCRPT_ASSETS . '/css/integration_settings.css', [], SUBSCRPT_VERSION, 'all' );
369 799
370 800 $menu = new \SpringDevs\Subscription\Admin\Menu();
371 801 $menu->render_admin_header( __( 'Integrations', 'subscription' ) );
372 802 include 'views/integrations.php';