PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.0.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.0.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 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
← All changes | includes/Admin/Integrations.php +385 -40 1.5.12.0.0 View file →
@@ -29,13 +29,13 @@
29 29
30 30 // Admin menu (sidebar).
31 31 add_action( 'admin_menu', array( $this, 'register_admin_menu' ), 20 );
32 32
33 - // WP Subscription navbar.
34 - add_filter( 'wp_subscription_admin_header_menu_items', [ $this, 'add_integrations_menu_item' ], 10, 2 );
33 + // WPSubscription navbar.
34 + add_filter( 'subscrpt_admin_header_menu_items', [ $this, 'add_integrations_menu_item' ], 10, 2 );
35 35
36 36 // Enqueue integrations scripts.
37 - // add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_integrations_scripts' ] );
37 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_integrations_scripts' ] );
38 38
39 39 // Integrations AJAX handler.
40 40 // add_action( 'admin_ajax_integrations_handler', [ $this,'integrations_handler_callback' ] );
41 41 // add_action( 'admin_ajax_nopriv_integrations_handler', [ $this,'integrations_handler_callback' ] );
@@ -57,19 +57,18 @@
57 57 public function register_admin_menu() {
58 58 $parent_slug = 'wp-subscription';
59 59 add_submenu_page(
60 60 $parent_slug,
61 - __( 'Integrations', 'wp_subscription' ),
62 - __( 'Integrations', 'wp_subscription' ),
61 + __( 'Integrations', 'subscription' ),
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 /**
71 - * Add Integrations link to the WP Subscription admin header menu.
70 + * Add Integrations link to the WPSubscription admin header menu.
72 71 *
73 72 * @param array $menu_items Array of menu items.
74 73 * @param string $current Current active menu item slug.
75 74 */
@@ -75,9 +74,9 @@
75 74 */
76 75 public function add_integrations_menu_item( $menu_items, $current ) {
77 76 $menu_items[] = [
78 77 'slug' => 'wp-subscription-integrations',
79 - 'label' => __( 'Integrations', 'wp_subscription' ),
78 + 'label' => __( 'Integrations', 'subscription' ),
80 79 'url' => admin_url( 'admin.php?page=wp-subscription-integrations' ),
81 80 ];
82 81 return $menu_items;
83 82 }
@@ -85,18 +84,27 @@
85 84 /**
86 85 * Enqueue scripts for integrations page.
87 86 */
88 87 public function enqueue_integrations_scripts() {
89 - wp_enqueue_script( 'wp-subs-integrations', WP_SUBSCRIPTION_ASSETS . '/js/integration_settings.js', [ 'jquery' ], WP_SUBSCRIPTION_VERSION, true );
88 + $screen = get_current_screen();
89 + if ( ! $screen || false === strpos( $screen->id, 'wp-subscription-integrations' ) ) {
90 + return;
91 + }
90 92
93 + wp_enqueue_script( 'subscrpt-integrations', SUBSCRPT_ASSETS . '/js/integration_settings.js', [], SUBSCRPT_VERSION, true );
94 +
91 95 wp_localize_script(
92 - 'wp-subs-integrations',
93 - 'wpSubsIntegrations',
96 + 'subscrpt-integrations',
97 + 'subscrptIntegrations',
94 98 array(
95 - 'nonce' => wp_create_nonce( 'wp_subs_integrations_nonce' ),
96 - 'ajax_url' => admin_url( 'admin-ajax.php' ),
99 + 'nonce' => wp_create_nonce( 'subscrpt_integration_install_nonce' ),
100 + 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
97 101 )
98 102 );
103 +
104 + // Browser-side filter rail. Enqueued on this hook, not in the render
105 + // callback, so it always loads.
106 + wp_enqueue_script( 'subscrpt-integrations-filter', SUBSCRPT_ASSETS . '/js/admin/integrations-filter.js', [], SUBSCRPT_VERSION, true );
99 107 }
100 108
101 109 /**
102 110 * Handle AJAX request for integrations.
@@ -112,12 +120,24 @@
112 120 /**
113 121 * Check if a payment gateway is installed and active.
114 122 *
115 123 * @param string $gateway_id Gateway ID.
124 + * @param bool $partial_match Whether to allow partial match of gateway ID.
116 125 * @return bool
117 126 */
118 - protected function is_gateway_installed( $gateway_id ) {
127 + public static function is_gateway_installed( $gateway_id, $partial_match = false ) {
119 128 $installed_gateways = WC()->payment_gateways()->payment_gateways();
129 +
130 + // Partial match check. For gateways with dynamic IDs.
131 + if ( $partial_match ) {
132 + foreach ( $installed_gateways as $key => $gateway ) {
133 + if ( strpos( $key, $gateway_id ) !== false ) {
134 + return true;
135 + }
136 + }
137 + return false;
138 + }
139 +
120 140 return isset( $installed_gateways[ $gateway_id ] );
121 141 }
122 142
123 143 /**
@@ -123,12 +143,24 @@
123 143 /**
124 144 * Check if a payment gateway is enabled.
125 145 *
126 146 * @param string $gateway_id Gateway ID.
147 + * @param bool $partial_match Whether to allow partial match of gateway ID.
127 148 * @return bool
128 149 */
129 - protected function is_gateway_enabled( $gateway_id ) {
150 + public static function is_gateway_enabled( $gateway_id, $partial_match = false ) {
130 151 $installed_gateways = WC()->payment_gateways()->payment_gateways();
152 +
153 + // Partial match check. For gateways with dynamic IDs.
154 + if ( $partial_match ) {
155 + foreach ( $installed_gateways as $key => $gateway ) {
156 + if ( strpos( $key, $gateway_id ) !== false ) {
157 + return $gateway->is_available();
158 + }
159 + }
160 + return false;
161 + }
162 +
131 163 if ( ! isset( $installed_gateways[ $gateway_id ] ) ) {
132 164 return false;
133 165 }
134 166 return $installed_gateways[ $gateway_id ]->is_available();
@@ -176,14 +208,15 @@
176 208 * @return array
177 209 */
178 210 protected function get_integrations(): array {
179 211 $integrations = [
180 - [
181 - 'title' => 'PayPal for WP Subscription',
182 - 'description' => 'Accept subscription payments via PayPal.',
183 - 'icon_url' => WP_SUBSCRIPTION_ASSETS . '/images/paypal.svg',
212 + 'paypal' => [
213 + 'title' => 'PayPal',
214 + 'description' => 'Accept recurring subscription payments directly through PayPal.',
215 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/paypal.svg',
216 + 'type' => 'payment_gateway',
184 217 'is_installed' => 'on' === get_option( 'wp_subs_paypal_integration_enabled', 'off' ),
185 - 'is_active' => $this->is_gateway_enabled( 'wp_subscription_paypal' ),
218 + 'is_active' => self::is_gateway_enabled( 'wp_subscription_paypal' ),
186 219 'supports_recurring' => true,
187 220 'actions' => [
188 221 // [
189 222 // 'action' => 'install',
@@ -205,21 +238,22 @@
205 238 // 'class' => 'button button-primary wp-subs-button-danger',
206 239 // ],
207 240 ],
208 241 ],
209 - [
242 + 'stripe' => [
210 243 'title' => 'Stripe',
211 244 'description' => 'Process subscription payments securely with Stripe.',
212 - 'icon_url' => 'https://ps.w.org/woocommerce-gateway-stripe/assets/icon-256x256.png',
245 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/stripe.png',
246 + 'type' => 'payment_gateway',
213 247 'is_installed' => class_exists( 'WC_Stripe' ),
214 - 'is_active' => $this->is_gateway_enabled( 'stripe' ),
248 + 'is_active' => self::is_gateway_enabled( 'stripe' ),
215 249 'supports_recurring' => true,
216 250 'actions' => [
217 251 [
218 - 'action' => 'install',
219 - 'label' => 'Install Now',
220 - 'type' => 'link',
221 - 'url' => admin_url( 'plugin-install.php?s=WooCommerce%2520Stripe%2520Payment%2520Gateway&tab=search&type=term' ),
252 + 'action' => 'install',
253 + 'label' => 'Install Now',
254 + 'type' => 'function',
255 + 'function' => "subscrptInstallPlugin(this, 'woocommerce-gateway-stripe')",
222 256 ],
223 257 [
224 258 'action' => 'settings',
225 259 'label' => 'Settings',
@@ -227,21 +261,22 @@
227 261 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe&panel=settings' ),
228 262 ],
229 263 ],
230 264 ],
231 - [
265 + 'paddle' => [
232 266 'title' => 'Paddle',
233 267 'description' => 'Process subscription payments securely with Paddle.',
234 - 'icon_url' => WP_SUBSCRIPTION_ASSETS . '/images/paddle.svg',
268 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/paddle.svg',
269 + 'type' => 'payment_gateway',
235 270 'is_installed' => class_exists( 'SmartPayWoo\Gateways\Paddle\SmartPay_Paddle' ),
236 - 'is_active' => $this->is_gateway_enabled( 'smartpay_paddle' ),
271 + 'is_active' => self::is_gateway_enabled( 'smartpay_paddle' ),
237 272 'supports_recurring' => true,
238 273 'actions' => [
239 274 [
240 275 'action' => 'install',
241 - 'label' => 'Install Now',
242 - 'type' => 'link',
243 - 'url' => admin_url( 'plugin-install.php?s=WooCommerce%2520Stripe%2520Payment%2520Gateway&tab=search&type=term' ),
276 + 'label' => 'Get Paddle',
277 + 'type' => 'external_link',
278 + 'url' => 'https://wpsmartpay.com/paddle-for-woocommerce/',
244 279 ],
245 280 [
246 281 'action' => 'enable',
247 282 'label' => 'Enable Gateway',
@@ -261,12 +296,318 @@
261 296 'url' => 'https://wpsmartpay.com/paddle-for-woocommerce/',
262 297 ],
263 298 ],
264 299 ],
300 + 'mollie' => [
301 + 'title' => 'Mollie',
302 + 'description' => 'Pay for subscriptions with Mollie Payments for WooCommerce.',
303 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/mollie.png',
304 + 'type' => 'payment_gateway',
305 + 'is_pro' => true,
306 + 'is_installed' => class_exists( 'Mollie\WooCommerce\Activation\ActivationModule' ),
307 + 'is_active' => self::is_gateway_enabled( 'mollie_wc_gateway', true ),
308 + 'supports_recurring' => true,
309 + 'actions' => [
310 + [
311 + 'action' => 'install',
312 + 'label' => 'Install Now',
313 + 'type' => 'function',
314 + 'function' => "subscrptInstallPlugin(this, 'mollie-payments-for-woocommerce')",
315 + ],
316 + [
317 + 'action' => 'settings',
318 + 'label' => 'Settings',
319 + 'type' => 'link',
320 + 'url' => admin_url( 'admin.php?page=wc-settings&tab=mollie_settings' ),
321 + ],
322 + [
323 + 'label' => 'More Details',
324 + 'type' => 'external_link',
325 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-payment-with-mollie?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
326 + ],
327 + ],
328 + ],
329 + 'razorpay' => [
330 + 'title' => 'Razorpay',
331 + 'description' => 'Pay for subscriptions securely with Razorpay for WooCommerce.',
332 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/razorpay.png',
333 + 'type' => 'payment_gateway',
334 + 'is_pro' => true,
335 + 'is_beta' => true,
336 + 'is_installed' => class_exists( 'WC_Razorpay' ),
337 + 'is_active' => self::is_gateway_enabled( 'razorpay' ),
338 + 'supports_recurring' => true,
339 + 'actions' => [
340 + [
341 + 'action' => 'install',
342 + 'label' => 'Install Now',
343 + 'type' => 'function',
344 + 'function' => "subscrptInstallPlugin(this, 'woo-razorpay')",
345 + ],
346 + [
347 + 'action' => 'settings',
348 + 'label' => 'Settings',
349 + 'type' => 'link',
350 + 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=razorpay' ),
351 + ],
352 + [
353 + 'label' => 'More Details',
354 + 'type' => 'external_link',
355 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-payment-with-razorpay?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
356 + ],
357 + ],
358 + ],
359 + 'xendit' => [
360 + 'title' => 'Xendit',
361 + 'description' => 'Pay for subscriptions securely with Xendit for WooCommerce.',
362 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/xendit.png',
363 + 'type' => 'payment_gateway',
364 + 'is_pro' => true,
365 + 'is_beta' => true,
366 + 'is_installed' => class_exists( 'WC_Xendit_CC' ),
367 + 'is_active' => self::is_gateway_enabled( 'xendit' ),
368 + 'supports_recurring' => true,
369 + 'actions' => [
370 + [
371 + 'action' => 'install',
372 + 'label' => 'Install Now',
373 + 'type' => 'function',
374 + 'function' => "subscrptInstallPlugin(this, 'woo-xendit-virtual-accounts')",
375 + ],
376 + [
377 + 'action' => 'settings',
378 + 'label' => 'Settings',
379 + 'type' => 'link',
380 + 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout&section=xendit_gateway' ),
381 + ],
382 + [
383 + 'label' => 'More Details',
384 + 'type' => 'external_link',
385 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-payment-with-xendit?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
386 + ],
387 + ],
388 + ],
265 389 ];
266 390
391 + // Third-party integrations (requires Pro plugin to function).
392 + $third_party = [
393 + // LMS.
394 + 'tutor_lms' => [
395 + 'title' => 'Tutor LMS',
396 + 'description' => 'Restrict course access based on subscription status. Enroll and unenroll students automatically.',
397 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/tutor-lms.jpeg',
398 + 'type' => 'third_party',
399 + 'is_pro' => true,
400 + 'category' => 'lms',
401 + 'is_installed' => is_plugin_active( 'tutor/tutor.php' ) && class_exists( 'TUTOR\Tutor' ),
402 + 'is_active' => is_plugin_active( 'tutor/tutor.php' ) && class_exists( 'TUTOR\Tutor' ),
403 + 'actions' => [
404 + [
405 + 'action' => 'install',
406 + 'label' => __( 'Install Now', 'subscription' ),
407 + 'type' => 'function',
408 + 'function' => "subscrptInstallPlugin(this, 'tutor')",
409 + ],
410 + [
411 + 'label' => __( 'Learn More', 'subscription' ),
412 + 'type' => 'external_link',
413 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-tutor-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
414 + ],
415 + ],
416 + ],
417 + 'learnpress' => [
418 + 'title' => 'LearnPress',
419 + 'description' => 'Connect subscriptions with LearnPress courses. Enroll users automatically when subscriptions are active.',
420 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/learnpress.png',
421 + 'type' => 'third_party',
422 + 'is_pro' => true,
423 + 'category' => 'lms',
424 + 'is_installed' => is_plugin_active( 'learnpress/learnpress.php' ) && class_exists( 'LearnPress' ),
425 + 'is_active' => is_plugin_active( 'learnpress/learnpress.php' ) && class_exists( 'LearnPress' ),
426 + 'actions' => [
427 + [
428 + 'action' => 'install',
429 + 'label' => __( 'Install Now', 'subscription' ),
430 + 'type' => 'function',
431 + 'function' => "subscrptInstallPlugin(this, 'learnpress')",
432 + ],
433 + [
434 + 'label' => __( 'Learn More', 'subscription' ),
435 + 'type' => 'external_link',
436 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-learnpress-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
437 + ],
438 + ],
439 + ],
440 + 'learndash' => [
441 + 'title' => 'LearnDash',
442 + 'description' => 'Sync subscription status with LearnDash group enrollment and course access.',
443 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/learndash.jpeg',
444 + 'type' => 'third_party',
445 + 'is_pro' => true,
446 + 'category' => 'lms',
447 + 'is_installed' => is_plugin_active( 'sfwd-lms/sfwd_lms.php' ) && class_exists( 'LearnDash\Core\App' ),
448 + 'is_active' => is_plugin_active( 'sfwd-lms/sfwd_lms.php' ) && class_exists( 'LearnDash\Core\App' ),
449 + 'actions' => [
450 + [
451 + 'action' => 'install',
452 + 'label' => __( 'Get LearnDash', 'subscription' ),
453 + 'type' => 'external_link',
454 + 'url' => 'https://www.learndash.com/',
455 + ],
456 + [
457 + 'label' => __( 'Learn More', 'subscription' ),
458 + 'type' => 'external_link',
459 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-learndash-lms?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
460 + ],
461 + ],
462 + ],
463 + // CRM.
464 + 'fluentcrm' => [
465 + 'title' => 'FluentCRM',
466 + 'description' => 'Trigger email sequences and manage contacts based on subscription events and status changes.',
467 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/fluentcrm.png',
468 + 'type' => 'third_party',
469 + 'is_pro' => true,
470 + 'category' => 'crm',
471 + 'is_installed' => class_exists( 'FluentCrm\App\Services\Funnel\BaseTrigger' ),
472 + 'is_active' => class_exists( 'FluentCrm\App\Services\Funnel\BaseTrigger' ),
473 + 'actions' => [
474 + [
475 + 'action' => 'install',
476 + 'label' => __( 'Install Now', 'subscription' ),
477 + 'type' => 'function',
478 + 'function' => "subscrptInstallPlugin(this, 'fluent-crm')",
479 + ],
480 + [
481 + 'label' => __( 'Learn More', 'subscription' ),
482 + 'type' => 'external_link',
483 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-fluent-crm?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
484 + ],
485 + ],
486 + ],
487 + // Automation.
488 + 'automatorwp' => [
489 + 'title' => 'AutomatorWP',
490 + 'description' => 'Build powerful automations triggered by subscription events without writing any code.',
491 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/automatorwp.png',
492 + 'type' => 'third_party',
493 + 'is_pro' => true,
494 + 'category' => 'automation',
495 + 'is_installed' => is_plugin_active( 'automatorwp/automatorwp.php' ) && class_exists( 'AutomatorWP' ),
496 + 'is_active' => is_plugin_active( 'automatorwp/automatorwp.php' ) && class_exists( 'AutomatorWP' ),
497 + 'actions' => [
498 + [
499 + 'action' => 'install',
500 + 'label' => __( 'Install Now', 'subscription' ),
501 + 'type' => 'function',
502 + 'function' => "subscrptInstallPlugin(this, 'automatorwp')",
503 + ],
504 + // [
505 + // 'label' => __( 'Learn More', 'subscription' ),
506 + // 'type' => 'external_link',
507 + // 'url' => 'https://docs.wpsubscription.co/en/',
508 + // ],
509 + ],
510 + ],
511 + 'wpfusion' => [
512 + 'title' => 'WP Fusion',
513 + 'description' => 'Sync subscription data with your CRM and marketing platforms through WP Fusion.',
514 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/wp-fusion.png',
515 + 'type' => 'third_party',
516 + 'is_pro' => true,
517 + 'category' => 'automation',
518 + 'is_installed' => class_exists( 'WPF_Integrations_Base' ),
519 + 'is_active' => class_exists( 'WPF_Integrations_Base' ),
520 + 'actions' => [
521 + [
522 + 'action' => 'install',
523 + 'label' => __( 'Get WP Fusion', 'subscription' ),
524 + 'type' => 'external_link',
525 + 'url' => 'https://wpfusion.com/',
526 + ],
527 + // [
528 + // 'label' => __( 'Learn More', 'subscription' ),
529 + // 'type' => 'external_link',
530 + // 'url' => 'https://docs.wpsubscription.co/en/',
531 + // ],
532 + ],
533 + ],
534 + // Email Marketing.
535 + 'mailpoet' => [
536 + 'title' => 'MailPoet',
537 + 'description' => 'Add subscribers to MailPoet lists and trigger email automations based on subscription lifecycle events.',
538 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/mailpoet.png',
539 + 'type' => 'third_party',
540 + 'is_pro' => true,
541 + 'category' => 'email',
542 + 'is_installed' => is_plugin_active( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
543 + 'is_active' => is_plugin_active( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ),
544 + 'actions' => [
545 + [
546 + 'action' => 'install',
547 + 'label' => __( 'Install Now', 'subscription' ),
548 + 'type' => 'function',
549 + 'function' => "subscrptInstallPlugin(this, 'mailpoet')",
550 + ],
551 + [
552 + 'label' => __( 'Learn More', 'subscription' ),
553 + 'type' => 'external_link',
554 + 'url' => 'https://docs.wpsubscription.co/en/wpsubscription-mailpoet?utm_source=plugin&utm_medium=admin&utm_campaign=docs',
555 + ],
556 + ],
557 + ],
558 + // License Management.
559 + 'wp_soft_lic' => [
560 + 'title' => 'WP Software License',
561 + 'description' => 'Issue and validate software licenses for subscription-based digital products.',
562 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/wp-software-license.png',
563 + 'type' => 'third_party',
564 + 'is_pro' => true,
565 + 'category' => 'license',
566 + 'is_installed' => is_plugin_active( 'software-license/software-license.php' ) && class_exists( 'WOO_SL' ),
567 + 'is_active' => is_plugin_active( 'software-license/software-license.php' ) && class_exists( 'WOO_SL' ),
568 + 'actions' => [
569 + [
570 + 'action' => 'install',
571 + 'label' => __( 'Get Plugin', 'subscription' ),
572 + 'type' => 'external_link',
573 + 'url' => 'https://wpsoftwarelicense.com/',
574 + ],
575 + // [
576 + // 'label' => __( 'Learn More', 'subscription' ),
577 + // 'type' => 'external_link',
578 + // 'url' => 'https://docs.wpsubscription.co/en/',
579 + // ],
580 + ],
581 + ],
582 + 'license_mgr' => [
583 + 'title' => 'License Manager for WooCommerce',
584 + 'description' => 'Generate and manage software license keys that are automatically tied to active subscriptions.',
585 + 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/license-manager.png',
586 + 'type' => 'third_party',
587 + 'is_pro' => true,
588 + 'category' => 'license',
589 + 'is_installed' => is_plugin_active( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ) && class_exists( 'LicenseManagerForWooCommerce\Models\Resources\License' ),
590 + 'is_active' => is_plugin_active( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ) && class_exists( 'LicenseManagerForWooCommerce\Models\Resources\License' ),
591 + 'actions' => [
592 + [
593 + 'action' => 'install',
594 + 'label' => __( 'Install Now', 'subscription' ),
595 + 'type' => 'function',
596 + 'function' => "subscrptInstallPlugin(this, 'license-manager-for-woocommerce')",
597 + ],
598 + // [
599 + // 'label' => __( 'Learn More', 'subscription' ),
600 + // 'type' => 'external_link',
601 + // 'url' => 'https://docs.wpsubscription.co/en/',
602 + // ],
603 + ],
604 + ],
605 + ];
606 + $integrations = array_merge( $integrations, $third_party );
607 +
267 608 // Add more integrations as needed.
268 - add_filter( 'wp_subscription_integrations', $integrations );
609 + $integrations = apply_filters( 'wpsubs_integrations', $integrations );
269 610
270 611 return $integrations;
271 612 }
272 613
@@ -281,9 +622,10 @@
281 622 foreach ( $integrations as $integration ) {
282 623 $is_installed = $integration['is_installed'] ?? false;
283 624 $is_active = $integration['is_active'] ?? false;
284 625
285 - $cleaned_actions = [];
626 + $cleaned_actions = [];
627 + $shown_install_url = null;
286 628
287 629 foreach ( $integration['actions'] as $integration_action ) {
288 630 $action_tag = $integration_action['action'] ?? null;
289 631
@@ -289,8 +631,9 @@
289 631
290 632 if ( 'install' === $action_tag ) {
291 633 if ( ! $is_installed ) {
292 634 $cleaned_actions[] = $integration_action;
635 + $shown_install_url = $integration_action['url'] ?? null;
293 636 }
294 637 continue;
295 638 }
296 639 if ( 'uninstall' === $action_tag ) {
@@ -311,9 +654,14 @@
311 654 }
312 655 continue;
313 656 }
314 657
315 - // Default.
658 + // Default. Skip a "More Details"-style link that just repeats the
659 + // install/"Get X" link already shown (e.g. Paddle), so the card
660 + // does not carry the same URL twice.
661 + if ( null !== $shown_install_url && ( $integration_action['url'] ?? null ) === $shown_install_url ) {
662 + continue;
663 + }
316 664 $cleaned_actions[] = $integration_action;
317 665 }
318 666
319 667 // Overwrite.
@@ -330,13 +678,10 @@
330 678 public function render_integrations_page() {
331 679 $integrations = $this->integrations;
332 680 $integrations = $this->filter_integration_actions( $integrations );
333 681
334 - // Integrations styles.
335 - // wp_enqueue_style( 'wp-subs-integration-settings', WP_SUBSCRIPTION_ASSETS . '/css/integration_settings.css', [], WP_SUBSCRIPTION_VERSION, 'all' );
336 -
337 682 $menu = new \SpringDevs\Subscription\Admin\Menu();
338 - $menu->render_admin_header();
683 + $menu->render_admin_header( __( 'Integrations', 'subscription' ) );
339 684 include 'views/integrations.php';
340 685 $menu->render_admin_footer();
341 686 }
342 687 }