| @@ -26,9 +26,8 @@ | ||
| 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 | 29 | * @since 4.12 |
| 30 | - * | |
| 31 | 30 | * @param object $screen WP Screen object. |
| 32 | 31 | * |
| 33 | 32 | * @return void |
| 34 | 33 | */ |
| @@ -66,10 +65,9 @@ | ||
| 66 | 65 | $addon_list = $this->get_addons(); |
| 67 | 66 | |
| 68 | 67 | // Lowercase, trim, remove punctuation/special chars, decode url, remove 'formidable'. |
| 69 | 68 | $normalized_term = $this->search_to_array( $args->search ); |
| 70 | - | |
| 71 | - if ( ! $normalized_term ) { | |
| 69 | + if ( empty( $normalized_term ) ) { | |
| 72 | 70 | // Don't add anything extra. |
| 73 | 71 | return $result; |
| 74 | 72 | } |
| 75 | 73 | |
| @@ -74,9 +72,9 @@ | ||
| 74 | 72 | } |
| 75 | 73 | |
| 76 | 74 | $matching_addon = $this->matching_addon( $addon_list, $normalized_term ); |
| 77 | 75 | |
| 78 | - if ( ! $matching_addon || ! $this->should_display_hint( $matching_addon ) ) { | |
| 76 | + if ( empty( $matching_addon ) || ! $this->should_display_hint( $matching_addon ) ) { | |
| 79 | 77 | return $result; |
| 80 | 78 | } |
| 81 | 79 | |
| 82 | 80 | $inject = (array) $this->get_plugin_data(); |
| @@ -129,9 +127,10 @@ | ||
| 129 | 127 | if ( ! isset( $addon_opts['search_terms'] ) ) { |
| 130 | 128 | $addon_opts['search_terms'] = ''; |
| 131 | 129 | } |
| 132 | 130 | |
| 133 | - $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] ); | |
| 131 | + $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] ); | |
| 132 | + | |
| 134 | 133 | $matched_terms = array_intersect( $addon_terms, $normalized_term ); |
| 135 | 134 | |
| 136 | 135 | if ( count( $matched_terms ) === count( $normalized_term ) ) { |
| 137 | 136 | $matching_addon = $addon_id; |
| @@ -188,9 +187,8 @@ | ||
| 188 | 187 | /** |
| 189 | 188 | * Modify URL used to fetch to plugin information so it pulls Formidable plugin page. |
| 190 | 189 | * |
| 191 | 190 | * @since 4.12 |
| 192 | - * | |
| 193 | 191 | * @param string $url URL to load in dialog pulling the plugin page from wporg. |
| 194 | 192 | * |
| 195 | 193 | * @return string The URL with 'formidable' instead of 'frm-plugin-search'. |
| 196 | 194 | */ |
| @@ -206,10 +204,9 @@ | ||
| 206 | 204 | * @return void |
| 207 | 205 | */ |
| 208 | 206 | private function maybe_dismiss() { |
| 209 | 207 | $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' ); |
| 210 | - | |
| 211 | - if ( $addon ) { | |
| 208 | + if ( ! empty( $addon ) ) { | |
| 212 | 209 | $this->add_to_dismissed_hints( $addon ); |
| 213 | 210 | } |
| 214 | 211 | } |
| 215 | 212 | |
| @@ -221,9 +218,9 @@ | ||
| 221 | 218 | * @return array List of dismissed hints. |
| 222 | 219 | */ |
| 223 | 220 | protected function get_dismissed_hints() { |
| 224 | 221 | $dismissed_hints = get_option( self::$dismissed_opt ); |
| 225 | - return $dismissed_hints && is_array( $dismissed_hints ) ? $dismissed_hints : array(); | |
| 222 | + return ! empty( $dismissed_hints ) && is_array( $dismissed_hints ) ? $dismissed_hints : array(); | |
| 226 | 223 | } |
| 227 | 224 | |
| 228 | 225 | /** |
| 229 | 226 | * Save the hint in the list of dismissed hints. |
| @@ -265,9 +262,8 @@ | ||
| 265 | 262 | * Take a raw search query and return something a bit more standardized and |
| 266 | 263 | * easy to work with. |
| 267 | 264 | * |
| 268 | 265 | * @param string $term The raw search term. |
| 269 | - * | |
| 270 | 266 | * @return string A simplified/sanitized version. |
| 271 | 267 | */ |
| 272 | 268 | private function sanitize_search_term( $term ) { |
| 273 | 269 | $term = strtolower( urldecode( $term ) ); |
| @@ -275,9 +271,11 @@ | ||
| 275 | 271 | // remove non-alpha/space chars. |
| 276 | 272 | $term = preg_replace( '/[^a-z ]/', '', $term ); |
| 277 | 273 | |
| 278 | 274 | // remove strings that don't help matches. |
| 279 | - return trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) ); | |
| 275 | + $term = trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) ); | |
| 276 | + | |
| 277 | + return $term; | |
| 280 | 278 | } |
| 281 | 279 | |
| 282 | 280 | /** |
| 283 | 281 | * @since 4.12 |
| @@ -282,9 +280,8 @@ | ||
| 282 | 280 | /** |
| 283 | 281 | * @since 4.12 |
| 284 | 282 | * |
| 285 | 283 | * @param string $terms |
| 286 | - * | |
| 287 | 284 | * @return array |
| 288 | 285 | */ |
| 289 | 286 | private function search_to_array( $terms ) { |
| 290 | 287 | $terms = $this->sanitize_search_term( $terms ); |
| @@ -321,9 +318,9 @@ | ||
| 321 | 318 | 'plugin' => $plugin['plugin'], |
| 322 | 319 | ), |
| 323 | 320 | admin_url( 'plugins.php' ) |
| 324 | 321 | ); |
| 325 | - $links['frm_get_started'] = '<a href="' . esc_url( $activate_url ) . '" class="button activate-now" aria-label="Activate ' . esc_attr( $plugin['name'] ) . '">' . __( 'Activate', 'formidable' ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 322 | + $links['frm_get_started'] = '<a href="' . esc_url( $activate_url ) . '" class="button activate-now" aria-label="Activate ' . esc_attr( $plugin['name'] ) . '">' . __( 'Activate', 'formidable' ) . '</a>'; | |
| 326 | 323 | } |
| 327 | 324 | } elseif ( ! $is_active && isset( $plugin['url'] ) ) { |
| 328 | 325 | // Go to the add-ons page to install. |
| 329 | 326 | $links[] = '<a |
| @@ -353,9 +350,8 @@ | ||
| 353 | 350 | } |
| 354 | 351 | |
| 355 | 352 | /** |
| 356 | 353 | * @param string $plugin |
| 357 | - * | |
| 358 | 354 | * @return bool |
| 359 | 355 | */ |
| 360 | 356 | protected function is_installed( $plugin ) { |
| 361 | 357 | $all_plugins = FrmAppHelper::get_plugins(); |