PluginProbe
Falcon – Cache, Performance, Security, Cleanup, and Tweaks / 2.9.2
Falcon – Cache, Performance, Security, Cleanup, and Tweaks v2.9.2
2.11.2 2.11.1 2.11.0 2.10.1 trunk 1.0.1 1.0.2 1.0.3 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.3 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1.0 2.10.0 2.2.0 All 45 releases
falcon / src / Core.php

Core.php in Falcon – Cache, Performance, Security, Cleanup, and Tweaks 2.9.2, at src/Core.php

54 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Falcon;
3
4 class Core {
5 public function __construct() {
6 add_action( 'activated_plugin', [ $this, 'redirect' ], 10, 2 );
7 add_filter( 'plugin_action_links_falcon/falcon.php', [ $this, 'add_plugin_action_links' ] );
8 add_filter( 'plugin_row_meta', [ $this, 'add_plugin_meta_links' ], 10, 2 );
9 }
10
11 public function redirect( $plugin, $network_wide = false ): void {
12 $is_cli = 'cli' === php_sapi_name();
13 $is_plugin = 'falcon/falcon.php' === $plugin;
14
15 $action = isset( $_POST['action'] ) ? sanitize_text_field( wp_unslash( $_POST['action'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
16 $checked = isset( $_POST['checked'] ) && is_array( $_POST['checked'] ) ? count( $_POST['checked'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification
17 $is_bulk_activate = $action === 'activate-selected' && $checked > 1;
18 $is_doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
19
20 if ( ! $is_plugin || $network_wide || $is_cli || $is_bulk_activate || $this->is_bundled() || $is_doing_ajax ) {
21 return;
22 }
23
24 wp_safe_redirect( admin_url( 'options-general.php?page=falcon' ) );
25 die;
26 }
27
28 private function is_bundled(): bool {
29 foreach ( $_REQUEST as $key => $value ) { // phpcs:ignore WordPress.Security.NonceVerification
30 if ( str_contains( $key, 'tgmpa' ) || ( is_string( $value ) && str_contains( $value, 'tgmpa' ) ) ) {
31 return true;
32 }
33 }
34 return false;
35 }
36
37 public function add_plugin_action_links( array $links ): array {
38 $links[] = '<a href="' . esc_url( admin_url( 'options-general.php?page=falcon' ) ) . '">' . __( 'Settings', 'falcon' ) . '</a>';
39 return $links;
40 }
41
42 public function add_plugin_meta_links( array $meta, string $file ) {
43 if ( $file !== 'falcon/falcon.php' ) {
44 return $meta;
45 }
46
47 $meta[] = '<a href="https://wordpress.org/support/plugin/falcon/reviews/?filter=5" target="_blank" title="' . esc_html__( 'Rate Falcon on WordPress.org', 'falcon' ) . '" style="color: #ffb900">'
48 . str_repeat( '<span class="dashicons dashicons-star-filled" style="font-size: 16px; width:16px; height: 16px"></span>', 5 )
49 . '</a>';
50
51 return $meta;
52 }
53 }
54