]; } if ( ! Install::can_install_and_activate( $link['action'], 'plugin' ) ) { return $this->plugin_fallback_cta( $file, (bool) $link['installed'], $install, $activate ); } return [ 'label' => $link['installed'] ? $activate : $install, 'modifier' => 'grey', 'action' => $link['action'], 'plugin' => $link['plugin'], 'reload' => true, ]; } /** * Build the out-of-band CTA for a wordpress.org plugin the user cannot install in place. * * An installed-but-inactive plugin can still be activated from the Plugins screen — multisite * site admins keep `activate_plugins` while losing `install_plugins` — so a user who holds that * capability is sent there. Everyone else gets the plugin's wordpress.org page, which stays * useful when file modifications are disabled and the install must happen out of band. Neither * shape carries `action` or `reload`, so the install JS ignores it and it navigates normally. * * @since 2.0.2 * * @param string $file Plugin main-file path (folder/file.php). * @param bool $is_installed Whether the plugin is already on disk. * @param string $install Label when the plugin is absent. * @param string $activate Label when the plugin is installed but inactive. * * @return array */ private function plugin_fallback_cta( string $file, bool $is_installed, string $install, string $activate ): array { $fallback = Install::get_fallback_destination( $file, $is_installed ); $cta = [ 'label' => $fallback['is_activate'] ? $activate : $install, 'url' => $fallback['url'], 'modifier' => 'grey', ]; // Only the wordpress.org route leaves the admin, so only it carries the external flag. if ( ! $fallback['is_activate'] ) { $cta['external'] = true; } return $cta; } /** * Get the Stripe gateway tile data from the Payments empty state provider. * * @since 2.0.0 * * @return array|null Gateway data, or null when the Stripe integration is unavailable. */ private function get_stripe_gateway(): ?array { $stripe = Stripe::class; if ( ! class_exists( $stripe ) || ! method_exists( $stripe, 'get_started_gateway' ) ) { return null; } $gateway = $stripe::get_started_gateway(); if ( ! is_array( $gateway ) ) { return null; } // Route the Connect button through the checklist's own OAuth kickoff so the // post-connect redirect lands back on the checklist (see StripeConnect), // rather than the payments settings page. $gateway['url'] = add_query_arg( StripeConnect::KICKOFF_ARG, 1, admin_url( 'admin.php' ) ); return $gateway; } /** * Resolve a "View All" footer URL. * * @since 2.0.0 * * @param string $admin_path The wp-admin path used on Pro and Elite. * @param string $marketing_url Marketing URL used on the other tiers. * @param string $utm_content UTM content tag for the marketing URL. * * @return string */ private function view_all_url( string $admin_path, string $marketing_url, string $utm_content ): string { if ( $this->promos->is_pro_plus() ) { return admin_url( $admin_path ); } return wpforms_utm_link( $marketing_url, 'Setup Checklist', $utm_content ); } }