PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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 +15 -25 6.286.13 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,19 +182,16 @@
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 */
197 190 public function plugin_details( $url ) {
198 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
199 191 return false !== stripos( $url, 'tab=plugin-information&plugin=' . self::$slug )
200 192 ? 'plugin-install.php?tab=plugin-information&plugin=formidable&TB_iframe=true&width=600&height=550'
201 193 : $url;
202 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
203 194 }
204 195
205 196 /**
206 197 * @since 4.12
@@ -208,10 +199,9 @@
208 199 * @return void
209 200 */
210 201 private function maybe_dismiss() {
211 202 $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' );
212 -
213 - if ( $addon ) {
203 + if ( ! empty( $addon ) ) {
214 204 $this->add_to_dismissed_hints( $addon );
215 205 }
216 206 }
217 207
@@ -223,9 +213,9 @@
223 213 * @return array List of dismissed hints.
224 214 */
225 215 protected function get_dismissed_hints() {
226 216 $dismissed_hints = get_option( self::$dismissed_opt );
227 - return $dismissed_hints && is_array( $dismissed_hints ) ? $dismissed_hints : array();
217 + return ! empty( $dismissed_hints ) && is_array( $dismissed_hints ) ? $dismissed_hints : array();
228 218 }
229 219
230 220 /**
231 221 * Save the hint in the list of dismissed hints.
@@ -237,9 +227,9 @@
237 227 * @return bool Whether the card was added to the list and hence dismissed.
238 228 */
239 229 protected function add_to_dismissed_hints( $hint ) {
240 230 $hints = array_merge( $this->get_dismissed_hints(), array( $hint ) );
241 - return update_option( self::$dismissed_opt, $hints, false );
231 + return update_option( self::$dismissed_opt, $hints, 'no' );
242 232 }
243 233
244 234 /**
245 235 * Checks that the addon slug passed should be displayed.
@@ -267,19 +257,20 @@
267 257 * Take a raw search query and return something a bit more standardized and
268 258 * easy to work with.
269 259 *
270 260 * @param string $term The raw search term.
271 - *
272 261 * @return string A simplified/sanitized version.
273 262 */
274 263 private function sanitize_search_term( $term ) {
275 264 $term = strtolower( urldecode( $term ) );
276 265
277 - // Remove non-alpha/space chars.
266 + // remove non-alpha/space chars.
278 267 $term = preg_replace( '/[^a-z ]/', '', $term );
279 268
280 - // Remove strings that don't help matches.
281 - return trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
269 + // remove strings that don't help matches.
270 + $term = trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
271 +
272 + return $term;
282 273 }
283 274
284 275 /**
285 276 * @since 4.12
@@ -284,9 +275,8 @@
284 275 /**
285 276 * @since 4.12
286 277 *
287 278 * @param string $terms
288 - *
289 279 * @return array
290 280 */
291 281 private function search_to_array( $terms ) {
292 282 $terms = $this->sanitize_search_term( $terms );
@@ -323,9 +313,9 @@
323 313 'plugin' => $plugin['plugin'],
324 314 ),
325 315 admin_url( 'plugins.php' )
326 316 );
327 - $links['frm_get_started'] = '<a href="' . esc_url( $activate_url ) . '" class="button activate-now" aria-label="Activate ' . esc_attr( $plugin['name'] ) . '">' . esc_html__( '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>';
328 318 }
329 319 } elseif ( ! $is_active && isset( $plugin['url'] ) ) {
330 320 // Go to the add-ons page to install.
331 321 $links[] = '<a
@@ -330,9 +320,10 @@
330 320 // Go to the add-ons page to install.
331 321 $links[] = '<a
332 322 class="button-secondary"
333 323 href="' . esc_url( admin_url( 'admin.php?page=formidable-addons' ) ) . '"
334 - >' . esc_html__( 'Install Now', 'formidable' ) . '</a>';
324 + >' . __( 'Install Now', 'formidable' ) . '</a>';
325 +
335 326 } elseif ( ! empty( $plugin['link'] ) ) {
336 327 // Add link pointing to a relevant doc page in formidable.com.
337 328 $links[] = '<a
338 329 class="button-primary frm-plugin-search__learn-more"
@@ -354,9 +345,8 @@
354 345 }
355 346
356 347 /**
357 348 * @param string $plugin
358 - *
359 349 * @return bool
360 350 */
361 351 protected function is_installed( $plugin ) {
362 352 $all_plugins = FrmAppHelper::get_plugins();