| @@ -25,12 +25,11 @@ | ||
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Add actions and filters only if this is the plugin installation screen and it's the first page. |
| 28 | 28 | * |
| 29 | + * @since 4.12 | |
| 29 | 30 | * @param object $screen WP Screen object. |
| 30 | 31 | * |
| 31 | - * @since 4.12 | |
| 32 | - * | |
| 33 | 32 | * @return void |
| 34 | 33 | */ |
| 35 | 34 | public function start( $screen ) { |
| 36 | 35 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| @@ -57,8 +56,13 @@ | ||
| 57 | 56 | if ( empty( $args->search ) ) { |
| 58 | 57 | return $result; |
| 59 | 58 | } |
| 60 | 59 | |
| 60 | + if ( is_wp_error( $result ) ) { | |
| 61 | + // This may happen if the request failed due to an internet connection issue. | |
| 62 | + return $result; | |
| 63 | + } | |
| 64 | + | |
| 61 | 65 | $addon_list = $this->get_addons(); |
| 62 | 66 | |
| 63 | 67 | // Lowercase, trim, remove punctuation/special chars, decode url, remove 'formidable'. |
| 64 | 68 | $normalized_term = $this->search_to_array( $args->search ); |
| @@ -74,18 +78,19 @@ | ||
| 74 | 78 | } |
| 75 | 79 | |
| 76 | 80 | $inject = (array) $this->get_plugin_data(); |
| 77 | 81 | $overrides = array( |
| 78 | - 'plugin-search' => true, // Helps to determine if that an injected card. | |
| 79 | - 'name' => sprintf( | |
| 82 | + // Helps to determine if that an injected card. | |
| 83 | + 'plugin-search' => true, | |
| 84 | + 'name' => sprintf( | |
| 80 | 85 | /* translators: Formidable addon name */ |
| 81 | 86 | esc_html_x( 'Formidable %s', 'Formidable Addon Name', 'formidable' ), |
| 82 | 87 | $addon_list[ $matching_addon ]['name'] |
| 83 | 88 | ), |
| 84 | - 'addon' => $addon_list[ $matching_addon ]['slug'], | |
| 85 | - 'short_description' => $addon_list[ $matching_addon ]['excerpt'], | |
| 86 | - 'slug' => self::$slug, | |
| 87 | - 'version' => $addon_list[ $matching_addon ]['version'], | |
| 89 | + 'addon' => $addon_list[ $matching_addon ]['slug'], | |
| 90 | + 'short_description' => $addon_list[ $matching_addon ]['excerpt'], | |
| 91 | + 'slug' => self::$slug, | |
| 92 | + 'version' => $addon_list[ $matching_addon ]['version'], | |
| 88 | 93 | ); |
| 89 | 94 | |
| 90 | 95 | if ( ! empty( $addon_list[ $matching_addon ]['external'] ) ) { |
| 91 | 96 | unset( $overrides['name'] ); |
| @@ -124,11 +129,11 @@ | ||
| 124 | 129 | } |
| 125 | 130 | |
| 126 | 131 | $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] ); |
| 127 | 132 | |
| 128 | - $matches = ! empty( array_intersect( $addon_terms, $normalized_term ) ); | |
| 133 | + $matched_terms = array_intersect( $addon_terms, $normalized_term ); | |
| 129 | 134 | |
| 130 | - if ( $matches ) { | |
| 135 | + if ( count( $matched_terms ) === count( $normalized_term ) ) { | |
| 131 | 136 | $matching_addon = $addon_id; |
| 132 | 137 | break; |
| 133 | 138 | } |
| 134 | 139 | } |
| @@ -181,12 +186,11 @@ | ||
| 181 | 186 | |
| 182 | 187 | /** |
| 183 | 188 | * Modify URL used to fetch to plugin information so it pulls Formidable plugin page. |
| 184 | 189 | * |
| 190 | + * @since 4.12 | |
| 185 | 191 | * @param string $url URL to load in dialog pulling the plugin page from wporg. |
| 186 | 192 | * |
| 187 | - * @since 4.12 | |
| 188 | - * | |
| 189 | 193 | * @return string The URL with 'formidable' instead of 'frm-plugin-search'. |
| 190 | 194 | */ |
| 191 | 195 | public function plugin_details( $url ) { |
| 192 | 196 | return false !== stripos( $url, 'tab=plugin-information&plugin=' . self::$slug ) |
| @@ -299,9 +303,9 @@ | ||
| 299 | 303 | |
| 300 | 304 | // By the time this filter is applied, self_admin_url was already applied and we don't need it anymore. |
| 301 | 305 | remove_filter( 'self_admin_url', array( $this, 'plugin_details' ) ); |
| 302 | 306 | |
| 303 | - $links = array(); | |
| 307 | + $links = array(); | |
| 304 | 308 | $is_installed = $this->is_installed( $plugin['plugin'] ); |
| 305 | 309 | $is_active = is_plugin_active( $plugin['plugin'] ); |
| 306 | 310 | |
| 307 | 311 | // Plugin installed, active, feature not enabled; prompt to enable. |
| @@ -306,11 +310,11 @@ | ||
| 306 | 310 | |
| 307 | 311 | // Plugin installed, active, feature not enabled; prompt to enable. |
| 308 | 312 | if ( ! $is_active && $is_installed ) { |
| 309 | 313 | if ( current_user_can( 'activate_plugins' ) ) { |
| 310 | - $activate_url = add_query_arg( | |
| 314 | + $activate_url = add_query_arg( | |
| 311 | 315 | array( |
| 312 | - 'action' => 'activate', | |
| 316 | + 'action' => 'activate', | |
| 313 | 317 | '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin['plugin'] ), |
| 314 | 318 | 'plugin' => $plugin['plugin'], |
| 315 | 319 | ), |
| 316 | 320 | admin_url( 'plugins.php' ) |
| @@ -331,9 +335,9 @@ | ||
| 331 | 335 | href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-learn-more', $plugin['link'] ) ) . '" |
| 332 | 336 | target="_blank" |
| 333 | 337 | data-addon="' . esc_attr( $plugin['addon'] ) . '" |
| 334 | 338 | >' . esc_html__( 'Learn more', 'formidable' ) . '</a>'; |
| 335 | - } | |
| 339 | + }//end if | |
| 336 | 340 | |
| 337 | 341 | // Dismiss link. |
| 338 | 342 | $dismiss = add_query_arg( array( 'frm-dismiss' => $plugin['id'] ) ); |
| 339 | 343 | $links[] = '<a |