PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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 +27 -35 6.286.8 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,9 +68,9 @@
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();
@@ -82,17 +76,17 @@
82 76 $inject = (array) $this->get_plugin_data();
83 77 $overrides = array(
84 78 // Helps to determine if that an injected card.
85 79 'plugin-search' => true,
86 - 'name' => sprintf(
80 + 'name' => sprintf(
87 81 /* translators: Formidable addon name */
88 82 esc_html_x( 'Formidable %s', 'Formidable Addon Name', 'formidable' ),
89 83 $addon_list[ $matching_addon ]['name']
90 84 ),
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'],
85 + 'addon' => $addon_list[ $matching_addon ]['slug'],
86 + 'short_description' => $addon_list[ $matching_addon ]['excerpt'],
87 + 'slug' => self::$slug,
88 + 'version' => $addon_list[ $matching_addon ]['version'],
95 89 );
96 90
97 91 if ( ! empty( $addon_list[ $matching_addon ]['external'] ) ) {
98 92 unset( $overrides['name'] );
@@ -129,9 +123,10 @@
129 123 if ( ! isset( $addon_opts['search_terms'] ) ) {
130 124 $addon_opts['search_terms'] = '';
131 125 }
132 126
133 - $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
127 + $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
128 +
134 129 $matched_terms = array_intersect( $addon_terms, $normalized_term );
135 130
136 131 if ( count( $matched_terms ) === count( $normalized_term ) ) {
137 132 $matching_addon = $addon_id;
@@ -187,20 +182,18 @@
187 182
188 183 /**
189 184 * Modify URL used to fetch to plugin information so it pulls Formidable plugin page.
190 185 *
186 + * @param string $url URL to load in dialog pulling the plugin page from wporg.
187 + *
191 188 * @since 4.12
192 189 *
193 - * @param string $url URL to load in dialog pulling the plugin page from wporg.
194 - *
195 190 * @return string The URL with 'formidable' instead of 'frm-plugin-search'.
196 191 */
197 192 public function plugin_details( $url ) {
198 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
199 193 return false !== stripos( $url, 'tab=plugin-information&plugin=' . self::$slug )
200 194 ? 'plugin-install.php?tab=plugin-information&plugin=formidable&TB_iframe=true&width=600&height=550'
201 195 : $url;
202 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
203 196 }
204 197
205 198 /**
206 199 * @since 4.12
@@ -208,10 +201,9 @@
208 201 * @return void
209 202 */
210 203 private function maybe_dismiss() {
211 204 $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' );
212 -
213 - if ( $addon ) {
205 + if ( ! empty( $addon ) ) {
214 206 $this->add_to_dismissed_hints( $addon );
215 207 }
216 208 }
217 209
@@ -223,9 +215,9 @@
223 215 * @return array List of dismissed hints.
224 216 */
225 217 protected function get_dismissed_hints() {
226 218 $dismissed_hints = get_option( self::$dismissed_opt );
227 - return $dismissed_hints && is_array( $dismissed_hints ) ? $dismissed_hints : array();
219 + return ! empty( $dismissed_hints ) && is_array( $dismissed_hints ) ? $dismissed_hints : array();
228 220 }
229 221
230 222 /**
231 223 * Save the hint in the list of dismissed hints.
@@ -237,9 +229,9 @@
237 229 * @return bool Whether the card was added to the list and hence dismissed.
238 230 */
239 231 protected function add_to_dismissed_hints( $hint ) {
240 232 $hints = array_merge( $this->get_dismissed_hints(), array( $hint ) );
241 - return update_option( self::$dismissed_opt, $hints, false );
233 + return update_option( self::$dismissed_opt, $hints, 'no' );
242 234 }
243 235
244 236 /**
245 237 * Checks that the addon slug passed should be displayed.
@@ -267,19 +259,20 @@
267 259 * Take a raw search query and return something a bit more standardized and
268 260 * easy to work with.
269 261 *
270 262 * @param string $term The raw search term.
271 - *
272 263 * @return string A simplified/sanitized version.
273 264 */
274 265 private function sanitize_search_term( $term ) {
275 266 $term = strtolower( urldecode( $term ) );
276 267
277 - // Remove non-alpha/space chars.
268 + // remove non-alpha/space chars.
278 269 $term = preg_replace( '/[^a-z ]/', '', $term );
279 270
280 - // Remove strings that don't help matches.
281 - return trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
271 + // remove strings that don't help matches.
272 + $term = trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
273 +
274 + return $term;
282 275 }
283 276
284 277 /**
285 278 * @since 4.12
@@ -284,9 +277,8 @@
284 277 /**
285 278 * @since 4.12
286 279 *
287 280 * @param string $terms
288 - *
289 281 * @return array
290 282 */
291 283 private function search_to_array( $terms ) {
292 284 $terms = $this->sanitize_search_term( $terms );
@@ -308,9 +300,9 @@
308 300
309 301 // By the time this filter is applied, self_admin_url was already applied and we don't need it anymore.
310 302 remove_filter( 'self_admin_url', array( $this, 'plugin_details' ) );
311 303
312 - $links = array();
304 + $links = array();
313 305 $is_installed = $this->is_installed( $plugin['plugin'] );
314 306 $is_active = is_plugin_active( $plugin['plugin'] );
315 307
316 308 // Plugin installed, active, feature not enabled; prompt to enable.
@@ -315,17 +307,17 @@
315 307
316 308 // Plugin installed, active, feature not enabled; prompt to enable.
317 309 if ( ! $is_active && $is_installed ) {
318 310 if ( current_user_can( 'activate_plugins' ) ) {
319 - $activate_url = add_query_arg(
311 + $activate_url = add_query_arg(
320 312 array(
321 - 'action' => 'activate',
313 + 'action' => 'activate',
322 314 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin['plugin'] ),
323 315 'plugin' => $plugin['plugin'],
324 316 ),
325 317 admin_url( 'plugins.php' )
326 318 );
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
319 + $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 320 }
329 321 } elseif ( ! $is_active && isset( $plugin['url'] ) ) {
330 322 // Go to the add-ons page to install.
331 323 $links[] = '<a
@@ -330,9 +322,10 @@
330 322 // Go to the add-ons page to install.
331 323 $links[] = '<a
332 324 class="button-secondary"
333 325 href="' . esc_url( admin_url( 'admin.php?page=formidable-addons' ) ) . '"
334 - >' . esc_html__( 'Install Now', 'formidable' ) . '</a>';
326 + >' . __( 'Install Now', 'formidable' ) . '</a>';
327 +
335 328 } elseif ( ! empty( $plugin['link'] ) ) {
336 329 // Add link pointing to a relevant doc page in formidable.com.
337 330 $links[] = '<a
338 331 class="button-primary frm-plugin-search__learn-more"
@@ -354,9 +347,8 @@
354 347 }
355 348
356 349 /**
357 350 * @param string $plugin
358 - *
359 351 * @return bool
360 352 */
361 353 protected function is_installed( $plugin ) {
362 354 $all_plugins = FrmAppHelper::get_plugins();