PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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 -22 6.26 → trunk View file →
@@ -33,15 +33,17 @@
33 33 * @return void
34 34 */
35 35 public function start( $screen ) {
36 36 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
37 - if ( 'plugin-install' === $screen->base && ( ! isset( $_GET['paged'] ) || 1 === intval( $_GET['paged'] ) ) ) {
38 - add_filter( 'plugins_api_result', array( $this, 'inject_suggestion' ), 10, 3 );
39 - add_filter( 'self_admin_url', array( $this, 'plugin_details' ) );
40 - add_filter( 'plugin_install_action_links', array( $this, 'insert_related_links' ), 10, 2 );
41 - add_action( 'admin_enqueue_scripts', array( $this, 'load_plugins_search_script' ) );
42 - $this->maybe_dismiss();
37 + if ( 'plugin-install' !== $screen->base || ( isset( $_GET['paged'] ) && 1 !== intval( $_GET['paged'] ) ) ) {
38 + return;
43 39 }
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();
44 46 }
45 47
46 48 /**
47 49 * Intercept the plugins API response and add in an appropriate card.
@@ -67,9 +69,9 @@
67 69
68 70 // Lowercase, trim, remove punctuation/special chars, decode url, remove 'formidable'.
69 71 $normalized_term = $this->search_to_array( $args->search );
70 72
71 - if ( empty( $normalized_term ) ) {
73 + if ( ! $normalized_term ) {
72 74 // Don't add anything extra.
73 75 return $result;
74 76 }
75 77
@@ -74,9 +76,9 @@
74 76 }
75 77
76 78 $matching_addon = $this->matching_addon( $addon_list, $normalized_term );
77 79
78 - if ( empty( $matching_addon ) || ! $this->should_display_hint( $matching_addon ) ) {
80 + if ( ! $matching_addon || ! $this->should_display_hint( $matching_addon ) ) {
79 81 return $result;
80 82 }
81 83
82 84 $inject = (array) $this->get_plugin_data();
@@ -129,10 +131,9 @@
129 131 if ( ! isset( $addon_opts['search_terms'] ) ) {
130 132 $addon_opts['search_terms'] = '';
131 133 }
132 134
133 - $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
134 -
135 + $addon_terms = $this->search_to_array( $addon_opts['search_terms'] . ' ' . $addon_opts['name'] );
135 136 $matched_terms = array_intersect( $addon_terms, $normalized_term );
136 137
137 138 if ( count( $matched_terms ) === count( $normalized_term ) ) {
138 139 $matching_addon = $addon_id;
@@ -195,11 +196,13 @@
195 196 *
196 197 * @return string The URL with 'formidable' instead of 'frm-plugin-search'.
197 198 */
198 199 public function plugin_details( $url ) {
200 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
199 201 return false !== stripos( $url, 'tab=plugin-information&plugin=' . self::$slug )
200 202 ? 'plugin-install.php?tab=plugin-information&plugin=formidable&TB_iframe=true&width=600&height=550'
201 203 : $url;
204 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
202 205 }
203 206
204 207 /**
205 208 * @since 4.12
@@ -208,9 +211,9 @@
208 211 */
209 212 private function maybe_dismiss() {
210 213 $addon = FrmAppHelper::get_param( 'frm-dismiss', '', 'get', 'absint' );
211 214
212 - if ( ! empty( $addon ) ) {
215 + if ( $addon ) {
213 216 $this->add_to_dismissed_hints( $addon );
214 217 }
215 218 }
216 219
@@ -222,9 +225,9 @@
222 225 * @return array List of dismissed hints.
223 226 */
224 227 protected function get_dismissed_hints() {
225 228 $dismissed_hints = get_option( self::$dismissed_opt );
226 - return ! empty( $dismissed_hints ) && is_array( $dismissed_hints ) ? $dismissed_hints : array();
229 + return $dismissed_hints && is_array( $dismissed_hints ) ? $dismissed_hints : array();
227 230 }
228 231
229 232 /**
230 233 * Save the hint in the list of dismissed hints.
@@ -236,9 +239,9 @@
236 239 * @return bool Whether the card was added to the list and hence dismissed.
237 240 */
238 241 protected function add_to_dismissed_hints( $hint ) {
239 242 $hints = array_merge( $this->get_dismissed_hints(), array( $hint ) );
240 - return update_option( self::$dismissed_opt, $hints, 'no' );
243 + return update_option( self::$dismissed_opt, $hints, false );
241 244 }
242 245
243 246 /**
244 247 * Checks that the addon slug passed should be displayed.
@@ -272,15 +275,13 @@
272 275 */
273 276 private function sanitize_search_term( $term ) {
274 277 $term = strtolower( urldecode( $term ) );
275 278
276 - // remove non-alpha/space chars.
279 + // Remove non-alpha/space chars.
277 280 $term = preg_replace( '/[^a-z ]/', '', $term );
278 281
279 - // remove strings that don't help matches.
280 - $term = trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
281 -
282 - return $term;
282 + // Remove strings that don't help matches.
283 + return trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) );
283 284 }
284 285
285 286 /**
286 287 * @since 4.12
@@ -324,9 +325,9 @@
324 325 'plugin' => $plugin['plugin'],
325 326 ),
326 327 admin_url( 'plugins.php' )
327 328 );
328 - $links['frm_get_started'] = '<a href="' . esc_url( $activate_url ) . '" class="button activate-now" aria-label="Activate ' . esc_attr( $plugin['name'] ) . '">' . __( 'Activate', 'formidable' ) . '</a>';
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
329 330 }
330 331 } elseif ( ! $is_active && isset( $plugin['url'] ) ) {
331 332 // Go to the add-ons page to install.
332 333 $links[] = '<a
@@ -331,10 +332,9 @@
331 332 // Go to the add-ons page to install.
332 333 $links[] = '<a
333 334 class="button-secondary"
334 335 href="' . esc_url( admin_url( 'admin.php?page=formidable-addons' ) ) . '"
335 - >' . __( 'Install Now', 'formidable' ) . '</a>';
336 -
336 + >' . esc_html__( 'Install Now', 'formidable' ) . '</a>';
337 337 } elseif ( ! empty( $plugin['link'] ) ) {
338 338 // Add link pointing to a relevant doc page in formidable.com.
339 339 $links[] = '<a
340 340 class="button-primary frm-plugin-search__learn-more"
@@ -346,9 +346,9 @@
346 346
347 347 // Dismiss link.
348 348 $dismiss = add_query_arg( array( 'frm-dismiss' => $plugin['id'] ) );
349 349 $links[] = '<a
350 - href="' . $dismiss . '"
350 + href="' . esc_url( $dismiss ) . '"
351 351 class="frm-plugin-search__dismiss"
352 352 data-addon="' . esc_attr( $plugin['addon'] ) . '"
353 353 >' . esc_html__( 'Hide this suggestion', 'formidable' ) . '</a>';
354 354