-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathwp-rocket.php
More file actions
240 lines (222 loc) · 9.42 KB
/
wp-rocket.php
File metadata and controls
240 lines (222 loc) · 9.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
/**
* Plugin Name: WP Rocket
* Plugin URI: https://wp-rocket.me
* Description: The best WordPress performance plugin.
* Version: 3.20.0.3
* Requires at least: 5.8
* Requires PHP: 7.3
* Code Name: Iego
* Author: WP Media
* Author URI: https://wp-media.me
* Licence: GPLv2 or later
*
* Text Domain: rocket
* Domain Path: /languages
*
* Copyright 2013-2025 WP Rocket
*/
defined( 'ABSPATH' ) || exit;
// Rocket defines.
define( 'WP_ROCKET_VERSION', '3.20.0.3' );
define( 'WP_ROCKET_WP_VERSION', '5.8' );
define( 'WP_ROCKET_WP_VERSION_TESTED', '6.3.1' );
define( 'WP_ROCKET_PHP_VERSION', '7.3' );
define( 'WP_ROCKET_PRIVATE_KEY', false );
define( 'WP_ROCKET_SLUG', 'wp_rocket_settings' );
define( 'WP_ROCKET_WEB_MAIN', 'https://wp-rocket.me/' );
define( 'WP_ROCKET_WEB_API', WP_ROCKET_WEB_MAIN . 'api/wp-rocket/' ); // only used in deprecated code.
define( 'WP_ROCKET_WEB_CHECK', WP_ROCKET_WEB_MAIN . 'check_update.php' ); // only used in deprecated code.
define( 'WP_ROCKET_WEB_VALID', WP_ROCKET_WEB_MAIN . 'valid_key.php' ); // only used in deprecated code.
define( 'WP_ROCKET_WEB_INFO', WP_ROCKET_WEB_MAIN . 'plugin_information.php' ); // only used in deprecated code.
define( 'WP_ROCKET_FILE', __FILE__ );
define( 'WP_ROCKET_PATH', realpath( plugin_dir_path( WP_ROCKET_FILE ) ) . '/' );
define( 'WP_ROCKET_INC_PATH', realpath( WP_ROCKET_PATH . 'inc/' ) . '/' );
require_once WP_ROCKET_INC_PATH . 'constants.php';
define( 'WP_ROCKET_DEPRECATED_PATH', realpath( WP_ROCKET_INC_PATH . 'deprecated/' ) . '/' );
define( 'WP_ROCKET_FRONT_PATH', realpath( WP_ROCKET_INC_PATH . 'front/' ) . '/' );
define( 'WP_ROCKET_ADMIN_PATH', realpath( WP_ROCKET_INC_PATH . 'admin' ) . '/' );
define( 'WP_ROCKET_ADMIN_UI_PATH', realpath( WP_ROCKET_ADMIN_PATH . 'ui' ) . '/' );
define( 'WP_ROCKET_ADMIN_UI_MODULES_PATH', realpath( WP_ROCKET_ADMIN_UI_PATH . 'modules' ) . '/' );
define( 'WP_ROCKET_COMMON_PATH', realpath( WP_ROCKET_INC_PATH . 'common' ) . '/' );
define( 'WP_ROCKET_FUNCTIONS_PATH', realpath( WP_ROCKET_INC_PATH . 'functions' ) . '/' );
define( 'WP_ROCKET_VENDORS_PATH', realpath( WP_ROCKET_INC_PATH . 'vendors' ) . '/' );
define( 'WP_ROCKET_3RD_PARTY_PATH', realpath( WP_ROCKET_INC_PATH . '3rd-party' ) . '/' );
if ( ! defined( 'WP_ROCKET_CONFIG_PATH' ) ) {
define( 'WP_ROCKET_CONFIG_PATH', WP_CONTENT_DIR . '/wp-rocket-config/' );
}
define( 'WP_ROCKET_URL', plugin_dir_url( WP_ROCKET_FILE ) );
define( 'WP_ROCKET_INC_URL', WP_ROCKET_URL . 'inc/' );
define( 'WP_ROCKET_ADMIN_URL', WP_ROCKET_INC_URL . 'admin/' );
define( 'WP_ROCKET_ASSETS_URL', WP_ROCKET_URL . 'assets/' );
define( 'WP_ROCKET_ASSETS_PATH', WP_ROCKET_PATH . 'assets/' );
define( 'WP_ROCKET_ASSETS_JS_URL', WP_ROCKET_ASSETS_URL . 'js/' );
define( 'WP_ROCKET_ASSETS_JS_PATH', WP_ROCKET_ASSETS_PATH . 'js/' );
define( 'WP_ROCKET_ASSETS_CSS_URL', WP_ROCKET_ASSETS_URL . 'css/' );
define( 'WP_ROCKET_ASSETS_IMG_URL', WP_ROCKET_ASSETS_URL . 'img/' );
if ( ! defined( 'WP_ROCKET_CACHE_ROOT_PATH' ) ) {
define( 'WP_ROCKET_CACHE_ROOT_PATH', WP_CONTENT_DIR . '/cache/' );
}
define( 'WP_ROCKET_CACHE_PATH', WP_ROCKET_CACHE_ROOT_PATH . 'wp-rocket/' );
define( 'WP_ROCKET_MINIFY_CACHE_PATH', WP_ROCKET_CACHE_ROOT_PATH . 'min/' );
define( 'WP_ROCKET_CACHE_BUSTING_PATH', WP_ROCKET_CACHE_ROOT_PATH . 'busting/' );
define( 'WP_ROCKET_CRITICAL_CSS_PATH', WP_ROCKET_CACHE_ROOT_PATH . 'critical-css/' );
define( 'WP_ROCKET_USED_CSS_PATH', WP_ROCKET_CACHE_ROOT_PATH . 'used-css/' );
if ( ! defined( 'WP_ROCKET_CACHE_ROOT_URL' ) ) {
define( 'WP_ROCKET_CACHE_ROOT_URL', WP_CONTENT_URL . '/cache/' );
}
define( 'WP_ROCKET_CACHE_URL', WP_ROCKET_CACHE_ROOT_URL . 'wp-rocket/' );
define( 'WP_ROCKET_MINIFY_CACHE_URL', WP_ROCKET_CACHE_ROOT_URL . 'min/' );
define( 'WP_ROCKET_CACHE_BUSTING_URL', WP_ROCKET_CACHE_ROOT_URL . 'busting/' );
define( 'WP_ROCKET_USED_CSS_URL', WP_ROCKET_CACHE_ROOT_URL . 'used-css/' );
if ( ! defined( 'CHMOD_WP_ROCKET_CACHE_DIRS' ) ) {
define( 'CHMOD_WP_ROCKET_CACHE_DIRS', 0755 ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
}
if ( ! defined( 'WP_ROCKET_LASTVERSION' ) ) {
define( 'WP_ROCKET_LASTVERSION', '3.19.4' );
}
/**
* We use is_readable() with @ silencing as WP_Filesystem() can use different methods to access the filesystem.
*
* This is more performant and more compatible. It allows us to work around file permissions and missing credentials.
*/
if ( @is_readable( WP_ROCKET_PATH . 'licence-data.php' ) ) { //phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
@include WP_ROCKET_PATH . 'licence-data.php'; //phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
}
add_filter('pre_http_request', function($response, $args, $url) {
if (strpos($url, 'api.wp-rocket.me/valid_key.php') !== false || strpos($url, 'wp-rocket.me/valid_key.php') !== false) {
$key = 'WEADOWN000000005603B1EBE59708542';
$email = 'noreply@weadown.com';
return array(
'response' => array('code' => 200),
'body' => json_encode(array(
'success' => true,
'data' => array(
'consumer_key' => substr($key, 0, 8),
'consumer_email' => $email,
'secret_key' => hash('crc32', $email)
)
))
);
}
if (strpos($url, 'api.wp-rocket.me/stat/1.0/wp-rocket/user.php') !== false) {
return array(
'response' => array('code' => 200),
'body' => json_encode(array(
'licence_account' => -1,
'licence_expiration' => time() + (50 * YEAR_IN_SECONDS),
'licence' => array('name' => 'Infinite'),
'status' => 'valid',
'has_auto_renew' => true,
'date_created' => time() - (30 * DAY_IN_SECONDS)
))
);
}
if (strpos($url, 'api.wp-rocket.me/check_update.php') !== false || strpos($url, 'wp-rocket.me/check_update.php') !== false) {
return array(
'response' => array('code' => 200),
'body' => json_encode(array(
'version' => WP_ROCKET_VERSION,
'details_url' => '',
'download_url' => ''
))
);
}
if (strpos($url, 'saas.gpltimes.com/rucss-job') !== false) {
return array(
'response' => array('code' => 200),
'body' => json_encode(array(
'status' => 'ok',
'code' => 200
))
);
}
return $response;
}, 10, 3);
add_action('init', function() {
$key = 'WEADOWN000000005603B1EBE59708542';
$email = 'noreply@weadown.com';
$options = get_transient('wp_rocket_settings');
if ($options && isset($options['license']) && '1' === $options['license']) {
$options['license'] = time();
$options['ignore'] = true;
set_transient('wp_rocket_settings', $options, YEAR_IN_SECONDS);
}
if (!$options || empty($options['secret_key'])) {
$options = array(
'consumer_key' => substr($key, 0, 8),
'consumer_email' => $email,
'secret_key' => hash('crc32', $email),
'license' => time(),
'ignore' => true
);
set_transient('wp_rocket_settings', $options, YEAR_IN_SECONDS);
}
update_option('wp_rocket_no_licence', 0);
$customer_data = (object) array(
'licence_account' => -1,
'licence_expiration' => time() + (50 * YEAR_IN_SECONDS),
'licence' => (object) array('name' => 'Infinite'),
'status' => 'valid',
'has_auto_renew' => true,
'date_created' => time() - (30 * DAY_IN_SECONDS),
'performance_monitoring' => (object) array(
'expiration' => time() + (50 * YEAR_IN_SECONDS),
'cancelled_at' => null,
'manage_url' => null,
'active_sku' => 'perf-monitor-advanced',
'plans' => array(
(object) array(
'sku' => 'perf-monitor-advanced',
'price' => '8.99',
'limit' => '10',
'title' => 'Advanced',
'subtitle' => 'See how your top pages perform and quickly spot and optimize what slows your site down.',
'description' => 'Up to 10 pages • Weekly updates',
'billing' => '* Billed monthly. You can cancel at any time, each month started is due.',
'highlights' => array(
'Up to 10 pages tracked',
'Automatic performance monitoring',
'Unlimited on-demand tests',
'Full GTmetrix performance reports'
),
'status' => 'active',
'button' => (object) array(
'label' => 'Your plan',
'action' => 'none',
'url' => null
)
)
)
)
);
set_transient('wp_rocket_customer_data', $customer_data, DAY_IN_SECONDS);
});
require WP_ROCKET_INC_PATH . 'compat.php';
require WP_ROCKET_INC_PATH . 'classes/class-wp-rocket-requirements-check.php';
/**
* Loads WP Rocket translations
*
* @since 3.0
* @author Remy Perona
*
* @return void
*/
function rocket_load_textdomain() {
load_plugin_textdomain( 'rocket', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action( 'init', 'rocket_load_textdomain' );
$wp_rocket_requirement_checks = new WP_Rocket_Requirements_Check(
[
'plugin_name' => 'WP Rocket',
'plugin_file' => WP_ROCKET_FILE,
'plugin_version' => WP_ROCKET_VERSION,
'plugin_last_version' => WP_ROCKET_LASTVERSION,
'wp_version' => WP_ROCKET_WP_VERSION,
'php_version' => WP_ROCKET_PHP_VERSION,
]
);
if ( $wp_rocket_requirement_checks->check() ) {
require WP_ROCKET_INC_PATH . 'main.php';
}
unset( $wp_rocket_requirement_checks );