PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.0
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 +16 -41 6.266.0 View file →
@@ -25,13 +25,11 @@
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 - * @since 4.12
30 - *
31 29 * @param object $screen WP Screen object.
32 30 *
33 - * @return void
31 + * @since 4.12
34 32 */
35 33 public function start( $screen ) {
36 34 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
37 35 if ( 'plugin-install' === $screen->base && ( ! isset( $_GET['paged'] ) || 1 === intval( $_GET['paged'] ) ) ) {
@@ -48,10 +46,8 @@
48 46 *
49 47 * @param object $result Plugin search results.
50 48 * @param string $action unused.
51 49 * @param object $args Search args.
52 - *
53 - * @return object
54 50 */
55 51 public function inject_suggestion( $result, $action, $args ) {
56 52 // Looks like a search query; it's matching time.
57 53 if ( empty( $args->search ) ) {
@@ -57,18 +53,12 @@
57 53 if ( empty( $args->search ) ) {
58 54 return $result;
59 55 }
60 56
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 57 $addon_list = $this->get_addons();
67 58
68 59 // Lowercase, trim, remove punctuation/special chars, decode url, remove 'formidable'.
69 60 $normalized_term = $this->search_to_array( $args->search );
70 -
71 61 if ( empty( $normalized_term ) ) {
72 62 // Don't add anything extra.
73 63 return $result;
74 64 }
@@ -80,19 +70,18 @@
80 70 }
81 71
82 72 $inject = (array) $this->get_plugin_data();
83 73 $overrides = array(
84 - // Helps to determine if that an injected card.
85 - 'plugin-search' => true,
86 - 'name' => sprintf(
74 + 'plugin-search' => true, // Helps to determine if that an injected card.
75 + 'name' => sprintf(
87 76 /* translators: Formidable addon name */
88 77 esc_html_x( 'Formidable %s', 'Formidable Addon Name', 'formidable' ),
89 78 $addon_list[ $matching_addon ]['name']
90 79 ),
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'],
80 + 'addon' => $addon_list[ $matching_addon ]['slug'],
81 + 'short_description' => $addon_list[ $matching_addon ]['excerpt'],
82 + 'slug' => self::$slug,
83 + 'version' => $addon_list[ $matching_addon ]['version'],
95 84 );
96 85
97 86 if ( ! empty( $addon_list[ $matching_addon ]['external'] ) ) {
98 87 unset( $overrides['name'] );
@@ -111,12 +100,9 @@
111 100 * Search for any addons that match the searched terms.
112 101 *
113 102 * @since 4.12
114 103 *
115 - * @param array $addon_list
116 - * @param array $normalized_term
117 - *
118 - * @return int|null
104 + * @return int
119 105 */
120 106 private function matching_addon( $addon_list, $normalized_term ) {
121 107 $matching_addon = null;
122 108
@@ -131,11 +117,11 @@
131 117 }
132 118
133 119 $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
134 120
135 - $matched_terms = array_intersect( $addon_terms, $normalized_term );
121 + $matches = ! empty( array_intersect( $addon_terms, $normalized_term ) );
136 122
137 - if ( count( $matched_terms ) === count( $normalized_term ) ) {
123 + if ( $matches ) {
138 124 $matching_addon = $addon_id;
139 125 break;
140 126 }
141 127 }
@@ -188,12 +174,12 @@
188 174
189 175 /**
190 176 * Modify URL used to fetch to plugin information so it pulls Formidable plugin page.
191 177 *
178 + * @param string $url URL to load in dialog pulling the plugin page from wporg.
179 + *
192 180 * @since 4.12
193 181 *
194 - * @param string $url URL to load in dialog pulling the plugin page from wporg.
195 - *
196 182 * @return string The URL with 'formidable' instead of 'frm-plugin-search'.
197 183 */
198 184 public function plugin_details( $url ) {
199 185 return false !== stripos( $url, 'tab=plugin-information&plugin=' . self::$slug )
@@ -202,14 +188,11 @@
202 188 }
203 189
204 190 /**
205 191 * @since 4.12
206 - *
207 - * @return void
208 192 */
209 193 private function maybe_dismiss() {
210 194 $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' );
211 -
212 195 if ( ! empty( $addon ) ) {
213 196 $this->add_to_dismissed_hints( $addon );
214 197 }
215 198 }
@@ -266,9 +249,8 @@
266 249 * Take a raw search query and return something a bit more standardized and
267 250 * easy to work with.
268 251 *
269 252 * @param string $term The raw search term.
270 - *
271 253 * @return string A simplified/sanitized version.
272 254 */
273 255 private function sanitize_search_term( $term ) {
274 256 $term = strtolower( urldecode( $term ) );
@@ -284,10 +266,8 @@
284 266
285 267 /**
286 268 * @since 4.12
287 269 *
288 - * @param string $terms
289 - *
290 270 * @return array
291 271 */
292 272 private function search_to_array( $terms ) {
293 273 $terms = $this->sanitize_search_term( $terms );
@@ -298,10 +278,8 @@
298 278 * Put some more appropriate links on our custom result cards.
299 279 *
300 280 * @param array $links Related links.
301 281 * @param array $plugin Plugin result information.
302 - *
303 - * @return array
304 282 */
305 283 public function insert_related_links( $links, $plugin ) {
306 284 if ( self::$slug !== $plugin['slug'] ) {
307 285 return $links;
@@ -309,9 +287,9 @@
309 287
310 288 // By the time this filter is applied, self_admin_url was already applied and we don't need it anymore.
311 289 remove_filter( 'self_admin_url', array( $this, 'plugin_details' ) );
312 290
313 - $links = array();
291 + $links = array();
314 292 $is_installed = $this->is_installed( $plugin['plugin'] );
315 293 $is_active = is_plugin_active( $plugin['plugin'] );
316 294
317 295 // Plugin installed, active, feature not enabled; prompt to enable.
@@ -316,11 +294,11 @@
316 294
317 295 // Plugin installed, active, feature not enabled; prompt to enable.
318 296 if ( ! $is_active && $is_installed ) {
319 297 if ( current_user_can( 'activate_plugins' ) ) {
320 - $activate_url = add_query_arg(
298 + $activate_url = add_query_arg(
321 299 array(
322 - 'action' => 'activate',
300 + 'action' => 'activate',
323 301 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin['plugin'] ),
324 302 'plugin' => $plugin['plugin'],
325 303 ),
326 304 admin_url( 'plugins.php' )
@@ -341,9 +319,9 @@
341 319 href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-learn-more', $plugin['link'] ) ) . '"
342 320 target="_blank"
343 321 data-addon="' . esc_attr( $plugin['addon'] ) . '"
344 322 >' . esc_html__( 'Learn more', 'formidable' ) . '</a>';
345 - }//end if
323 + }
346 324
347 325 // Dismiss link.
348 326 $dismiss = add_query_arg( array( 'frm-dismiss' => $plugin['id'] ) );
349 327 $links[] = '<a
@@ -356,9 +334,8 @@
356 334 }
357 335
358 336 /**
359 337 * @param string $plugin
360 - *
361 338 * @return bool
362 339 */
363 340 protected function is_installed( $plugin ) {
364 341 $all_plugins = FrmAppHelper::get_plugins();
@@ -366,10 +343,8 @@
366 343 }
367 344
368 345 /**
369 346 * Load the search scripts and CSS for PSH.
370 - *
371 - * @return void
372 347 */
373 348 public function load_plugins_search_script() {
374 349 wp_enqueue_script( self::$slug, FrmAppHelper::plugin_url() . '/js/plugin-search.js', array(), FrmAppHelper::plugin_version(), true );
375 350 wp_localize_script(