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 +22 -34 6.326.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 */
@@ -33,17 +32,15 @@
33 32 * @return void
34 33 */
35 34 public function start( $screen ) {
36 35 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
37 - if ( 'plugin-install' !== $screen->base || ( isset( $_GET['paged'] ) && 1 !== intval( $_GET['paged'] ) ) ) {
38 - return;
36 + if ( 'plugin-install' === $screen->base && ( ! isset( $_GET['paged'] ) || 1 === intval( $_GET['paged'] ) ) ) {
37 + add_filter( 'plugins_api_result', array( $this, 'inject_suggestion' ), 10, 3 );
38 + add_filter( 'self_admin_url', array( $this, 'plugin_details' ) );
39 + add_filter( 'plugin_install_action_links', array( $this, 'insert_related_links' ), 10, 2 );
40 + add_action( 'admin_enqueue_scripts', array( $this, 'load_plugins_search_script' ) );
41 + $this->maybe_dismiss();
39 42 }
40 -
41 - add_filter( 'plugins_api_result', array( $this, 'inject_suggestion' ), 10, 3 );
42 - add_filter( 'self_admin_url', array( $this, 'plugin_details' ) );
43 - add_filter( 'plugin_install_action_links', array( $this, 'insert_related_links' ), 10, 2 );
44 - add_action( 'admin_enqueue_scripts', array( $this, 'load_plugins_search_script' ) );
45 - $this->maybe_dismiss();
46 43 }
47 44
48 45 /**
49 46 * Intercept the plugins API response and add in an appropriate card.
@@ -59,19 +56,13 @@
59 56 if ( empty( $args->search ) ) {
60 57 return $result;
61 58 }
62 59
63 - if ( is_wp_error( $result ) ) {
64 - // This may happen if the request failed due to an internet connection issue.
65 - return $result;
66 - }
67 -
68 60 $addon_list = $this->get_addons();
69 61
70 62 // Lowercase, trim, remove punctuation/special chars, decode url, remove 'formidable'.
71 63 $normalized_term = $this->search_to_array( $args->search );
72 -
73 - if ( ! $normalized_term ) {
64 + if ( empty( $normalized_term ) ) {
74 65 // Don't add anything extra.
75 66 return $result;
76 67 }
77 68
@@ -76,9 +67,9 @@
76 67 }
77 68
78 69 $matching_addon = $this->matching_addon( $addon_list, $normalized_term );
79 70
80 - if ( ! $matching_addon || ! $this->should_display_hint( $matching_addon ) ) {
71 + if ( empty( $matching_addon ) || ! $this->should_display_hint( $matching_addon ) ) {
81 72 return $result;
82 73 }
83 74
84 75 $inject = (array) $this->get_plugin_data();
@@ -131,9 +122,10 @@
131 122 if ( ! isset( $addon_opts['search_terms'] ) ) {
132 123 $addon_opts['search_terms'] = '';
133 124 }
134 125
135 - $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 +
136 128 $matched_terms = array_intersect( $addon_terms, $normalized_term );
137 129
138 130 if ( count( $matched_terms ) === count( $normalized_term ) ) {
139 131 $matching_addon = $addon_id;
@@ -190,19 +182,16 @@
190 182 /**
191 183 * Modify URL used to fetch to plugin information so it pulls Formidable plugin page.
192 184 *
193 185 * @since 4.12
194 - *
195 186 * @param string $url URL to load in dialog pulling the plugin page from wporg.
196 187 *
197 188 * @return string The URL with 'formidable' instead of 'frm-plugin-search'.
198 189 */
199 190 public function plugin_details( $url ) {
200 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
201 191 return false !== stripos( $url, 'tab=plugin-information&plugin=' . self::$slug )
202 192 ? 'plugin-install.php?tab=plugin-information&plugin=formidable&TB_iframe=true&width=600&height=550'
203 193 : $url;
204 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
205 194 }
206 195
207 196 /**
208 197 * @since 4.12
@@ -210,10 +199,9 @@
210 199 * @return void
211 200 */
212 201 private function maybe_dismiss() {
213 202 $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' );
214 -
215 - if ( $addon ) {
203 + if ( ! empty( $addon ) ) {
216 204 $this->add_to_dismissed_hints( $addon );
217 205 }
218 206 }
219 207
@@ -225,9 +213,9 @@
225 213 * @return array List of dismissed hints.
226 214 */
227 215 protected function get_dismissed_hints() {
228 216 $dismissed_hints = get_option( self::$dismissed_opt );
229 - return $dismissed_hints && is_array( $dismissed_hints ) ? $dismissed_hints : array();
217 + return ! empty( $dismissed_hints ) && is_array( $dismissed_hints ) ? $dismissed_hints : array();
230 218 }
231 219
232 220 /**
233 221 * Save the hint in the list of dismissed hints.
@@ -239,9 +227,9 @@
239 227 * @return bool Whether the card was added to the list and hence dismissed.
240 228 */
241 229 protected function add_to_dismissed_hints( $hint ) {
242 230 $hints = array_merge( $this->get_dismissed_hints(), array( $hint ) );
243 - return update_option( self::$dismissed_opt, $hints, false );
231 + return update_option( self::$dismissed_opt, $hints, 'no' );
244 232 }
245 233
246 234 /**
247 235 * Checks that the addon slug passed should be displayed.
@@ -269,19 +257,20 @@
269 257 * Take a raw search query and return something a bit more standardized and
270 258 * easy to work with.
271 259 *
272 260 * @param string $term The raw search term.
273 - *
274 261 * @return string A simplified/sanitized version.
275 262 */
276 263 private function sanitize_search_term( $term ) {
277 264 $term = strtolower( urldecode( $term ) );
278 265
279 - // Remove non-alpha/space chars.
266 + // remove non-alpha/space chars.
280 267 $term = preg_replace( '/[^a-z ]/', '', $term );
281 268
282 - // Remove strings that don't help matches.
283 - 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;
284 273 }
285 274
286 275 /**
287 276 * @since 4.12
@@ -286,9 +275,8 @@
286 275 /**
287 276 * @since 4.12
288 277 *
289 278 * @param string $terms
290 - *
291 279 * @return array
292 280 */
293 281 private function search_to_array( $terms ) {
294 282 $terms = $this->sanitize_search_term( $terms );
@@ -325,9 +313,9 @@
325 313 'plugin' => $plugin['plugin'],
326 314 ),
327 315 admin_url( 'plugins.php' )
328 316 );
329 - $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>';
330 318 }
331 319 } elseif ( ! $is_active && isset( $plugin['url'] ) ) {
332 320 // Go to the add-ons page to install.
333 321 $links[] = '<a
@@ -332,9 +320,10 @@
332 320 // Go to the add-ons page to install.
333 321 $links[] = '<a
334 322 class="button-secondary"
335 323 href="' . esc_url( admin_url( 'admin.php?page=formidable-addons' ) ) . '"
336 - >' . esc_html__( 'Install Now', 'formidable' ) . '</a>';
324 + >' . __( 'Install Now', 'formidable' ) . '</a>';
325 +
337 326 } elseif ( ! empty( $plugin['link'] ) ) {
338 327 // Add link pointing to a relevant doc page in formidable.com.
339 328 $links[] = '<a
340 329 class="button-primary frm-plugin-search__learn-more"
@@ -346,9 +335,9 @@
346 335
347 336 // Dismiss link.
348 337 $dismiss = add_query_arg( array( 'frm-dismiss' => $plugin['id'] ) );
349 338 $links[] = '<a
350 - href="' . esc_url( $dismiss ) . '"
339 + href="' . $dismiss . '"
351 340 class="frm-plugin-search__dismiss"
352 341 data-addon="' . esc_attr( $plugin['addon'] ) . '"
353 342 >' . esc_html__( 'Hide this suggestion', 'formidable' ) . '</a>';
354 343
@@ -356,9 +345,8 @@
356 345 }
357 346
358 347 /**
359 348 * @param string $plugin
360 - *
361 349 * @return bool
362 350 */
363 351 protected function is_installed( $plugin ) {
364 352 $all_plugins = FrmAppHelper::get_plugins();