-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathCdn_BunnyCdn_Widget_View_Unauthorized.php
200 lines (180 loc) · 6.11 KB
/
Cdn_BunnyCdn_Widget_View_Unauthorized.php
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
<?php
/**
* File: Cdn_BunnyCdn_Widget_View_Unauthorized.php
*
* @since 2.6.0
*
* @package W3TC
*/
namespace W3TC;
defined( 'W3TC' ) || die();
?>
<div id="bunnycdn-widget" class="w3tc_bunnycdn_signup">
<?php
$cdn_engine = $c->get_string( 'cdn.engine' );
$cdn_enabled = $c->get_boolean( 'cdn.enabled' );
$cdn_name = Cache::engine_name( $cdn_engine );
$cdnfsd_engine = $c->get_string( 'cdnfsd.engine' );
$cdnfsd_enabled = $c->get_boolean( 'cdnfsd.enabled' );
$cdnfsd_name = Cache::engine_name( $cdnfsd_engine );
// Check if BunnyCDN is selected but not fully configured.
$is_bunny_cdn_incomplete = (
(
$cdn_enabled &&
'bunnycdn' === $cdn_engine &&
empty( $c->get_integer( 'cdn.bunnycdn.pull_zone_id' ) )
) ||
(
$cdnfsd_enabled &&
'bunnycdn' === $cdnfsd_engine &&
empty( $c->get_integer( 'cdnfsd.bunnycdn.pull_zone_id' ) )
)
);
// Check if a non-BunnyCDN is configured.
$is_other_cdn_configured = (
(
$cdn_enabled &&
! empty( $cdn_engine ) &&
'bunnycdn' !== $cdn_engine
) ||
(
$cdnfsd_enabled &&
! empty( $cdnfsd_engine ) &&
'bunnycdn' !== $cdnfsd_engine
)
);
if ( $is_bunny_cdn_incomplete ) {
// BunnyCDN selected but not fully configured.
?>
<p class="notice notice-error">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML a tag to CDN settings page, 2 closing HTML a tag.
__( 'W3 Total Cache has detected that BunnyCDN is selected but not fully configured. Please use the "Authorize" button on the %1$sCDN%2$s settings page to connect a pull zone.', 'w3-total-cache' ),
'<a href="' . esc_url_raw( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ) ) . '">',
'</a>'
),
array(
'a' => array(
'href' => array(),
),
)
);
?>
</p>
<?php
} elseif ( $is_other_cdn_configured ) {
// A CDN is configured but it is not BunnyCDN.
?>
<p class="notice notice-error">
<?php
switch (true) {
case $cdn_enabled && ! empty( $cdn_engine ) && $cdnfsd_enabled && ! empty( $cdnfsd_engine ):
$cdn_label =
$cdn_name .
' <acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">' . __( 'CDN', 'w3-total-cache' ) . '</acronym>' .
' ' . __( 'and', 'w3-total-cache' ) . ' ' .
$cdnfsd_name .
' <acronym title="' . __( 'Content Delivery Network Full Site Delivery', 'w3-total-cache' ) . '">' . __( 'CDN FSD', 'w3-total-cache' ) . '</acronym>';
break;
case $cdn_enabled && ! empty( $cdn_engine ):
$cdn_label =
$cdn_name .
' <acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">' . __( 'CDN', 'w3-total-cache' ) . '</acronym>';
break;
case $cdnfsd_enabled && ! empty( $cdnfsd_engine ):
$cdn_label =
$cdnfsd_name .
' <acronym title="' . __( 'Content Delivery Network Full Site Delivery', 'w3-total-cache' ) . '">' . __( 'CDN FSD', 'w3-total-cache' ) . '</acronym>';
break;
default:
$cdn_label =
__( 'Unknown', 'w3-total-cache' ) .
' <acronym title="' . __( 'Content Delivery Network / Content Delivery Network Full Site Delivery', 'w3-total-cache' ) . '">' . __( 'CDN / CDN FSD', 'w3-total-cache' ) . '</acronym>';
break;
}
echo wp_kses(
sprintf(
// translators: 1 configured CDN/CDN FSD label.
__( 'W3 Total Cache has detected that you are using the %1$s, which is fully supported and compatible. For optimal performance and value, we recommend considering BunnyCDN as an alternative.', 'w3-total-cache' ),
$cdn_label
),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</p>
<?php
} else {
// No CDN is configured.
?>
<p class="notice notice-error">
<?php
echo wp_kses(
sprintf(
// translators: 1 HTML acronym for Content Delivery Network (CDN).
__( 'W3 Total Cache has detected that you do not have a %1$s configured. For optimal performance and value, we recommend considering BunnyCDN.', 'w3-total-cache' ),
'<acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">' . __( 'CDN', 'w3-total-cache' ) . '</acronym>'
),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</p>
<?php
}
?>
<p>
<?php
w3tc_e(
'cdn.bunnycdn.widget.v2.header',
\sprintf(
// translators: 1 HTML acronym for Content Delivery Network (CDN).
\__( 'Enhance your website performance by adding Bunny.Net\'s (%1$s) service to your site.', 'w3-total-cache' ),
'<acronym title="' . \__( 'Content Delivery Network', 'w3-total-cache' ) . '">' . \__( 'CDN', 'w3-total-cache' ) . '</acronym>'
)
);
?>
</p>
<h4 class="w3tc_bunnycdn_signup_h4"><?php \esc_html_e( 'New customer? Sign up now to speed up your site!', 'w3-total-cache' ); ?></h4>
<p>
<?php
w3tc_e(
'cdn.bunnycdn.widget.v2.works_magically',
\__( 'Bunny CDN works magically with W3 Total Cache to speed up your site around the world for as little as $1 per month.', 'w3-total-cache' )
);
?>
</p>
<a class="button-primary" href="<?php echo esc_url( W3TC_BUNNYCDN_SIGNUP_URL ); ?>" target="_blank">
<?php \esc_html_e( 'Sign Up Now ', 'w3-total-cache' ); ?>
</a>
<h4 class="w3tc_bunnycdn_signup_h4"><?php esc_html_e( 'Current customers', 'w3-total-cache' ); ?></h4>
<p>
<?php
w3tc_e(
'cdn.bunnycdn.widget.v2.existing',
\sprintf(
// translators: 1 HTML acronym for Content Delivery Network (CDN).
\__(
'If you\'re an existing Bunny CDN customer, enable %1$s and authorize. If you need help configuring your %1$s, we also offer Premium Services to assist you.',
'w3-total-cache'
),
'<acronym title="' . \__( 'Content Delivery Network', 'w3-total-cache' ) . '">' . \__( 'CDN', 'w3-total-cache' ) . '</acronym>'
)
);
?>
</p>
<a class="button-primary" href="<?php echo \esc_url( \wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_cdn' ), 'w3tc' ) ); ?>">
<?php \esc_html_e( 'Authorize', 'w3-total-cache' ); ?>
</a>
<a class="button" href="<?php echo \esc_url( \wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_support' ), 'w3tc' ) ); ?>">
<?php \esc_html_e( 'Premium Services', 'w3-total-cache' ); ?>
</a>
</div>