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