| @@ -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§ion=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§ion=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§ion=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,9 +346,9 @@ | ||
| 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 | 354 | 'is_installed' => class_exists( 'Mollie\WooCommerce\Activation\ActivationModule' ), |
| @@ -304,28 +356,28 @@ | ||
| 304 | 356 | 'supports_recurring' => true, |
| 305 | 357 | 'actions' => [ |
| 306 | 358 | [ |
| 307 | 359 | 'action' => 'install', |
| 308 | - 'label' => 'Install Now', | |
| 360 | + 'label' => __( 'Install Now', 'subscription' ), | |
| 309 | 361 | 'type' => 'function', |
| 310 | 362 | 'function' => "subscrptInstallPlugin(this, 'mollie-payments-for-woocommerce')", |
| 311 | 363 | ], |
| 312 | 364 | [ |
| 313 | 365 | 'action' => 'settings', |
| 314 | - 'label' => 'Settings', | |
| 366 | + 'label' => __( 'Settings', 'subscription' ), | |
| 315 | 367 | 'type' => 'link', |
| 316 | 368 | 'url' => admin_url( 'admin.php?page=wc-settings&tab=mollie_settings' ), |
| 317 | 369 | ], |
| 318 | 370 | [ |
| 319 | - 'label' => 'More Details', | |
| 371 | + 'label' => __( 'More Details', 'subscription' ), | |
| 320 | 372 | 'type' => 'external_link', |
| 321 | - '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', | |
| 322 | 374 | ], |
| 323 | 375 | ], |
| 324 | 376 | ], |
| 325 | 377 | 'razorpay' => [ |
| 326 | 378 | 'title' => 'Razorpay', |
| 327 | - 'description' => 'Pay for subscriptions securely with Razorpay for WooCommerce.', | |
| 379 | + 'description' => __( 'Pay for subscriptions securely with Razorpay for WooCommerce.', 'subscription' ), | |
| 328 | 380 | 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/razorpay.png', |
| 329 | 381 | 'type' => 'payment_gateway', |
| 330 | 382 | 'is_pro' => true, |
| 331 | 383 | 'is_beta' => true, |
| @@ -334,28 +386,28 @@ | ||
| 334 | 386 | 'supports_recurring' => true, |
| 335 | 387 | 'actions' => [ |
| 336 | 388 | [ |
| 337 | 389 | 'action' => 'install', |
| 338 | - 'label' => 'Install Now', | |
| 390 | + 'label' => __( 'Install Now', 'subscription' ), | |
| 339 | 391 | 'type' => 'function', |
| 340 | 392 | 'function' => "subscrptInstallPlugin(this, 'woo-razorpay')", |
| 341 | 393 | ], |
| 342 | 394 | [ |
| 343 | 395 | 'action' => 'settings', |
| 344 | - 'label' => 'Settings', | |
| 396 | + 'label' => __( 'Settings', 'subscription' ), | |
| 345 | 397 | 'type' => 'link', |
| 346 | 398 | 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=razorpay' ), |
| 347 | 399 | ], |
| 348 | 400 | [ |
| 349 | - 'label' => 'More Details', | |
| 401 | + 'label' => __( 'More Details', 'subscription' ), | |
| 350 | 402 | 'type' => 'external_link', |
| 351 | - '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', | |
| 352 | 404 | ], |
| 353 | 405 | ], |
| 354 | 406 | ], |
| 355 | 407 | 'xendit' => [ |
| 356 | 408 | 'title' => 'Xendit', |
| 357 | - 'description' => 'Pay for subscriptions securely with Xendit for WooCommerce.', | |
| 409 | + 'description' => __( 'Pay for subscriptions securely with Xendit for WooCommerce.', 'subscription' ), | |
| 358 | 410 | 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/xendit.png', |
| 359 | 411 | 'type' => 'payment_gateway', |
| 360 | 412 | 'is_pro' => true, |
| 361 | 413 | 'is_beta' => true, |
| @@ -364,38 +416,43 @@ | ||
| 364 | 416 | 'supports_recurring' => true, |
| 365 | 417 | 'actions' => [ |
| 366 | 418 | [ |
| 367 | 419 | 'action' => 'install', |
| 368 | - 'label' => 'Install Now', | |
| 420 | + 'label' => __( 'Install Now', 'subscription' ), | |
| 369 | 421 | 'type' => 'function', |
| 370 | 422 | 'function' => "subscrptInstallPlugin(this, 'woo-xendit-virtual-accounts')", |
| 371 | 423 | ], |
| 372 | 424 | [ |
| 373 | 425 | 'action' => 'settings', |
| 374 | - 'label' => 'Settings', | |
| 426 | + 'label' => __( 'Settings', 'subscription' ), | |
| 375 | 427 | 'type' => 'link', |
| 376 | 428 | 'url' => admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=xendit_gateway' ), |
| 377 | 429 | ], |
| 378 | 430 | [ |
| 379 | - 'label' => 'More Details', | |
| 431 | + 'label' => __( 'More Details', 'subscription' ), | |
| 380 | 432 | 'type' => 'external_link', |
| 381 | - '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', | |
| 382 | 434 | ], |
| 383 | 435 | ], |
| 384 | 436 | ], |
| 385 | 437 | ]; |
| 386 | 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 | + | |
| 387 | 444 | // Third-party integrations (requires Pro plugin to function). |
| 388 | 445 | $third_party = [ |
| 389 | 446 | // LMS. |
| 390 | 447 | 'tutor_lms' => [ |
| 391 | 448 | 'title' => 'Tutor LMS', |
| 392 | - 'description' => 'Restrict course access based on subscription status. Enroll and unenroll students automatically.', | |
| 393 | - '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', | |
| 394 | 451 | 'type' => 'third_party', |
| 395 | 452 | 'is_pro' => true, |
| 396 | 453 | 'category' => 'lms', |
| 397 | - 'is_installed' => is_plugin_active( 'tutor/tutor.php' ) && class_exists( 'TUTOR\Tutor' ), | |
| 454 | + 'is_installed' => $this->is_plugin_installed( 'tutor/tutor.php' ), | |
| 398 | 455 | 'is_active' => is_plugin_active( 'tutor/tutor.php' ) && class_exists( 'TUTOR\Tutor' ), |
| 399 | 456 | 'actions' => [ |
| 400 | 457 | [ |
| 401 | 458 | 'action' => 'install', |
| @@ -403,22 +460,28 @@ | ||
| 403 | 460 | 'type' => 'function', |
| 404 | 461 | 'function' => "subscrptInstallPlugin(this, 'tutor')", |
| 405 | 462 | ], |
| 406 | 463 | [ |
| 464 | + 'action' => 'activate', | |
| 465 | + 'label' => __( 'Activate', 'subscription' ), | |
| 466 | + 'type' => 'function', | |
| 467 | + 'function' => "subscrptActivatePlugin(this, 'tutor/tutor.php')", | |
| 468 | + ], | |
| 469 | + [ | |
| 407 | 470 | 'label' => __( 'Learn More', 'subscription' ), |
| 408 | 471 | 'type' => 'external_link', |
| 409 | - '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', | |
| 410 | 473 | ], |
| 411 | 474 | ], |
| 412 | 475 | ], |
| 413 | 476 | 'learnpress' => [ |
| 414 | 477 | 'title' => 'LearnPress', |
| 415 | - 'description' => 'Connect subscriptions with LearnPress courses. Enroll users automatically when subscriptions are active.', | |
| 416 | - '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', | |
| 417 | 480 | 'type' => 'third_party', |
| 418 | 481 | 'is_pro' => true, |
| 419 | 482 | 'category' => 'lms', |
| 420 | - 'is_installed' => is_plugin_active( 'learnpress/learnpress.php' ) && class_exists( 'LearnPress' ), | |
| 483 | + 'is_installed' => $this->is_plugin_installed( 'learnpress/learnpress.php' ), | |
| 421 | 484 | 'is_active' => is_plugin_active( 'learnpress/learnpress.php' ) && class_exists( 'LearnPress' ), |
| 422 | 485 | 'actions' => [ |
| 423 | 486 | [ |
| 424 | 487 | 'action' => 'install', |
| @@ -426,22 +489,28 @@ | ||
| 426 | 489 | 'type' => 'function', |
| 427 | 490 | 'function' => "subscrptInstallPlugin(this, 'learnpress')", |
| 428 | 491 | ], |
| 429 | 492 | [ |
| 493 | + 'action' => 'activate', | |
| 494 | + 'label' => __( 'Activate', 'subscription' ), | |
| 495 | + 'type' => 'function', | |
| 496 | + 'function' => "subscrptActivatePlugin(this, 'learnpress/learnpress.php')", | |
| 497 | + ], | |
| 498 | + [ | |
| 430 | 499 | 'label' => __( 'Learn More', 'subscription' ), |
| 431 | 500 | 'type' => 'external_link', |
| 432 | - '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', | |
| 433 | 502 | ], |
| 434 | 503 | ], |
| 435 | 504 | ], |
| 436 | 505 | 'learndash' => [ |
| 437 | 506 | 'title' => 'LearnDash', |
| 438 | - 'description' => 'Sync subscription status with LearnDash group enrollment and course access.', | |
| 507 | + 'description' => __( 'Sync subscription status with LearnDash group enrollment and course access.', 'subscription' ), | |
| 439 | 508 | 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/learndash.jpeg', |
| 440 | 509 | 'type' => 'third_party', |
| 441 | 510 | 'is_pro' => true, |
| 442 | 511 | 'category' => 'lms', |
| 443 | - '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' ), | |
| 444 | 513 | 'is_active' => is_plugin_active( 'sfwd-lms/sfwd_lms.php' ) && class_exists( 'LearnDash\Core\App' ), |
| 445 | 514 | 'actions' => [ |
| 446 | 515 | [ |
| 447 | 516 | 'action' => 'install', |
| @@ -449,11 +518,17 @@ | ||
| 449 | 518 | 'type' => 'external_link', |
| 450 | 519 | 'url' => 'https://www.learndash.com/', |
| 451 | 520 | ], |
| 452 | 521 | [ |
| 522 | + 'action' => 'activate', | |
| 523 | + 'label' => __( 'Activate', 'subscription' ), | |
| 524 | + 'type' => 'function', | |
| 525 | + 'function' => "subscrptActivatePlugin(this, 'sfwd-lms/sfwd_lms.php')", | |
| 526 | + ], | |
| 527 | + [ | |
| 453 | 528 | 'label' => __( 'Learn More', 'subscription' ), |
| 454 | 529 | 'type' => 'external_link', |
| 455 | - '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', | |
| 456 | 531 | ], |
| 457 | 532 | ], |
| 458 | 533 | ], |
| 459 | 534 | // CRM. |
| @@ -458,14 +533,14 @@ | ||
| 458 | 533 | ], |
| 459 | 534 | // CRM. |
| 460 | 535 | 'fluentcrm' => [ |
| 461 | 536 | 'title' => 'FluentCRM', |
| 462 | - 'description' => 'Trigger email sequences and manage contacts based on subscription events and status changes.', | |
| 463 | - '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', | |
| 464 | 539 | 'type' => 'third_party', |
| 465 | 540 | 'is_pro' => true, |
| 466 | 541 | 'category' => 'crm', |
| 467 | - 'is_installed' => class_exists( 'FluentCrm\App\Services\Funnel\BaseTrigger' ), | |
| 542 | + 'is_installed' => $this->is_plugin_installed( 'fluent-crm/fluent-crm.php' ), | |
| 468 | 543 | 'is_active' => class_exists( 'FluentCrm\App\Services\Funnel\BaseTrigger' ), |
| 469 | 544 | 'actions' => [ |
| 470 | 545 | [ |
| 471 | 546 | 'action' => 'install', |
| @@ -473,11 +548,17 @@ | ||
| 473 | 548 | 'type' => 'function', |
| 474 | 549 | 'function' => "subscrptInstallPlugin(this, 'fluent-crm')", |
| 475 | 550 | ], |
| 476 | 551 | [ |
| 552 | + 'action' => 'activate', | |
| 553 | + 'label' => __( 'Activate', 'subscription' ), | |
| 554 | + 'type' => 'function', | |
| 555 | + 'function' => "subscrptActivatePlugin(this, 'fluent-crm/fluent-crm.php')", | |
| 556 | + ], | |
| 557 | + [ | |
| 477 | 558 | 'label' => __( 'Learn More', 'subscription' ), |
| 478 | 559 | 'type' => 'external_link', |
| 479 | - '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', | |
| 480 | 561 | ], |
| 481 | 562 | ], |
| 482 | 563 | ], |
| 483 | 564 | // Automation. |
| @@ -482,14 +563,14 @@ | ||
| 482 | 563 | ], |
| 483 | 564 | // Automation. |
| 484 | 565 | 'automatorwp' => [ |
| 485 | 566 | 'title' => 'AutomatorWP', |
| 486 | - 'description' => 'Build powerful automations triggered by subscription events without writing any code.', | |
| 487 | - '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', | |
| 488 | 569 | 'type' => 'third_party', |
| 489 | 570 | 'is_pro' => true, |
| 490 | 571 | 'category' => 'automation', |
| 491 | - 'is_installed' => is_plugin_active( 'automatorwp/automatorwp.php' ) && class_exists( 'AutomatorWP' ), | |
| 572 | + 'is_installed' => $this->is_plugin_installed( 'automatorwp/automatorwp.php' ), | |
| 492 | 573 | 'is_active' => is_plugin_active( 'automatorwp/automatorwp.php' ) && class_exists( 'AutomatorWP' ), |
| 493 | 574 | 'actions' => [ |
| 494 | 575 | [ |
| 495 | 576 | 'action' => 'install', |
| @@ -496,23 +577,29 @@ | ||
| 496 | 577 | 'label' => __( 'Install Now', 'subscription' ), |
| 497 | 578 | 'type' => 'function', |
| 498 | 579 | 'function' => "subscrptInstallPlugin(this, 'automatorwp')", |
| 499 | 580 | ], |
| 581 | + [ | |
| 582 | + 'action' => 'activate', | |
| 583 | + 'label' => __( 'Activate', 'subscription' ), | |
| 584 | + 'type' => 'function', | |
| 585 | + 'function' => "subscrptActivatePlugin(this, 'automatorwp/automatorwp.php')", | |
| 586 | + ], | |
| 500 | 587 | // [ |
| 501 | 588 | // 'label' => __( 'Learn More', 'subscription' ), |
| 502 | 589 | // 'type' => 'external_link', |
| 503 | - // 'url' => 'https://docs.converslabs.com/en/', | |
| 590 | + // 'url' => 'https://docs.wpsubscription.co/en/', | |
| 504 | 591 | // ], |
| 505 | 592 | ], |
| 506 | 593 | ], |
| 507 | 594 | 'wpfusion' => [ |
| 508 | 595 | 'title' => 'WP Fusion', |
| 509 | - 'description' => 'Sync subscription data with your CRM and marketing platforms through WP Fusion.', | |
| 510 | - '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', | |
| 511 | 598 | 'type' => 'third_party', |
| 512 | 599 | 'is_pro' => true, |
| 513 | 600 | 'category' => 'automation', |
| 514 | - 'is_installed' => class_exists( 'WPF_Integrations_Base' ), | |
| 601 | + 'is_installed' => $this->is_plugin_installed( 'wp-fusion/wp-fusion.php' ) || class_exists( 'WPF_Integrations_Base' ), | |
| 515 | 602 | 'is_active' => class_exists( 'WPF_Integrations_Base' ), |
| 516 | 603 | 'actions' => [ |
| 517 | 604 | [ |
| 518 | 605 | 'action' => 'install', |
| @@ -519,12 +606,18 @@ | ||
| 519 | 606 | 'label' => __( 'Get WP Fusion', 'subscription' ), |
| 520 | 607 | 'type' => 'external_link', |
| 521 | 608 | 'url' => 'https://wpfusion.com/', |
| 522 | 609 | ], |
| 610 | + [ | |
| 611 | + 'action' => 'activate', | |
| 612 | + 'label' => __( 'Activate', 'subscription' ), | |
| 613 | + 'type' => 'function', | |
| 614 | + 'function' => "subscrptActivatePlugin(this, 'wp-fusion/wp-fusion.php')", | |
| 615 | + ], | |
| 523 | 616 | // [ |
| 524 | 617 | // 'label' => __( 'Learn More', 'subscription' ), |
| 525 | 618 | // 'type' => 'external_link', |
| 526 | - // 'url' => 'https://docs.converslabs.com/en/', | |
| 619 | + // 'url' => 'https://docs.wpsubscription.co/en/', | |
| 527 | 620 | // ], |
| 528 | 621 | ], |
| 529 | 622 | ], |
| 530 | 623 | // Email Marketing. |
| @@ -529,14 +622,14 @@ | ||
| 529 | 622 | ], |
| 530 | 623 | // Email Marketing. |
| 531 | 624 | 'mailpoet' => [ |
| 532 | 625 | 'title' => 'MailPoet', |
| 533 | - 'description' => 'Add subscribers to MailPoet lists and trigger email automations based on subscription lifecycle events.', | |
| 534 | - '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', | |
| 535 | 628 | 'type' => 'third_party', |
| 536 | 629 | 'is_pro' => true, |
| 537 | 630 | 'category' => 'email', |
| 538 | - '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' ), | |
| 539 | 632 | 'is_active' => is_plugin_active( 'mailpoet/mailpoet.php' ) || is_plugin_active( 'mailpoet-premium/mailpoet-premium.php' ), |
| 540 | 633 | 'actions' => [ |
| 541 | 634 | [ |
| 542 | 635 | 'action' => 'install', |
| @@ -544,11 +637,17 @@ | ||
| 544 | 637 | 'type' => 'function', |
| 545 | 638 | 'function' => "subscrptInstallPlugin(this, 'mailpoet')", |
| 546 | 639 | ], |
| 547 | 640 | [ |
| 641 | + 'action' => 'activate', | |
| 642 | + 'label' => __( 'Activate', 'subscription' ), | |
| 643 | + 'type' => 'function', | |
| 644 | + 'function' => "subscrptActivatePlugin(this, 'mailpoet/mailpoet.php')", | |
| 645 | + ], | |
| 646 | + [ | |
| 548 | 647 | 'label' => __( 'Learn More', 'subscription' ), |
| 549 | 648 | 'type' => 'external_link', |
| 550 | - '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', | |
| 551 | 650 | ], |
| 552 | 651 | ], |
| 553 | 652 | ], |
| 554 | 653 | // License Management. |
| @@ -553,14 +652,14 @@ | ||
| 553 | 652 | ], |
| 554 | 653 | // License Management. |
| 555 | 654 | 'wp_soft_lic' => [ |
| 556 | 655 | 'title' => 'WP Software License', |
| 557 | - 'description' => 'Issue and validate software licenses for subscription-based digital products.', | |
| 656 | + 'description' => __( 'Issue and validate software licenses for subscription-based digital products.', 'subscription' ), | |
| 558 | 657 | 'icon_url' => SUBSCRPT_ASSETS . '/images/integrations/wp-software-license.png', |
| 559 | 658 | 'type' => 'third_party', |
| 560 | 659 | 'is_pro' => true, |
| 561 | 660 | 'category' => 'license', |
| 562 | - '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' ), | |
| 563 | 662 | 'is_active' => is_plugin_active( 'software-license/software-license.php' ) && class_exists( 'WOO_SL' ), |
| 564 | 663 | 'actions' => [ |
| 565 | 664 | [ |
| 566 | 665 | 'action' => 'install', |
| @@ -567,23 +666,29 @@ | ||
| 567 | 666 | 'label' => __( 'Get Plugin', 'subscription' ), |
| 568 | 667 | 'type' => 'external_link', |
| 569 | 668 | 'url' => 'https://wpsoftwarelicense.com/', |
| 570 | 669 | ], |
| 670 | + [ | |
| 671 | + 'action' => 'activate', | |
| 672 | + 'label' => __( 'Activate', 'subscription' ), | |
| 673 | + 'type' => 'function', | |
| 674 | + 'function' => "subscrptActivatePlugin(this, 'software-license/software-license.php')", | |
| 675 | + ], | |
| 571 | 676 | // [ |
| 572 | 677 | // 'label' => __( 'Learn More', 'subscription' ), |
| 573 | 678 | // 'type' => 'external_link', |
| 574 | - // 'url' => 'https://docs.converslabs.com/en/', | |
| 679 | + // 'url' => 'https://docs.wpsubscription.co/en/', | |
| 575 | 680 | // ], |
| 576 | 681 | ], |
| 577 | 682 | ], |
| 578 | 683 | 'license_mgr' => [ |
| 579 | 684 | 'title' => 'License Manager for WooCommerce', |
| 580 | - 'description' => 'Generate and manage software license keys that are automatically tied to active subscriptions.', | |
| 581 | - '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', | |
| 582 | 687 | 'type' => 'third_party', |
| 583 | 688 | 'is_pro' => true, |
| 584 | 689 | 'category' => 'license', |
| 585 | - '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' ), | |
| 586 | 691 | 'is_active' => is_plugin_active( 'license-manager-for-woocommerce/license-manager-for-woocommerce.php' ) && class_exists( 'LicenseManagerForWooCommerce\Models\Resources\License' ), |
| 587 | 692 | 'actions' => [ |
| 588 | 693 | [ |
| 589 | 694 | 'action' => 'install', |
| @@ -590,12 +695,18 @@ | ||
| 590 | 695 | 'label' => __( 'Install Now', 'subscription' ), |
| 591 | 696 | 'type' => 'function', |
| 592 | 697 | 'function' => "subscrptInstallPlugin(this, 'license-manager-for-woocommerce')", |
| 593 | 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 | + ], | |
| 594 | 705 | // [ |
| 595 | 706 | // 'label' => __( 'Learn More', 'subscription' ), |
| 596 | 707 | // 'type' => 'external_link', |
| 597 | - // 'url' => 'https://docs.converslabs.com/en/', | |
| 708 | + // 'url' => 'https://docs.wpsubscription.co/en/', | |
| 598 | 709 | // ], |
| 599 | 710 | ], |
| 600 | 711 | ], |
| 601 | 712 | ]; |
| @@ -618,10 +729,16 @@ | ||
| 618 | 729 | foreach ( $integrations as $integration ) { |
| 619 | 730 | $is_installed = $integration['is_installed'] ?? false; |
| 620 | 731 | $is_active = $integration['is_active'] ?? false; |
| 621 | 732 | |
| 622 | - $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; | |
| 623 | 737 | |
| 738 | + $cleaned_actions = []; | |
| 739 | + $shown_install_url = null; | |
| 740 | + | |
| 624 | 741 | foreach ( $integration['actions'] as $integration_action ) { |
| 625 | 742 | $action_tag = $integration_action['action'] ?? null; |
| 626 | 743 | |
| 627 | 744 | if ( 'install' === $action_tag ) { |
| @@ -626,8 +743,9 @@ | ||
| 626 | 743 | |
| 627 | 744 | if ( 'install' === $action_tag ) { |
| 628 | 745 | if ( ! $is_installed ) { |
| 629 | 746 | $cleaned_actions[] = $integration_action; |
| 747 | + $shown_install_url = $integration_action['url'] ?? null; | |
| 630 | 748 | } |
| 631 | 749 | continue; |
| 632 | 750 | } |
| 633 | 751 | if ( 'uninstall' === $action_tag ) { |
| @@ -635,8 +753,14 @@ | ||
| 635 | 753 | $cleaned_actions[] = $integration_action; |
| 636 | 754 | } |
| 637 | 755 | continue; |
| 638 | 756 | } |
| 757 | + if ( 'activate' === $action_tag ) { | |
| 758 | + if ( $is_installed && ! $plugin_active ) { | |
| 759 | + $cleaned_actions[] = $integration_action; | |
| 760 | + } | |
| 761 | + continue; | |
| 762 | + } | |
| 639 | 763 | if ( 'enable' === $action_tag ) { |
| 640 | 764 | if ( $is_installed && ! $is_active ) { |
| 641 | 765 | $cleaned_actions[] = $integration_action; |
| 642 | 766 | } |
| @@ -642,15 +766,20 @@ | ||
| 642 | 766 | } |
| 643 | 767 | continue; |
| 644 | 768 | } |
| 645 | 769 | if ( 'settings' === $action_tag ) { |
| 646 | - if ( $is_installed ) { | |
| 770 | + if ( $is_installed && ( '' === $plugin_file || $plugin_active ) ) { | |
| 647 | 771 | $cleaned_actions[] = $integration_action; |
| 648 | 772 | } |
| 649 | 773 | continue; |
| 650 | 774 | } |
| 651 | 775 | |
| 652 | - // 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 | + } | |
| 653 | 782 | $cleaned_actions[] = $integration_action; |
| 654 | 783 | } |
| 655 | 784 | |
| 656 | 785 | // Overwrite. |
| @@ -666,11 +795,8 @@ | ||
| 666 | 795 | */ |
| 667 | 796 | public function render_integrations_page() { |
| 668 | 797 | $integrations = $this->integrations; |
| 669 | 798 | $integrations = $this->filter_integration_actions( $integrations ); |
| 670 | - | |
| 671 | - // Integrations styles. | |
| 672 | - // wp_enqueue_style( 'wp-subs-integration-settings', SUBSCRPT_ASSETS . '/css/integration_settings.css', [], SUBSCRPT_VERSION, 'all' ); | |
| 673 | 799 | |
| 674 | 800 | $menu = new \SpringDevs\Subscription\Admin\Menu(); |
| 675 | 801 | $menu->render_admin_header( __( 'Integrations', 'subscription' ) ); |
| 676 | 802 | include 'views/integrations.php'; |