PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
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 +24 -32 6.276.7 View file →
@@ -25,12 +25,12 @@
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 32 *
31 - * @param object $screen WP Screen object.
32 - *
33 33 * @return void
34 34 */
35 35 public function start( $screen ) {
36 36 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
@@ -57,19 +57,13 @@
57 57 if ( empty( $args->search ) ) {
58 58 return $result;
59 59 }
60 60
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 61 $addon_list = $this->get_addons();
67 62
68 63 // Lowercase, trim, remove punctuation/special chars, decode url, remove 'formidable'.
69 64 $normalized_term = $this->search_to_array( $args->search );
70 -
71 - if ( ! $normalized_term ) {
65 + if ( empty( $normalized_term ) ) {
72 66 // Don't add anything extra.
73 67 return $result;
74 68 }
75 69
@@ -74,25 +68,24 @@
74 68 }
75 69
76 70 $matching_addon = $this->matching_addon( $addon_list, $normalized_term );
77 71
78 - if ( ! $matching_addon || ! $this->should_display_hint( $matching_addon ) ) {
72 + if ( empty( $matching_addon ) || ! $this->should_display_hint( $matching_addon ) ) {
79 73 return $result;
80 74 }
81 75
82 76 $inject = (array) $this->get_plugin_data();
83 77 $overrides = array(
84 - // Helps to determine if that an injected card.
85 - 'plugin-search' => true,
86 - 'name' => sprintf(
78 + 'plugin-search' => true, // Helps to determine if that an injected card.
79 + 'name' => sprintf(
87 80 /* translators: Formidable addon name */
88 81 esc_html_x( 'Formidable %s', 'Formidable Addon Name', 'formidable' ),
89 82 $addon_list[ $matching_addon ]['name']
90 83 ),
91 - 'addon' => $addon_list[ $matching_addon ]['slug'],
92 - 'short_description' => $addon_list[ $matching_addon ]['excerpt'],
93 - 'slug' => self::$slug,
94 - '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'],
95 88 );
96 89
97 90 if ( ! empty( $addon_list[ $matching_addon ]['external'] ) ) {
98 91 unset( $overrides['name'] );
@@ -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;
@@ -187,12 +181,12 @@
187 181
188 182 /**
189 183 * Modify URL used to fetch to plugin information so it pulls Formidable plugin page.
190 184 *
185 + * @param string $url URL to load in dialog pulling the plugin page from wporg.
186 + *
191 187 * @since 4.12
192 188 *
193 - * @param string $url URL to load in dialog pulling the plugin page from wporg.
194 - *
195 189 * @return string The URL with 'formidable' instead of 'frm-plugin-search'.
196 190 */
197 191 public function plugin_details( $url ) {
198 192 return false !== stripos( $url, 'tab=plugin-information&plugin=' . self::$slug )
@@ -206,10 +200,9 @@
206 200 * @return void
207 201 */
208 202 private function maybe_dismiss() {
209 203 $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' );
210 -
211 - if ( $addon ) {
204 + if ( ! empty( $addon ) ) {
212 205 $this->add_to_dismissed_hints( $addon );
213 206 }
214 207 }
215 208
@@ -221,9 +214,9 @@
221 214 * @return array List of dismissed hints.
222 215 */
223 216 protected function get_dismissed_hints() {
224 217 $dismissed_hints = get_option( self::$dismissed_opt );
225 - return $dismissed_hints && is_array( $dismissed_hints ) ? $dismissed_hints : array();
218 + return ! empty( $dismissed_hints ) && is_array( $dismissed_hints ) ? $dismissed_hints : array();
226 219 }
227 220
228 221 /**
229 222 * Save the hint in the list of dismissed hints.
@@ -265,9 +258,8 @@
265 258 * Take a raw search query and return something a bit more standardized and
266 259 * easy to work with.
267 260 *
268 261 * @param string $term The raw search term.
269 - *
270 262 * @return string A simplified/sanitized version.
271 263 */
272 264 private function sanitize_search_term( $term ) {
273 265 $term = strtolower( urldecode( $term ) );
@@ -275,9 +267,11 @@
275 267 // remove non-alpha/space chars.
276 268 $term = preg_replace( '/[^a-z ]/', '', $term );
277 269
278 270 // remove strings that don't help matches.
279 - return trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
271 + $term = trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
272 +
273 + return $term;
280 274 }
281 275
282 276 /**
283 277 * @since 4.12
@@ -282,9 +276,8 @@
282 276 /**
283 277 * @since 4.12
284 278 *
285 279 * @param string $terms
286 - *
287 280 * @return array
288 281 */
289 282 private function search_to_array( $terms ) {
290 283 $terms = $this->sanitize_search_term( $terms );
@@ -306,9 +299,9 @@
306 299
307 300 // By the time this filter is applied, self_admin_url was already applied and we don't need it anymore.
308 301 remove_filter( 'self_admin_url', array( $this, 'plugin_details' ) );
309 302
310 - $links = array();
303 + $links = array();
311 304 $is_installed = $this->is_installed( $plugin['plugin'] );
312 305 $is_active = is_plugin_active( $plugin['plugin'] );
313 306
314 307 // Plugin installed, active, feature not enabled; prompt to enable.
@@ -313,17 +306,17 @@
313 306
314 307 // Plugin installed, active, feature not enabled; prompt to enable.
315 308 if ( ! $is_active && $is_installed ) {
316 309 if ( current_user_can( 'activate_plugins' ) ) {
317 - $activate_url = add_query_arg(
310 + $activate_url = add_query_arg(
318 311 array(
319 - 'action' => 'activate',
312 + 'action' => 'activate',
320 313 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin['plugin'] ),
321 314 'plugin' => $plugin['plugin'],
322 315 ),
323 316 admin_url( 'plugins.php' )
324 317 );
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
318 + $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 319 }
327 320 } elseif ( ! $is_active && isset( $plugin['url'] ) ) {
328 321 // Go to the add-ons page to install.
329 322 $links[] = '<a
@@ -338,9 +331,9 @@
338 331 href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-learn-more', $plugin['link'] ) ) . '"
339 332 target="_blank"
340 333 data-addon="' . esc_attr( $plugin['addon'] ) . '"
341 334 >' . esc_html__( 'Learn more', 'formidable' ) . '</a>';
342 - }//end if
335 + }
343 336
344 337 // Dismiss link.
345 338 $dismiss = add_query_arg( array( 'frm-dismiss' => $plugin['id'] ) );
346 339 $links[] = '<a
@@ -353,9 +346,8 @@
353 346 }
354 347
355 348 /**
356 349 * @param string $plugin
357 - *
358 350 * @return bool
359 351 */
360 352 protected function is_installed( $plugin ) {
361 353 $all_plugins = FrmAppHelper::get_plugins();