PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24
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 -20 6.286.24 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 */
@@ -66,10 +65,9 @@
66 65 $addon_list = $this->get_addons();
67 66
68 67 // Lowercase, trim, remove punctuation/special chars, decode url, remove 'formidable'.
69 68 $normalized_term = $this->search_to_array( $args->search );
70 -
71 - if ( ! $normalized_term ) {
69 + if ( empty( $normalized_term ) ) {
72 70 // Don't add anything extra.
73 71 return $result;
74 72 }
75 73
@@ -74,9 +72,9 @@
74 72 }
75 73
76 74 $matching_addon = $this->matching_addon( $addon_list, $normalized_term );
77 75
78 - if ( ! $matching_addon || ! $this->should_display_hint( $matching_addon ) ) {
76 + if ( empty( $matching_addon ) || ! $this->should_display_hint( $matching_addon ) ) {
79 77 return $result;
80 78 }
81 79
82 80 $inject = (array) $this->get_plugin_data();
@@ -129,9 +127,10 @@
129 127 if ( ! isset( $addon_opts['search_terms'] ) ) {
130 128 $addon_opts['search_terms'] = '';
131 129 }
132 130
133 - $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
131 + $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
132 +
134 133 $matched_terms = array_intersect( $addon_terms, $normalized_term );
135 134
136 135 if ( count( $matched_terms ) === count( $normalized_term ) ) {
137 136 $matching_addon = $addon_id;
@@ -188,19 +187,16 @@
188 187 /**
189 188 * Modify URL used to fetch to plugin information so it pulls Formidable plugin page.
190 189 *
191 190 * @since 4.12
192 - *
193 191 * @param string $url URL to load in dialog pulling the plugin page from wporg.
194 192 *
195 193 * @return string The URL with 'formidable' instead of 'frm-plugin-search'.
196 194 */
197 195 public function plugin_details( $url ) {
198 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
199 196 return false !== stripos( $url, 'tab=plugin-information&plugin=' . self::$slug )
200 197 ? 'plugin-install.php?tab=plugin-information&plugin=formidable&TB_iframe=true&width=600&height=550'
201 198 : $url;
202 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
203 199 }
204 200
205 201 /**
206 202 * @since 4.12
@@ -208,10 +204,9 @@
208 204 * @return void
209 205 */
210 206 private function maybe_dismiss() {
211 207 $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' );
212 -
213 - if ( $addon ) {
208 + if ( ! empty( $addon ) ) {
214 209 $this->add_to_dismissed_hints( $addon );
215 210 }
216 211 }
217 212
@@ -223,9 +218,9 @@
223 218 * @return array List of dismissed hints.
224 219 */
225 220 protected function get_dismissed_hints() {
226 221 $dismissed_hints = get_option( self::$dismissed_opt );
227 - return $dismissed_hints && is_array( $dismissed_hints ) ? $dismissed_hints : array();
222 + return ! empty( $dismissed_hints ) && is_array( $dismissed_hints ) ? $dismissed_hints : array();
228 223 }
229 224
230 225 /**
231 226 * Save the hint in the list of dismissed hints.
@@ -237,9 +232,9 @@
237 232 * @return bool Whether the card was added to the list and hence dismissed.
238 233 */
239 234 protected function add_to_dismissed_hints( $hint ) {
240 235 $hints = array_merge( $this->get_dismissed_hints(), array( $hint ) );
241 - return update_option( self::$dismissed_opt, $hints, false );
236 + return update_option( self::$dismissed_opt, $hints, 'no' );
242 237 }
243 238
244 239 /**
245 240 * Checks that the addon slug passed should be displayed.
@@ -267,19 +262,20 @@
267 262 * Take a raw search query and return something a bit more standardized and
268 263 * easy to work with.
269 264 *
270 265 * @param string $term The raw search term.
271 - *
272 266 * @return string A simplified/sanitized version.
273 267 */
274 268 private function sanitize_search_term( $term ) {
275 269 $term = strtolower( urldecode( $term ) );
276 270
277 - // Remove non-alpha/space chars.
271 + // remove non-alpha/space chars.
278 272 $term = preg_replace( '/[^a-z ]/', '', $term );
279 273
280 - // Remove strings that don't help matches.
281 - return trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
274 + // remove strings that don't help matches.
275 + $term = trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
276 +
277 + return $term;
282 278 }
283 279
284 280 /**
285 281 * @since 4.12
@@ -284,9 +280,8 @@
284 280 /**
285 281 * @since 4.12
286 282 *
287 283 * @param string $terms
288 - *
289 284 * @return array
290 285 */
291 286 private function search_to_array( $terms ) {
292 287 $terms = $this->sanitize_search_term( $terms );
@@ -323,9 +318,9 @@
323 318 'plugin' => $plugin['plugin'],
324 319 ),
325 320 admin_url( 'plugins.php' )
326 321 );
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
322 + $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 323 }
329 324 } elseif ( ! $is_active && isset( $plugin['url'] ) ) {
330 325 // Go to the add-ons page to install.
331 326 $links[] = '<a
@@ -330,9 +325,10 @@
330 325 // Go to the add-ons page to install.
331 326 $links[] = '<a
332 327 class="button-secondary"
333 328 href="' . esc_url( admin_url( 'admin.php?page=formidable-addons' ) ) . '"
334 - >' . esc_html__( 'Install Now', 'formidable' ) . '</a>';
329 + >' . __( 'Install Now', 'formidable' ) . '</a>';
330 +
335 331 } elseif ( ! empty( $plugin['link'] ) ) {
336 332 // Add link pointing to a relevant doc page in formidable.com.
337 333 $links[] = '<a
338 334 class="button-primary frm-plugin-search__learn-more"
@@ -354,9 +350,8 @@
354 350 }
355 351
356 352 /**
357 353 * @param string $plugin
358 - *
359 354 * @return bool
360 355 */
361 356 protected function is_installed( $plugin ) {
362 357 $all_plugins = FrmAppHelper::get_plugins();