PluginProbe
AEH Speed Optimization: Browser Cache, Optimized Minify, Lazy Loading & Image Optimization / trunk
AEH Speed Optimization: Browser Cache, Optimized Minify, Lazy Loading & Image Optimization vtrunk
3.3.0 trunk 1.0 1.1 1.2 2.0 2.1 2.10.0 2.2 2.3 2.4 2.5 2.6 2.7 2.7.1 2.7.2 2.7.3 2.8.0 2.8.1 2.8.2 2.9.0 2.9.1 2.9.2 3.0.0 3.1.0 All 26 releases
add-expires-headers / add-expires-headers.php

add-expires-headers.php in AEH Speed Optimization: Browser Cache, Optimized Minify, Lazy Loading & Image Optimization trunk, at add-expires-headers.php

190 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 Plugin Name: AEH Speed Optimization: Browser Cache, Optimized Minify, Lazy Loading & Image Optimization
5 Plugin URI: http://www.addexpiresheaders.com/
6 Description: AEH Speed Optimization boosts site speed with caching, minification, lazy loading, and image optimization to improve performance and SEO.
7 Author: Passionate Brains
8 Version: 3.3.0
9 Author URI: http://www.addexpiresheaders.com/
10 License: GPLv2 or later
11 */
12 /* initiating freemius */
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16 if (function_exists('dd_aeh')) {
17 dd_aeh()->set_basename(false, __FILE__);
18 } else {
19 if (!function_exists('dd_aeh')) {
20 // Create a helper function for easy SDK access.
21 function dd_aeh()
22 {
23 global $dd_aeh;
24 if (!isset($dd_aeh)) {
25 // Include Freemius SDK.
26 require_once dirname(__FILE__) . '/vendor/freemius/start.php';
27 $dd_aeh = fs_dynamic_init(array(
28 'id' => '5598',
29 'slug' => 'add-expires-headers',
30 'premium_slug' => 'AddExpiresHeaders-premium',
31 'type' => 'plugin',
32 'public_key' => 'pk_ba20d9daf118a0e03f28dbbc805e3',
33 'is_premium' => false,
34 'premium_suffix' => 'Pro',
35 'has_addons' => false,
36 'has_paid_plans' => true,
37 'trial' => array(
38 'days' => 3,
39 'is_require_payment' => false,
40 ),
41 'has_affiliation' => 'all',
42 'menu' => array(
43 'slug' => 'aeh_pro_plugin_options',
44 'first-path' => 'admin.php?page=aeh_pro_plugin_options',
45 'support' => false,
46 ),
47 'is_live' => true,
48 ));
49 }
50 return $dd_aeh;
51 }
52
53 // Init Freemius.
54 dd_aeh();
55 // Signal that SDK was initiated.
56 do_action('dd_aeh_loaded');
57 }
58 /* Defining some of constant which will be helpful throughout */
59 if (!defined('AEH_BASENAME')) {
60 define('AEH_BASENAME', plugin_basename(__FILE__));
61 }
62 if (!defined('AEH_DIR')) {
63 define('AEH_DIR', plugin_dir_path(__FILE__));
64 }
65 if (!defined('AEH_URL')) {
66 define('AEH_URL', plugin_dir_url(__FILE__));
67 }
68 if (!defined('AEH_SITE_URL')) {
69 define('AEH_SITE_URL', site_url());
70 }
71 if (!defined('AEH_SITE_DOMAIN')) {
72 define('AEH_SITE_DOMAIN', trim(str_ireplace(array('http://', 'https://'), '', trim(AEH_SITE_URL, '/'))));
73 }
74 if (!defined('AEH_PREFIX')) {
75 define('AEH_PREFIX', 'AEH_');
76 }
77 if (!defined('AEH_VERSION')) {
78 define('AEH_VERSION', '3.3.0');
79 }
80 /* Definining main class */
81 if (!class_exists('AEH_Pro')) {
82 class AEH_Pro
83 {
84 private static $instance = null;
85
86 public $main = null;
87
88 public $admin = null;
89
90 public $minify = null;
91
92 public $lazy_loading = null;
93
94 public $image_optimize = null;
95
96 public $external_cache = null;
97
98 public static function get_instance()
99 {
100 if (!self::$instance) {
101 self::$instance = new self();
102 }
103 return self::$instance;
104 }
105
106 private function __construct()
107 {
108 if ($this->aeh_compat_checker()) {
109 $this->includes();
110 $this->init();
111 }
112 }
113
114 /*loads other support classes*/
115 private function includes()
116 {
117 require_once AEH_DIR . 'main/class-aeh-minify.php';
118 require_once AEH_DIR . 'main/class-aeh-settings.php';
119 require_once AEH_DIR . 'main/class-aeh-main.php';
120 require_once AEH_DIR . 'main/class-aeh-admin.php';
121 require_once AEH_DIR . 'main/class-aeh-lazy-loading.php';
122 }
123
124 /* init support classes*/
125 private function init()
126 {
127 $this->main = new AEH_Main();
128 $this->admin = new AEH_Admin();
129 $this->minify = new AEH_Minify();
130 $this->lazy_loading = new AEH_Lazy_Loading();
131 }
132
133 /* returning main class object */
134 public function main()
135 {
136 return $this->main;
137 }
138
139 /* returning admin class object */
140 public function admin()
141 {
142 return $this->admin;
143 }
144
145 public function minify()
146 {
147 return $this->minify;
148 }
149
150 public function external_cache()
151 {
152 return $this->external_cache;
153 }
154
155 public static function dd_aeh_uninstall_cleanup()
156 {
157 AEH_Pro::get_instance()->main()->remove_settings();
158 AEH_Pro::get_instance()->minify()->aeh_purge_all_uninstall();
159 }
160
161 /* checking compatibility for plugin to get activated and working */
162 public function aeh_compat_checker()
163 {
164 global $wp_version;
165 $error = '';
166 if (version_compare(PHP_VERSION, '5.4', '<')) {
167 $error = 'AEH Speed Optimization requires PHP 5.4 or higher. You’re still on ' . PHP_VERSION;
168 }
169 if (version_compare($GLOBALS['wp_version'], '4.5', '<')) {
170 $error = 'AEH Speed Optimization requires WP 4.5 or higher. You’re still on ' . $GLOBALS['wp_version'];
171 }
172 if (is_plugin_active(plugin_basename(__FILE__)) && !empty($error) || !empty($error)) {
173 if (isset($_GET['activate'])) {
174 unset($_GET['activate']);
175 }
176 add_action('admin_notices', function () use ($error) {
177 echo '<div class="notice notice-error is-dismissible"><p><b>' . $error . '</b></p></div>';
178 });
179 return false;
180 } else {
181 return true;
182 }
183 }
184 }
185 }
186 add_action('plugins_loaded', array('AEH_Pro', 'get_instance'));
187 dd_aeh()->add_action('after_uninstall', array('AEH_Pro', 'dd_aeh_uninstall_cleanup'));
188 register_uninstall_hook(__FILE__, array('AEH_Pro', 'dd_aeh_uninstall_cleanup'));
189 }
190