PluginProbe
BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager & MCP / 2.4.13
BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager & MCP v2.4.13
3.1.2 3.1.1 3.1.0 3.0.1 3.0.0 2.4.13 2.4.12 2.4.11 2.4.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 All 109 releases
betterlinks / includes / Admin.php

Admin.php in BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager & MCP 2.4.13, at includes/Admin.php

70 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BetterLinks;
4 if ( ! defined( 'ABSPATH' ) ) { exit; }
5
6 class Admin {
7 public function __construct() {
8 $this->add_menu();
9 $this->add_scripts();
10 $this->dispatch_action();
11 }
12
13 public function add_menu() {
14 new Admin\Menu();
15 }
16
17 public function add_scripts() {
18 new Admin\Assets();
19 }
20
21 public function dispatch_action() {
22 new Admin\Ajax();
23 Admin\ShortLinkGenerator::getInstance();
24 Admin\Metabox::init();
25 // new Admin\Notice();
26 add_action('admin_init', [$this, 'init_notices']);
27 add_filter( 'BetterLinks/Admin/skip_no_conflict', [ $this, 'skip_no_conflict' ] );
28 add_filter( 'plugin_action_links_' . BETTERLINKS_PLUGIN_BASENAME, array( $this, 'insert_plugin_links' ) );
29 add_action( 'admin_head-toplevel_page_betterlinks', array( $this, 'append_no_cache_meta' ) );
30 add_action( 'admin_head-toplevel_page_betterlinks-analytics', array( $this, 'append_no_cache_meta' ) );
31 add_action( 'admin_head-toplevel_page_betterlinks-settings', array( $this, 'append_no_cache_meta' ) );
32 add_action( 'betterlinks/admin/after_import_data', array( $this, 'after_import_data' ) );
33 }
34
35 public function init_notices() {
36 new Admin\Notice();
37 }
38
39 public function skip_no_conflict() {
40 $whitelist = [ '127.0.0.1', '::1' ];
41 $remote = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
42 if ( in_array( $remote, $whitelist, true ) ) {
43 return true;
44 }
45
46 return false;
47 }
48
49 public function insert_plugin_links( $links ) {
50 if ( ! apply_filters( 'betterlinks/pro_enabled', false ) ) {
51 $links[] = '<a href="https://wpdeveloper.com/in/upgrade-betterlinks" target="_blank" style="color: #000000; font-weight: bold;">' . __( 'Upgrade to Pro', 'betterlinks' ) . '</a>';
52 }
53
54 return $links;
55 }
56
57 public function append_no_cache_meta() {
58 echo '<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
59 <meta http-equiv="Pragma" content="no-cache">
60 <meta http-equiv="Expires" content="0">';
61 }
62
63 public function after_import_data() {
64 $Cron = new Cron();
65 $Cron->write_json_links();
66 $Cron->analytics();
67 \BetterLinks\Helper::clear_query_cache();
68 }
69 }
70