html-settings-updates.php
8.94 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?php
/**
* Renders the "License Information" and "Update Information" metaboxes.
*
* @package ACF
*/
$nonce = $active ? 'deactivate_pro_license' : 'activate_pro_license';
$activate_deactivate_btn = $active ? __( 'Deactivate License', 'acf' ) : __( 'Activate License', 'acf' );
/**
* Renders the license status table.
*
* @since 6.?
*
* @param array $status The current license status array.
* @return void
*/
function acf_pro_render_license_status_table( $status ) {
// Bail early if we don't have a status from the server.
if ( acf_pro_get_license_key() && empty( $status['status'] ) ) {
return;
}
$status['status'] = ! empty( $status['status'] ) ? $status['status'] : 'inactive';
$status_text = _x( 'Inactive', 'license status', 'acf' );
$is_lifetime = ! empty( $status['lifetime'] );
if ( 'active' === $status['status'] ) {
$status_text = _x( 'Active', 'license status', 'acf' );
} elseif ( 'expired' === $status['status'] ) {
$status_text = _x( 'Expired', 'license status', 'acf' );
} elseif ( 'cancelled' === $status['status'] ) {
$status_text = _x( 'Cancelled', 'license status', 'acf' );
}
$indicator = '<span class="acf-license-status ' . esc_attr( $status['status'] ) . '">' . esc_html( $status_text ) . '</span>';
?>
<table class="acf-license-status-table">
<tr>
<th>
<?php
if ( $is_lifetime || 'inactive' === $status['status'] ) {
esc_html_e( 'License Status', 'acf' );
} else {
esc_html_e( 'Subscription Status', 'acf' );
}
?>
</th>
<td><?php echo acf_esc_html( $indicator ); ?></td>
</tr>
<?php if ( ! empty( $status['name'] ) ) : ?>
<tr>
<th>
<?php
if ( $is_lifetime ) {
esc_html_e( 'License Type', 'acf' );
} else {
esc_html_e( 'Subscription Type', 'acf' );
}
?>
</th>
<td>
<?php
if ( $is_lifetime ) {
esc_html_e( 'Lifetime - ', 'acf' );
}
echo esc_html( $status['name'] );
?>
</td>
</tr>
<?php endif; ?>
<?php if ( ! $is_lifetime && ! empty( $status['expiry'] ) && is_numeric( $status['expiry'] ) ) : ?>
<tr>
<th>
<?php
if ( acf_pro_is_license_expired( $status ) ) {
esc_html_e( 'Subscription Expired', 'acf' );
} else {
esc_html_e( 'Subscription Expires', 'acf' );
}
?>
</th>
<td>
<?php
$date_format = get_option( 'date_format', 'F j, Y' );
$expiry_date = date_i18n( $date_format, $status['expiry'] );
echo esc_html( $expiry_date );
?>
</td>
</tr>
<?php endif; ?>
</table>
<?php
}
/**
* Renders the "Manage License"/"Renew Subscription" button.
*
* @since 6.?
*
* @param array $status The current license status.
* @return void
*/
function acf_pro_render_manage_license_button( $status ) {
// Lifetime licenses don't have anything to manage.
if ( ! empty( $status['lifetime'] ) ) {
return;
}
$url = 'https://www.advancedcustomfields.com/my-account/view-licenses/';
$text = __( 'Manage License', 'acf' );
$class = '';
if ( ! empty( $status['manage_subscription_url'] ) ) {
$url = $status['manage_subscription_url'];
} elseif ( ! empty( $status['view_licenses_url'] ) ) {
$url = $status['view_licenses_url'];
}
$url = acf_add_url_utm_tags( $url, 'updates page', 'manage license button' );
if ( acf_pro_is_license_expired( $status ) ) {
$text = __( 'Renew Subscription', 'acf' );
$class = ' acf-btn acf-renew-subscription';
}
printf(
'<a href="%1$s" target="_blank" class="acf-manage-license-btn%2$s">%3$s<i class="acf-icon acf-icon-arrow-up-right"></i></a>',
esc_url( $url ),
esc_attr( $class ),
esc_html( $text )
);
}
?>
<div class="wrap acf-settings-wrap acf-updates">
<h1><?php esc_html_e( 'Updates', 'acf' ); ?></h1>
<div class="acf-box" id="acf-license-information">
<div class="title">
<h3><?php esc_html_e( 'License Information', 'acf' ); ?></h3>
</div>
<div class="inner">
<?php if ( $is_defined_license ) : ?>
<p class="acf-license-defined">
<?php echo acf_esc_html( apply_filters( 'acf/admin/license_key_constant_message', __( 'Your license key is defined in wp-config.php.', 'acf' ) ) ); ?>
</p>
<?php if ( ! $active ) : ?>
<form class="acf-retry-activation" action="" method="post">
<?php acf_nonce_input( 'acf_delete_activation_transient' ); ?>
<input type="submit" value="<?php echo esc_attr( __( 'Retry Activation', 'acf' ) ); ?>" class="button button-primary">
</form>
<?php endif; ?>
<?php else : // License is not defined. ?>
<form action="" method="post" class="acf-activation-form">
<?php acf_nonce_input( $nonce ); ?>
<label for="acf-field-acf_pro_license"><?php esc_html_e( 'License Key', 'acf' ); ?></label>
<?php
acf_render_field(
array(
'type' => 'text',
'name' => 'acf_pro_license',
'value' => str_repeat( '*', strlen( $license ) ),
'readonly' => $active ? 1 : 0,
)
);
$activate_deactivate_btn_id = $active ? 'id="deactivate-license" ' : '';
$activate_deactivate_btn_class = $active ? ' acf-btn-tertiary' : '';
?>
<input <?php echo $activate_deactivate_btn_id; ?>type="submit" value="<?php echo esc_attr( $activate_deactivate_btn ); ?>" class="acf-btn<?php echo esc_attr( $activate_deactivate_btn_class ); ?>">
<?php
acf_pro_render_manage_license_button( $license_status );
if ( acf_pro_is_license_expired( $license_status ) ) {
$acf_recheck_url = admin_url( 'edit.php?post_type=acf-field-group&page=acf-settings-updates&acf-recheck-license=true' );
$acf_recheck_text = __( 'Recheck License', 'acf' );
printf(
'<a class="acf-recheck-license" href="%1$s"><i class="acf-icon acf-icon-regenerate"></i>%2$s</a>',
esc_url( $acf_recheck_url ),
esc_html( $acf_recheck_text )
);
}
?>
</form>
<?php endif; // End of license_defined check. ?>
<div class="acf-license-status-wrap">
<?php
acf_pro_render_license_status_table( $license_status );
if ( ! $active ) :
?>
<div class="acf-no-license-view-pricing">
<span>
<?php
$acf_view_pricing_text = esc_html__( 'View pricing & purchase', 'acf' );
$acf_view_pricing_link = sprintf(
'<a href=%s target="_blank">%s <i class="acf-icon acf-icon-arrow-up-right"></i></a>',
acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/pro/', 'ACF upgrade', 'license activations' ),
$acf_view_pricing_text
);
printf(
/* translators: %s - link to ACF website */
__( 'Don\'t have an ACF PRO license? %s', 'acf' ),
$acf_view_pricing_link
);
?>
</span>
</div>
<?php endif; ?>
</div>
</div>
</div>
<div class="acf-box" id="acf-update-information">
<div class="title">
<h3><?php esc_html_e( 'Update Information', 'acf' ); ?></h3>
</div>
<div class="inner">
<table class="form-table">
<tbody>
<tr>
<th>
<label><?php esc_html_e( 'Current Version', 'acf' ); ?></label>
</th>
<td>
<?php echo esc_html( $current_version ); ?>
</td>
</tr>
<tr>
<th>
<label><?php esc_html_e( 'Latest Version', 'acf' ); ?></label>
</th>
<td>
<?php echo esc_html( $remote_version ); ?>
</td>
</tr>
<tr>
<th>
<label><?php esc_html_e( 'Update Available', 'acf' ); ?></label>
</th>
<td>
<?php if ( $update_available ) : ?>
<span style="margin-right: 5px;"><?php esc_html_e( 'Yes', 'acf' ); ?></span>
<?php else : ?>
<span style="margin-right: 5px;"><?php esc_html_e( 'No', 'acf' ); ?></span>
<?php endif; ?>
</td>
</tr>
<?php if ( $upgrade_notice ) : ?>
<tr>
<th>
<label><?php esc_html_e( 'Upgrade Notice', 'acf' ); ?></label>
</th>
<td>
<?php echo acf_esc_html( $upgrade_notice ); ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php if ( $changelog ) : ?>
<div class="acf-update-changelog">
<?php echo acf_esc_html( $changelog ); ?>
</div>
<?php endif; ?>
<?php if ( $update_available ) : ?>
<?php if ( $wp_not_compatible ) : ?>
<a class="button" disabled="disabled" href="#"><?php esc_html_e( 'Please upgrade WordPress to update ACF', 'acf' ); ?></a>
<?php elseif ( $license_error ) : ?>
<a class="button" disabled="disabled" href="#"><?php esc_html_e( 'Please reactivate your license to unlock updates', 'acf' ); ?></a>
<?php elseif ( $active ) : ?>
<a class="acf-btn" href="<?php echo esc_attr( admin_url( 'plugins.php?s=Advanced+Custom+Fields+Pro' ) ); ?>"><?php esc_html_e( 'Update Plugin', 'acf' ); ?></a>
<?php else : ?>
<a class="button" disabled="disabled" href="#"><?php esc_html_e( 'Enter your license key to unlock updates', 'acf' ); ?></a>
<?php endif; ?>
<?php else : ?>
<a class="acf-btn acf-btn-secondary" href="<?php echo esc_attr( add_query_arg( 'force-check', 1 ) ); ?>"><?php esc_html_e( 'Check For Updates', 'acf' ); ?></a>
<?php endif; ?>
</div>
</div>
</div>