Cdn_Plugin_Admin.php
7.54 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
<?php
namespace W3TC;
class Cdn_Plugin_Admin {
function run() {
$config_labels = new Cdn_ConfigLabels();
add_filter( 'w3tc_config_labels', array( $config_labels, 'config_labels' ) );
$c = Dispatcher::config();
$cdn_engine = $c->get_string( 'cdn.engine' );
if ( $c->get_boolean( 'cdn.enabled' ) &&
!Cdn_Util::is_engine_fsd( $cdn_engine ) ) {
$admin_notes = new Cdn_AdminNotes();
add_filter( 'w3tc_notes', array( $admin_notes, 'w3tc_notes' ) );
add_filter( 'w3tc_errors', array( $admin_notes, 'w3tc_errors' ) );
}
// attach to actions without firing class loading at all without need
if ( $cdn_engine == 'cloudfront_fsd' ) {
add_action( 'admin_print_scripts-performance_page_w3tc_cdn', array(
'\W3TC\Cdn_CloudFrontFsd_Page',
'admin_print_scripts_w3tc_cdn' ) );
add_action( 'w3tc_ajax', array(
'\W3TC\Cdn_CloudFrontFsd_Popup',
'w3tc_ajax' ) );
add_action( 'w3tc_settings_cdn', array(
'\W3TC\Cdn_CloudFrontFsd_Page',
'w3tc_settings_cdn' ) );
} elseif ( $cdn_engine == 'google_drive' ) {
add_action( 'admin_print_scripts-performance_page_w3tc_cdn', array(
'\W3TC\Cdn_GoogleDrive_Page',
'admin_print_scripts_w3tc_cdn' ) );
add_action( 'w3tc_settings_cdn_boxarea_configuration', array(
'\W3TC\Cdn_GoogleDrive_Page',
'w3tc_settings_cdn_boxarea_configuration'
) );
} elseif ( $cdn_engine == 'highwinds' ) {
add_action( 'admin_print_scripts-performance_page_w3tc_cdn', array(
'\W3TC\Cdn_Highwinds_Page',
'admin_print_scripts_w3tc_cdn' ) );
add_action( 'w3tc_ajax', array(
'\W3TC\Cdn_Highwinds_Popup',
'w3tc_ajax' ) );
add_action( 'admin_init_w3tc_dashboard', array(
'\W3TC\Cdn_Highwinds_Widget',
'admin_init_w3tc_dashboard' ) );
add_action( 'w3tc_ajax_cdn_highwinds_widgetdata', array(
'\W3TC\Cdn_Highwinds_Widget',
'w3tc_ajax_cdn_highwinds_widgetdata' ) );
add_action( 'w3tc_settings_cdn_boxarea_configuration', array(
'\W3TC\Cdn_Highwinds_Page',
'w3tc_settings_cdn_boxarea_configuration' ) );
} elseif ( $cdn_engine == 'maxcdn_fsd' ) {
add_action( 'admin_print_scripts-performance_page_w3tc_cdn', array(
'\W3TC\Cdn_MaxCdnFsd_Page',
'admin_print_scripts_w3tc_cdn' ) );
add_action( 'w3tc_ajax', array(
'\W3TC\Cdn_MaxCdnFsd_Popup',
'w3tc_ajax' ) );
add_action( 'w3tc_settings_cdn', array(
'\W3TC\Cdn_MaxCdnFsd_Page',
'w3tc_settings_cdn' ) );
} elseif ( $cdn_engine == 'rackspace_cdn' ) {
add_filter( 'w3tc_admin_actions', array(
'\W3TC\Cdn_RackSpaceCdn_Page',
'w3tc_admin_actions' ) );
add_action( 'admin_print_scripts-performance_page_w3tc_cdn', array(
'\W3TC\Cdn_RackSpaceCdn_Page',
'admin_print_scripts_w3tc_cdn' ) );
add_action( 'w3tc_ajax', array(
'\W3TC\Cdn_RackSpaceCdn_Popup',
'w3tc_ajax' ) );
add_action( 'w3tc_settings_cdn_boxarea_configuration', array(
'\W3TC\Cdn_RackSpaceCdn_Page',
'w3tc_settings_cdn_boxarea_configuration' ) );
} elseif ( $cdn_engine == 'rscf' ) {
add_action( 'admin_print_scripts-performance_page_w3tc_cdn', array(
'\W3TC\Cdn_RackSpaceCloudFiles_Page',
'admin_print_scripts_w3tc_cdn' ) );
add_action( 'w3tc_ajax', array(
'\W3TC\Cdn_RackSpaceCloudFiles_Popup',
'w3tc_ajax' ) );
add_action( 'w3tc_settings_cdn_boxarea_configuration', array(
'\W3TC\Cdn_RackSpaceCloudFiles_Page',
'w3tc_settings_cdn_boxarea_configuration' ) );
}
add_action( 'w3tc_settings_general_boxarea_cdn', array(
$this,
'w3tc_settings_general_boxarea_cdn'
) );
}
public function w3tc_settings_general_boxarea_cdn() {
$config = Dispatcher::config();
$engine_optgroups = array();
$engine_values = array();
$is_fsd = Util_Environment::is_w3tc_pro( $config );
if ( $is_fsd ) {
$engine_optgroups[] = __( 'Full Site Delivery:', 'w3-total-cache' );
$engine_values['cloudfront_fsd'] = array(
'label' => __( 'Amazon CloudFront', 'w3-total-cache' ),
'optgroup' => 0
);
$engine_values['maxcdn_fsd'] = array(
'label' => __( 'MaxCDN (recommended)', 'w3-total-cache' ),
'optgroup' => 0
);
$optgroup_pull = count( $engine_optgroups );
$engine_optgroups[] = __( 'Origin Pull / Mirror:', 'w3-total-cache' );
} else {
$optgroup_pull = count( $engine_optgroups );
$engine_optgroups[] = __( 'Origin Pull / Mirror:', 'w3-total-cache' );
}
$optgroup_push = count( $engine_optgroups );
$engine_optgroups[] = __( 'Origin Push:', 'w3-total-cache' );
$engine_values['akamai'] = array(
'label' => __( 'Akamai', 'w3-total-cache' ),
'optgroup' => $optgroup_pull
);
$engine_values['cf2'] = array(
'label' => __( 'Amazon CloudFront', 'w3-total-cache' ),
'disabled' => ( !Util_Installed::curl() ? true : null ),
'optgroup' => $optgroup_pull
);
$engine_values['att'] = array(
'label' => __( 'AT&T', 'w3-total-cache' ),
'optgroup' => $optgroup_pull
);
$engine_values['cotendo'] = array(
'label' => __( 'Cotendo (Akamai)', 'w3-total-cache' ),
'optgroup' => $optgroup_pull
);
$engine_values['mirror'] = array(
'label' => __( 'Generic Mirror', 'w3-total-cache' ),
'optgroup' => $optgroup_pull
);
$engine_values['highwinds'] = array(
'label' => __( 'Highwinds', 'w3-total-cache' ),
'optgroup' => $optgroup_pull
);
$engine_values['maxcdn'] = array(
'label' => __( 'MaxCDN', 'w3-total-cache' ),
'optgroup' => $optgroup_pull
);
$engine_values['netdna'] = array(
'label' => __( 'MaxCDN Enterprise (NetDNA)', 'w3-total-cache' ),
'optgroup' => $optgroup_pull
);
$engine_values['rackspace_cdn'] = array(
'label' => __( 'RackSpace CDN', 'w3-total-cache' ),
'optgroup' => $optgroup_pull
);
$engine_values['edgecast'] = array(
'label' => __( 'Verizon Digital Media Services (EdgeCast) / Media Temple ProCDN', 'w3-total-cache' ),
'optgroup' => $optgroup_pull
);
$engine_values['cf'] = array(
'disabled' => ( !Util_Installed::curl() ? true : null ),
'label' => __( 'Amazon CloudFront', 'w3-total-cache' ),
'optgroup' => $optgroup_push
);
$engine_values['s3'] = array(
'disabled' => ( !Util_Installed::curl() ? true : null ),
'label' => __( 'Amazon Simple Storage Service (S3)', 'w3-total-cache' ),
'optgroup' => $optgroup_push
);
$engine_values['s3_compatible'] = array(
'disabled' => ( !Util_Installed::curl() ? true : null ),
'label' => __( 'Amazon Simple Storage Service (S3) Compatible', 'w3-total-cache' ),
'optgroup' => $optgroup_push
);
$engine_values['google_drive'] = array(
'label' => __( 'Google Drive', 'w3-total-cache' ),
'optgroup' => $optgroup_push
);
$engine_values['azure'] = array(
'label' => __( 'Microsoft Azure Storage', 'w3-total-cache' ),
'optgroup' => $optgroup_push
);
$engine_values['rscf'] = array(
'disabled' => ( !Util_Installed::curl() ? true : null ),
'label' => __( 'Rackspace Cloud Files', 'w3-total-cache' ),
'optgroup' => $optgroup_push
);
$engine_values['ftp'] = array(
'disabled' => ( !Util_Installed::ftp() ? true : null ),
'label' => __( 'Self-hosted / File Transfer Protocol Upload', 'w3-total-cache' ),
'optgroup' => $optgroup_push
);
$cdn_enabled = $config->get_boolean( 'cdn.enabled' );
$cdn_engine = $config->get_string( 'cdn.engine' );
$tag = '';
if ( $cdn_engine == 'cloudfront_fsd' )
$tag = '#cdn-fsd-cloudfront';
elseif ( $cdn_engine == 'maxcdn_fsd' )
$tag = '#cdn-fsd-maxcdn';
if ( empty( $tag ) )
$cdn_engine_extra_description = '';
else
$cdn_engine_extra_description =
' See <a href="admin.php?page=w3tc_faq' . $tag .
'">setup instructions</a>';
include W3TC_DIR . '/Cdn_GeneralPage_View.php';
}
}