Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin Search Hints: only display feature suggestion when your plan supports it #11876

Merged
merged 2 commits into from Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 17 additions & 12 deletions modules/plugin-search.php
Expand Up @@ -263,7 +263,6 @@ public function get_extra_features() {
* Intercept the plugins API response and add in an appropriate card for Jetpack
*/
public function inject_jetpack_module_suggestion( $result, $action, $args ) {

// Looks like a search query; it's matching time
if ( ! empty( $args->search ) ) {
require_once JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php';
Expand Down Expand Up @@ -299,7 +298,19 @@ public function inject_jetpack_module_suggestion( $result, $action, $args ) {

// Try to match a passed search term with module's search terms
foreach ( $jetpack_modules_list as $module_slug => $module_opts ) {
if ( false !== stripos( $module_opts['search_terms'] . ', ' . $module_opts['name'], $normalized_term ) ) {
/*
* Does the site's current plan support the feature?
* We don't use Jetpack_Plan::supports() here because
* that check always returns Akismet as supported,
* since Akismet has a free version.
*/
$current_plan = Jetpack_Plan::get();
$is_supported_by_plan = in_array( $module_slug, $current_plan['supports'], true );

if (
false !== stripos( $module_opts['search_terms'] . ', ' . $module_opts['name'], $normalized_term )
&& $is_supported_by_plan
) {
$matching_module = $module_slug;
break;
}
Expand Down Expand Up @@ -455,21 +466,15 @@ class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button"
// Jetpack installed, active, feature not enabled; prompt to enable.
} elseif (
current_user_can( 'jetpack_activate_modules' ) &&
! Jetpack::is_module_active( $plugin['module'] )
! Jetpack::is_module_active( $plugin['module'] ) &&
Jetpack_Plan::supports( $plugin['module'] )
) {
$links[] = Jetpack_Plan::supports( $plugin['module'] )
? '<button
$links[] = '<button
id="plugin-select-activate"
class="jetpack-plugin-search__primary button"
data-module="' . esc_attr( $plugin['module'] ) . '"
data-configure-url="' . esc_url( $this->get_configure_url( $plugin['module'], $plugin['configure_url'] ) ) . '"
> ' . esc_html__( 'Enable', 'jetpack' ) . '</button>'
: '<a
class="jetpack-plugin-search__primary button"
href="' . esc_url( $this->get_upgrade_url( $plugin['module'] ) ) . '"
data-module="' . esc_attr( $plugin['module'] ) . '"
data-track="purchase"
> ' . esc_html__( 'Purchase', 'jetpack' ) . '</button>';
> ' . esc_html__( 'Enable', 'jetpack' ) . '</button>';

// Jetpack installed, active, feature enabled; link to settings.
} elseif (
Expand Down
1 change: 1 addition & 0 deletions modules/vaultpress.php
Expand Up @@ -10,6 +10,7 @@
* Auto Activate: Yes
* Feature: Security, Health
* Additional Search Queries: backup, cloud backup, database backup, restore, wordpress backup, backup plugin, wordpress backup plugin, back up, backup wordpress, backwpup, vaultpress, backups, off-site backups, offsite backup, offsite, off-site, antivirus, malware scanner, security, virus, viruses, prevent viruses, scan, anti-virus, antimalware, protection, safe browsing, malware, wp security, wordpress security
* Plans: personal, business, premium
*/

add_action( 'jetpack_modules_loaded', 'vaultpress_jetpack_stub' );
Expand Down