| @@ -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. |
| @@ -194,11 +196,13 @@ | ||
| 194 | 196 | * |
| 195 | 197 | * @return string The URL with 'formidable' instead of 'frm-plugin-search'. |
| 196 | 198 | */ |
| 197 | 199 | public function plugin_details( $url ) { |
| 200 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 198 | 201 | return false !== stripos( $url, 'tab=plugin-information&plugin=' . self::$slug ) |
| 199 | 202 | ? 'plugin-install.php?tab=plugin-information&plugin=formidable&TB_iframe=true&width=600&height=550' |
| 200 | 203 | : $url; |
| 204 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 201 | 205 | } |
| 202 | 206 | |
| 203 | 207 | /** |
| 204 | 208 | * @since 4.12 |
| @@ -235,9 +239,9 @@ | ||
| 235 | 239 | * @return bool Whether the card was added to the list and hence dismissed. |
| 236 | 240 | */ |
| 237 | 241 | protected function add_to_dismissed_hints( $hint ) { |
| 238 | 242 | $hints = array_merge( $this->get_dismissed_hints(), array( $hint ) ); |
| 239 | - return update_option( self::$dismissed_opt, $hints, 'no' ); | |
| 243 | + return update_option( self::$dismissed_opt, $hints, false ); | |
| 240 | 244 | } |
| 241 | 245 | |
| 242 | 246 | /** |
| 243 | 247 | * Checks that the addon slug passed should be displayed. |
| @@ -271,12 +275,12 @@ | ||
| 271 | 275 | */ |
| 272 | 276 | private function sanitize_search_term( $term ) { |
| 273 | 277 | $term = strtolower( urldecode( $term ) ); |
| 274 | 278 | |
| 275 | - // remove non-alpha/space chars. | |
| 279 | + // Remove non-alpha/space chars. | |
| 276 | 280 | $term = preg_replace( '/[^a-z ]/', '', $term ); |
| 277 | 281 | |
| 278 | - // remove strings that don't help matches. | |
| 282 | + // Remove strings that don't help matches. | |
| 279 | 283 | return trim( str_replace( array( 'formidable', 'free', 'wordpress', 'wp ', 'plugin' ), '', $term ) ); |
| 280 | 284 | } |
| 281 | 285 | |
| 282 | 286 | /** |
| @@ -321,9 +325,9 @@ | ||
| 321 | 325 | 'plugin' => $plugin['plugin'], |
| 322 | 326 | ), |
| 323 | 327 | admin_url( 'plugins.php' ) |
| 324 | 328 | ); |
| 325 | - $links['frm_get_started'] = '<a href="' . esc_url( $activate_url ) . '" class="button activate-now" aria-label="Activate ' . esc_attr( $plugin['name'] ) . '">' . __( 'Activate', 'formidable' ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 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 | |
| 326 | 330 | } |
| 327 | 331 | } elseif ( ! $is_active && isset( $plugin['url'] ) ) { |
| 328 | 332 | // Go to the add-ons page to install. |
| 329 | 333 | $links[] = '<a |
| @@ -328,10 +332,9 @@ | ||
| 328 | 332 | // Go to the add-ons page to install. |
| 329 | 333 | $links[] = '<a |
| 330 | 334 | class="button-secondary" |
| 331 | 335 | href="' . esc_url( admin_url( 'admin.php?page=formidable-addons' ) ) . '" |
| 332 | - >' . __( 'Install Now', 'formidable' ) . '</a>'; | |
| 333 | - | |
| 336 | + >' . esc_html__( 'Install Now', 'formidable' ) . '</a>'; | |
| 334 | 337 | } elseif ( ! empty( $plugin['link'] ) ) { |
| 335 | 338 | // Add link pointing to a relevant doc page in formidable.com. |
| 336 | 339 | $links[] = '<a |
| 337 | 340 | class="button-primary frm-plugin-search__learn-more" |
| @@ -343,9 +346,9 @@ | ||
| 343 | 346 | |
| 344 | 347 | // Dismiss link. |
| 345 | 348 | $dismiss = add_query_arg( array( 'frm-dismiss' => $plugin['id'] ) ); |
| 346 | 349 | $links[] = '<a |
| 347 | - href="' . $dismiss . '" | |
| 350 | + href="' . esc_url( $dismiss ) . '" | |
| 348 | 351 | class="frm-plugin-search__dismiss" |
| 349 | 352 | data-addon="' . esc_attr( $plugin['addon'] ) . '" |
| 350 | 353 | >' . esc_html__( 'Hide this suggestion', 'formidable' ) . '</a>'; |
| 351 | 354 | |