PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.4
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 +17 -29 6.35.4 View file →
@@ -28,10 +28,8 @@
28 28 *
29 29 * @param object $screen WP Screen object.
30 30 *
31 31 * @since 4.12
32 - *
33 - * @return void
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 ) ) {
@@ -86,12 +82,8 @@
86 82 'slug' => self::$slug,
87 83 'version' => $addon_list[ $matching_addon ]['version'],
88 84 );
89 85
90 - if ( ! empty( $addon_list[ $matching_addon ]['external'] ) ) {
91 - unset( $overrides['name'] );
92 - }
93 -
94 86 // Splice in the base addon data.
95 87 $inject = array_merge( $inject, $addon_list[ $matching_addon ], $overrides );
96 88
97 89 // Add it to the top of the list.
@@ -104,12 +96,9 @@
104 96 * Search for any addons that match the searched terms.
105 97 *
106 98 * @since 4.12
107 99 *
108 - * @param array $addon_list
109 - * @param array $normalized_term
110 - *
111 - * @return int|null
100 + * @return int
112 101 */
113 102 private function matching_addon( $addon_list, $normalized_term ) {
114 103 $matching_addon = null;
115 104
@@ -118,17 +107,22 @@
118 107 if ( ! is_array( $addon_opts ) || empty( $addon_opts['excerpt'] ) ) {
119 108 continue;
120 109 }
121 110
111 + /*
112 + * Does the site's current plan support the feature?
113 + */
114 + $is_supported_by_plan = ! empty( $addon_opts['url'] );
115 +
122 116 if ( ! isset( $addon_opts['search_terms'] ) ) {
123 117 $addon_opts['search_terms'] = '';
124 118 }
125 119
126 - $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
120 + $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ', ' . $addon_opts['name'] );
127 121
128 122 $matches = ! empty( array_intersect( $addon_terms, $normalized_term ) );
129 123
130 - if ( $matches ) {
124 + if ( $matches && $is_supported_by_plan ) {
131 125 $matching_addon = $addon_id;
132 126 break;
133 127 }
134 128 }
@@ -142,10 +136,9 @@
142 136 * @return array
143 137 */
144 138 private function get_addons() {
145 139 $api = new FrmFormApi();
146 - $addons = $api->get_api_info();
147 - return apply_filters( 'frm_plugin_search', $addons );
140 + return $api->get_api_info();
148 141 }
149 142
150 143 /**
151 144 * Get the plugin repo's data to populate the fields with.
@@ -195,10 +188,8 @@
195 188 }
196 189
197 190 /**
198 191 * @since 4.12
199 - *
200 - * @return void
201 192 */
202 193 private function maybe_dismiss() {
203 194 $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' );
204 195 if ( ! empty( $addon ) ) {
@@ -275,14 +266,13 @@
275 266
276 267 /**
277 268 * @since 4.12
278 269 *
279 - * @param string $terms
280 270 * @return array
281 271 */
282 272 private function search_to_array( $terms ) {
283 273 $terms = $this->sanitize_search_term( $terms );
284 - return array_filter( explode( ' ', $terms ) );
274 + return array_filter( explode( ',', $terms ) );
285 275 }
286 276
287 277 /**
288 278 * Put some more appropriate links on our custom result cards.
@@ -288,10 +278,8 @@
288 278 * Put some more appropriate links on our custom result cards.
289 279 *
290 280 * @param array $links Related links.
291 281 * @param array $plugin Plugin result information.
292 - *
293 - * @return array
294 282 */
295 283 public function insert_related_links( $links, $plugin ) {
296 284 if ( self::$slug !== $plugin['slug'] ) {
297 285 return $links;
@@ -302,8 +290,9 @@
302 290
303 291 $links = array();
304 292 $is_installed = $this->is_installed( $plugin['plugin'] );
305 293 $is_active = is_plugin_active( $plugin['plugin'] );
294 + $has_access = ! empty( $plugin['url'] );
306 295
307 296 // Plugin installed, active, feature not enabled; prompt to enable.
308 297 if ( ! $is_active && $is_installed ) {
309 298 if ( current_user_can( 'activate_plugins' ) ) {
@@ -344,21 +333,20 @@
344 333
345 334 return $links;
346 335 }
347 336
348 - /**
349 - * @param string $plugin
350 - * @return bool
351 - */
352 337 protected function is_installed( $plugin ) {
353 - $all_plugins = FrmAppHelper::get_plugins();
338 + if ( ! function_exists( 'get_plugins' ) ) {
339 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
340 + }
341 +
342 + $all_plugins = get_plugins();
343 +
354 344 return isset( $all_plugins[ $plugin ] );
355 345 }
356 346
357 347 /**
358 348 * Load the search scripts and CSS for PSH.
359 - *
360 - * @return void
361 349 */
362 350 public function load_plugins_search_script() {
363 351 wp_enqueue_script( self::$slug, FrmAppHelper::plugin_url() . '/js/plugin-search.js', array(), FrmAppHelper::plugin_version(), true );
364 352 wp_localize_script(