PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.10
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.10
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmPluginSearch.php +10 -19 6.276.10 View file →
@@ -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 */
@@ -57,19 +56,13 @@
57 56 if ( empty( $args->search ) ) {
58 57 return $result;
59 58 }
60 59
61 - if ( is_wp_error( $result ) ) {
62 - // This may happen if the request failed due to an internet connection issue.
63 - return $result;
64 - }
65 -
66 60 $addon_list = $this->get_addons();
67 61
68 62 // Lowercase, trim, remove punctuation/special chars, decode url, remove 'formidable'.
69 63 $normalized_term = $this->search_to_array( $args->search );
70 -
71 - if ( ! $normalized_term ) {
64 + if ( empty( $normalized_term ) ) {
72 65 // Don't add anything extra.
73 66 return $result;
74 67 }
75 68
@@ -74,9 +67,9 @@
74 67 }
75 68
76 69 $matching_addon = $this->matching_addon( $addon_list, $normalized_term );
77 70
78 - if ( ! $matching_addon || ! $this->should_display_hint( $matching_addon ) ) {
71 + if ( empty( $matching_addon ) || ! $this->should_display_hint( $matching_addon ) ) {
79 72 return $result;
80 73 }
81 74
82 75 $inject = (array) $this->get_plugin_data();
@@ -129,9 +122,10 @@
129 122 if ( ! isset( $addon_opts['search_terms'] ) ) {
130 123 $addon_opts['search_terms'] = '';
131 124 }
132 125
133 - $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
126 + $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
127 +
134 128 $matched_terms = array_intersect( $addon_terms, $normalized_term );
135 129
136 130 if ( count( $matched_terms ) === count( $normalized_term ) ) {
137 131 $matching_addon = $addon_id;
@@ -188,9 +182,8 @@
188 182 /**
189 183 * Modify URL used to fetch to plugin information so it pulls Formidable plugin page.
190 184 *
191 185 * @since 4.12
192 - *
193 186 * @param string $url URL to load in dialog pulling the plugin page from wporg.
194 187 *
195 188 * @return string The URL with 'formidable' instead of 'frm-plugin-search'.
196 189 */
@@ -206,10 +199,9 @@
206 199 * @return void
207 200 */
208 201 private function maybe_dismiss() {
209 202 $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' );
210 -
211 - if ( $addon ) {
203 + if ( ! empty( $addon ) ) {
212 204 $this->add_to_dismissed_hints( $addon );
213 205 }
214 206 }
215 207
@@ -221,9 +213,9 @@
221 213 * @return array List of dismissed hints.
222 214 */
223 215 protected function get_dismissed_hints() {
224 216 $dismissed_hints = get_option( self::$dismissed_opt );
225 - return $dismissed_hints && is_array( $dismissed_hints ) ? $dismissed_hints : array();
217 + return ! empty( $dismissed_hints ) && is_array( $dismissed_hints ) ? $dismissed_hints : array();
226 218 }
227 219
228 220 /**
229 221 * Save the hint in the list of dismissed hints.
@@ -265,9 +257,8 @@
265 257 * Take a raw search query and return something a bit more standardized and
266 258 * easy to work with.
267 259 *
268 260 * @param string $term The raw search term.
269 - *
270 261 * @return string A simplified/sanitized version.
271 262 */
272 263 private function sanitize_search_term( $term ) {
273 264 $term = strtolower( urldecode( $term ) );
@@ -275,9 +266,11 @@
275 266 // remove non-alpha/space chars.
276 267 $term = preg_replace( '/[^a-z ]/', '', $term );
277 268
278 269 // remove strings that don't help matches.
279 - return trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
270 + $term = trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
271 +
272 + return $term;
280 273 }
281 274
282 275 /**
283 276 * @since 4.12
@@ -282,9 +275,8 @@
282 275 /**
283 276 * @since 4.12
284 277 *
285 278 * @param string $terms
286 - *
287 279 * @return array
288 280 */
289 281 private function search_to_array( $terms ) {
290 282 $terms = $this->sanitize_search_term( $terms );
@@ -321,9 +313,9 @@
321 313 'plugin' => $plugin['plugin'],
322 314 ),
323 315 admin_url( 'plugins.php' )
324 316 );
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
317 + $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 318 }
327 319 } elseif ( ! $is_active && isset( $plugin['url'] ) ) {
328 320 // Go to the add-ons page to install.
329 321 $links[] = '<a
@@ -353,9 +345,8 @@
353 345 }
354 346
355 347 /**
356 348 * @param string $plugin
357 - *
358 349 * @return bool
359 350 */
360 351 protected function is_installed( $plugin ) {
361 352 $all_plugins = FrmAppHelper::get_plugins();