updated plugin `W3 Total Cache` version 2.5.0

This commit is contained in:
KawaiiPunk 2023-10-22 22:21:26 +00:00 committed by Gitium
parent 2f6b5b6047
commit 9e3fa792d7
255 changed files with 10113 additions and 23010 deletions

View File

@ -344,11 +344,11 @@ class BrowserCache_Environment_Nginx {
}
if ( ! empty( $feature_v ) ) {
$rules .= ' Header set Feature-Policy "' . implode( ';', $feature_v ) . "\"\n";
$rules[] = ' Header set Feature-Policy "' . implode( ';', $feature_v ) . "\"\n";
}
if ( ! empty( $permission_v ) ) {
$rules .= ' Header set Permissions-Policy "' . implode( ',', $permission_v ) . "\"\n";
$rules[] = ' Header set Permissions-Policy "' . implode( ',', $permission_v ) . "\"\n";
}
}
}

View File

@ -1232,5 +1232,4 @@ $feature_policies = array(
?>
</table>
<?php Util_Ui::button_config_save( 'browsercache_security' ); ?>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -377,7 +377,7 @@ class BrowserCache_Plugin {
$menu_items['20190.browsercache'] = array(
'id' => 'w3tc_flush_browsercache',
'parent' => 'w3tc_flush',
'title' => __( 'Browser Cache: Update Media Query String', 'w3-total-cache' ),
'title' => __( 'Browser Cache', 'w3-total-cache' ),
'href' => wp_nonce_url( admin_url(
'admin.php?page=w3tc_dashboard&amp;w3tc_flush_browser_cache' ),
'w3tc' )

View File

@ -62,7 +62,7 @@ class CacheFlush {
* Flushes object cache
*/
function objectcache_flush() {
if ( $this->_config->get_boolean( 'objectcache.enabled' ) ) {
if ( $this->_config->getf_boolean( 'objectcache.enabled' ) ) {
$this->_executor->objectcache_flush();
}
}

View File

@ -188,7 +188,7 @@ class CacheFlush_Locally {
add_action( 'w3tc_flush_all',
array( $this, 'dbcache_flush' ),
100, 2 );
if ( $config->get_boolean( 'objectcache.enabled' ) )
if ( $config->getf_boolean( 'objectcache.enabled' ) )
add_action( 'w3tc_flush_all',
array( $this, 'objectcache_flush' ),
200, 1 );

View File

@ -70,9 +70,6 @@ class CacheGroups_Plugin_Admin extends Base_Page_Settings {
// Load view.
require W3TC_DIR . '/CacheGroups_Plugin_Admin_View.php';
// Footer.
require W3TC_INC_DIR . '/options/common/footer.php';
}
/**
@ -99,7 +96,7 @@ class CacheGroups_Plugin_Admin extends Base_Page_Settings {
$theme = isset( $group_config['theme'] ) ? trim( $group_config['theme'] ) : 'default';
$enabled = isset( $group_config['enabled'] ) ? (bool) $group_config['enabled'] : true;
$redirect = isset( $group_config['redirect'] ) ? trim( $group_config['redirect'] ) : '';
$agents = isset( $group_config['agents'] ) ? explode( "\r\n", trim( $group_config['agents'] ) ) : array();
$agents = isset( $group_config['agents'] ) ? Util_Environment::textarea_to_array( $group_config['agents'] ) : array();
$mobile_groups[ $group ] = array(
'theme' => $theme,
@ -151,9 +148,12 @@ class CacheGroups_Plugin_Admin extends Base_Page_Settings {
$group_config
);
$mobile_groups[ $group ]['agents'] = array_unique( $mobile_groups[ $group ]['agents'] );
$mobile_groups[ $group ]['agents'] = array_map( 'strtolower', $mobile_groups[ $group ]['agents'] );
$mobile_groups[ $group ]['agents'] = array_unique(
array_map(
'strtolower',
$mobile_groups[ $group ]['agents']
)
);
sort( $mobile_groups[ $group ]['agents'] );
}
@ -183,7 +183,7 @@ class CacheGroups_Plugin_Admin extends Base_Page_Settings {
$theme = isset( $group_config['theme'] ) ? trim( $group_config['theme'] ) : 'default';
$enabled = isset( $group_config['enabled'] ) ? (bool) $group_config['enabled'] : true;
$redirect = isset( $group_config['redirect'] ) ? trim( $group_config['redirect'] ) : '';
$referrers = isset( $group_config['referrers'] ) ? explode( "\r\n", trim( $group_config['referrers'] ) ) : array();
$referrers = isset( $group_config['referrers'] ) ? Util_Environment::textarea_to_array( $group_config['referrers'] ) : array();
$referrer_groups[ $group ] = array(
'theme' => $theme,
@ -209,9 +209,12 @@ class CacheGroups_Plugin_Admin extends Base_Page_Settings {
$group_config
);
$referrer_groups[ $group ]['referrers'] = array_unique( $referrer_groups[ $group ]['referrers'] );
$referrer_groups[ $group ]['referrers'] = array_map( 'strtolower', $referrer_groups[ $group ]['referrers'] );
$referrer_groups[ $group ]['referrers'] = array_unique(
array_map(
'strtolower',
$referrer_groups[ $group ]['referrers']
)
);
sort( $referrer_groups[ $group ]['referrers'] );
}
@ -238,15 +241,9 @@ class CacheGroups_Plugin_Admin extends Base_Page_Settings {
$group = trim( $group, '_' );
if ( $group ) {
$enabled = isset( $group_config['enabled'] ) ?
(bool) $group_config['enabled'] : false;
$cache = isset( $group_config['cache'] ) ?
(bool) $group_config['cache'] : false;
$cookies = isset( $group_config['cookies'] ) ?
explode( "\r\n", trim( $group_config['cookies'] ) ) : array();
$cookies = array_unique( $cookies );
sort( $cookies );
$enabled = isset( $group_config['enabled'] ) ? (bool) $group_config['enabled'] : false;
$cache = isset( $group_config['cache'] ) ? (bool) $group_config['cache'] : false;
$cookies = isset( $group_config['cookies'] ) ? Util_Environment::textarea_to_array( $group_config['cookies'] ) : array();
$cookiegroups[ $group ] = array(
'enabled' => $enabled,

View File

@ -7,62 +7,123 @@
*/
jQuery(function() {
jQuery(document).on( 'submit', '#cachegroups_form', function() {
var error = [];
// User agent groups.
var mobile_groups = jQuery('#mobile_groups li');
mobile_groups.each(function(index, mobile_group) {
var $mobile_group = jQuery(mobile_group);
jQuery('#mobile_form').on( 'submit', function() {
var error = false;
if ($mobile_group.find('.mobile_group_enabled:checked').length) {
var name = $mobile_group.find('.mobile_group').text();
var theme = $mobile_group.find('select').val();
var redirect = $mobile_group.find('input[type=text]').val();
var agents = $mobile_group.find('textarea').val().split("\n").filter(function(line){return line.trim()!==''}).map(function(line){return line.trim();});
jQuery('#mobile_groups li').each(function() {
if (jQuery(this).find(':checked').length) {
var group = jQuery(this).find('.mobile_group').text();
var theme = jQuery(this).find(':selected').val();
var redirect = jQuery(this).find('input[type=text]').val();
var agents = jQuery.trim(jQuery(this).find('textarea').val()).split("\n");
mobile_groups.not($mobile_group).each(function(index, compare_mobile_group) {
var $compare_mobile_group = jQuery(compare_mobile_group);
jQuery('#mobile_groups li').each(function() {
if (jQuery(this).find(':checked').length) {
var compare_group = jQuery(this).find('.mobile_group').text();
if (compare_group != group) {
var compare_theme = jQuery(this).find(':selected').val();
var compare_redirect = jQuery(this).find('input[type=text]').val();
var compare_agents = jQuery.trim(jQuery(this).find('textarea').val()).split("\n");
if ($compare_mobile_group.find('.mobile_group_enabled:checked').length) {
var compare_name = $compare_mobile_group.find('.mobile_group').text();
var compare_theme = $compare_mobile_group.find('select').val();
var compare_redirect = $compare_mobile_group.find('input[type=text]').val();
var compare_agents = $compare_mobile_group.find('textarea').val().split("\n").filter(function(line){return line.trim()!==''}).map(function(line){return line.trim();});
if (compare_redirect == '' && redirect == '' && compare_theme != '' && compare_theme == theme) {
alert('Duplicate theme "' + compare_theme + '" found in the group "' + group + '".');
error = true;
return false;
}
var groups = sort_array([name, compare_name]);
if (compare_redirect != '' && compare_redirect == redirect) {
alert('Duplicate redirect "' + compare_redirect + '" found in the group "' + group + '".');
error = true;
return false;
}
if (compare_redirect === '' && redirect === '' && compare_theme !== '' && compare_theme === theme) {
error.push('Duplicate theme "' + compare_theme + '" found in the user agent groups "' + groups[0] + '" and "' + groups[1] + '"');
}
jQuery.each(compare_agents, function(index, value) {
if (jQuery.inArray(value, agents) != -1) {
alert('Duplicate stem "' + value + '" found in the group "' + compare_group + '".');
error = true;
return false;
}
});
}
}
});
if (compare_redirect !== '' && compare_redirect === redirect) {
error.push('Duplicate redirect "' + compare_redirect + '" found in the user agent groups "' + groups[0] + '" and "' + groups[1] + '"');
}
if (error) {
return false;
}
}
});
jQuery.each(compare_agents, function(index, value) {
if (jQuery.inArray(value, agents) !== -1) {
error.push('Duplicate stem "' + value + '" found in the user agent groups "' + groups[0] + '" and "' + groups[1] + '"');
}
});
}
});
}
});
if (error) {
var referrer_groups = jQuery('#referrer_groups li');
referrer_groups.each(function(index, referrer_group) {
var $referrer_group = jQuery(referrer_group);
if ($referrer_group.find('.referrer_group_enabled:checked').length) {
var name = $referrer_group.find('.referrer_group').text();
var theme = $referrer_group.find('select').val();
var redirect = $referrer_group.find('input[type=text]').val();
var agents = $referrer_group.find('textarea').val().split("\n").filter(function(line){return line.trim()!==''}).map(function(line){return line.trim();});
referrer_groups.not($referrer_group).each(function(index, compare_referrer_group) {
var $compare_referrer_group = jQuery(compare_referrer_group);
if ($compare_referrer_group.find('.referrer_group_enabled:checked').length) {
var compare_name = $compare_referrer_group.find('.referrer_group').text();
var compare_theme = $compare_referrer_group.find('select').val();
var compare_redirect = $compare_referrer_group.find('input[type=text]').val();
var compare_agents = $compare_referrer_group.find('textarea').val().split("\n").filter(function(line){return line.trim()!==''}).map(function(line){return line.trim();});
var groups = sort_array([name, compare_name]);
if (compare_redirect === '' && redirect === '' && compare_theme !== '' && compare_theme === theme) {
error.push('Duplicate theme "' + compare_theme + '" found in the referrer groups "' + groups[0] + '" and "' + groups[1] + '"');
}
if (compare_redirect !== '' && compare_redirect === redirect) {
error.push('Duplicate redirect "' + compare_redirect + '" found in the referrer groups "' + groups[0] + '" and "' + groups[1] + '"');
}
jQuery.each(compare_agents, function(index, value) {
if (jQuery.inArray(value, agents) !== -1) {
error.push('Duplicate stem "' + value + '" found in the referrer groups "' + groups[0] + '" and "' + groups[1] + '"');
}
});
}
});
}
});
var cookiegroups = jQuery('#cookiegroups li');
cookiegroups.each(function(index, cookiegroup) {
var $cookiegroup = jQuery(cookiegroup);
if ($cookiegroup.find('.cookiegroup_enabled:checked').length) {
var name = $cookiegroup.find('.cookiegroup_name').text();
var agents = $cookiegroup.find('textarea').val().split("\n").filter(function(line){return line.trim()!==''}).map(function(line){return line.trim();});
console.log(agents);
cookiegroups.not($cookiegroup).each(function(index, compare_cookiegroup) {
var $compare_cookiegroup = jQuery(compare_cookiegroup);
if ($compare_cookiegroup.find('.cookiegroup_enabled:checked').length) {
var compare_name = $compare_cookiegroup.find('.cookiegroup_name').text();
var compare_agents = $compare_cookiegroup.find('textarea').val().split("\n").filter(function(line){return line.trim()!==''}).map(function(line){return line.trim();});
console.log(compare_agents);
var groups = sort_array([name, compare_name]);
jQuery.each(compare_agents, function(index, value) {
if (jQuery.inArray(value, agents) !== -1) {
error.push('Duplicate stem "' + value + '" found in the cookie groups "' + groups[0] + '" and "' + groups[1] + '"');
}
});
}
});
}
});
if (error.length !== 0) {
alert(unique_array(error).join('\n'));
return false;
}
return true;
});
jQuery('#mobile_add').on( 'click', function() {
jQuery(document).on( 'click', '#mobile_add', function() {
var group = prompt('Enter group name (only "0-9", "a-z", "_" symbols are allowed).');
if (group !== null) {
@ -83,7 +144,46 @@ jQuery(function() {
});
if (!exists) {
var li = jQuery('<li id="mobile_group_' + group + '"><table class="form-table"><tr><th>Group name:</th><td><span class="mobile_group_number">' + (jQuery('#mobile_groups li').length + 1) + '.</span> <span class="mobile_group">' + group + '</span> <input type="button" class="button mobile_delete" value="Delete group" /></td></tr><tr><th><label for="mobile_groups_' + group + '_enabled">Enabled:</label></th><td><input type="hidden" name="mobile_groups[' + group + '][enabled]" value="0" /><input id="mobile_groups_' + group + '_enabled" type="checkbox" name="mobile_groups[' + group + '][enabled]" value="1" checked="checked" /></td></tr><tr><th><label for="mobile_groups_' + group + '_theme">Theme:</label></th><td><select id="mobile_groups_' + group + '_theme" name="mobile_groups[' + group + '][theme]"><option value="">-- Pass-through --</option></select><p class="description">Assign this group of user agents to a specific them. Leaving this option "Active Theme" allows any plugins you have (e.g. mobile plugins) to properly handle requests for these user agents. If the "redirect users to" field is not empty, this setting is ignored.</p></td></tr><tr><th><label for="mobile_groups_' + group + '_redirect">Redirect users to:</label></th><td><input id="mobile_groups_' + group + '_redirect" type="text" name="mobile_groups[' + group + '][redirect]" value="" size="60" /><p class="description">A 302 redirect is used to send this group of users to another hostname (domain); recommended if a 3rd party service provides a mobile version of your site.</p></td></tr><tr><th><label for="mobile_groups_' + group + '_agents">User agents:</label></th><td><textarea id="mobile_groups_' + group + '_agents" name="mobile_groups[' + group + '][agents]" rows="10" cols="50"></textarea><p class="description">Specify the user agents for this group.</p></td></tr></table></li>');
var li = jQuery('<li id="mobile_group_' + group + '">' +
'<table class="form-table">' +
'<tr>' +
'<th>Group name:</th>' +
'<td>' +
'<span class="mobile_group_number">' + (jQuery('#mobile_groups li').length + 1) + '.</span> ' +
'<span class="mobile_group">' + group + '</span> ' +
'<input type="button" class="button mobile_delete" value="Delete group" />' +
'</td>' +
'</tr>' +
'<tr>' +
'<th><label for="mobile_groups_' + group + '_enabled">Enabled:</label></th>' +
'<td>' +
'<input type="hidden" name="mobile_groups[' + group + '][enabled]" value="0" />' +
'<input id="mobile_groups_' + group + '_enabled" class="mobile_group_enabled" type="checkbox" name="mobile_groups[' + group + '][enabled]" value="1" checked="checked" />' +
'</td>' +
'</tr>' +
'<tr>' +
'<th><label for="mobile_groups_' + group + '_theme">Theme:</label></th>' +
'<td>' +
'<select id="mobile_groups_' + group + '_theme" name="mobile_groups[' + group + '][theme]"><option value="">-- Pass-through --</option></select>' +
'<p class="description">Assign this group of user agents to a specific them. Leaving this option "Active Theme" allows any plugins you have (e.g. mobile plugins) to properly handle requests for these user agents. If the "redirect users to" field is not empty, this setting is ignored.</p>' +
'</td>' +
'</tr>' +
'<tr>' +
'<th><label for="mobile_groups_' + group + '_redirect">Redirect users to:</label></th>' +
'<td>' +
'<input id="mobile_groups_' + group + '_redirect" type="text" name="mobile_groups[' + group + '][redirect]" value="" size="60" />' +
'<p class="description">A 302 redirect is used to send this group of users to another hostname (domain); recommended if a 3rd party service provides a mobile version of your site.</p>' +
'</td>' +
'</tr>' +
'<tr>' +
'<th><label for="mobile_groups_' + group + '_agents">User agents:</label></th>' +
'<td>' +
'<textarea id="mobile_groups_' + group + '_agents" name="mobile_groups[' + group + '][agents]" rows="10" cols="50"></textarea>' +
'<p class="description">Specify the user agents for this group.</p>' +
'</td>' +
'</tr>' +
'</table>' +
'</li>');
var select = li.find('select');
jQuery.each(mobile_themes, function(index, value) {
@ -101,7 +201,7 @@ jQuery(function() {
}
});
jQuery('.mobile_delete').on('click', function () {
jQuery(document).on('click', '.mobile_delete', function () {
if (confirm('Are you sure want to delete this group?')) {
jQuery(this).parents('#mobile_groups li').remove();
w3tc_mobile_groups_clear();
@ -113,59 +213,7 @@ jQuery(function() {
// Referrer groups.
jQuery('#referrer_form').on( 'submit', function() {
var error = false;
jQuery('#referrer_groups li').each(function() {
if (jQuery(this).find(':checked').length) {
var group = jQuery(this).find('.referrer_group').text();
var theme = jQuery(this).find(':selected').val();
var redirect = jQuery(this).find('input[type=text]').val();
var agents = jQuery.trim(jQuery(this).find('textarea').val()).split("\n");
jQuery('#referrer_groups li').each(function() {
if (jQuery(this).find(':checked').length) {
var compare_group = jQuery(this).find('.referrer_group').text();
if (compare_group != group) {
var compare_theme = jQuery(this).find(':selected').val();
var compare_redirect = jQuery(this).find('input[type=text]').val();
var compare_agents = jQuery.trim(jQuery(this).find('textarea').val()).split("\n");
if (compare_redirect == '' && redirect == '' && compare_theme != '' && compare_theme == theme) {
alert('Duplicate theme "' + compare_theme + '" found in the group "' + group + '".');
error = true;
return false;
}
if (compare_redirect != '' && compare_redirect == redirect) {
alert('Duplicate redirect "' + compare_redirect + '" found in the group "' + group + '".');
error = true;
return false;
}
jQuery.each(compare_agents, function(index, value) {
if (jQuery.inArray(value, agents) != -1) {
alert('Duplicate stem "' + value + '" found in the group "' + compare_group + '".');
error = true;
return false;
}
});
}
}
});
if (error) {
return false;
}
}
});
if (error) {
return false;
}
});
jQuery('#referrer_add').on( 'click', function() {
jQuery(document).on( 'click', '#referrer_add', function() {
var group = prompt('Enter group name (only "0-9", "a-z", "_" symbols are allowed).');
if (group !== null) {
@ -186,7 +234,48 @@ jQuery(function() {
});
if (!exists) {
var li = jQuery('<li id="referrer_group_' + group + '"><table class="form-table"><tr><th>Group name:</th><td><span class="referrer_group_number">' + (jQuery('#referrer_groups li').length + 1) + '.</span> <span class="referrer_group">' + group + '</span> <input type="button" class="button referrer_delete" value="Delete group" /></td></tr><tr><th><label for="referrer_groups_' + group + '_enabled">Enabled:</label></th><td><input type="hidden" name="referrer_groups[' + group + '][enabled]" value="0" /><input id="referrer_groups_' + group + '_enabled" type="checkbox" name="referrer_groups[' + group + '][enabled]" value="1" checked="checked" /></td></tr><tr><th><label for="referrer_groups_' + group + '_theme">Theme:</label></th><td><select id="referrer_groups_' + group + '_theme" name="referrer_groups[' + group + '][theme]"><option value="">-- Pass-through --</option></select><p class="description">Assign this group of referrers to a specific them. Leaving this option "Active Theme" allows any plugins you have (e.g. referrer plugins) to properly handle requests for these referrers. If the "redirect users to" field is not empty, this setting is ignored.</p></td></tr><tr><th><label for="referrer_groups_' + group + '_redirect">Redirect users to:</label></th><td><input id="referrer_groups_' + group + '_redirect" type="text" name="referrer_groups[' + group + '][redirect]" value="" size="60" /><p class="description">A 302 redirect is used to send this group of users to another hostname (domain); recommended if a 3rd party service provides a referrer version of your site.</p></td></tr><tr><th><label for="referrer_groups_' + group + '_referrers">Referrers:</label></th><td><textarea id="referrer_groups_' + group + '_referrers" name="referrer_groups[' + group + '][referrers]" rows="10" cols="50"></textarea><p class="description">Specify the referrers for this group.</p></td></tr></table></li>');
var li = jQuery('<li id="referrer_group_' + group + '">' +
'<table class="form-table">' +
'<tr>' +
'<th>Group name:</th>' +
'<td>' +
'<span class="referrer_group_number">' + (jQuery('#referrer_groups li').length + 1) + '.</span> ' +
'<span class="referrer_group">' + group + '</span> ' +
'<input type="button" class="button referrer_delete" value="Delete group" />' +
'</td>' +
'</tr>' +
'<tr>' +
'<th>' +
'<label for="referrer_groups_' + group + '_enabled">Enabled:</label>' +
'</th>' +
'<td>' +
'<input type="hidden" name="referrer_groups[' + group + '][enabled]" value="0" />' +
'<input id="referrer_groups_' + group + '_enabled" class="referrer_group_enabled" type="checkbox" name="referrer_groups[' + group + '][enabled]" value="1" checked="checked" />' +
'</td>' +
'</tr>' +
'<tr>' +
'<th><label for="referrer_groups_' + group + '_theme">Theme:</label></th>' +
'<td>' +
'<select id="referrer_groups_' + group + '_theme" name="referrer_groups[' + group + '][theme]"><option value="">-- Pass-through --</option></select>' +
'<p class="description">Assign this group of referrers to a specific them. Leaving this option "Active Theme" allows any plugins you have (e.g. referrer plugins) to properly handle requests for these referrers. If the "redirect users to" field is not empty, this setting is ignored.</p>' +
'</td>' +
'</tr>' +
'<tr>' +
'<th><label for="referrer_groups_' + group + '_redirect">Redirect users to:</label></th>' +
'<td>' +
'<input id="referrer_groups_' + group + '_redirect" type="text" name="referrer_groups[' + group + '][redirect]" value="" size="60" />' +
'<p class="description">A 302 redirect is used to send this group of users to another hostname (domain); recommended if a 3rd party service provides a referrer version of your site.</p>' +
'</td>' +
'</tr>' +
'<tr>' +
'<th><label for="referrer_groups_' + group + '_referrers">Referrers:</label></th>' +
'<td>' +
'<textarea id="referrer_groups_' + group + '_referrers" name="referrer_groups[' + group + '][referrers]" rows="10" cols="50"></textarea>' +
'<p class="description">Specify the referrers for this group.</p>' +
'</td>' +
'</tr>' +
'</table>' +
'</li>');
var select = li.find('select');
jQuery.each(referrer_themes, function(index, value) {
@ -204,7 +293,7 @@ jQuery(function() {
}
});
jQuery('.referrer_delete').on('click', function () {
jQuery(document).on('click', '.referrer_delete', function () {
if (confirm('Are you sure want to delete this group?')) {
jQuery(this).parents('#referrer_groups li').remove();
w3tc_referrer_groups_clear();
@ -216,7 +305,7 @@ jQuery(function() {
// Cookie groups.
jQuery( '#w3tc_cookiegroup_add' ).on( 'click', function() {
jQuery(document).on( 'click', '#w3tc_cookiegroup_add', function() {
var group = prompt('Enter group name (only "0-9", "a-z", "_" symbols are allowed).');
if (group !== null) {
@ -241,27 +330,32 @@ jQuery(function() {
'<table class="form-table">' +
'<tr>' +
'<th>Group name:</th>' +
'<td><span class="cookiegroup_number">' + (jQuery('#cookiegroups li').length + 1) + '.</span> ' +
'<td>' +
'<span class="cookiegroup_number">' + (jQuery('#cookiegroups li').length + 1) + '.</span> ' +
'<span class="cookiegroup_name">' + group + '</span> ' +
'<input type="button" class="button cookiegroup_delete" value="Delete group" /></td>' +
'<input type="button" class="button w3tc_cookiegroup_delete" value="Delete group" />' +
'</td>' +
'</tr>' +
'<tr>' +
'<th><label for="cookiegroup_' + group + '_enabled">Enabled:</label></th>' +
'<td>' +
'<input id="cookiegroup_' + group + '_enabled" type="checkbox" name="cookiegroups[' +
group + '][enabled]" value="1" checked="checked" /></td>' +
'<input id="cookiegroup_' + group + '_enabled" class="cookiegroup_enabled" type="checkbox" name="cookiegroups[' + group + '][enabled]" value="1" checked="checked" />' +
'</td>' +
'</tr>' +
'<tr>' +
'<th><label for="cookiegroup_' + group + '_cache">Cache:</label></th>' +
'<td>' +
'<input id="cookiegroup_' + group + '_cache" type="checkbox" name="cookiegroups[' +
group + '][cache]" value="1" checked="checked" /></td></tr>' +
'<input id="cookiegroup_' + group + '_cache" type="checkbox" name="cookiegroups[' + group + '][cache]" value="1" checked="checked" /></td>' +
'</tr>' +
'<tr>' +
'<th><label for="cookiegroups_' + group + '_cookies">Cookies:</label></th>' +
'<td><textarea id="cookiegroups_' + group + '_cookies" name="cookiegroups[' +
group + '][cookies]" rows="10" cols="50"></textarea>' +
'<p class="description">Specify the cookies for this group. Values like \'cookie\', \'cookie=value\', and cookie[a-z]+=value[a-z]+are supported. Remember to escape special characters like spaces, dots or dashes with a backslash. Regular expressions are also supported.</p></td></tr>' +
'</table></li>');
'<td>' +
'<textarea id="cookiegroups_' + group + '_cookies" name="cookiegroups[' + group + '][cookies]" rows="10" cols="50"></textarea>' +
'<p class="description">Specify the cookies for this group. Values like \'cookie\', \'cookie=value\', and cookie[a-z]+=value[a-z]+are supported. Remember to escape special characters like spaces, dots or dashes with a backslash. Regular expressions are also supported.</p>' +
'</td>' +
'</tr>' +
'</table>' +
'</li>');
var select = li.find('select');
jQuery('#cookiegroups').append(li);
@ -275,7 +369,7 @@ jQuery(function() {
}
});
jQuery('.w3tc_cookiegroup_delete').on( 'click', function () {
jQuery(document).on( 'click', '.w3tc_cookiegroup_delete', function () {
if (confirm('Are you sure want to delete this group?')) {
jQuery(this).parents('#cookiegroups li').remove();
w3tc_cookiegroups_clear();
@ -322,3 +416,10 @@ function w3tc_cookiegroups_clear() {
jQuery('#cookiegroups_empty').hide();
}
}
function unique_array(array) {
return jQuery.grep(array,function(el,i){return i === jQuery.inArray(el,array)});
}
function sort_array(array) {
return array.sort();
}

View File

@ -21,8 +21,9 @@ if ( ! defined( 'W3TC' ) ) {
?>
<form id="cachegroups_form" action="admin.php?page=<?php echo esc_attr( $this->_page ); ?>" method="post">
<?php Util_UI::print_control_bar( 'cachegroups_form_control' ); ?>
<!-- User Agenet Groups -->
<!-- User Agenet Groups -->
<script type="text/javascript">/*<![CDATA[*/
var mobile_themes = {};
@ -67,7 +68,7 @@ if ( ! defined( 'W3TC' ) ) {
<td>
<input type="hidden" name="mobile_groups[<?php echo esc_attr( $group ); ?>][enabled]" value="0" />
<input id="mobile_groups_<?php echo esc_attr( $group ); ?>_enabled"
type="checkbox"
class="mobile_group_enabled" type="checkbox"
name="mobile_groups[<?php echo esc_attr( $group ); ?>][enabled]"
<?php disabled( $useragent_groups['disabled'] ); ?> value="1"
<?php checked( $group_config['enabled'], true ); ?> />
@ -124,10 +125,6 @@ if ( ! defined( 'W3TC' ) ) {
<div id="mobile_groups_empty" style="display: none;"><?php esc_html_e( 'No groups added. All user agents recieve the same page and minify cache results.', 'w3-total-cache' ); ?></div>
<?php
if ( ! $useragent_groups['disabled'] ) {
Util_Ui::button_config_save( 'mobile' );
}
Util_Ui::postbox_footer();
Util_Ui::postbox_header(
@ -187,7 +184,10 @@ if ( ! defined( 'W3TC' ) ) {
</th>
<td>
<input type="hidden" name="referrer_groups[<?php echo esc_attr( $group ); ?>][enabled]" value="0" />
<input id="referrer_groups_<?php echo esc_attr( $group ); ?>_enabled" type="checkbox" name="referrer_groups[<?php echo esc_attr( $group ); ?>][enabled]" value="1"<?php checked( $group_config['enabled'], true ); ?> />
<input id="referrer_groups_<?php echo esc_attr( $group ); ?>_enabled"
class="referrer_group_enabled" type="checkbox"
name="referrer_groups[<?php echo esc_attr( $group ); ?>][enabled]"
value="1"<?php checked( $group_config['enabled'], true ); ?> />
</td>
</tr>
<tr>
@ -228,7 +228,6 @@ if ( ! defined( 'W3TC' ) ) {
</ul>
<div id="referrer_groups_empty" style="display: none;"><?php esc_html_e( 'No groups added. All referrers recieve the same page and minify cache results.', 'w3-total-cache' ); ?></div>
<?php Util_Ui::button_config_save( 'referrers' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>
@ -271,7 +270,7 @@ if ( ! defined( 'W3TC' ) ) {
</th>
<td>
<input id="cookiegroup_<?php echo esc_attr( $group ); ?>_enabled"
type="checkbox"
class="cookiegroup_enabled" type="checkbox"
name="cookiegroups[<?php echo esc_attr( $group ); ?>][enabled]"
<?php disabled( $cookie_groups['disabled'] ); ?> value="1"
<?php checked( $group_config['enabled'], true ); ?> />
@ -288,7 +287,8 @@ if ( ! defined( 'W3TC' ) ) {
type="checkbox"
name="cookiegroups[<?php echo esc_attr( $group ); ?>][cache]"
<?php disabled( $cookie_groups['disabled'] ); ?> value="1"
<?php checked( $group_config['cache'], true ); ?> />
<?php checked( $group_config['cache'], true ); ?> /> <?php esc_html_e( 'Enable', 'w3-total-cache' ); ?>
<p class="description"><?php esc_html_e( 'Controls whether web pages can be cached or not when cookies from this group are detected.', 'w3-total-cache' ); ?></p>
</td>
</tr>
<tr>
@ -313,10 +313,6 @@ if ( ! defined( 'W3TC' ) ) {
<div id="cookiegroups_empty" style="display: none;"><?php esc_html_e( 'No groups added. All Cookies recieve the same page and minify cache results.', 'w3-total-cache' ); ?></div>
<?php
if ( ! $cookie_groups['disabled'] ) {
Util_Ui::button_config_save( 'pgcache_cookiegroups' );
}
Util_Ui::postbox_footer();
Util_Ui::postbox_header(

View File

@ -270,7 +270,13 @@ class Cache_File_Generic extends Cache_File {
}
}
@touch( $old_entry_path, 1479904835 );
/**
* Disabling this as we don't want to immediately hard-expire _old cache files as there is a
* 30 second window where they are still served via get_with_old calls. During AWS testing on
* WP 5.9/6.3 this was resulting in the _old file immediately being removed during the clean
* operation, resulting in failed automated tests (8/1/2023)
*/
// @touch( $old_entry_path, 1479904835 );
return true;
}

View File

@ -506,13 +506,4 @@ class Cdn_AdminActions {
return 200 == $code;
}
}
function w3tc_cdn_stackpath_signup() {
try {
$state = Dispatcher::config_state();
$state->set( 'track.stackpath_signup', time() );
$state->save();
} catch ( \Exception $ex ) {}
Util_Environment::redirect( W3TC_STACKPATH_SIGNUP_URL );
}
}

View File

@ -11,7 +11,7 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
Util_Ui::postbox_header(
Util_Ui::postbox_header_tabs(
wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
@ -28,8 +28,19 @@ Util_Ui::postbox_header(
),
)
),
esc_html__(
'Content Delivery Network (CDN) is a powerful feature that can significantly enhance the performance of
your WordPress website. By leveraging a distributed network of servers located worldwide, a CDN helps
deliver your website\'s static files, such as images, CSS, and JavaScript, to visitors more efficiently.
This reduces the latency and improves the loading speed of your website, resulting in a faster and
smoother browsing experience for your users. With W3 Total Cache\'s CDN integration, you can easily
configure and connect your website to a CDN service of your choice, unleashing the full potential of
your WordPress site\'s speed optimization.',
'w3-total-cache'
),
'',
'cdn'
'cdn',
Util_UI::admin_url( 'admin.php?page=w3tc_cdn' )
);
Util_Ui::config_overloading_button(
array(
@ -39,50 +50,49 @@ Util_Ui::config_overloading_button(
?>
<p>
<?php
w3tc_e(
'cdn.general.header',
wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'Host static files with your %1$sCDN%2$s to reduce page load time.',
'w3-total-cache'
),
'<acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">',
'</acronym>'
),
array(
'acronym' => array(
'title' => array(),
),
)
)
);
$config = Dispatcher::config();
$cdn_engine = $config->get_string( 'cdn.engine' );
$cdnfsd_engine = $config->get_string( 'cdnfsd.engine' );
$stackpaths = array( 'stackpath', 'stackpath2' );
if ( ! $cdn_enabled ) {
echo '&nbsp;' . wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
// translators: 3 opening HTML a tag, 4 closing HTML a tag.
__(
'If you do not have a %1$sCDN%2$s provider try StackPath. %3$sSign up now to enjoy a special offer!%4$s.',
'w3-total-cache'
),
'<acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">',
'</acronym>',
'<a href="' . esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_stackpath_signup' ), 'w3tc' ) ) . '" target="_blank">',
'</a>'
),
array(
'acronym' => array(
'title' => array(),
),
'a' => array(
'href' => array(),
'target' => array(),
),
)
);
if ( in_array( $cdn_engine, $stackpaths, true ) || in_array( $cdnfsd_engine, $stackpaths, true ) ) {
?>
<div class="notice notice-warning inline">
<p>
<?php
// StackPath sunset is 12:00 am Central (UTC-6:00) on November, 22, 2023 (1700629200).
$date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
printf(
// translators: 1 StackPath sunset datetime.
__(
'StackPath will cease operations at %1$s.',
'w3-total-cache'
),
wp_date( $date_time_format, '1700629200' )
);
?>
</p>
</div>
<?php
} elseif ( 'highwinds' === $cdn_engine || 'highwinds' === $cdnfsd_engine ) {
?>
<div class="notice notice-warning inline">
<p>
<?php
// HighWinds sunset is 12:00 am Central (UTC-6:00) on November, 22, 2023 (1700629200).
$date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
printf(
// translators: 1 HighWinds sunset datetime.
__(
'HighWinds will cease operations at %1$s.',
'w3-total-cache'
),
wp_date( $date_time_format, '1700629200' )
);
?>
</p>
</div>
<?php
}
?>
</p>
@ -144,12 +154,6 @@ Util_Ui::config_overloading_button(
<?php
do_action( 'w3tc_settings_general_boxarea_cdn_footer' );
Util_Ui::button_config_save(
'general_cdn',
'<input id="cdn_purge" type="button" value="' . __( 'Empty cache', 'w3-total-cache' ) .
'" ' . ( $cdn_enabled && Cdn_Util::can_purge_all( $config->get_string( 'cdn.engine' ) ) ? '' : ' disabled="disabled" ' ) .
' class="button {nonce: \'' . wp_create_nonce( 'w3tc' ) . '\'}" />'
);
?>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -5,6 +5,24 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<p>
<div class="notice notice-warning inline">
<p>
<?php
// HighWinds sunset is 12:00 am Central (UTC-6:00) on November, 22, 2023 (1700629200).
$date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
printf(
// translators: 1 HighWinds sunset datetime.
__(
'HighWinds will cease operations at %1$s.',
'w3-total-cache'
),
wp_date( $date_time_format, '1700629200' )
);
?>
</p>
</div>
</p>
<div class="wrapper">
<div class="tools area">
<ul class="w3tchw_tools">

View File

@ -5,6 +5,24 @@ if ( !defined( 'W3TC' ) )
die();
?>
<p>
<div class="notice notice-warning inline">
<p>
<?php
// HighWinds sunset is 12:00 am Central (UTC-6:00) on November, 22, 2023 (1700629200).
$date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
printf(
// translators: 1 HighWinds sunset datetime.
__(
'HighWinds will cease operations at %1$s.',
'w3-total-cache'
),
wp_date( $date_time_format, '1700629200' )
);
?>
</p>
</div>
</p>
<div class="wrapper">
Not configured
</div>

View File

@ -790,7 +790,7 @@ class Cdn_Plugin {
$menu_items['20710.cdn'] = array(
'id' => 'w3tc_cdn_flush_all',
'parent' => 'w3tc_flush',
'title' => __( 'CDN: All', 'w3-total-cache' ),
'title' => __( 'CDN Cache', 'w3-total-cache' ),
'href' => wp_nonce_url( admin_url( 'admin.php?page=w3tc_cdn&amp;w3tc_flush_cdn' ), 'w3tc' ),
);
}

View File

@ -5,40 +5,6 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<?php if ( ! $authorized ) : ?>
<tr>
<th style="width: 300px;"><label><?php esc_html_e( 'Create account:', 'w3-total-cache' ); ?></label></th>
<td>
<p class="notice notice-error">
<?php
w3tc_e(
'cdn.stackpath.widget.v2.no_cdn',
sprintf(
// translators: 1 HTML acronym for Content Delivery Network (CDN).
__( 'W3 Total Cache has detected that you do not have a %1$s configured', 'w3-total-cache' ),
'<acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">' . __( 'CDN', 'w3-total-cache' ) . '</acronym>'
)
);
?>
</p>
<p>
<?php esc_html_e( 'Enhance your website Performance with StackPath\'s CDN services. StackPath works magically with W3 Total Cache to speed up your site around the world for as little as $10 a month.', 'w3-total-cache' ); ?>
</p>
<p>
<a href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL ); ?>" target="_blank" id="stackpath-create-account" class="button-primary"><?php w3tc_e( 'cdn.stackpath2.signUpAndSave', __( 'Sign Up Now and save!', 'w3-total-cache' ) ); ?></a>
</p>
<p class="description">
<?php
w3tc_e(
'cdn.stackpath2.signUpAndSave.description',
__( 'StackPath is a service that lets you speed up your site even more with W3 Total Cache. Sign up now to recieve a special offer!', 'w3-total-cache' )
);
?>
</p>
</td>
</tr>
<?php endif; ?>
<tr>
<th style="width: 300px;">
<label>

View File

@ -5,6 +5,24 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<p>
<div class="notice notice-warning inline">
<p>
<?php
// StackPath sunset is 12:00 am Central (UTC-6:00) on November, 22, 2023 (1700629200).
$date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
printf(
// translators: 1 StackPath sunset datetime.
__(
'StackPath will cease operations at %1$s.',
'w3-total-cache'
),
wp_date( $date_time_format, '1700629200' )
);
?>
</p>
</div>
</p>
<div class="w3tcstackpath2_loading w3tc_loading w3tc_hidden">Loading...</div>
<div class="w3tcstackpath2_error w3tc_none">
An error occurred

View File

@ -5,6 +5,24 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<p>
<div class="notice notice-warning inline">
<p>
<?php
// StackPath sunset is 12:00 am Central (UTC-6:00) on November, 22, 2023 (1700629200).
$date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
printf(
// translators: 1 StackPath sunset datetime.
__(
'StackPath will cease operations at %1$s.',
'w3-total-cache'
),
wp_date( $date_time_format, '1700629200' )
);
?>
</p>
</div>
</p>
<div id="stackpath-widget" class="w3tcstackpath_signup">
<?php if ( ! $c->get_boolean( 'cdn.enabled' ) ) : ?>
<p class="notice notice-error">
@ -20,32 +38,6 @@ if ( ! defined( 'W3TC' ) ) {
?>
</p>
<?php endif ?>
<p>
<?php
w3tc_e(
'cdn.stackpath.widget.v2.header',
sprintf(
// translators: 1 HTML acronym for Content Delivery Network (CDN).
__( 'Enhance your website performance by adding StackPath\'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="w3tcstackpath_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.stackpath2.widget.v2.works_magically',
__( 'StackPath works magically with W3 Total Cache to speed up your site around the world for as little as $10 per month.', 'w3-total-cache' )
);
?>
</p>
<a class="button-primary" href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL ); ?>" target="_blank">
<?php esc_html_e( 'Sign Up Now ', 'w3-total-cache' ); ?>
</a>
<p>
<h4 class="w3tcstackpath_signup_h4"><?php esc_html_e( 'Current customers', 'w3-total-cache' ); ?></h4>
<p>

View File

@ -5,16 +5,6 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<?php if ( ! $authorized ) : ?>
<tr>
<th style="width: 300px;"><label><?php esc_html_e( 'Create account:', 'w3-total-cache' ); ?></label></th>
<td>
<a href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL ); ?>" target="_blank" id="stackpath-create-account" class="button-primary"><?php w3tc_e( 'cdn.stackpath.signUpAndSave', __( 'Sign Up Now and save!', 'w3-total-cache' ) ); ?></a>
<p class="description"><?php w3tc_e( 'cdn.stackpath.signUpAndSave.description', __( 'StackPath is a service that lets you speed up your site even more with W3 Total Cache. Sign up now and save!', 'w3-total-cache' ) ); ?></p>
</td>
</tr>
<?php endif; ?>
<tr>
<th style="width: 300px;">
<label>

View File

@ -5,6 +5,24 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<p>
<div class="notice notice-warning inline">
<p>
<?php
$date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
$sunset_timestamp = wp_date( $date_time_format, '1700629200' );
printf(
// translators: 1 sunset unix timestamp.
__(
'StackPath will cease operations at %1$s.',
'w3-total-cache'
),
$sunset_timestamp
);
?>
</p>
</div>
</p>
<div class="w3tcstackpath_loading w3tc_loading w3tc_hidden">Loading...</div>
<div class="w3tcstackpath_error w3tc_none">
An error occurred

View File

@ -5,23 +5,26 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<p>
<div class="notice notice-warning inline">
<p>
<?php
// StackPath sunset is 12:00 am Central (UTC-6:00) on November, 22, 2023 (1700629200).
$date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
printf(
// translators: 1 StackPath sunset datetime.
__(
'StackPath will cease operations at %1$s.',
'w3-total-cache'
),
wp_date( $date_time_format, '1700629200' )
);
?>
</p>
</div>
</p>
<div id="stackpath-widget" class="w3tcstackpath_signup">
<p>
<?php
w3tc_e(
'cdn.stackpath.widget.header',
sprintf(
// translators: 1 HTML acronym for Content Delivery Network (CDN).
__( 'Dramatically increase website speeds in just a few clicks! Add the StackPath content delivery network (%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="w3tcstackpath_signup_h4"><?php esc_html_e( 'New customers', 'w3-total-cache' ); ?></h4>
<p><?php w3tc_e( 'cdn.stackpath.widget.works_magically', __( 'StackPath works magically with W3 Total Cache.', 'w3-total-cache' ) ); ?></p>
<a class="button-primary" href="<?php echo esc_url( W3TC_STACKPATH_SIGNUP_URL ); ?>" target="_blank"><?php esc_html_e( 'Sign Up Now ', 'w3-total-cache' ); ?></a>
<p><!--span class="desc"><?php esc_html_e( 'Exclusive offers availabel for W3TC users!', 'w3-total-cache' ); ?></span></p>-->
<h4 class="w3tcstackpath_signup_h4"><?php esc_html_e( 'Current customers', 'w3-total-cache' ); ?></h4>
<p>
<?php

View File

@ -9,8 +9,6 @@ $key = $config->get_string( 'cdnfsd.cloudfront.access_key' );
$authorized = ! empty( $key );
?>
<form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ), '', 'configuration' ); ?>
<table class="form-table">
<tr>
@ -68,7 +66,4 @@ $authorized = ! empty( $key );
<?php endif; ?>
</table>
<?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>

View File

@ -21,36 +21,9 @@ if ( ! defined( 'W3TC' ) ) {
'<acronym title="' . __( 'Content Delivery Network', 'w3-total-cache' ) . '">' . __( 'CDN', 'w3-total-cache' ) . '</acronym>'
)
);
if ( ! $cdnfsd_enabled ) {
echo '&nbsp;' . wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag,
// translators: 3 opening HTML a tag to W3TC MaxCDN Signup admin page, 4 closing HTML a tag.
__(
'If you do not have a %1$sCDN%2$s provider try StackPath. %3$sSign up now to enjoy a special offer!%4$s.',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Content Delivery Network', 'w3-total-cache' ) . '">',
'</acronym>',
'<a href="' . esc_url( wp_nonce_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard&w3tc_cdn_stackpath_signup' ), 'w3tc' ) ) . '" target="_blank">',
'</a>'
),
array(
'acronym' => array(
'title' => array(),
),
'a' => array(
'href' => array(),
'target' => array(),
),
)
);
}
?>
</p>
<table class="<?php echo esc_attr( Util_Ui::table_class() ); ?>">
<table class="form-table">
<?php
Util_Ui::config_item_pro(
array(

View File

@ -9,8 +9,6 @@ $key = $config->get_string( 'cdnfsd.limelight.api_key' );
$authorized = ! empty( $key );
?>
<form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ), '', 'configuration' ); ?>
<table class="form-table">
<tr>
@ -31,5 +29,3 @@ $authorized = ! empty( $key );
</tr>
</table>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>

View File

@ -9,8 +9,6 @@ $key = $config->get_string( 'cdnfsd.stackpath2.client_id' );
$authorized = ! empty( $key );
?>
<form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
<div class="metabox-holder">
<?php
Util_Ui::postbox_header(
esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ),
@ -78,7 +76,4 @@ $authorized = ! empty( $key );
<?php endif; ?>
</table>
<?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>

View File

@ -9,8 +9,6 @@ $key = $config->get_string( 'cdnfsd.stackpath.api_key' );
$authorized = ! empty( $key );
?>
<form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ), '', 'configuration' ); ?>
<table class="form-table">
<tr>
@ -72,7 +70,4 @@ $authorized = ! empty( $key );
<?php endif ?>
</table>
<?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>

View File

@ -15,8 +15,6 @@ $key = $config->get_string( 'cdnfsd.transparentcdn.client_id' );
$authorized = ! empty( $key );
?>
<form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
<div class="metabox-holder">
<?php
Util_Ui::postbox_header(
__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ),
@ -66,7 +64,5 @@ $authorized = ! empty( $key );
</td>
</tr>
</table>
<?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>

View File

@ -99,8 +99,9 @@ class ConfigCompiler {
$this->_keys = $keys;
// move _date to initial state
foreach ( $this->_keys as $key => $value )
foreach ( $this->_keys as $key => $value ) {
$this->_data[$key] = $value['default'];
}
$this->_data['version'] = W3TC_VERSION;

View File

@ -2600,9 +2600,7 @@ $keys = array(
'extensions.active' => array(
'type' => 'array',
'default' => array(
'fragmentcache' => 'w3-total-cache/Extension_FragmentCache_Plugin.php',
),
'default' => array(),
),
'extensions.active_frontend' => array(
'type' => 'array',
@ -2638,6 +2636,12 @@ $keys = array(
'type' => 'boolean',
'default' => true,
),
'fragmentcache' => array(
'type' => 'array',
'default' => array(
'engine' => 'file',
),
),
// extensions keys:
//

View File

@ -21,7 +21,7 @@ class DbCache_Environment {
$exs = new Util_Environment_Exceptions();
try {
if ( $config->get_boolean( 'dbcache.enabled' ) ||
Util_Environment::is_dbcluster() ) {
Util_Environment::is_dbcluster( $config ) ) {
$this->create_addin();
} else {
$this->delete_addin();

View File

@ -30,7 +30,7 @@ class DbCache_Page extends Base_Page_Settings {
*/
function dbcluster_config() {
$this->_page = 'w3tc_dbcluster_config';
if ( Util_Environment::is_dbcluster() )
if ( Util_Environment::is_dbcluster( $this->_config ) )
$content = @file_get_contents( W3TC_FILE_DB_CLUSTER_CONFIG );
else
$content = @file_get_contents( W3TC_DIR . '/ini/dbcluster-config-sample.php' );

View File

@ -60,7 +60,8 @@ class DbCache_Plugin {
add_action( 'edit_user_profile_update', array( $this, 'on_change' ), 0 );
if ( Util_Environment::is_wpmu() ) {
add_action( 'delete_blog', array( $this, 'on_change' ), 0 );
add_action( 'wp_uninitialize_site', array( $this, 'on_change' ), 0 );
add_action( 'wp_update_site', array( $this, 'on_change' ), 0 );
}
add_filter( 'w3tc_admin_bar_menu', array( $this, 'w3tc_admin_bar_menu' ) );

View File

@ -25,7 +25,7 @@ class DbCache_Wpdb extends DbCache_WpdbBase {
if ( !$is_installing && $config->get_boolean( 'dbcache.enabled' ) ) {
$processors[] = new DbCache_WpdbInjection_QueryCaching();
}
if ( Util_Environment::is_dbcluster() ) {
if ( Util_Environment::is_dbcluster( $config ) ) {
// dbcluster use mysqli only since other is obsolete now
if ( !defined( 'WP_USE_EXT_MYSQL' ) ) {
define( 'WP_USE_EXT_MYSQL', false );

View File

@ -215,21 +215,21 @@ class DbCache_WpdbNew extends DbCache_WpdbBase {
}
/**
* Default initialization method, calls wp_db apropriate method
* Default initialization method, calls wp_db appropriate method.
*/
public function default_initialize() {
parent::__construct( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_insert( $table, $data, $format = null ) {
return parent::insert( $table, $data, $format );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_query( $query ) {
return parent::query( $query );
@ -240,91 +240,91 @@ class DbCache_WpdbNew extends DbCache_WpdbBase {
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_prepare( $query, $args ) {
return parent::prepare( $query, ...$args );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_replace( $table, $data, $format = null ) {
return parent::replace( $table, $data, $format );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_update( $table, $data, $where, $format = null, $where_format = null ) {
return parent::update( $table, $data, $where, $format, $where_format );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_delete( $table, $where, $where_format = null ) {
return parent::delete( $table, $where, $where_format );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_init_charset() {
return parent::init_charset();
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_set_charset( $dbh, $charset = null, $collate = null ) {
return parent::set_charset( $dbh, $charset, $collate );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_set_sql_mode( $modes = array() ) {
return parent::set_sql_mode( $modes );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_flush() {
return parent::flush();
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_check_database_version( $dbh_or_table = false ) {
return parent::check_database_version( $dbh_or_table );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_supports_collation( $dbh_or_table = false ) {
return parent::supports_collation( $dbh_or_table );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_has_cap( $db_cap, $dbh_or_table = false ) {
return parent::has_cap( $db_cap, $dbh_or_table );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function default_db_version( $dbh_or_table = false ) {
return parent::db_version( $dbh_or_table );
}
/**
* Default implementation, calls wp_db apropriate method
* Default implementation, calls wp_db appropriate method.
*/
public function switch_active_processor( $offset ) {
$new_processor_number = $this->active_processor_number + $offset;
@ -348,12 +348,24 @@ class DbCache_WpdbNew extends DbCache_WpdbBase {
* class CallUnderlying
*/
class _CallUnderlying {
/**
* WPDB mixin.
*
* @var object
*/
private $wpdb_mixin;
/**
* Constructor.
*
* @param object $manager Manager.
*/
function __construct( $manager ) {
$this->wpdb_mixin = $manager;
}
/**
* Calls underlying processor's aproptiate method of wp_db
* Calls underlying processor's appropriate method of wp_db.
*/
function initialize() {
$switched = $this->wpdb_mixin->switch_active_processor( 1 );
@ -370,7 +382,7 @@ class _CallUnderlying {
}
/**
* Calls underlying processor's aproptiate method of wp_db
* Calls underlying processor's appropriate method of wp_db.
*/
function flush() {
$switched = $this->wpdb_mixin->switch_active_processor( 1 );
@ -387,7 +399,7 @@ class _CallUnderlying {
}
/**
* Calls underlying processor's aproptiate method of wp_db
* Calls underlying processor's appropriate method of wp_db.
*/
function query( $query ) {
$switched = $this->wpdb_mixin->switch_active_processor( 1 );
@ -404,7 +416,7 @@ class _CallUnderlying {
}
/**
* Calls underlying processor's aproptiate method of wp_db
* Calls underlying processor's appropriate method of wp_db.
*/
function _escape( $data ) {
$switched = $this->wpdb_mixin->switch_active_processor( 1 );
@ -421,7 +433,7 @@ class _CallUnderlying {
}
/**
* Calls underlying processor's aproptiate method of wp_db
* Calls underlying processor's appropriate method of wp_db.
*/
function prepare( $query, $args ) {
$switched = $this->wpdb_mixin->switch_active_processor( 1 );
@ -438,7 +450,7 @@ class _CallUnderlying {
}
/**
* Calls underlying processor's aproptiate method of wp_db
* Calls underlying processor's appropriate method of wp_db.
*/
function insert( $table, $data, $format = null ) {
$switched = $this->wpdb_mixin->switch_active_processor( 1 );
@ -455,7 +467,7 @@ class _CallUnderlying {
}
/**
* Calls underlying processor's aproptiate method of wp_db
* Calls underlying processor's appropriate method of wp_db.
*/
function replace( $table, $data, $format = null ) {
$switched = $this->wpdb_mixin->switch_active_processor( 1 );
@ -472,7 +484,7 @@ class _CallUnderlying {
}
/**
* Calls underlying processor's aproptiate method of wp_db
* Calls underlying processor's appropriate method of wp_db.
*/
function update( $table, $data, $where, $format = null, $where_format = null ) {
$switched = $this->wpdb_mixin->switch_active_processor( 1 );

View File

@ -215,7 +215,7 @@ class Dispatcher {
if ( is_null( $cache ) ) {
$c = Dispatcher::config();
$engineConfig = null;
if ( $c->get_boolean( 'objectcache.enabled' ) ) {
if ( $c->getf_boolean( 'objectcache.enabled' ) ) {
$provider = Dispatcher::component( 'ObjectCache_WpObjectCache_Regular' );
} else if ( $c->get_boolean( 'dbcache.enabled' ) ) {
$provider = Dispatcher::component( 'DbCache_Core' );

View File

@ -6,36 +6,37 @@ if ( ! defined( 'W3TC' ) ) {
}
?>
<form action="admin.php?page=w3tc_extensions&amp;extension=amp&amp;action=view" method="post">
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Configuration', 'w3-total-cache' ), '', '' ); ?>
<table class="form-table">
<?php
Util_Ui::config_item(
array(
'key' => array( 'amp', 'url_type' ),
'label' => esc_html__( 'AMP URL Type:', 'w3-total-cache' ),
'control' => 'radiogroup',
'radiogroup_values' => array(
'tag' => 'tag',
'querystring' => 'query string',
),
'description' => esc_html__(
'If AMP page URLs are tag based (/my-page/amp/) or query string based (/my-page?amp)',
'w3-total-cache'
),
)
);
Util_Ui::config_item(
array(
'key' => array( 'amp', 'url_postfix' ),
'label' => esc_html__( 'AMP URL Postfix:', 'w3-total-cache' ),
'control' => 'textbox',
'description' => 'Postfix used',
)
);
?>
</table>
<?php Util_Ui::button_config_save( 'extension_amp_configuration' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>
<?php Util_UI::print_control_bar( 'extension_amp_form_control' ); ?>
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Configuration', 'w3-total-cache' ), '', 'configuration' ); ?>
<table class="form-table">
<?php
Util_Ui::config_item(
array(
'key' => array( 'amp', 'url_type' ),
'label' => esc_html__( 'AMP URL Type:', 'w3-total-cache' ),
'control' => 'radiogroup',
'radiogroup_values' => array(
'tag' => 'tag',
'querystring' => 'query string',
),
'description' => esc_html__(
'If AMP page URLs are tag based (/my-page/amp/) or query string based (/my-page?amp)',
'w3-total-cache'
),
)
);
Util_Ui::config_item(
array(
'key' => array( 'amp', 'url_postfix' ),
'label' => esc_html__( 'AMP URL Postfix:', 'w3-total-cache' ),
'control' => 'textbox',
'description' => 'Postfix used',
)
);
?>
</table>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>

View File

@ -5,8 +5,6 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<form id="cdn_form" action="admin.php?page=w3tc_cdn" method="post">
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Configuration: Full-Site Delivery', 'w3-total-cache' ), '', 'configuration' ); ?>
<table class="form-table">
<tr>
@ -21,7 +19,4 @@ if ( ! defined( 'W3TC' ) ) {
</tr>
</table>
<?php Util_Ui::button_config_save( 'cdn_configuration' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>

View File

@ -4,12 +4,24 @@ namespace W3TC;
if ( ! defined( 'W3TC' ) ) {
die();
}
Util_Ui::postbox_header_tabs(
esc_html__( 'Network Performance &amp; Security powered by CloudFlare', 'w3-total-cache' ),
esc_html__(
'CloudFlare is a powerful content delivery network (CDN) and security service that can greatly enhance
the performance and security of your WordPress website. By integrating CloudFlare with W3 Total Cache,
you can take advantage of its global network of servers to deliver your website\'s content faster to
visitors from around the world, resulting in reduced loading times and improved user experience.
Additionally, CloudFlare offers various optimization features like minification, caching, and image
optimization, further accelerating your website\'s loading speed and overall performance.',
'w3-total-cache'
),
'',
'cloudflare'
);
Util_Ui::config_overloading_button( array( 'key' => 'cloudflare.configuration_overloaded' ) );
?>
<?php Util_Ui::postbox_header( esc_html__( 'Network Performance &amp; Security powered by CloudFlare', 'w3-total-cache' ), '', 'cloudflare' ); ?>
<?php Util_Ui::config_overloading_button( array( 'key' => 'cloudflare.configuration_overloaded' ) ); ?>
<p>
<?php esc_html_e( 'CloudFlare protects and accelerates websites.', 'w3-total-cache' ); ?>
</p>
<table class="form-table">
<?php
@ -34,10 +46,4 @@ if ( ! defined( 'W3TC' ) ) {
?>
</table>
<?php
Util_Ui::button_config_save(
'general_cloudflare',
'<input type="submit" name="w3tc_cloudflare_flush" value="' . esc_attr__( 'Empty cache', 'w3-total-cache' ) . '" class="button" />'
);
?>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -5,14 +5,6 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<p id="w3tc-options-menu">
<?php esc_html_e( 'Jump to:', 'w3-total-cache' ); ?>
<a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
<a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a> |
<a href="#credentials"><?php esc_html_e( 'Credentials', 'w3-total-cache' ); ?></a> |
<a href="#general"><?php esc_html_e( 'General', 'w3-total-cache' ); ?></a> |
<a href="#info"><?php esc_html_e( 'Information', 'w3-total-cache' ); ?></a>
</p>
<p>
<?php esc_html_e( 'CloudFlare extension is currently ', 'w3-total-cache' ); ?>
<?php
@ -45,6 +37,7 @@ if ( ! defined( 'W3TC' ) ) {
</form>
<form action="admin.php?page=w3tc_extensions&amp;extension=cloudflare&amp;action=view" method="post">
<?php Util_UI::print_control_bar( 'extension_cloudflare_form_control' ); ?>
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Credentials', 'w3-total-cache' ), '', 'credentials' ); ?>
<table class="form-table">
@ -152,7 +145,6 @@ if ( ! defined( 'W3TC' ) ) {
</table>
<?php endif; ?>
<?php Util_Ui::button_config_save( 'extension_cloudflare_general' ); ?>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -159,7 +159,7 @@ class Extension_CloudFlare_Plugin_Admin {
$menu_items['20810.cloudflare'] = array(
'id' => 'w3tc_flush_cloudflare',
'parent' => 'w3tc_flush',
'title' => __( 'CloudFlare: All', 'w3-total-cache' ),
'title' => __( 'CloudFlare', 'w3-total-cache' ),
'href' => wp_nonce_url( admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_cloudflare_flush' ), 'w3tc' ),
);
@ -294,12 +294,12 @@ class Extension_CloudFlare_Plugin_Admin {
$can_empty_file = $modules->can_empty_file();
$can_empty_varnish = $modules->can_empty_varnish();
$actions[] = __( ' or ', 'w3-total-cache' ) . '<input id="flush_all_except_cf" class="button" type="submit"
name="w3tc_cloudflare_flush_all_except_cf" value="' . __( 'empty all caches except CloudFlare', 'w3-total-cache' ) . '"' .
(
( ! $can_empty_memcache && ! $can_empty_opcode && ! $can_empty_file && ! esc_attr( $can_empty_varnish ) ) ?
'disabled="disabled"' : ''
) . '> at once';
$actions[] = sprintf(
'<input type="submit" class="dropdown-item" name="w3tc_cloudflare_flush_all_except_cf" value="%1$s"%2$s>',
esc_attr__( 'Empty All Caches Except CloudFlare', 'w3-total-cache' ),
( ! $can_empty_memcache && ! $can_empty_opcode && ! $can_empty_file && ! $can_empty_varnish )
? ' disabled="disabled"' : ''
);
return $actions;
}

View File

@ -5,26 +5,40 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
Util_Ui::postbox_header( 'Fragment Cache', '', 'fragmentcache' );
$config = Dispatcher::config();
Util_Ui::postbox_header_tabs(
esc_html__( 'Fragment Cache', 'w3-total-cache' ),
esc_html__(
'Fragment caching is a powerful feature that helps improve the speed and performance of your
website. It allows you to cache specific sections or fragments of your web pages instead
of caching the entire page. By selectively caching these fragments, such as sidebar widgets
or dynamic content, you can reduce the processing time required to generate the page,
resulting in faster load times and improved overall site performance.',
'w3-total-cache'
),
'',
'fragmentcache',
Util_UI::admin_url( 'admin.php?page=w3tc_fragmentcache' )
);
?>
<p><?php esc_html_e( 'Enable fragment caching reduce execution time for common operations.', 'w3-total-cache' ); ?></p>
<table class="form-table">
<?php
Util_Ui::config_item_engine(
array(
'key' => array( 'fragmentcache', 'engine' ),
'label' => __( 'Fragment Cache Method:', 'w3-total-cache' ),
'empty_value' => true,
)
$fragmentcache_config = array(
'key' => array( 'fragmentcache', 'engine' ),
'label' => __( 'Fragment Cache Method:', 'w3-total-cache' ),
'empty_value' => true,
'pro' => true,
);
if ( ! Util_Environment::is_w3tc_pro( $config ) ) {
$fragmentcache_config['disabled'] = true;
}
Util_Ui::config_item_engine( $fragmentcache_config );
?>
</table>
<?php
Util_Ui::button_config_save(
'general_fragmentcache',
'<input type="submit" name="w3tc_flush_fragmentcache" value="' . __( 'Empty cache', 'w3-total-cache' ) . '" class="button" />'
);
?>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -8,13 +8,6 @@ if ( ! defined( 'W3TC' ) ) {
$engine = $config->get_string( array( 'fragmentcache', 'engine' ) );
?>
<p id="w3tc-options-menu">
<?php esc_html_e( 'Jump to:', 'w3-total-cache' ); ?>
<a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
<a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a> |
<a href="#overview"><?php esc_html_e( 'Overview', 'w3-total-cache' ); ?></a> |
<a href="#advanced"><?php esc_html_e( 'Advanced', 'w3-total-cache' ); ?></a>
</p>
<p>
<?php Util_Ui::pro_wrap_maybe_start2(); ?>
@ -26,9 +19,9 @@ $engine = $config->get_string( array( 'fragmentcache', 'engine' ) );
<?php esc_html_e( 'is currently', 'w3-total-cache' ); ?>
<?php if ( $config->is_extension_active_frontend( 'fragmentcache' ) ) : ?>
<span class="w3tc-enabled"><?php esc_html_e( 'enabled', 'w3-total-cache' ); ?></span>
<span class="w3tc-enabled"><?php esc_html_e( 'enabled', 'w3-total-cache' ); ?></span>.
<?php else : ?>
<span class="w3tc-disabled"><?php esc_html_e( 'disabled', 'w3-total-cache' ); ?></span>
<span class="w3tc-disabled"><?php esc_html_e( 'disabled', 'w3-total-cache' ); ?></span>.
<?php
$ext = Extensions_Util::get_extension( $config, 'fragmentcache' );
if ( ! empty( $ext['requirements'] ) ) {
@ -36,31 +29,12 @@ $engine = $config->get_string( array( 'fragmentcache', 'engine' ) );
}
?>
<?php endif; ?>
.
<?php Util_Ui::pro_wrap_maybe_end2( 'fragmentcache_header' ); ?>
<p>
<form action="admin.php?page=w3tc_fragmentcache" method="post">
<p>
<?php
echo wp_kses(
Util_Ui::nonce_field( 'w3tc' ),
array(
'input' => array(
'type' => array(),
'name' => array(),
'value' => array(),
),
)
);
?>
<input type="submit" name="w3tc_flush_fragmentcache" value="<?php esc_attr_e( 'Empty the entire cache', 'w3-total-cache' ); ?>" class="button" />
<?php esc_html_e( 'if needed.', 'w3-total-cache' ); ?>
</p>
</form>
</p>
<form action="admin.php?page=w3tc_fragmentcache" method="post">
<?php Util_UI::print_control_bar( 'extension_fragmentcache_form_control' ); ?>
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Overview', 'w3-total-cache' ), '', 'overview' ); ?>
<table class="form-table">
@ -120,7 +94,6 @@ $engine = $config->get_string( array( 'fragmentcache', 'engine' ) );
</tr>
</table>
<?php Util_Ui::button_config_save( 'extension_fragmentcache' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>

View File

@ -17,69 +17,55 @@ class Extension_FragmentCache_Plugin {
* Runs plugin
*/
function run() {
add_filter( 'w3tc_config_default_values', array(
$this, 'w3tc_config_default_values' ) );
add_filter( 'w3tc_config_default_values', array( $this, 'w3tc_config_default_values' ) );
$config = Dispatcher::config();
// remainder only when extension is frontend-active
if ( !$config->is_extension_active_frontend( 'fragmentcache' ) )
/**
* This filter is documented in Generic_AdminActions_Default.php under the read_request method.
*/
add_filter( 'w3tc_config_key_descriptor', array( $this, 'w3tc_config_key_descriptor' ), 10, 2 );
$is_active = $this->_config->is_extension_active_frontend( 'fragmentcache' );
$engine = $this->_config->get_string( array( 'fragmentcache', 'engine' ) );
// remainder only when extension is frontend-active.
if ( ! $is_active || empty( $engine ) ) {
return;
}
add_action( 'init', array( $this, 'on_init' ), 9999999 );
add_filter( 'cron_schedules', array(
$this,
'cron_schedules'
) );
add_filter( 'cron_schedules', array( $this, 'cron_schedules' ) );
add_filter( 'w3tc_footer_comment', array( $this, 'w3tc_footer_comment' ) );
add_filter( 'w3tc_footer_comment', array(
$this,
'w3tc_footer_comment'
) );
if ( $this->_config->get_string( array( 'fragmentcache', 'engine' ) ) == 'file' ) {
add_action( 'w3_fragmentcache_cleanup', array(
$this,
'cleanup'
) );
if ( 'file' === $engine ) {
add_action( 'w3_fragmentcache_cleanup', array( $this, 'cleanup' ) );
}
add_action( 'switch_blog', array(
$this,
'switch_blog'
), 0, 2 );
add_action( 'switch_blog', array( $this, 'switch_blog' ), 0, 2 );
$groups = $this->_config->get_array( array( 'fragmentcache', 'groups' ) );
foreach ( $groups as $group ) {
$split = explode( ',', $group );
$group = array_shift( $split );
$split = explode( ',', $group );
$group = array_shift( $split );
$actions = $split;
$this->_core->register_group( $group, $actions,
$this->_config->get_integer( array( 'fragmentcache', 'lifetime' ) ) );
$this->_core->register_group( $group, $actions, $this->_config->get_integer( array( 'fragmentcache', 'lifetime' ) ) );
}
// handle transients by own cache
// handle transients by own cache.
if ( Util_Environment::is_w3tc_pro( $this->_config ) ) {
$wp_cache = Dispatcher::component( 'ObjectCache_WpObjectCache' );
$fc_cache = Dispatcher::component( 'Extension_FragmentCache_WpObjectCache' );
$wp_cache->register_cache( $fc_cache, array(
'transient', 'site-transient' ) );
$wp_cache->register_cache( $fc_cache, array( 'transient', 'site-transient' ) );
}
// flush operations
add_action( 'w3tc_flush_all',
array( $this, 'w3tc_flush_all' ),
300 );
add_action( 'w3tc_flush_fragmentcache', array(
$this, 'w3tc_flush_fragmentcache' ) );
add_action( 'w3tc_flush_fragmentcache_group', array(
$this, 'w3tc_flush_fragmentcache_group' ), 10, 2 );
// flush operations.
add_action( 'w3tc_flush_all', array( $this, 'w3tc_flush_all' ), 300 );
add_action( 'w3tc_flush_fragmentcache', array( $this, 'w3tc_flush_fragmentcache' ) );
add_action( 'w3tc_flush_fragmentcache_group', array( $this, 'w3tc_flush_fragmentcache_group' ), 10, 2 );
// usage statistics handling
add_action( 'w3tc_usage_statistics_of_request', array(
$this, 'w3tc_usage_statistics_of_request' ), 10, 1 );
add_filter( 'w3tc_usage_statistics_metrics', array(
$this, 'w3tc_usage_statistics_metrics' ) );
// usage statistics handling.
add_action( 'w3tc_usage_statistics_of_request', array( $this, 'w3tc_usage_statistics_of_request' ), 10, 1 );
add_filter( 'w3tc_usage_statistics_metrics', array( $this, 'w3tc_usage_statistics_metrics' ) );
}
@ -212,6 +198,24 @@ class Extension_FragmentCache_Plugin {
return array_merge( $metrics, array(
'fragmentcache_calls_total', 'fragmentcache_calls_hits' ) );
}
/**
* Specify config key typing for fields that need it.
*
* @since 2.4.2
*
* @param mixed $descriptor Descriptor.
* @param mixed $key Compound key array.
*
* @return array
*/
public function w3tc_config_key_descriptor( $descriptor, $key ) {
if ( is_array( $key ) && 'fragmentcache.groups' === implode( '.', $key ) ) {
$descriptor = array( 'type' => 'array' );
}
return $descriptor;
}
}

View File

@ -13,6 +13,10 @@ class Extension_FragmentCache_Plugin_Admin {
static public function w3tc_extensions( $extensions, $config ) {
$requirements = array();
if ( ! Util_Environment::is_w3tc_pro( $config ) ) {
$requirements[] = __( 'Valid W3 Total Cache Pro license', 'w3-total-cache' );
}
$extensions['fragmentcache'] = array (
'name' => 'Fragment Cache',
'author' => 'W3 EDGE',
@ -30,8 +34,7 @@ class Extension_FragmentCache_Plugin_Admin {
'version' => '1.0',
'enabled' => empty( $requirements ),
'requirements' => implode( ', ', $requirements ),
'active_frontend_own_control' => true,
'path' => 'w3-total-cache/Extension_FragmentCache_Plugin.php'
'path' => 'w3-total-cache/Extension_FragmentCache_Plugin.php',
);
return $extensions;
@ -86,9 +89,11 @@ class Extension_FragmentCache_Plugin_Admin {
public function w3tc_extension_plugin_links( $links ) {
$links = array();
$links[] = '<a class="edit" href="' .
esc_attr( Util_Ui::admin_url( 'admin.php?page=w3tc_fragmentcache' ) ) .
'">'. __( 'Settings' ).'</a>';
if ( $this->_config->is_extension_active_frontend( 'fragmentcache' ) && Util_Environment::is_w3tc_pro( $this->_config ) ) {
$links[] = '<a class="edit" href="' . esc_attr( Util_Ui::admin_url( 'admin.php?page=w3tc_fragmentcache' ) ) . '">'
. __( 'Settings', 'w3-total-cache' ) . '</a>';
}
return $links;
}
@ -97,13 +102,14 @@ class Extension_FragmentCache_Plugin_Admin {
public function w3tc_admin_menu( $menu ) {
$menu['w3tc_fragmentcache'] = array(
'page_title' => __( 'Fragment Cache', 'w3-total-cache' ),
'menu_text' => '<span class="w3tc_menu_item_pro">' .
__( 'Fragment Cache', 'w3-total-cache' ) . '</span>',
'visible_always' => false,
'order' => 1100
);
if ( $this->_config->is_extension_active_frontend( 'fragmentcache' ) && Util_Environment::is_w3tc_pro( $this->_config ) ) {
$menu['w3tc_fragmentcache'] = array(
'page_title' => __( 'Fragment Cache', 'w3-total-cache' ),
'menu_text' => '<span class="w3tc_menu_item_pro">' . __( 'Fragment Cache', 'w3-total-cache' ) . '</span>',
'visible_always' => false,
'order' => 1100,
);
}
return $menu;
}
@ -111,13 +117,12 @@ class Extension_FragmentCache_Plugin_Admin {
public function w3tc_admin_bar_menu( $menu_items ) {
if ( $this->_config->is_extension_active_frontend( 'fragmentcache' ) ) {
if ( $this->_config->is_extension_active_frontend( 'fragmentcache' ) && Util_Environment::is_w3tc_pro( $this->_config ) ) {
$menu_items['20510.fragmentcache'] = array(
'id' => 'w3tc_flush_fragmentcache',
'id' => 'w3tc_flush_fragmentcache',
'parent' => 'w3tc_flush',
'title' => __( 'Fragment Cache: All Fragments', 'w3-total-cache' ),
'href' => wp_nonce_url( admin_url(
'admin.php?page=w3tc_dashboard&amp;w3tc_flush_fragmentcache' ), 'w3tc' )
'title' => __( 'Fragment Cache', 'w3-total-cache' ),
'href' => wp_nonce_url( admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_flush_fragmentcache' ), 'w3tc' )
);
}
@ -134,14 +139,7 @@ class Extension_FragmentCache_Plugin_Admin {
public function w3tc_config_save( $config ) {
// frontend activity
$engine = $config->get_string( array( 'fragmentcache', 'engine' ) );
$is_frontend_active = ( !empty( $engine ) &&
Util_Environment::is_w3tc_pro( $config ) );
$config->set_extension_active_frontend( 'fragmentcache',
$is_frontend_active );
$config->set_extension_active_frontend( 'fragmentcache', Util_Environment::is_w3tc_pro( $config ) );
}

View File

@ -5,15 +5,6 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<p id="w3tc-options-menu">
<?php esc_html_e( 'Jump to:', 'w3-total-cache' ); ?>
<a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
<a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a> |
<a href="#header"><?php esc_html_e( 'Header', 'w3-total-cache' ); ?></a> |
<a href="#content"><?php esc_html_e( 'Content', 'w3-total-cache' ); ?></a> |
<a href="#sidebar"><?php esc_html_e( 'Sidebar', 'w3-total-cache' ); ?></a> |
<a href="#exclusions"><?php esc_html_e( 'Exclusions', 'w3-total-cache' ); ?></a>
</p>
<p>
<?php esc_html_e( 'Genesis extension is currently ', 'w3-total-cache' ); ?>
<?php
@ -68,7 +59,7 @@ if ( ! defined( 'W3TC' ) ) {
);
?>
</table>
<?php Util_Ui::button_config_save( 'extension_genesis_header' ); ?>
<?php Util_Ui::postbox_footer(); ?>
<?php Util_Ui::postbox_header( esc_html__( 'Content', 'w3-total-cache' ), '', 'content' ); ?>
@ -146,7 +137,7 @@ if ( ! defined( 'W3TC' ) ) {
);
?>
</table>
<?php Util_Ui::button_config_save( 'extension_genesis_content' ); ?>
<?php Util_Ui::postbox_footer(); ?>
<?php Util_Ui::postbox_header( esc_html__( 'Sidebar', 'w3-total-cache' ), '', 'sidebar' ); ?>
@ -171,7 +162,7 @@ if ( ! defined( 'W3TC' ) ) {
);
?>
</table>
<?php Util_Ui::button_config_save( 'extension_genesis_sidebar' ); ?>
<?php Util_Ui::postbox_footer(); ?>
<?php Util_Ui::postbox_header( esc_html__( 'Footer', 'w3-total-cache' ) ); ?>
@ -206,7 +197,7 @@ if ( ! defined( 'W3TC' ) ) {
);
?>
</table>
<?php Util_Ui::button_config_save( 'extension_genesis_footer' ); ?>
<?php Util_Ui::postbox_footer(); ?>
<?php Util_Ui::postbox_header( esc_html__( 'Exclusions', 'w3-total-cache' ), '', 'exclusions' ); ?>
@ -233,7 +224,7 @@ if ( ! defined( 'W3TC' ) ) {
<input <?php disabled( $config->is_sealed( 'genesis.theme' ) ); ?> type="hidden" name="<?php echo esc_attr( $name ); ?>" value="" />
<?php foreach ( $hooks as $hook => $hook_label ) : ?>
<input <?php disabled( $config->is_sealed( 'genesis.theme' ) ); ?>
<input <?php disabled( $config->is_sealed( 'genesis.theme' ) ); ?>
type="checkbox" name="<?php echo esc_attr( $name ); ?>[]"
value="<?php echo esc_attr( $hook ); ?>"
<?php checked( in_array( $hook, $saved_hooks, true ) ); ?>
@ -272,7 +263,7 @@ if ( ! defined( 'W3TC' ) ) {
</td>
</tr>
</table>
<?php Util_Ui::button_config_save( 'extension_genesis_exclusions' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>

View File

@ -21,16 +21,9 @@ if ( ! defined( 'W3TC' ) ) {
?>
<div class="wrap" id="w3tc">
<?php
// Upgrade banner.
if ( ! Util_Environment::is_w3tc_pro( $c ) ) {
require W3TC_INC_DIR . '/options/parts/dashboard_banner.php';
}
?>
<?php Util_Ui::print_breadcrumb(); ?>
<p>
Total Cache Image Service is currently
Total Cache WebP Converter is currently
<?php
if ( $c->is_extension_active( 'imageservice' ) ) {
?>
@ -46,9 +39,10 @@ if ( $c->is_extension_active( 'imageservice' ) ) {
</p>
<form id="w3tc-imageservice-settings" action="upload.php?page=w3tc_extension_page_imageservice" method="post">
<?php Util_UI::print_control_bar( 'extension_imageservice_form_control' ); ?>
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Configuration', 'w3-total-cache' ), '', '' ); ?>
<?php Util_Ui::postbox_header( esc_html__( 'Configuration', 'w3-total-cache' ), '', 'configuration' ); ?>
<table class="form-table" id="w3tc-imageservice-config">
<?php
@ -107,10 +101,9 @@ Util_Ui::config_item(
</table>
<?php
Util_Ui::button_config_save( 'extension_imageservice_configuration' );
Util_Ui::postbox_footer();
Util_Ui::postbox_header( esc_html__( 'Tools', 'w3-total-cache' ), '', '' );
Util_Ui::postbox_header( esc_html__( 'Tools', 'w3-total-cache' ), '', 'tools' );
?>
<table class="form-table" id="w3tc-imageservice-tools">
@ -146,7 +139,7 @@ Util_Ui::postbox_footer();
Util_Ui::postbox_header(
esc_html__( 'Statistics', 'w3-total-cache' ),
'',
'w3tc-imageservice-statistics'
'statistics'
);
?>
@ -194,7 +187,7 @@ Util_Ui::postbox_header(
</td>
</tr>
<tr>
<th><?php esc_html_e( 'Image Service API usage:', 'w3-total-cache' ); ?></th>
<th><?php esc_html_e( 'WebP Converter API usage:', 'w3-total-cache' ); ?></th>
<td>
<table id="w3tc-imageservice-usage">
<tr>
@ -226,5 +219,3 @@ Util_Ui::postbox_header(
</div>
</form>
</div>

View File

@ -99,7 +99,7 @@ class Extension_ImageService_Plugin_Admin {
$library_url = esc_url( Util_Ui::admin_url( 'upload.php?mode=list' ) );
$extensions['imageservice'] = array(
'name' => 'Image Service',
'name' => 'WebP Converter',
'author' => 'BoldGrid',
'description' => esc_html( $description ),
'author_uri' => 'https://www.boldgrid.com/',
@ -114,7 +114,7 @@ class Extension_ImageService_Plugin_Admin {
'notice' => sprintf(
// translators: 1: HTML anchor open tag, 2: HTML anchor close tag, 3: HTML anchor open tag, 4: HTML anchor open tag.
__(
'Total Cache Image Service has been activated. Now, you can %1$sadjust the settings%2$s or go to the %3$sMedia Library%2$s to convert images to WebP. %4$sLearn more%2$s.',
'Total Cache WebP Converter has been activated. Now, you can %1$sadjust the settings%2$s or go to the %3$sMedia Library%2$s to convert images to WebP. %4$sLearn more%2$s.',
'w3-total-cache'
),
'<a class="edit" href="' . $settings_url . '">',
@ -489,8 +489,8 @@ class Extension_ImageService_Plugin_Admin {
// Add settings submenu to Media top-level menu.
add_submenu_page(
'upload.php',
esc_html__( 'Total Cache Image Service', 'w3-total-cache' ),
esc_html__( 'Total Cache Image Service', 'w3-total-cache' ),
esc_html__( 'Total Cache WebP Converter', 'w3-total-cache' ),
esc_html__( 'Total Cache WebP Converter', 'w3-total-cache' ),
'edit_posts',
'w3tc_extension_page_imageservice',
array( $this, 'settings_page' )
@ -515,6 +515,8 @@ class Extension_ImageService_Plugin_Admin {
if ( $is_settings_page ) {
wp_enqueue_style( 'w3tc-options' );
wp_enqueue_style( 'w3tc-bootstrap-css' );
wp_enqueue_script( 'w3tc-options' );
}
if ( $is_settings_page || $is_media_page ) {
@ -572,7 +574,7 @@ class Extension_ImageService_Plugin_Admin {
),
'tos_choice' => Licensing_Core::get_tos_choice(),
'track_usage' => $this->config->get_boolean( 'common.track_usage' ),
'ga_profile' => ( defined( 'W3TC_DEVELOPER' ) && W3TC_DEVELOPER ) ? 'UA-2264433-7' : 'UA-2264433-8',
'ga_profile' => ( defined( 'W3TC_DEVELOPER' ) && W3TC_DEVELOPER ) ? 'G-Q3CHQJWERM' : 'G-5TFS8M5TTY',
'settings' => $this->config->get_array( 'imageservice' ),
'settingsUrl' => esc_url( Util_Ui::admin_url( 'upload.php?page=w3tc_extension_page_imageservice' ) ),
)
@ -605,7 +607,7 @@ class Extension_ImageService_Plugin_Admin {
// Delete transient for displaying activation notice.
delete_transient( 'w3tc_activation_imageservice' );
$posts_columns['imageservice'] = '<span class="w3tc-convert"></span> ' . esc_html__( 'Image Service', 'w3-total-cache' );
$posts_columns['imageservice'] = '<span class="w3tc-convert"></span> ' . esc_html__( 'WebP Converter', 'w3-total-cache' );
return $posts_columns;
}
@ -855,7 +857,7 @@ class Extension_ImageService_Plugin_Admin {
<script>history.pushState( null, '', location.href.split( '?' )[0] );</script>
<div class="updated notice notice-success is-dismissible">
<p>Total Cache Image Service</p>
<p>Total Cache WebP Converter</p>
<p>
<?php
@ -900,7 +902,7 @@ class Extension_ImageService_Plugin_Admin {
?>
<script>history.pushState( null, '', location.href.split( '?' )[0] );</script>
<div class="updated notice notice-success is-dismissible"><p>Total Cache Image Service</p>
<div class="updated notice notice-success is-dismissible"><p>Total Cache WebP Converter</p>
<p><?php esc_html_e( 'All selected optimizations have been reverted.', 'w3-total-cache' ); ?></p>
</div>
<?php
@ -912,7 +914,7 @@ class Extension_ImageService_Plugin_Admin {
// If not in list mode, then print a notice to switch to it.
if ( 'list' !== $mode ) {
?>
<div class="notice notice-warning is-dismissible"><p>Total Cache Image Service -
<div class="notice notice-warning is-dismissible"><p>Total Cache WebP Converter -
<?php
printf(
// translators: 1: HTML anchor open tag, 2: HTML anchor close tag.

View File

@ -4,10 +4,23 @@ namespace W3TC;
if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<?php
Util_Ui::postbox_header( esc_html__( 'Monitoring', 'w3-total-cache' ), '', 'monitoring' );
Util_Ui::postbox_header_tabs(
esc_html__( 'Monitoring', 'w3-total-cache' ),
esc_html__(
'"New Relic" is a powerful performance monitoring and analysis tool that enhance the speed and efficiency
of a WordPress website. By utilizing New Relic, website owners can gain valuable insights into their
site\'s performance, identifying bottlenecks, slow queries, and other performance issues. With this
information, users can optimize their website\'s configuration, improve caching strategies, and make
informed decisions to deliver a faster and more responsive browsing experience for their visitors.',
'w3-total-cache'
),
'',
'monitoring',
Util_UI::admin_url( 'admin.php?page=w3tc_monitoring' )
);
Util_Ui::config_overloading_button( array( 'key' => 'newrelic.configuration_overloaded' ) );
?>
<?php if ( ! $new_relic_installed ) : ?>
@ -82,5 +95,5 @@ Util_Ui::config_overloading_button( array( 'key' => 'newrelic.configuration_over
</td>
</tr>
</table>
<?php Util_Ui::button_config_save( 'general_newrelic' ); ?>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -6,24 +6,19 @@ if ( ! defined( 'W3TC' ) ) {
}
?>
<p>
<?php esc_html_e( 'Jump to:', 'w3-total-cache' ); ?>
<a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
<a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a>
</p>
<p>
<?php esc_html_e( 'NewRelic extension is currently', 'w3-total-cache' ); ?>
<?php
if ( $config->is_extension_active_frontend( 'newrelic' ) ) {
echo '<span class="w3tc-enabled">' . esc_html__( 'enabled', 'w3-total-cache' ) . '</span>';
echo '<span class="w3tc-enabled">' . esc_html__( 'enabled', 'w3-total-cache' ) . '</span>.';
} else {
echo '<span class="w3tc-disabled">' . esc_html__( 'disabled', 'w3-total-cache' ) . '</span>';
echo '<span class="w3tc-disabled">' . esc_html__( 'disabled', 'w3-total-cache' ) . '</span>.';
}
?>
.
<p>
<form action="admin.php?page=w3tc_monitoring" method="post">
<?php Util_UI::print_control_bar( 'extension_newrelic_dashboard_form_control' ); ?>
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Application Settings', 'w3-total-cache' ), '', 'application' ); ?>
<?php if ( $application_settings ) : ?>
@ -169,238 +164,236 @@ if ( ! defined( 'W3TC' ) ) {
<p><?php esc_html_e( 'Application settings are only visible when New Relic is enabled', 'w3-total-cache' ); ?></p>
<?php endif; ?>
<?php Util_Ui::postbox_footer(); ?>
</form>
<form action="admin.php?page=w3tc_monitoring" method="post">
<?php Util_Ui::postbox_header( esc_html__( 'Dashboard Settings', 'w3-total-cache' ), '', 'dashboard' ); ?>
<table class="form-table">
<tr>
<th>
<label for="newrelic_cache_time">
<?php esc_html_e( 'Cache time:', 'w3-total-cache' ); ?>
</label>
</th>
<td><input id="newrelic_cache_time" name="extension__newrelic__cache_time"
type="text" value="<?php echo esc_attr( $config->get_integer( array( 'newrelic', 'cache_time', 5 ) ) ); ?>"
<?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
<p class="description">
<?php esc_html_e( 'How many minutes data retrieved from New Relic should be stored. Minimum is 1 minute.', 'w3-total-cache' ); ?>
</p>
</td>
</tr>
</table>
<?php Util_Ui::button_config_save( 'extension_newrelic_dashboard' ); ?>
<?php Util_Ui::postbox_footer(); ?>
<?php Util_Ui::postbox_header( esc_html__( 'Behavior Settings', 'w3-total-cache' ), '', 'behavior' ); ?>
<table class="form-table">
<tr>
<th colspan="2">
<?php
Util_Ui::checkbox(
'',
Util_Ui::config_key_to_http_name( array( 'newrelic', 'accept.logged_roles' ) ),
$config->get_boolean( array( 'newrelic', 'accept.logged_roles' ) ),
$config->is_sealed( 'newrelic' )
);
echo wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'Use %1$sRUM%2$s only for following user roles',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
'</acronym>'
),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</label>
<p class="description">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'Select user roles that %1$sRUM%2$s should be enabled for:',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
'</acronym>'
),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</p>
<div id="newrelic_accept_roles" class="w3tc_reject_roles">
<?php $saved_roles = $config->get_array( array( 'newrelic', 'accept.roles' ) ); ?>
<input type="hidden" name="newrelic___accept__roles" value="" /><br />
<?php foreach ( get_editable_roles() as $role_name => $role_data ) : ?>
<input type="checkbox" name="newrelic___accept__roles[]" value="<?php echo esc_attr( $role_name ); ?>"
<?php checked( in_array( $role_name, $saved_roles, true ) ); ?>
id="role_<?php echo esc_attr( $role_name ); ?>"
<?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
<label for="role_<?php echo esc_attr( $role_name ); ?>"><?php echo esc_html( $role_data['name'] ); ?></label>
<?php endforeach; ?>
</div>
</th>
</tr>
<tr>
<th>
<label for="newrelic_include_rum">
<?php
wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'Include %1$sRUM%2$s in compressed or cached pages:',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
'</acronym>'
),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</label>
</th>
<td>
<input name="extension__newrelic__include_rum" type="hidden" value="0"
<?php Util_Ui::postbox_header( esc_html__( 'Dashboard Settings', 'w3-total-cache' ), '', 'dashboard' ); ?>
<table class="form-table">
<tr>
<th>
<label for="newrelic_cache_time">
<?php esc_html_e( 'Cache time:', 'w3-total-cache' ); ?>
</label>
</th>
<td><input id="newrelic_cache_time" name="extension__newrelic__cache_time"
type="text" value="<?php echo esc_attr( $config->get_integer( array( 'newrelic', 'cache_time', 5 ) ) ); ?>"
<?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
<input id="newrelic_include_rum" name="extension__newrelic__include_rum"
type="checkbox" value="1"
<?php checked( $config->get_boolean( array( 'newrelic', 'include_rum' ) ) ); ?>
<?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
<p class="description">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'This enables inclusion of %1$sRUM%2$s when using Page Cache together with Browser Cache gzip or when using Page Cache with Disc: Enhanced',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
'</acronym>'
),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</p>
</td>
</tr>
<tr>
<th>
<label for="newrelic_use_php_function">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'Use %1$sPHP%2$s function to set application name:',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Hypertext Preprocessor', 'w3-total-cache' ) . '">',
'</acronym>'
),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</label>
</th>
<td>
<?php if ( Util_Environment::is_wpmu() ) : ?>
<input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" checked="checked" disabled="disabled" />
<p class="description">
<?php esc_html_e( 'This is required when using New Relic on a network install to set the proper names for sites.', 'w3-total-cache' ); ?>
<?php esc_html_e( 'How many minutes data retrieved from New Relic should be stored. Minimum is 1 minute.', 'w3-total-cache' ); ?>
</p>
<?php else : ?>
<input name="extension__newrelic__use_php_function" type="hidden" value="0" />
<input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'use_php_function' ) ) ); ?>/>
</td>
</tr>
</table>
<?php Util_Ui::postbox_footer(); ?>
<?php Util_Ui::postbox_header( esc_html__( 'Behavior Settings', 'w3-total-cache' ), '', 'behavior' ); ?>
<table class="form-table">
<tr>
<th colspan="2">
<?php
Util_Ui::checkbox(
'',
Util_Ui::config_key_to_http_name( array( 'newrelic', 'accept.logged_roles' ) ),
$config->get_boolean( array( 'newrelic', 'accept.logged_roles' ) ),
$config->is_sealed( 'newrelic' )
);
echo wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'Use %1$sRUM%2$s only for following user roles',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
'</acronym>'
),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</label>
<p class="description">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML a tag to NewRelic per directory settings documentation, 2 closing HTML a tag.
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'Enable this to dynamically set proper application name. (See New Relic %1$sPer-directory settings%2$s for other methods.',
'Select user roles that %1$sRUM%2$s should be enabled for:',
'w3-total-cache'
),
'<a href="https://newrelic.com/docs/php/per-directory-settings">',
'</a>'
'<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
'</acronym>'
),
array(
'a' => array(
'href' => array(),
'acronym' => array(
'title' => array(),
),
)
);
?>
</p>
<?php endif ?>
</td>
</tr>
<tr>
<th>
<label for="newrelic_enable_xmit">
<?php
esc_html_e( 'Enable XMIT:', 'w3-total-cache' )
?>
</label>
</th>
<td><input name="" type="hidden" value="0" />
<input id="newrelic_enable_xmit" name="extension__newrelic__enable_xmit" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'enable_xmit' ) ) ); ?> <?php Util_Ui::sealing_disabled( 'newrelic' ); ?>/>
<p class="description">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML em tag, 2 opening HTML a tag to NewRelic PHP API documentation,
// translators: 3 closing HTML a tag, 4 closing HTML em tag.
__(
'Enable this if you want to record the metric and transaction data (until the name is changed using PHP function), specify a value of true for this argument to make the agent send the transaction to the daemon. There is a slight performance impact as it takes a few milliseconds for the agent to dump its data. %1$sFrom %2$sNew Relic PHP API doc%3$s%4$s',
'w3-total-cache'
<div id="newrelic_accept_roles" class="w3tc_reject_roles">
<?php $saved_roles = $config->get_array( array( 'newrelic', 'accept.roles' ) ); ?>
<input type="hidden" name="newrelic___accept__roles" value="" /><br />
<?php foreach ( get_editable_roles() as $role_name => $role_data ) : ?>
<input type="checkbox" name="newrelic___accept__roles[]" value="<?php echo esc_attr( $role_name ); ?>"
<?php checked( in_array( $role_name, $saved_roles, true ) ); ?>
id="role_<?php echo esc_attr( $role_name ); ?>"
<?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
<label for="role_<?php echo esc_attr( $role_name ); ?>"><?php echo esc_html( $role_data['name'] ); ?></label>
<?php endforeach; ?>
</div>
</th>
</tr>
<tr>
<th>
<label for="newrelic_include_rum">
<?php
wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'Include %1$sRUM%2$s in compressed or cached pages:',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
'</acronym>'
),
'<em>',
'<a href="https://newrelic.com/docs/php/the-php-api">',
'</a>',
'</em>'
),
array(
'a' => array(
'href' => array(),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</label>
</th>
<td>
<input name="extension__newrelic__include_rum" type="hidden" value="0"
<?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
<input id="newrelic_include_rum" name="extension__newrelic__include_rum"
type="checkbox" value="1"
<?php checked( $config->get_boolean( array( 'newrelic', 'include_rum' ) ) ); ?>
<?php Util_Ui::sealing_disabled( 'newrelic' ); ?> />
<p class="description">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'This enables inclusion of %1$sRUM%2$s when using Page Cache together with Browser Cache gzip or when using Page Cache with Disc: Enhanced',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Real User Monitoring', 'w3-total-cache' ) . '">',
'</acronym>'
),
'em' => array(),
)
);
?>
</p>
</td>
</tr>
</table>
<?php Util_Ui::button_config_save( 'extension_newrelic_behaviour' ); ?>
<?php Util_Ui::postbox_footer(); ?>
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</p>
</td>
</tr>
<tr>
<th>
<label for="newrelic_use_php_function">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML acronym tag, 2 closing HTML acronym tag.
__(
'Use %1$sPHP%2$s function to set application name:',
'w3-total-cache'
),
'<acronym title="' . esc_attr__( 'Hypertext Preprocessor', 'w3-total-cache' ) . '">',
'</acronym>'
),
array(
'acronym' => array(
'title' => array(),
),
)
);
?>
</label>
</th>
<td>
<?php if ( Util_Environment::is_wpmu() ) : ?>
<input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" checked="checked" disabled="disabled" />
<p class="description">
<?php esc_html_e( 'This is required when using New Relic on a network install to set the proper names for sites.', 'w3-total-cache' ); ?>
</p>
<?php else : ?>
<input name="extension__newrelic__use_php_function" type="hidden" value="0" />
<input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'use_php_function' ) ) ); ?>/>
<p class="description">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML a tag to NewRelic per directory settings documentation, 2 closing HTML a tag.
__(
'Enable this to dynamically set proper application name. (See New Relic %1$sPer-directory settings%2$s for other methods.',
'w3-total-cache'
),
'<a href="https://newrelic.com/docs/php/per-directory-settings">',
'</a>'
),
array(
'a' => array(
'href' => array(),
),
)
);
?>
</p>
<?php endif ?>
</td>
</tr>
<tr>
<th>
<label for="newrelic_enable_xmit">
<?php
esc_html_e( 'Enable XMIT:', 'w3-total-cache' )
?>
</label>
</th>
<td><input name="" type="hidden" value="0" />
<input id="newrelic_enable_xmit" name="extension__newrelic__enable_xmit" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'enable_xmit' ) ) ); ?> <?php Util_Ui::sealing_disabled( 'newrelic' ); ?>/>
<p class="description">
<?php
echo wp_kses(
sprintf(
// translators: 1 opening HTML em tag, 2 opening HTML a tag to NewRelic PHP API documentation,
// translators: 3 closing HTML a tag, 4 closing HTML em tag.
__(
'Enable this if you want to record the metric and transaction data (until the name is changed using PHP function), specify a value of true for this argument to make the agent send the transaction to the daemon. There is a slight performance impact as it takes a few milliseconds for the agent to dump its data. %1$sFrom %2$sNew Relic PHP API doc%3$s%4$s',
'w3-total-cache'
),
'<em>',
'<a href="https://newrelic.com/docs/php/the-php-api">',
'</a>',
'</em>'
),
array(
'a' => array(
'href' => array(),
),
'em' => array(),
)
);
?>
</p>
</td>
</tr>
</table>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>
<?php if ( $view_metric ) : ?>

View File

@ -5,24 +5,19 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<p>
<?php esc_html_e( 'Jump to:', 'w3-total-cache' ); ?>
<a href="admin.php?page=w3tc_general"><?php esc_html_e( 'Main Menu', 'w3-total-cache' ); ?></a> |
<a href="admin.php?page=w3tc_extensions"><?php esc_html_e( 'Extensions', 'w3-total-cache' ); ?></a>
</p>
<p>
<?php esc_html_e( 'Swarmify extension is currently', 'w3-total-cache' ); ?>
<?php
if ( $config->is_extension_active_frontend( 'swarmify' ) ) {
echo '<span class="w3tc-enabled">' . esc_html__( 'enabled', 'w3-total-cache' ) . '</span>';
echo '<span class="w3tc-enabled">' . esc_html__( 'enabled', 'w3-total-cache' ) . '</span>.';
} else {
echo '<span class="w3tc-disabled">' . esc_html__( 'disabled', 'w3-total-cache' ) . '</span>';
echo '<span class="w3tc-disabled">' . esc_html__( 'disabled', 'w3-total-cache' ) . '</span>.';
}
?>
.
<p>
<form action="admin.php?page=w3tc_extensions&amp;extension=swarmify&amp;action=view" method="post">
<?php Util_UI::print_control_bar( 'extension_swarmify_form_control' ); ?>
<div class="metabox-holder">
<?php Util_Ui::postbox_header( esc_html__( 'Configuration', 'w3-total-cache' ), '', 'configuration' ); ?>
<table class="form-table">
@ -38,7 +33,7 @@ if ( ! defined( 'W3TC' ) ) {
);
?>
</table>
<?php Util_Ui::button_config_save( 'extension_swarmify_configuration' ); ?>
<?php Util_Ui::postbox_footer(); ?>
<?php Util_Ui::postbox_header( esc_html__( 'Behavior Settings', 'w3-total-cache' ), '', 'behavior' ); ?>
@ -75,7 +70,7 @@ if ( ! defined( 'W3TC' ) ) {
);
?>
</table>
<?php Util_Ui::button_config_save( 'extension_swarmify_behaviour' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</div>
</form>

View File

@ -19,7 +19,7 @@ class Extension_Wpml_Plugin_Admin {
if ( !$state->get_boolean( 'wpml.hide_note_language_negotiation_type' ) ) {
$notes[] = sprintf(
__( 'W3 Total Cache\'s Page caching cannot work effectively when WPML Language URL formatis "Language name added as a parameter" used. Please consider another URL format. Visit the WPML -&gt; Languages settings. %s' ,
__( 'W3 Total Cache\'s Page caching cannot work effectively when WPML Language URL format is "Language name added as a parameter" used. Please consider another URL format. Visit the WPML -&gt; Languages settings. %s',
'w3-total-cache' ),
Util_Ui::button_hide_note2( array(
'w3tc_default_config_state' => 'y',
@ -111,7 +111,7 @@ class Extension_Wpml_Plugin_Admin {
$config = Dispatcher::config();
if ( !Util_Environment::is_w3tc_pro( $config ) )
$activate_text = 'Available after <a href="#" class="button-buy-plugin" data-src="wpml_requirements3">upgrade</a>. ';
$activate_text = 'Available after <a href="#" class="button-buy-plugin" data-src="wpml_requirements3">upgrade</a>. ';
else {
$activate_text = sprintf( '<a class="button" href="%s">Click here</a> to try it. ',
Util_Ui::url( array( 'w3tc_extensions_activate' => $extension_id ) ) );

View File

@ -231,7 +231,7 @@ class Extensions_Plugin_Admin {
if ( isset( $info['notice'] ) && get_transient( $transient_name ) ) {
?>
<div class="notice notice-warning is-dismissible">
<div class="notice notice-warning inline is-dismissible">
<p>
<?php
echo wp_kses(

View File

@ -235,13 +235,28 @@ class FeatureShowcase_Plugin_Admin {
}
return array(
'defer-scripts' => array(
'title' => esc_html__( 'Delay Scripts', 'w3-total-cache' ),
'icon' => 'dashicons-media-code',
'text' => esc_html__( "Delay the loading of specified internal/external JavaScript sources on your pages separate from Minify.", 'w3-total-cache' ),
'button' => '<button class="button" onclick="window.location=\'' . (
Util_Environment::is_w3tc_pro( $c ) && isset( $extensions[ 'user-experience-defer-scripts' ] )
? esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_userexperience#application' ) )
: esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_general#userexperience' ) )
) . '\'">' .
__( 'Settings', 'w3-total-cache' ) . '</button>',
'link' => '<a target="_blank" href="' . esc_url( 'https://www.boldgrid.com/support/w3-total-cache/defer-scripts-tool/?utm_source=w3tc&utm_medium=feature_showcase&utm_campaign=defer-scripts-tool' ) .
'">' . __( 'More info', 'w3-total-cache' ) . '<span class="dashicons dashicons-external"></span></a>',
'is_premium' => true,
'is_new' => true,
),
'pagespeed' => array(
'title' => esc_html__( 'Google Page Speed', 'w3-total-cache' ),
'icon' => 'dashicons-analytics',
'text' => esc_html__( "Adds the ability to analyze the website's homepage and provide a detailed breakdown of performance metrics including potential issues and proposed solutions.", 'w3-total-cache' ),
'button' => '<button class="button" onclick="window.location=\'' .
esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_pagespeed' ) ) . '\'">' .
__( 'Launch', 'w3-total-cache' ) . '</button>',
esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_pagespeed' ) ) . '\'">' .
__( 'Launch', 'w3-total-cache' ) . '</button>',
'link' => '<a target="_blank" href="' . esc_url( 'https://www.boldgrid.com/support/w3-total-cache/google-pagespeed-tool/?utm_source=w3tc&utm_medium=feature_showcase&utm_campaign=pagespeed-tool' ) .
'">' . __( 'More info', 'w3-total-cache' ) . '<span class="dashicons dashicons-external"></span></a>',
'is_premium' => false,
@ -356,7 +371,7 @@ class FeatureShowcase_Plugin_Admin {
'is_new' => false,
),
'imageservice' => array(
'title' => esc_html__( 'Image Service', 'w3-total-cache' ),
'title' => esc_html__( 'WebP Converter', 'w3-total-cache' ),
'icon' => 'dashicons-embed-photo',
'text' => esc_html( $imageservice_description ),
'button' => empty( $imageservice_button_text ) ? '' :

View File

@ -28,12 +28,7 @@ namespace W3TC;
$is_pro = Util_Environment::is_w3tc_pro( $config );
if ( $is_pro ) {
require W3TC_INC_DIR . '/options/common/header.php';
} else {
require W3TC_INC_DIR . '/options/parts/dashboard_banner.php';
}
require W3TC_INC_DIR . '/options/common/header.php';
?>
<div class="w3tc-page-container">
@ -80,17 +75,17 @@ foreach ( $cards as $feature_id => $card ) {
<div class="w3tc-card-body"><p><?php echo $card['text']; ?></p></div>
<div class="w3tc-card-footer">
<div class="w3tc-card-button">
<?php
if ( $is_premium && ! $is_pro ) {
?>
<button class="button w3tc-gopro-button button-buy-plugin" data-src="feature_showcase">Unlock Feature</button>
<?php
} elseif ( ! empty( $card['button'] ) ) {
echo $card['button'];
}
?>
<?php
if ( $is_premium && ! $is_pro ) {
?>
<button class="button w3tc-gopro-button button-buy-plugin" data-src="feature_showcase">
<?php esc_html_e( 'Unlock Feature', 'w3-total-cache' ); ?>
</button>
<?php
} elseif ( ! empty( $card['button'] ) ) {
echo $card['button'];
}
?>
</div><div class="w3tc-card-links"><?php echo $card['link']; ?></div>
</div>
</div>

View File

@ -48,7 +48,7 @@ class Generic_AdminActions_Default {
*
* @return void
*/
function w3tc_default_save_licence_key() {
function w3tc_default_save_license_key() {
$license = Util_Request::get_string( 'license_key' );
try {
$old_config = new Config();
@ -273,37 +273,6 @@ class Generic_AdminActions_Default {
}
}
/**
* Page Cache tab
*/
if ( 'w3tc_pgcache' === $this->_page ) {
// Textarea settings.
$settings = array(
'pgcache.mirrors.home_urls',
'pgcache.purge.pages',
'pgcache.accept.qs',
'pgcache.reject.ua',
'pgcache.reject.cookie',
'pgcache.reject.uri',
'pgcache.reject.categories',
'pgcache.reject.tags',
'pgcache.reject.authors',
'pgcache.reject.custom',
'pgcache.accept.files',
'pgcache.accept.uri',
'pgcache.cache.headers',
);
// Remove empty lines, trim values, and sort.
foreach ( $settings as $setting ) {
$setting_array = $config->get_array( $setting );
if ( ! empty( $setting_array ) && is_array( $setting_array ) ) {
$values = array_filter( array_map( 'trim', $setting_array ), 'strlen' );
sort( $values );
$config->set( $setting, $values );
}
}
}
/**
* Minify tab
*/
@ -696,10 +665,6 @@ class Generic_AdminActions_Default {
array_map( 'stripslashes_deep', $request_value );
} else {
$request_value = stripslashes( $request_value );
if ( strpos( $request_key, 'memcached__servers' ) || strpos( $request_key, 'redis__servers' ) ) {
$request_value = explode( ',', $request_value );
}
}
if ( 'extension__' === substr( $request_key, 0, 11 ) ) {
@ -712,26 +677,40 @@ class Generic_AdminActions_Default {
}
}
$key = Util_Ui::config_key_from_http_name( $request_key );
if ( is_array( $key ) ) {
$config->set( $key, $request_value );
} elseif ( array_key_exists( $key, $keys ) ) {
$descriptor = $keys[ $key ];
if ( isset( $descriptor['type'] ) ) {
if ( 'array' === $descriptor['type'] ) {
if ( is_array( $request_value ) ) {
$request_value = implode( "\n", $request_value );
}
$request_value = explode( "\n", str_replace( "\r\n", "\n", $request_value ) );
} elseif ( 'boolean' === $descriptor['type'] ) {
$request_value = ( '1' === $request_value );
} elseif ( 'integer' === $descriptor['type'] ) {
$request_value = (int) $request_value;
}
}
$key = Util_Ui::config_key_from_http_name( $request_key );
$descriptor = null;
$config->set( $key, $request_value );
if ( ! is_array( $key ) && array_key_exists( $key, $keys ) ) {
$descriptor = $keys[ $key ];
}
/**
* This filter is needed for compound keys to set the appropirate data type to save as.
* Mainly used by extensions with textarea fields that don't feature a ConfigKeys entry.
* If no filter exists to define such fields it will save as a string, requiring post-processing.
*
* @since 2.4.2
*
* @param mixed $descriptor Array containing correct data type or null if not matched.
* @param array $key Key to match on.
*/
$descriptor = apply_filters( 'w3tc_config_key_descriptor', $descriptor, $key );
if ( isset( $descriptor['type'] ) ) {
if ( 'array' === $descriptor['type'] ) {
if ( is_array( $request_value ) ) {
// This is needed for radio inputs.
$request_value = implode( "\n", $request_value );
}
$request_value = Util_Environment::textarea_to_array( $request_value );
} elseif ( 'boolean' === $descriptor['type'] ) {
$request_value = ( '1' === $request_value );
} elseif ( 'integer' === $descriptor['type'] ) {
$request_value = (int) $request_value;
}
}
$config->set( $key, $request_value );
}
}
}

View File

@ -275,7 +275,7 @@ class Generic_AdminActions_Flush {
$this->flush_dbcache();
}
if ( $this->_config->get_string( 'objectcache.engine' ) == $type && $this->_config->get_boolean( 'objectcache.enabled' ) ) {
if ( $this->_config->get_string( 'objectcache.engine' ) == $type && $this->_config->getf_boolean( 'objectcache.enabled' ) ) {
$this->flush_objectcache();
}

View File

@ -7,6 +7,11 @@
height: 36px;
line-height: 36px;
}
#w3tc-dashboard-widgets .hndle,
#w3tc-dashboard-widgets .hndle .w3tc-widget-w3tc-logo,
#w3tc-dashboard-widgets .hndle .w3tc-widget-text {
cursor: default;
}
#w3tc-dashboard-widgets .hndle, #w3tc-dashboard-widgets .hndle span {
font-family: Arial, sans-serif;
font-weight: bold;

View File

@ -254,6 +254,27 @@ class Generic_Plugin {
),
);
if (
! empty( $this->_config->get_string( array( 'cloudflare', 'email' ) ) )
&& ! empty( $this->_config->get_string( array( 'cloudflare', 'key' ) ) )
&& (
$modules->can_empty_memcache()
|| $modules->can_empty_opcode()
|| $modules->can_empty_file()
|| $modules->can_empty_varnish()
)
) {
$menu_items['10015.generic'] = array(
'id' => 'w3tc_flush_all_except_cf',
'parent' => 'w3tc',
'title' => __( 'Purge All Caches Except CloudFlare', 'w3-total-cache' ),
'href' => wp_nonce_url(
network_admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_cloudflare_flush_all_except_cf' ),
'w3tc'
),
);
}
if ( ! is_admin() ) {
$menu_items['10020.generic'] = array(
'id' => 'w3tc_flush_current_page',
@ -648,7 +669,7 @@ class Generic_Plugin {
private function is_debugging() {
$debug = $this->_config->get_boolean( 'pgcache.enabled' ) && $this->_config->get_boolean( 'pgcache.debug' );
$debug = $debug || ( $this->_config->get_boolean( 'dbcache.enabled' ) && $this->_config->get_boolean( 'dbcache.debug' ) );
$debug = $debug || ( $this->_config->get_boolean( 'objectcache.enabled' ) && $this->_config->get_boolean( 'objectcache.debug' ) );
$debug = $debug || ( $this->_config->getf_boolean( 'objectcache.enabled' ) && $this->_config->get_boolean( 'objectcache.debug' ) );
$debug = $debug || ( $this->_config->get_boolean( 'browsercache.enabled' ) && $this->_config->get_boolean( 'browsercache.debug' ) );
$debug = $debug || ( $this->_config->get_boolean( 'minify.enabled' ) && $this->_config->get_boolean( 'minify.debug' ) );
$debug = $debug || ( $this->_config->get_boolean( 'cdn.enabled' ) && $this->_config->get_boolean( 'cdn.debug' ) );

View File

@ -65,13 +65,16 @@ class Generic_Plugin_Admin {
add_action( 'wp_ajax_w3tc_ajax', array( $this, 'wp_ajax_w3tc_ajax' ) );
add_action( 'admin_head', array( $this, 'admin_head' ) );
add_action( 'admin_footer', array( $this, 'admin_footer' ) );
if ( is_network_admin() ) {
add_action( 'network_admin_menu', array( $this, 'network_admin_menu' ) );
add_filter( 'network_admin_plugin_action_links_' . W3TC_FILE, array( $this, 'plugin_action_links' ) );
add_action( 'network_admin_notices', array( $this, 'top_nav_bar' ), 0 );
} else {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_filter( 'plugin_action_links_' . W3TC_FILE, array( $this, 'plugin_action_links' ) );
add_action( 'admin_notices', array( $this, 'top_nav_bar' ), 0 );
}
add_filter( 'favorite_actions', array( $this, 'favorite_actions' ) );
@ -94,11 +97,11 @@ class Generic_Plugin_Admin {
// Load w3tc_message.
$message_id = Util_Request::get_string( 'w3tc_message' );
if ( $message_id ) {
$v = get_transient( 'w3tc_message' );
$v = get_option( 'w3tc_message' );
if ( isset( $v[ $message_id ] ) ) {
$this->w3tc_message = $v[ $message_id ];
delete_transient( 'w3tc_message' );
delete_option( 'w3tc_message' );
}
}
}
@ -362,6 +365,7 @@ class Generic_Plugin_Admin {
public function admin_enqueue_scripts() {
wp_register_style( 'w3tc-options', plugins_url( 'pub/css/options.css', W3TC_FILE ), array(), W3TC_VERSION );
wp_register_style( 'w3tc-lightbox', plugins_url( 'pub/css/lightbox.css', W3TC_FILE ), array(), W3TC_VERSION );
wp_register_style( 'w3tc-bootstrap-css', plugins_url( 'pub/css/bootstrap-buttons.css', W3TC_FILE ), array(), W3TC_VERSION );
wp_register_style( 'w3tc-widget', plugins_url( 'pub/css/widget.css', W3TC_FILE ), array(), W3TC_VERSION );
wp_register_script( 'w3tc-metadata', plugins_url( 'pub/js/metadata.js', W3TC_FILE ), array(), W3TC_VERSION, false );
@ -397,6 +401,15 @@ class Generic_Plugin_Admin {
}
}
/**
* Render sticky top navigation bar on all W3TC admin pages.
*/
public function top_nav_bar() {
if ( Util_Admin::is_w3tc_admin_page() ) {
require W3TC_INC_DIR . '/options/common/top_nav_bar.php';
}
}
/**
* Define icon styles for the custom post type.
*
@ -451,39 +464,52 @@ class Generic_Plugin_Admin {
}
if ( defined( 'W3TC_DEVELOPER' ) && W3TC_DEVELOPER ) {
$profile = 'UA-2264433-7';
$profile = 'G-Q3CHQJWERM';
} else {
$profile = 'UA-2264433-8';
$profile = 'G-5TFS8M5TTY';
}
$state = Dispatcher::config_state();
wp_enqueue_script(
'w3tc_ga',
'https://www.googletagmanager.com/gtag/js?id=' . esc_attr( $profile ),
array(),
W3TC_VERSION,
true
);
?>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://api.w3-edge.com/v1/analytics','w3tc_ga');
<script type="application/javascript">
var w3tc_ga_cid;
if (window.w3tc_ga) {
w3tc_ga('create', '<?php echo esc_html( $profile ); ?>', 'auto');
w3tc_ga('set', {
'dimension1': 'w3-total-cache',
'dimension2': '<?php echo esc_html( W3TC_VERSION ); ?>',
'dimension3': '<?php echo esc_html( $wp_version ); ?>',
'dimension4': 'php<?php echo esc_html( phpversion() ); ?>',
'dimension5': '<?php echo esc_attr( isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '' ); ?>',
'dimension6': 'mysql<?php echo esc_attr( $wpdb->db_version() ); ?>',
'dimension7': '<?php echo esc_url( Util_Environment::home_url_host() ); ?>',
'dimension9': '<?php echo esc_attr( $state->get_string( 'common.install_version' ) ); ?>',
'dimension10': '<?php echo esc_attr( Util_Environment::w3tc_edition( $this->_config ) ); ?>',
'dimension11': '<?php echo esc_attr( Util_Widget::list_widgets() ); ?>',
window.dataLayer = window.dataLayer || [];
function w3tc_ga(){dataLayer.push(arguments);}
w3tc_ga('js', new Date());
w3tc_ga('config', '<?php echo esc_attr( $profile ); ?>', {
'user_properties': {
'plugin': 'w3-total-cache',
'w3tc_version': '<?php echo esc_html( W3TC_VERSION ); ?>',
'wp_version': '<?php echo esc_html( $wp_version ); ?>',
'php_version': 'php<?php echo esc_html( phpversion() ); ?>',
'server_software': '<?php echo esc_attr( isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '' ); ?>',
'wpdb_version': 'mysql<?php echo esc_attr( $wpdb->db_version() ); ?>',
'home_url': '<?php echo esc_url( Util_Environment::home_url_host() ); ?>',
'w3tc_install_version': '<?php echo esc_attr( $state->get_string( 'common.install_version' ) ); ?>',
'w3tc_edition': '<?php echo esc_attr( Util_Environment::w3tc_edition( $this->_config ) ); ?>',
'w3tc_widgets': '<?php echo esc_attr( Util_Widget::list_widgets() ); ?>',
'page': '<?php echo esc_attr( $page ); ?>'
});
}
});
w3tc_ga('send', 'pageview');
}
const cidPromise = new Promise(resolve => {
w3tc_ga('get', '<?php echo esc_attr( $profile ); ?>', 'client_id', resolve);
});
cidPromise.then((cid) => {
w3tc_ga_cid = cid;
});
</script>
<?php
}
@ -506,6 +532,15 @@ class Generic_Plugin_Admin {
<?php
}
/**
* Defines the W3TC footer
*/
public function admin_footer() {
if ( $this->is_w3tc_page ) {
require W3TC_INC_DIR . '/options/common/footer.php';
}
}
/**
* Render network admin menu.
*/
@ -581,6 +616,7 @@ class Generic_Plugin_Admin {
*/
public function admin_print_styles() {
wp_enqueue_style( 'w3tc-options' );
wp_enqueue_style( 'w3tc-bootstrap-css' );
wp_enqueue_style( 'w3tc-lightbox' );
}
@ -829,11 +865,9 @@ class Generic_Plugin_Admin {
}
$line = preg_replace( '~^\s*\*\s*~', '', htmlspecialchars( $line ) );
echo '<li style="width: 50%; margin: 0; float: left; ' . ( 0 === $index % 2 ? 'clear: left;' : '' ) . '">' . esc_html( $line ) . '</li>';
} else {
if ( $ul ) {
echo '</ul><div style="clear: left;"></div>';
$ul = false;
}
} elseif ( $ul ) {
echo '</ul><div style="clear: left;"></div>';
$ul = false;
}
}
@ -951,6 +985,7 @@ class Generic_Plugin_Admin {
$note_messages = array(
'config_save' => __( 'Plugin configuration successfully updated.', 'w3-total-cache' ),
'config_save_flush' => __( 'Plugin configuration successfully updated and all caches successfully emptied.', 'w3-total-cache' ),
'flush_all' => __( 'All caches successfully emptied.', 'w3-total-cache' ),
'flush_memcached' => __( 'Memcached cache(s) successfully emptied.', 'w3-total-cache' ),
'flush_opcode' => __( 'Opcode cache(s) successfully emptied.', 'w3-total-cache' ),
@ -1096,7 +1131,7 @@ class Generic_Plugin_Admin {
foreach ( $notes as $key => $note ) {
echo wp_kses(
sprintf(
'<div class="updated w3tc_note" id="%1$s"><p>%2$s</p></div>',
'<div class="updated w3tc_note inline" id="%1$s"><p>%2$s</p></div>',
esc_attr( $key ),
$note
),
@ -1124,7 +1159,7 @@ class Generic_Plugin_Admin {
foreach ( $errors as $key => $error ) {
printf(
'<div class="error w3tc_error" id="%1$s"><p>%2$s</p></div>',
'<div class="error w3tc_error inline" id="%1$s"><p>%2$s</p></div>',
esc_attr( $key ),
$error // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);

View File

@ -35,8 +35,6 @@ if ( !defined( 'W3TC' ) )
</p>
<p>
<input
type="button"
class="button-primary button-buy-plugin"
data-src="community_widget" value="<?php esc_attr_e( 'Learn more about Pro', 'w3-total-cache' ) ?>" />
</p>
<input type="button" class="button-primary button-buy-plugin" data-src="community_widget"
value="<?php esc_attr_e( 'Learn more about Pro', 'w3-total-cache' ); ?>" />
</p>

View File

@ -1,16 +1,20 @@
<?php
namespace W3TC;
/**
* W3 Forum Widget
* File: Generic_WidgetServices.php
*
* @package W3TC
*/
namespace W3TC;
/**
* Class Generic_Plugin_WidgetServices
*/
class Generic_WidgetServices {
function __construct() {
/**
* Constructor
*/
public function __construct() {
}
/**
@ -18,95 +22,47 @@ class Generic_WidgetServices {
*
* @return void
*/
static public function admin_init_w3tc_dashboard() {
public static function admin_init_w3tc_dashboard() {
$o = new Generic_WidgetServices();
add_action( 'w3tc_widget_setup', array( $o, 'wp_dashboard_setup' ), 5000 );
add_action( 'w3tc_network_dashboard_setup',
array( $o, 'wp_dashboard_setup' ), 5000 );
add_action( 'w3tc_network_dashboard_setup', array( $o, 'wp_dashboard_setup' ), 5000 );
}
function wp_dashboard_setup() {
Util_Widget::add( 'w3tc_services',
'<div class="w3tc-widget-w3tc-logo"></div>' .
'<div class="w3tc-widget-text">' .
__( 'Premium Services', 'w3-total-cache' ) .
'</div>',
/**
* W3TC dashboard Premium Services widget.
*/
public function wp_dashboard_setup() {
Util_Widget::add(
'w3tc_services',
'<div class="w3tc-widget-w3tc-logo"></div><div class="w3tc-widget-text">' . __( 'Premium Services', 'w3-total-cache' ) . '</div>',
array( $this, 'widget_form' ),
null, 'normal' );
null,
'normal'
);
}
public function load_request_types() {
$v = get_site_option( 'w3tc_generic_widgetservices' );
try {
$v = json_decode( $v, true );
if ( isset( $v['items'] ) && isset( $v['expires'] ) &&
$v['expires'] > time() )
return $v['items'];
} catch ( \Exception $e ) {
}
$result = wp_remote_request( W3TC_SUPPORT_SERVICES_URL,
array( 'method' => 'GET' ) );
if ( is_wp_error( $result ) )
return null;
$response_json = json_decode( $result['body'], true );
if ( is_null( $response_json ) || !isset( $response_json['items'] ) )
return null;
update_site_option( 'w3tc_generic_widgetservices',
json_encode( array(
'content' => $response_json,
'expires' => time() + 3600 * 24 * 7
) ) );
return $response_json['items'];
}
/**
* Premium Services widget content.
*/
public function widget_form() {
$items = $this->load_request_types();
include W3TC_DIR . '/Generic_WidgetServices_View.php';
include W3TC_DIR . '/Generic_WidgetServices_View.php';
}
/*
wp_enqueue_style( 'w3tc-widget-newrelic',
plugins_url( 'Extension_NewRelic_Widget_View.css', W3TC_FILE ),
array(), W3TC_VERSION );
if ( Util_Admin::get_current_wp_page() == 'w3tc_dashboard' )
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
$this->_json_request_types = array(
'email_support' => sprintf( __( 'Less than 15 Minute Email Support Response %s', 'w3-total-cache' ), '(M-F 9AM - 5PM EDT): $175 USD' ),
'phone_support' => sprintf( __( 'Less than 15 Minute Phone Support Response %s', 'w3-total-cache' ), '(M-F 9AM - 5PM EDT): $250 USD' ),
'plugin_config' => sprintf( __( 'Professional Plugin Configuration %s', 'w3-total-cache' ), 'Starting @ $200 USD' ),
'theme_config' => sprintf( __( 'Theme Performance Optimization & Plugin Configuration %s', 'w3-total-cache' ), 'Starting @ $350 USD' ),
'linux_config' => sprintf( __( 'Linux Server Optimization & Plugin Configuration %s', 'w3-total-cache' ), 'Starting @ $450 USD' )
/**
* Premium Services widget services list.
*/
public static function get_services() {
return array(
__( 'Billing Support', 'w3-total-cache' ),
__( 'Sales Questions', 'w3-total-cache' ),
__( 'Submit a Bug Report', 'w3-total-cache' ),
__( 'Suggest a New Feature', 'w3-total-cache' ),
__( 'Performance Audit & Consultation', 'w3-total-cache' ),
__( 'Plugin Configuration', 'w3-total-cache' ),
__( 'CDN Configuration: Full-Site Delivery', 'w3-total-cache' ),
__( 'Hosting Environment Troubleshooting', 'w3-total-cache' ),
__( 'Eliminate render-blocking Javascripts', 'w3-total-cache' ),
__( 'Investigate Compatibility Issue', 'w3-total-cache' ),
);
$this->_request_types = array(
'email_support' => sprintf( __( 'Less than 15 Minute Email Support Response %s', 'w3-total-cache' ), '<br /><span>(M-F 9AM - 5PM EDT): $175 USD</span>' ),
'phone_support' => sprintf( __( 'Less than 15 Minute Phone Support Response %s', 'w3-total-cache' ), '<br /><span>(M-F 9AM - 5PM EDT): $250 USD</span>' ),
'plugin_config' => sprintf( __( 'Professional Plugin Configuration %s', 'w3-total-cache' ), '<br /><span>Starting @ $200 USD</span>' ),
'theme_config' => sprintf( __( 'Theme Performance Optimization & Plugin Configuration %s', 'w3-total-cache' ), '<br /><span>Starting @ $350 USD</span>' ),
'linux_config' => sprintf( __( 'Linux Server Optimization & Plugin Configuration %s', 'w3-total-cache' ), '<br /><span>Starting @ $450 USD</span>' )
);
function widget_form() {
include W3TC_INC_WIDGET_DIR . '/services.php';
}
public function enqueue() {
wp_enqueue_style( 'w3tc-widget' );
wp_enqueue_script( 'w3tc-metadata' );
wp_enqueue_script( 'w3tc-widget' );
}*/
}

View File

@ -5,33 +5,15 @@ if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<form action="admin.php" xmlns="http://www.w3.org/1999/html" method="get">
<input type="hidden" name="page" value="w3tc_support" />
<ul>
<?php
$cnt = is_array( $items ) ? count( $items ) : 0;
for ( $n = 0; $n < $cnt; $n++ ) :
?>
<li>
<div class="w3tc_generic_widgetservice_radio_outer">
<input id="service<?php echo esc_attr( $n ); ?>"
type="radio"
class="w3tc_generic_widgetservice_radio w3tc-ignore-change"
name="service_item"
value="<?php echo esc_attr( $n ); ?>" />
</div>
<label for="service<?php echo esc_attr( $n ); ?>" class="w3tc_generic_widgetservice_label">
<?php echo esc_html( $items[ $n ]['name'] ); ?>
</label>
</li>
<?php
endfor;
?>
</ul>
<div id="buy-w3-service-area"></div>
<p>
<input id="buy-w3-service" name="buy-w3-service" type="submit"
class="button button-primary button-large"
value="<?php esc_attr_e( 'Buy now', 'w3-total-cache' ); ?>" />
</p>
</form>
<ul class="w3tc-visible-ul">
<?php
$services = Generic_WidgetServices::get_services();
foreach ( $services as $service ) {
echo '<li>' . esc_html( $service ) . '</li>';
}
?>
</ul>
<br/>
<a class="button-primary" href="<?php echo esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_support' ) ); ?>">
<?php esc_html_e( 'Learn More', 'w3-total-cache' ); ?>
</a>

View File

@ -47,10 +47,7 @@ class Licensing_Plugin_Admin {
),
)
),
'href' => wp_nonce_url(
network_admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_message_action=licensing_upgrade' ),
'w3tc'
),
'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_message_action=licensing_upgrade' ), 'w3tc' ),
);
}
@ -59,7 +56,7 @@ class Licensing_Plugin_Admin {
'id' => 'w3tc_debug_overlay_upgrade',
'parent' => 'w3tc_debug_overlays',
'title' => esc_html__( 'Upgrade', 'w3-total-cache' ),
'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_message_action=licensing_upgrade' ), 'w3tc' )
'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_message_action=licensing_upgrade' ), 'w3tc' ),
);
}
@ -170,7 +167,7 @@ class Licensing_Plugin_Admin {
'It looks like your W3 Total Cache Pro license has expired. %1$s to continue using the Pro features',
'w3-total-cache'
),
'<input type="button" class="button-primary button-buy-plugin" data-nonce="' .
'<input type="button" class="button button-buy-plugin" data-nonce="' .
wp_create_nonce( 'w3tc' ) . '" data-renew-key="' . esc_attr( $this->get_license_key() ) .
'" data-src="licensing_expired" value="' . __( 'Renew Now', 'w3-total-cache' ) . '" />'
),

View File

@ -307,7 +307,7 @@ class Minify_Plugin {
$menu_items['20210.minify'] = array(
'id' => 'w3tc_flush_minify',
'parent' => 'w3tc_flush',
'title' => __( 'Minify', 'w3-total-cache' ),
'title' => __( 'Minify Cache', 'w3-total-cache' ),
'href' => wp_nonce_url( admin_url(
'admin.php?page=w3tc_dashboard&amp;w3tc_flush_minify' ),
'w3tc' )

View File

@ -46,7 +46,7 @@ class Minify_Plugin_Admin {
$menu_items['90040.minify'] = array(
'id' => 'w3tc_overlay_minify',
'parent' => 'w3tc_debug_overlays',
'title' => __( 'Minify', 'w3-total-cache' ),
'title' => __( 'Minify Cache', 'w3-total-cache' ),
'href' => wp_nonce_url( network_admin_url(
'admin.php?page=w3tc_dashboard&amp;w3tc_message_action=minify_help' ), 'w3tc' )
);

View File

@ -10,7 +10,7 @@ abstract class Mobile_Base {
private $_groups = array();
private $_compare_key = '';
private $_config_key = '';
private $_cacheclass = '';
private $_cachecase = '';
/**
* PHP5-style constructor

View File

@ -21,7 +21,7 @@ class ObjectCache_Environment {
$exs = new Util_Environment_Exceptions();
try {
$addin_required = $config->get_boolean( 'objectcache.enabled' );
$addin_required = $config->getf_boolean( 'objectcache.enabled' );
$addin_required = apply_filters( 'w3tc_objectcache_addin_required',
$addin_required );
@ -43,7 +43,7 @@ class ObjectCache_Environment {
* @throws Util_Environment_Exceptions
*/
public function fix_on_event( $config, $event, $old_config = null ) {
if ( $config->get_boolean( 'objectcache.enabled' ) &&
if ( $config->getf_boolean( 'objectcache.enabled' ) &&
$config->get_string( 'objectcache.engine' ) == 'file' ) {
if ( !wp_next_scheduled( 'w3_objectcache_cleanup' ) ) {
wp_schedule_event( time(),

View File

@ -17,7 +17,7 @@ class ObjectCache_Page extends Base_Page_Settings {
* @return void
*/
function view() {
$objectcache_enabled = $this->_config->get_boolean( 'objectcache.enabled' );
$objectcache_enabled = $this->_config->getf_boolean( 'objectcache.enabled' );
include W3TC_INC_DIR . '/options/objectcache.php';
}

View File

@ -75,7 +75,8 @@ class ObjectCache_Plugin {
add_filter( 'w3tc_usage_statistics_sources', array( $this, 'w3tc_usage_statistics_sources' ) );
if ( Util_Environment::is_wpmu() ) {
add_action( 'delete_blog', array( $this, 'on_change' ), 0 );
add_action( 'wp_uninitialize_site', array( $this, 'on_change' ), 0 );
add_action( 'wp_update_site', array( $this, 'on_change' ), 0 );
add_action( 'switch_blog', array( $this, 'switch_blog' ), 0, 2 );
}
}

View File

@ -7,7 +7,7 @@ class ObjectCache_Plugin_Admin {
add_filter( 'w3tc_config_labels', array( $config_labels, 'config_labels' ) );
$c = Dispatcher::config();
if ( $c->get_boolean( 'objectcache.enabled' ) ) {
if ( $c->getf_boolean( 'objectcache.enabled' ) ) {
add_filter( 'w3tc_errors', array( $this, 'w3tc_errors' ) );
add_filter( 'w3tc_notes', array( $this, 'w3tc_notes' ) );
add_filter( 'w3tc_usage_statistics_summary_from_history', array(

View File

@ -36,6 +36,24 @@ class ObjectCache_WpObjectCache {
return $cache->get( $id, $group, $force, $found );
}
/**
* Retrieves multiple values from the cache in one call.
*
* @since 2.2.8
*
* @param array $ids Array of keys under which the cache contents are stored.
* @param string $group Optional. Where the cache contents are grouped. Default 'default'.
* @param bool $force Optional. Whether to force an update of the local cache
* from the persistent cache. Default false.
*
* @return array Array of return values, grouped by key. Each value is either
* the cache contents on success, or false on failure.
*/
public function get_multiple( $ids, $group = 'default', $force = false ) {
$cache = $this->_get_engine( $group );
return $cache->get_multiple( $ids, $group, $force );
}
/**
* Set to the cache
*
@ -50,6 +68,23 @@ class ObjectCache_WpObjectCache {
return $cache->set( $id, $data, $group, $expire );
}
/**
* Sets multiple values to the cache in one call.
*
* @since 2.2.8
*
* @param array $data Array of key and value to be set.
* @param string $group Optional. Where the cache contents are grouped. Default empty.
* @param int $expire Optional. When to expire the cache contents, in seconds.
* Default 0 (no expiration).
*
* @return bool[] Array of return values, grouped by key. Each value is always true.
*/
public function set_multiple( $data, $group = 'default', $expire = 0 ) {
$cache = $this->_get_engine( $group );
return $cache->set_multiple( $data, $group, $expire );
}
/**
* Delete from the cache
*
@ -63,6 +98,22 @@ class ObjectCache_WpObjectCache {
return $cache->delete( $id, $group, $force );
}
/**
* Deletes multiple values from the cache in one call.
*
* @since 2.2.8
*
* @param array $keys Array of keys to be deleted.
* @param string $group Optional. Where the cache contents are grouped. Default empty.
*
* @return bool[] Array of return values, grouped by key. Each value is either
* true on success, or false if the contents were not deleted.
*/
public function delete_multiple( $keys, $group = 'default' ) {
$cache = $this->_get_engine( $group );
return $cache->delete_multiple( $keys, $group );
}
/**
* Add to the cache
*
@ -77,6 +128,24 @@ class ObjectCache_WpObjectCache {
return $cache->add( $id, $data, $group, $expire );
}
/**
* Adds multiple values to the cache in one call.
*
* @since 2.2.8
*
* @param array $data Array of keys and values to be added.
* @param string $group Optional. Where the cache contents are grouped. Default empty.
* @param int $expire Optional. When to expire the cache contents, in seconds.
* Default 0 (no expiration).
*
* @return bool[] Array of return values, grouped by key. Each value is either
* true on success, or false if cache key and group already exist.
*/
public function add_multiple( array $data, $group = '', $expire = 0 ) {
$cache = $this->_get_engine( $group );
return $cache->add_multiple( $data, $group, $expire );
}
/**
* Replace in the cache
*

View File

@ -243,6 +243,25 @@ class ObjectCache_WpObjectCache_Regular {
return $value;
}
/**
* Get multiple from the cache
*
* @since 2.2.8
*
* @param string $ids IDs.
* @param string $group Group.
* @param bool $force Force flag.
*
* @return mixed
*/
public function get_multiple( $ids, $group = 'default', $force = false ) {
$found_cache = array();
foreach ( $ids as $id ) {
$found_cache[ $id ] = $this->get( $id, $group, $force );
}
return $found_cache;
}
/**
* Set to the cache
*
@ -329,6 +348,27 @@ class ObjectCache_WpObjectCache_Regular {
return $return;
}
/**
* Sets multiple values to the cache in one call.
*
* @since 2.2.8
*
* @param array $data Array of keys and values to be set.
* @param string $group Optional. Where the cache contents are grouped. Default empty.
* @param int $expire Optional. When to expire the cache contents, in seconds.
* Default 0 (no expiration).
*
* @return bool[] Array of return values, grouped by key. Each value is either
* true on success, or false on failure.
*/
public function set_multiple( array $data, $group = '', $expire = 0 ) {
$values = array();
foreach ( $data as $key => $value ) {
$values[ $key ] = $this->set( $key, $value, $group, $expire );
}
return $values;
}
/**
* Delete from the cache
*
@ -371,6 +411,25 @@ class ObjectCache_WpObjectCache_Regular {
return $return;
}
/**
* Deletes multiple values from the cache in one call.
*
* @since 2.2.8
*
* @param array $keys Array of keys under which the cache to deleted.
* @param string $group Optional. Where the cache contents are grouped. Default empty.
*
* @return bool[] Array of return values, grouped by key. Each value is either
* true on success, or false if the contents were not deleted.
*/
public function delete_multiple( array $keys, $group = '' ) {
$values = array();
foreach ( $keys as $key ) {
$values[ $key ] = $this->delete( $key, $group );
}
return $values;
}
/**
* Add to the cache
*
@ -388,6 +447,27 @@ class ObjectCache_WpObjectCache_Regular {
return $this->set( $id, $data, $group, $expire );
}
/**
* Add multiple to the cache
*
* @since 2.2.8
*
* @param array $data Array of keys and values to be added.
* @param string $group Optional. Where the cache contents are grouped. Default empty.
* @param int $expire Optional. When to expire the cache contents, in seconds.
* Default 0 (no expiration).
*
* @return bool[] Array of return values, grouped by key. Each value is either
* true on success, or false if cache key and group already exist.
*/
public function add_multiple( array $data, $group = '', $expire = 0 ) {
$values = array();
foreach ( $data as $key => $value ) {
$values[ $key ] = $this->add( $key, $value, $group, $expire );
}
return $values;
}
/**
* Replace in the cache
*
@ -789,7 +869,7 @@ class ObjectCache_WpObjectCache_Regular {
/**
* Skip if disabled
*/
if ( !$this->_config->get_boolean( 'objectcache.enabled' ) ) {
if ( !$this->_config->getf_boolean( 'objectcache.enabled' ) ) {
$this->cache_reject_reason = 'objectcache.disabled';
return false;

View File

@ -344,7 +344,7 @@ class PageSpeed_Api {
* @param string $gacode New Google access authentication code.
* @param string $w3tc_pagespeed_key W3 API access key.
*
* @return JSON
* @return string
*/
public function process_authorization_response( $gacode, $w3tc_pagespeed_key ) {
if ( empty( $gacode ) ) {

View File

@ -33,15 +33,26 @@ class PageSpeed_Instructions {
'instructions' =>
'<p>' . wp_kses(
sprintf(
// translators: 1 W3TC plugin name, 2 HTML a tag to W3TC minify JS admin page
// translators: 3 HTML a tag to W3TC minify CSS admin page.
// translators: 1 W3TC plugin name, 2 HTML a tag to W3TC Minify JS admin page
// translators: 3 HTML a tag to W3TC general settings user experience section
// translators: 4 HTML a tag to W3TC user expereince advanced settings page
// translators: 5 HTML a tag to W3TC Minify CSS admin page, 6 HTML line break tag.
esc_html__(
'%1$s can eliminate render blocking resources. Once Minified, you can defer JS in the %2$s. Render blocking CSS can be eliminated in %3$s using the "Eliminate Render blocking CSS by moving it to HTTP body" (PRO FEATURE).',
'%1$s can eliminate render blocking resources.%6$sOnce Minified, you can defer JS in the
%2$s.%6$sThe Defer Scripts (PRO FEATURE) can also be used with or without Minify to defer
the loading of JS files containing the "src" attribute. Scripts matched using this
feature will be excluded from the Minify process. To enable this feature navigate
to %3$s and check the "Defer JavaScript" checkbox. Once enabled the settings can be found
at %4$s.%6$sRender blocking CSS can be eliminated in %5$s using the "Eliminate Render
blocking CSS by moving it to HTTP body" (PRO FEATURE).',
'w3-total-cache'
),
'W3 Total Cache',
'<a target="_blank" href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_minify#js' ) ) . '" alt="' . esc_attr__( 'Minify JS', 'w3-total-cache' ) . '">' . esc_html__( 'Performance &raquo; Minify &raquo; JS', 'w3-total-cache' ) . '</a> ',
'<a target="_blank" href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_minify#css' ) ) . '" alt="' . esc_attr__( 'Minify CSS', 'w3-total-cache' ) . '">' . esc_html__( 'Performance &raquo; Minify &raquo; CSS', 'w3-total-cache' ) . '</a>'
'<a target="_blank" href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_general#userexperience' ) ) . '" alt="' . esc_attr__( 'Defer Scripts', 'w3-total-cache' ) . '">' . esc_html__( 'Performance &raquo; General Settings &raquo; User Experience', 'w3-total-cache' ) . '</a>',
'<a target="_blank" href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_userexperience#application' ) ) . '" alt="' . esc_attr__( 'Defer Scripts Settings', 'w3-total-cache' ) . '">' . esc_html__( 'Performance &raquo; User Experience', 'w3-total-cache' ) . '</a>',
'<a target="_blank" href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_minify#css' ) ) . '" alt="' . esc_attr__( 'Minify CSS', 'w3-total-cache' ) . '">' . esc_html__( 'Performance &raquo; Minify &raquo; CSS', 'w3-total-cache' ) . '</a>',
'<br/><br/>'
),
$allowed_tags
) . '</p>',
@ -126,7 +137,7 @@ class PageSpeed_Instructions {
'<p>' . sprintf(
// translators: 1 W3TC plugin name, opening HTML a tag to Image Service extension, 3 closing HTML a tag.
esc_html__(
'Use %1$s %2$sImage Service%3$s to convert media library images to WebP.',
'Use %1$s %2$sWebP Converter%3$s to convert media library images to WebP.',
'w3-total-cache'
),
'W3 Total Cache',
@ -139,7 +150,7 @@ class PageSpeed_Instructions {
'<p>' . sprintf(
// translators: 1 W3TC plugin name, opening HTML a tag to Image Service extension, 3 closing HTML a tag.
esc_html__(
'Use %1$s %2$sImage Service%3$s to convert media library images to WebP.',
'Use %1$s %2$sWebP Converter%3$s to convert media library images to WebP.',
'w3-total-cache'
),
'W3 Total Cache',
@ -217,7 +228,7 @@ class PageSpeed_Instructions {
'<p>' . sprintf(
// translators: 1 W3TC plugin name, opening HTML a tag to Image Service extension, 3 closing HTML a tag.
esc_html__(
'Use %1$s %2$sImage Service%3$s to convert media library images to WebP.',
'Use %1$s %2$sWebP Converter%3$s to convert media library images to WebP.',
'w3-total-cache'
),
'W3 Total Cache',
@ -279,7 +290,7 @@ class PageSpeed_Instructions {
// translators: 1 W3TC plugin name, 2 opening HTML a tag to CSS Minify settings, 3 closing HTML a tag,
// translators: 4 opening html a tagl to JS Minify settings, 5 closing HTML a tag.
esc_html__(
'Compress your HTML, CSS, and JavaScript files and minify your CSS and JavaScript to ensure your text-based resources are as small as they can be. Use the %1$s Minify %2$sJS%3$s and %4$sCSS%5$s features to accomplish this.',
'Compress your HTML, CSS, and JavaScript files and Minify your CSS and JavaScript to ensure your text-based resources are as small as they can be. Use the %1$s Minify %2$sJS%3$s and %4$sCSS%5$s features to accomplish this.',
'w3-total-cache'
),
'W3 Total Cache',
@ -291,7 +302,7 @@ class PageSpeed_Instructions {
<p>' . sprintf(
// translators: 1 W3TC plugin name, 2 opening HTML a tag to W3TC extensions, 3 closing HTML a tag.
esc_html__(
'Optimize your image delivery by sizing them properly and compressing them for smaller sizes. Use Webp conversion via the %1$s %2$sImage Service%3$s extension.',
'Optimize your image delivery by sizing them properly and compressing them for smaller sizes. Use Webp conversion via the %1$s %2$sWebP Converter%3$s extension.',
'w3-total-cache'
),
'W3 Total Cache',

View File

@ -110,7 +110,7 @@ class PageSpeed_Page {
'Before you can get started using the Google PageSpeed tool, youll first need to authorize access. Please click %1$s.',
'w3-total-cache'
),
'<a href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_general#google_page_speed' ) ) . '" target="_blank">' . esc_html__( 'here', 'w3-total-cache' ) . '</a>'
'<a href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_general#google_pagespeed' ) ) . '" target="_blank">' . esc_html__( 'here', 'w3-total-cache' ) . '</a>'
),
)
);
@ -155,7 +155,7 @@ class PageSpeed_Page {
} else {
$api_response['time'] = time();
$api_response['display_time'] = \current_time( 'M jS, Y g:ia', false );
update_option( 'w3tc_pagespeed_data_' . $encoded_url, wp_json_encode( $api_response ), Util_PageSpeed::get_cache_life() );
update_option( 'w3tc_pagespeed_data_' . $encoded_url, wp_json_encode( $api_response ), 'yes' );
}
}

View File

@ -1,35 +1,39 @@
#w3tcps_container {
max-width: 1234px;
max-width: 1234px;
}
.w3tcps_loading .spinner {
margin-top: 0;
float: left;
margin-top: 0;
float: left;
}
.w3tcps_content .postbox {
border: unset;
box-shadow: unset;
background: unset;
border: unset;
box-shadow: unset;
background: unset;
}
.w3tcps_content .postbox-title {
border: unset !important;
}
.w3tcps_content .postbox .hndle {
border-bottom: unset !important;
border-bottom: unset !important;
}
.w3tcps_timestamp {
margin-right: 5px;
margin-right: 5px;
}
#w3tcps-core-metrics .inside {
display: flex;
flex-wrap: wrap;
gap: 5px;
display: flex;
flex-wrap: wrap;
gap: 5px;
}
.w3tcps_metric {
min-width: 255px;
flex: 1 1 33%;
min-width: 255px;
flex: 1 1 33%;
box-sizing: border-box;
border: 1px solid #c3c4c7;
background: #fff;
@ -37,7 +41,7 @@
.w3tcps_metric_title {
font-size: 14px;
border-bottom: 1px solid #ccd0d4;
border-bottom: 1px solid #ccd0d4;
}
.w3tcps_metric_title,
@ -47,27 +51,27 @@
}
.w3tcps_item_desciption {
background-color: hsla(210, 17%, 77%, 0.1);
padding: 15px !important;
margin: 0 !important;
background-color: hsla(210, 17%, 77%, 0.1);
padding: 15px !important;
margin: 0 !important;
}
.w3tcps_breakdown_items_container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
grid-row-gap: .75em;
grid-column-gap: .75em;
padding: .75em;
display: flex;
flex-direction: row;
flex-wrap: wrap;
grid-row-gap: .75em;
grid-column-gap: .75em;
padding: .75em;
}
.w3tcps_breakdown_items_container .w3tcps_breakdown_items_table,
.w3tcps_breakdown_items_container .w3tcps_instruction {
flex: 49%;
flex-grow: 1;
align-self: flex-start;
border: 1px solid #ccd0d4;
border-collapse: collapse;
flex: 49%;
flex-grow: 1;
align-self: flex-start;
border: 1px solid #ccd0d4;
border-collapse: collapse;
}
.w3tcps_breakdown_items_table {
@ -76,12 +80,12 @@
.w3tcps_breakdown_items_table th,
.w3tcps_breakdown_items_table td {
text-align: left;
text-align: left;
padding: 8px 10px;
}
.w3tcps_breakdown_items_table .copyurl {
cursor: pointer;
cursor: pointer;
}
.w3tcps_breakdown_items_table tr:nth-child(even) {
@ -89,11 +93,11 @@
}
.w3tcps_instruction {
padding: 0;
padding: 0;
}
.w3tc_instruction_copy {
padding: 10px;
padding: 10px;
}
#w3tcps_desktop {
@ -104,9 +108,9 @@
cursor: pointer;
}
.w3tcps_breakdown_items_toggle .dashicons{
.w3tcps_breakdown_items_toggle .dashicons {
position: absolute;
right: 35px;
right: 35px;
}
.w3tcps_range {
@ -118,17 +122,17 @@
}
.w3tcps_breakdown_items {
margin: 0;
padding: 0;
margin: 0;
padding: 0;
display: none;
background: #ffffff;
background: #ffffff;
}
#w3tcps-screenshots .inside {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 5px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 5px;
}
#w3tcps-screenshots .inside .w3tcps_screenshots_final_mobile,
@ -148,20 +152,20 @@
}
.w3tcps_audit_results {
border: 1px solid #c3c4c7;
border-top: 0;
border-bottom: 0;
border: 1px solid #c3c4c7;
border-top: 0;
border-bottom: 0;
background: #fff;
min-width: 320px;
min-width: 320px;
}
.w3tcps_screenshots_other_mobile,
.w3tcps_screenshots_final_mobile,
.w3tcps_screenshots_other_desktop,
.w3tcps_screenshots_final_desktop {
border: 1px solid #c3c4c7;
border: 1px solid #c3c4c7;
background: #fff;
min-width: 250px
min-width: 250px
}
.w3tcps_final_screenshot_container {
@ -171,12 +175,12 @@
.opportunities .audits,
.diagnostics .audits,
.passed_audits .audits {
padding: 0;
margin: 0;
border-left: 2px solid #72aee6;
border-right: 0;
border-top: 0;
border-bottom: 1px solid #ccd0d4;
padding: 0 !important;
margin: 0 !important;
border-left: 2px solid #72aee6;
border-right: 0;
border-top: 0;
border-bottom: 1px solid #ccd0d4;
}
.opportunities .w3tcps_range,
@ -195,7 +199,7 @@
.w3tcps_other_screenshot_container,
.w3tcps_final_screenshot_container {
text-align: center;
text-align: center;
}
.w3tcps_screenshots_other_mobile img,
@ -215,9 +219,9 @@
.w3tcps_blank::before {
border: calc(0.2 * 14px) solid #bdbdbd;
border-radius: 100%;
width: 12px;
width: 12px;
height: 12px;
min-width: 12px;
min-width: 12px;
}
.w3tcps_fail::before {
@ -232,13 +236,13 @@
background: #fa3;
width: calc(14px * 0.88);
height: calc(14px * 0.88);
min-width: 12px;
min-width: 12px;
}
.w3tcps_pass::before {
border-radius: 100%;
background: #0c6;
min-width: 14px;
min-width: 14px;
}
.gauge {
@ -250,7 +254,7 @@
margin: 0 10px;
}
.gauge:before{
.gauge:before {
content: "";
display: block;
padding-top: 50%;
@ -267,70 +271,70 @@
}
.gauge .percentage {
position: absolute;
position: absolute;
top: -1px;
left: -1px;
bottom: 0;
right: -1px;
background-color: var(--background, #fff);
transform:rotate(var(--rotation));
transform-origin: bottom center;
transform: rotate(var(--rotation));
transform-origin: bottom center;
transition-duration: 600;
}
.gauge .value {
position:absolute;
bottom:0%;
left:0;
width:100%;
position: absolute;
bottom: 0%;
left: 0;
width: 100%;
text-align: center;
}
.w3tc_fancy_header {
background: #0e1920;
border-bottom: 6px solid #cdeae7;
height: 2.75em;
position: relative;
background: #0e1920;
border-bottom: 6px solid #cdeae7;
height: 2.75em;
position: relative;
}
.w3tc_fancy_title {
color: #fff;
position: absolute;
bottom: 0;
padding-left: 50px;
color: #fff;
position: absolute;
bottom: 0;
padding-left: 50px;
}
.w3tc_fancy_title > span:nth-of-type(1),
.w3tc_fancy_title > span:nth-of-type(2),
.w3tc_fancy_title > span:nth-of-type(3) {
font-size: 2em;
.w3tc_fancy_title>span:nth-of-type(1),
.w3tc_fancy_title>span:nth-of-type(2),
.w3tc_fancy_title>span:nth-of-type(3) {
font-size: 2em;
}
.w3tc_fancy_title > span:nth-of-type(2) {
color: #30bec4;
.w3tc_fancy_title>span:nth-of-type(2) {
color: #30bec4;
}
.w3tc_fancy_title > span:nth-of-type(4) {
font-size: 1.8em;
font-style: italic;
.w3tc_fancy_title>span:nth-of-type(4) {
font-size: 1.8em;
font-style: italic;
}
.w3tc_fancy_icon {
position: absolute;
top: 3px;
left: 3px;
width: 37px;
height: 37px;
position: absolute;
top: 3px;
left: 3px;
width: 37px;
height: 37px;
}
@media only screen and (max-width: 1024px) {
.w3tcps_breakdown_items_container {
flex-direction: column;
}
.w3tcps_breakdown_items_container {
flex-direction: column;
}
}
@media only screen and (max-width: 600px) {
.w3tcps_audit_results {
border-top: 1px solid #ccd0d4;
}
}
.w3tcps_audit_results {
border-top: 1px solid #ccd0d4;
}
}

View File

@ -69,14 +69,11 @@ jQuery(document).ready(function ($) {
function w3tcps_breakdown_items_toggle() {
if (window.w3tc_ga) {
w3tc_ga(
'send',
'event',
'metric',
{
eventCategory: 'w3tc_pagespeed',
eventAction: 'metric',
eventLabel: $(this).attr('gatitle'),
eventValue: 0,
transport: 'beacon'
eventLabel: $(this).attr('gatitle')
}
);
}
@ -95,14 +92,11 @@ jQuery(document).ready(function ($) {
function w3tcps_mobile_toggle() {
if (window.w3tc_ga) {
w3tc_ga(
'send',
'event',
'mobile_tab',
{
eventCategory: 'w3tc_pagespeed',
eventAction: 'mobile_tab',
eventLabel: $('#w3tcps_control_mobile').text(),
eventValue: 0,
transport: 'beacon'
eventLabel: $('#w3tcps_control_mobile').text()
}
);
}
@ -123,14 +117,11 @@ jQuery(document).ready(function ($) {
function w3tcps_desktop_toggle() {
if (window.w3tc_ga) {
w3tc_ga(
'send',
'event',
'desktop_tab',
{
eventCategory: 'w3tc_pagespeed',
eventAction: 'desktop_tab',
eventLabel: $('#w3tcps_control_desktop').text(),
eventValue: 0,
transport: 'beacon'
eventLabel: $('#w3tcps_control_desktop').text()
}
);
}
@ -153,14 +144,11 @@ jQuery(document).ready(function ($) {
if (window.w3tc_ga) {
w3tc_ga(
'send',
'event',
'filter_tab',
{
eventCategory: 'w3tc_pagespeed',
eventAction: 'filter_tab',
eventLabel: $(this).text(),
eventValue: 0,
transport: 'beacon'
eventLabel: $(this).text()
}
);
}
@ -247,14 +235,11 @@ jQuery(document).ready(function ($) {
$('.w3tcps_content').on('click', '.w3tcps_analyze', function () {
if (window.w3tc_ga) {
w3tc_ga(
'send',
'event',
're_analyze',
{
eventCategory: 'w3tc_pagespeed',
eventAction: 're_analyze',
eventLabel: $(this).closest('.page_post').find('.w3tcps_buttons').attr('page_post_url'),
eventValue: 0,
transport: 'beacon'
eventLabel: $(this).closest('.page_post').find('.w3tcps_buttons').attr('page_post_url')
}
);
}

View File

@ -129,7 +129,7 @@ class PageSpeed_Widget {
'Before you can get started using the Google PageSpeed tool, youll first need to authorize access. Please click %1$s.',
'w3-total-cache'
),
'<a href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_general#google_page_speed' ) ) . '" target="_blank">' . esc_html__( 'here', 'w3-total-cache' ) . '</a>'
'<a href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_general#google_pagespeed' ) ) . '" target="_blank">' . esc_html__( 'here', 'w3-total-cache' ) . '</a>'
),
)
);
@ -174,7 +174,7 @@ class PageSpeed_Widget {
} else {
$api_response['time'] = time();
$api_response['display_time'] = \current_time( 'M jS, Y g:ia', false );
update_option( 'w3tc_pagespeed_data_' . $home_url, wp_json_encode( $api_response ), Util_PageSpeed::get_cache_life() );
update_option( 'w3tc_pagespeed_data_' . $home_url, wp_json_encode( $api_response ), 'yes' );
}
}

View File

@ -104,16 +104,29 @@ class PgCache_ContentGrabber {
private $output_size = 0;
/**
*
*
* @var bool If cached page should be displayed after init
*/
var $_late_init = false;
/**
* @var bool late caching
*/
var $_late_caching = false;
var $_cached_data = null;
var $_old_exists = false;
/**
* @var bool Nginx memcached flag
*/
var $_nginx_memcached = false;
/**
* @var string
*/
var $_page_group;
/**
* PHP5 Constructor
*/

View File

@ -327,7 +327,7 @@ class PgCache_Plugin {
$menu_items['20110.pagecache'] = array(
'id' => 'w3tc_flush_pgcache',
'parent' => 'w3tc_flush',
'title' => __( 'Page Cache: All', 'w3-total-cache' ),
'title' => __( 'Page Cache', 'w3-total-cache' ),
'href' => wp_nonce_url( admin_url( 'admin.php?page=w3tc_dashboard&amp;w3tc_flush_pgcache' ), 'w3tc' ),
);

View File

@ -218,6 +218,7 @@ class Root_AdminMenu {
if ( ! empty( Util_Request::get_string( 'w3tc_dbcluster_config' ) ) ) {
$options_dbcache = new DbCache_Page();
$options_dbcache->dbcluster_config();
return;
}
/**
@ -310,8 +311,6 @@ class Root_AdminMenu {
do_action( 'w3tc_settings_page-' . $this->_page ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
$view->render_footer();
break;
}
}

View File

@ -40,7 +40,7 @@ class Root_Loader {
$plugins[] = new DbCache_Plugin();
}
if ( $c->get_boolean( 'objectcache.enabled' ) ) {
if ( $c->getf_boolean( 'objectcache.enabled' ) ) {
$plugins[] = new ObjectCache_Plugin();
}

View File

@ -488,7 +488,7 @@ class SetupGuide_Plugin_Admin {
if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
$config = new Config();
$results = array(
'enabled' => $config->get_boolean( 'objectcache.enabled' ),
'enabled' => $config->getf_boolean( 'objectcache.enabled' ),
'engine' => $config->get_string( 'objectcache.engine' ),
'elapsed' => null,
);
@ -527,7 +527,7 @@ class SetupGuide_Plugin_Admin {
wp_send_json_success(
array(
'enabled' => $config->get_boolean( 'objectcache.enabled' ),
'enabled' => $config->getf_boolean( 'objectcache.enabled' ),
'engine' => $config->get_string( 'objectcache.engine' ),
)
);
@ -556,7 +556,7 @@ class SetupGuide_Plugin_Admin {
$is_updating = false;
$success = false;
$config = new Config();
$old_enabled = $config->get_boolean( 'objectcache.enabled' );
$old_enabled = $config->getf_boolean( 'objectcache.enabled' );
$old_engine = $config->get_string( 'objectcache.engine' );
$allowed_engines = array(
'',
@ -588,7 +588,7 @@ class SetupGuide_Plugin_Admin {
$f->objectcache_flush();
}
if ( $config->get_boolean( 'objectcache.enabled' ) === $enable &&
if ( $config->getf_boolean( 'objectcache.enabled' ) === $enable &&
( ! $enable || $config->get_string( 'objectcache.engine' ) === $engine ) ) {
$success = true;
$message = __( 'Settings updated', 'w3-total-cache' );
@ -608,7 +608,7 @@ class SetupGuide_Plugin_Admin {
'message' => $message,
'enable' => $enable,
'engine' => $engine,
'current_enabled' => $config->get_boolean( 'objectcache.enabled' ),
'current_enabled' => $config->getf_boolean( 'objectcache.enabled' ),
'current_engine' => $config->get_string( 'objectcache.engine' ),
'previous_enabled' => $old_enabled,
'previous_engine' => $old_engine,
@ -814,6 +814,67 @@ class SetupGuide_Plugin_Admin {
}
}
/**
* Admin-Ajax: Get the imageservice settings.
*
* @since 2.3.4
*
* @see \W3TC\Config::is_extension_active()
* @see \W3TC\Config::get_string()
*/
public function get_imageservice_settings() {
if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
$config = new Config();
wp_send_json_success(
array(
'enabled' => $config->is_extension_active( 'imageservice' ),
)
);
} else {
wp_send_json_error( __( 'Security violation', 'w3-total-cache' ), 403 );
}
}
/**
* Admin-Ajax: Configure image optimization.
*
* @since 2.3.4
*
* @see \W3TC\Dispatcher::component()
* @see \W3TC\Config::get_boolean()
* @see \W3TC\Config::set()
* @see \W3TC\Config::save()
* @see \W3TC\Dispatcher::component()
* @see \W3TC\CacheFlush::flush_posts()
*
* @uses $_POST['enable']
*/
public function config_imageservice() {
if ( wp_verify_nonce( Util_Request::get_string( '_wpnonce' ), 'w3tc_wizard' ) ) {
$enable = ! empty( Util_Request::get_string( 'enable' ) );
$config = new Config();
if ( ! empty( $enable ) ) {
Extensions_Util::activate_extension( 'imageservice', $config );
} else {
Extensions_Util::deactivate_extension( 'imageservice', $config );
}
$is_enabled = $config->is_extension_active( 'imageservice' );
wp_send_json_success(
array(
'success' => $is_enabled === $enable,
'enable' => $enable,
'imageservice_enabled' => $is_enabled,
)
);
} else {
wp_send_json_error( __( 'Security violation', 'w3-total-cache' ), 403 );
}
}
/**
* Display the terms of service dialog if needed.
*
@ -889,7 +950,7 @@ class SetupGuide_Plugin_Admin {
'install_version' => esc_attr( $state->get_string( 'common.install_version' ) ),
'w3tc_edition' => esc_attr( Util_Environment::w3tc_edition( $config ) ),
'list_widgets' => esc_attr( Util_Widget::list_widgets() ),
'ga_profile' => ( defined( 'W3TC_DEVELOPER' ) && W3TC_DEVELOPER ) ? 'UA-2264433-7' : 'UA-2264433-8',
'ga_profile' => ( defined( 'W3TC_DEVELOPER' ) && W3TC_DEVELOPER ) ? 'G-Q3CHQJWERM' : 'G-5TFS8M5TTY',
'tos_choice' => Licensing_Core::get_tos_choice(),
'track_usage' => $config->get_boolean( 'common.track_usage' ),
'test_complete_msg' => __(
@ -912,6 +973,7 @@ class SetupGuide_Plugin_Admin {
'enabled' => __( 'Enabled', 'w3-total-cache' ),
'notEnabled' => __( 'Not Enabled', 'w3-total-cache' ),
'dashboardUrl' => esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_dashboard' ) ),
'objcache_disabled' => ( ! $config->getf_boolean( 'objectcache.enabled' ) && has_filter( 'w3tc_config_item_objectcache.enabled' ) ),
),
),
),
@ -1022,6 +1084,20 @@ class SetupGuide_Plugin_Admin {
'config_browsercache',
),
),
array(
'tag' => 'wp_ajax_w3tc_get_imageservice_settings',
'function' => array(
$this,
'get_imageservice_settings',
),
),
array(
'tag' => 'wp_ajax_w3tc_config_imageservice',
'function' => array(
$this,
'config_imageservice',
),
),
array(
'tag' => 'wp_ajax_w3tc_get_lazyload_settings',
'function' => array(
@ -1059,6 +1135,10 @@ class SetupGuide_Plugin_Admin {
'id' => 'browsercache',
'text' => __( 'Browser Cache', 'w3-total-cache' ),
),
array(
'id' => 'imageservice',
'text' => __( 'Image Optimization', 'w3-total-cache' ),
),
array(
'id' => 'lazyload',
'text' => __( 'Lazy Load', 'w3-total-cache' ),
@ -1198,15 +1278,15 @@ class SetupGuide_Plugin_Admin {
) . '</p>
<p><strong>' . esc_html__( 'W3 Total Cache', 'w3-total-cache' ) . '</strong> ' .
esc_html__( 'can help you speed up dynamic pages by persistently storing objects.', 'w3-total-cache' ) .
'</p>
<p>
<input id="w3tc-test-objcache" class="button-primary" type="button" value="' .
esc_html__( 'Test Object Cache', 'w3-total-cache' ) . '">
<span class="hidden"><span class="spinner inline"></span>' . esc_html__( 'Testing', 'w3-total-cache' ) .
' <em>' . esc_html__( 'Object Cache', 'w3-total-cache' ) . '</em>&hellip;
</span>
</p>
<table id="w3tc-objcache-table" class="w3tc-setupguide-table widefat striped hidden">
'</p>' .
( ! $config->getf_boolean( 'objectcache.enabled' ) && has_filter( 'w3tc_config_item_objectcache.enabled' ) ? '<p class="notice notice-warning inline">' . esc_html__( 'Object Cache is disabled via filter.', 'w3-total-cache' ) . '</p>' : '' ) .
( ! has_filter( 'w3tc_config_item_objectcache.enabled' ) ? '<p>
<input id="w3tc-test-objcache" class="button-primary" type="button" value="' . esc_html__( 'Test Object Cache', 'w3-total-cache' ) . '">
<span class="hidden"><span class="spinner inline"></span>' . esc_html__( 'Testing', 'w3-total-cache' ) .
' <em>' . esc_html__( 'Object Cache', 'w3-total-cache' ) . '</em>&hellip;
</span>
</p>' : '' ) .
'<table id="w3tc-objcache-table" class="w3tc-setupguide-table widefat striped hidden">
<thead>
<tr>
<th>' . esc_html__( 'Select', 'w3-total-cache' ) . '</th>
@ -1265,6 +1345,18 @@ class SetupGuide_Plugin_Admin {
<tbody></tbody>
</table>',
),
array( // Image Service.
'headline' => __( 'Image Optimization', 'w3-total-cache' ),
'id' => 'io1',
'markup' => '<p>' .
esc_html__(
'Adds the ability to convert images in the Media Library to the modern WebP format for better performance.',
'w3-total-cache'
) . '</p>
<p>
<input type="checkbox" id="imageservice-enable" value="1" /> <label for="imageservice-enable">' .
esc_html__( 'Enable WebP Converter', 'w3-total-cache' ) . '</label></p>',
),
array( // Lazy load.
'headline' => __( 'Lazy Load', 'w3-total-cache' ),
'id' => 'll1',
@ -1314,16 +1406,31 @@ class SetupGuide_Plugin_Admin {
'<span id="w3tc-dbcache-engine">' . esc_html__( 'UNKNOWN', 'w3-total-cache' ) . '</span>'
) . '</p>
<p>' .
sprintf(
// translators: 1: HTML strong open tag, 2: HTML strong close tag, 3: Label.
esc_html__(
'%1$sObject Cache%2$s engine set to %1$s%3$s%2$s',
'w3-total-cache'
),
'<strong>',
'</strong>',
'<span id="w3tc-objcache-engine">' . esc_html__( 'UNKNOWN', 'w3-total-cache' ) . '</span>'
) . '</p>
(
! $config->getf_boolean( 'objectcache.enabled' ) && has_filter( 'w3tc_config_item_objectcache.enabled' )
?
sprintf(
// translators: 1: HTML strong open tag, 2: HTML strong close tag.
esc_html__(
'%1$sObject Cache%2$s is %1$sdisabled via filter%2$s',
'w3-total-cache'
),
'<strong>',
'</strong>'
)
:
sprintf(
// translators: 1: HTML strong open tag, 2: HTML strong close tag, 3: Label.
esc_html__(
'%1$sObject Cache%2$s engine set to %1$s%3$s%2$s',
'w3-total-cache'
),
'<strong>',
'</strong>',
'<span id="w3tc-objcache-engine">' . esc_html__( 'UNKNOWN', 'w3-total-cache' ) . '</span>'
)
) .
'</p>
<p>' .
sprintf(
// translators: 1: HTML strong open tag, 2: HTML strong close tag, 3: Label.
@ -1335,6 +1442,16 @@ class SetupGuide_Plugin_Admin {
'</strong>',
'<span id="w3tc-browsercache-setting">' . esc_html__( 'UNKNOWN', 'w3-total-cache' ) . '</span>'
) . '</p>
<p>' . sprintf(
// translators: 1: HTML strong open tag, 2: HTML strong close tag, 3: Label.
esc_html__(
'%1$sImage Optimization%2$s enabled? %1$s%3$s%2$s',
'w3-total-cache'
),
'<strong>',
'</strong>',
'<span id="w3tc-imageservice-setting">' . esc_html__( 'UNKNOWN', 'w3-total-cache' ) . '</span>'
) . '</p>
<p>' . sprintf(
// translators: 1: HTML strong open tag, 2: HTML strong close tag, 3: Label.
esc_html__(
@ -1363,10 +1480,17 @@ class SetupGuide_Plugin_Admin {
'Please visit %1$sGeneral Settings%2$s to learn more about these features.',
'w3-total-cache'
),
'<a href="' . esc_url(
$force_master_config || is_network_admin() ?
network_admin_url( 'admin.php?page=w3tc_general' ) : admin_url( 'admin.php?page=w3tc_general' )
) . '">',
'<a href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_general' ) ) . '">',
'</a>'
) . '</p>
<h3>' . esc_html__( 'Google PageSpeed Tool', 'w3-total-cache' ) . '</h3>
<p>' . sprintf(
// translators: 1: Anchor/link open tag, 2: Anchor/link close tag.
esc_html__(
'Google PageSpeed Insights can be used to analyze your homepage and provide an explanation of metrics and recommendations for improvements using W3 Total Cache features/extensions. This tool is enabled by default but will not function until authorization is granted, which can be done on the %1$sGeneral Settings%2$s page.',
'w3-total-cache'
),
'<a href="' . esc_url( Util_Ui::admin_url( 'admin.php?page=w3tc_general#google_pagespeed' ) ) . '">',
'</a>'
) . '</p>
<h3>' . esc_html__( 'Need help?', 'w3-total-cache' ) . '</h3>

View File

@ -74,7 +74,8 @@ class Support_Page {
Licensing_Core::terms_accept();
include W3TC_DIR . '/Support_Page_View_DoneContent.php';
} else
} else {
include W3TC_DIR . '/Support_Page_View_PageContent.php';
}
}
}

View File

@ -1,3 +1,4 @@
<?php include W3TC_INC_DIR . '/options/common/header.php'; ?>
<div style="text-align: center; font-weight: bold; margin-top: 50px">
Thank you for filling out the form
</div>

View File

@ -4,9 +4,23 @@ namespace W3TC;
if ( ! defined( 'W3TC' ) ) {
die();
}
?>
<?php Util_Ui::postbox_header( esc_html__( 'Opcode Cache', 'w3-total-cache' ), '', 'system_opcache' ); ?>
Util_Ui::postbox_header_tabs(
esc_html__( 'Opcode Cache', 'w3-total-cache' ),
esc_html__(
'Opcode cache is a powerful feature that enhances the performance of a WordPress website by caching
compiled PHP code. By storing pre-compiled code in memory, opcode cache eliminates the need for
repetitive interpretation and compilation of PHP files, resulting in significantly faster execution
times. Opcode cache reduces server load and improves response times, ultimately enhancing the
overall speed and responsiveness of your WordPress site. If opcode cache is available on the
hosting server it will automatically be selected in the dropdown and enabled.',
'w3-total-cache'
),
'',
'system_opcache'
);
?>
<table class="form-table">
<?php
Util_Ui::config_item(
@ -44,12 +58,5 @@ if ( ! defined( 'W3TC' ) ) {
);
?>
</table>
<?php
Util_Ui::button_config_save(
'general_opcache',
'<input type="submit" name="w3tc_opcache_flush" value="' . esc_attr__( 'Empty cache', 'w3-total-cache' ) . '"' .
( ( 'Not Available' !== $opcode_engine ) ? '' : ' disabled="disabled" ' ) . ' class="button" />'
);
?>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -1,27 +1,47 @@
<?php
/**
* File: UsageStatistics_GeneralPage_View.php
*
* @package W3TC
*/
namespace W3TC;
if ( !defined( 'W3TC' ) )
if ( ! defined( 'W3TC' ) ) {
die();
Util_Ui::postbox_header( 'Statistics', '', 'stats' );
}
$c = Dispatcher::config();
$is_pro = Util_Environment::is_w3tc_pro( $c );
?>
Util_Ui::postbox_header_tabs(
esc_html__( 'Statistics', 'w3-total-cache' ),
esc_html__(
'Cache Usage Statistics is a feature that provides valuable insights into the performance of your website\'s
caching system. It displays detailed data regarding the utilization of your cache and overall performance
metrics. By monitoring these statistics, website owners can identify areas of improvement, optimize their
caching settings, and ultimately enhance the speed and responsiveness of their WordPress site, resulting
in a smoother user experience for visitors.',
'w3-total-cache'
),
'',
'stats',
Util_UI::admin_url( 'admin.php?page=w3tc_stats' )
);
<table class="<?php echo esc_attr( Util_Ui::table_class() ); ?>">
<?php
Util_Ui::config_item_pro( array(
'key' => 'stats.enabled',
'label' => esc_html__( 'Cache usage statistics', 'w3-total-cache' ),
'control' => 'checkbox',
?>
<table class="form-table">
<?php
Util_Ui::config_item_pro(
array(
'key' => 'stats.enabled',
'label' => esc_html__( 'Cache usage statistics', 'w3-total-cache' ),
'control' => 'checkbox',
'checkbox_label' => __( 'Enable', 'w3-total-cache' ),
'disabled' => ( $is_pro ? null : true ),
'excerpt' => __( 'Enable statistics collection. Note that this consumes additional resources and is not recommended to be run continuously.',
'w3-total-cache' ),
'description' => array(
'disabled' => ( $is_pro ? null : true ),
'excerpt' => __( 'Enable statistics collection. Note that this consumes additional resources and is not recommended to be run continuously.', 'w3-total-cache' ),
'description' => array(
__( 'Statistics provides near-complete transparency into the behavior of your caching performance, allowing you to identify opportunities to further improve your website speed and ensure operations are working as expected. Includes metrics like cache sizes, object lifetimes, hit vs miss ratio, etc across every caching method configured in your settings.', 'w3-total-cache' ),
__( 'Some statistics are available directly on your Performance Dashboard, however, the comprehensive suite of statistics are available on the Statistics screen. Web server logs created by Nginx or Apache can be analyzed if accessible.', 'w3-total-cache' ),
wp_kses(
@ -34,76 +54,92 @@ Util_Ui::config_item_pro( array(
array( 'a' => array( 'href' => array() ) )
),
),
) );
Util_Ui::config_item( array(
'key' => 'stats.slot_seconds',
'label' => __( 'Slot time (seconds):', 'w3-total-cache' ),
'control' => 'textbox',
'textbox_type' => 'number',
'description' => __( 'The duration of time in seconds to collect statistics per interval.', 'w3-total-cache' ),
'show_in_free' => false,
) );
Util_Ui::config_item( array(
'key' => 'stats.slots_count',
'label' => __( 'Slots collected:', 'w3-total-cache' ),
'control' => 'textbox',
'textbox_type' => 'number',
'description' => __( 'The number of intervals that are represented in the graph.', 'w3-total-cache' ),
'show_in_free' => false,
) );
)
);
Util_Ui::config_item( array(
'key' => 'stats.cpu.enabled',
'control' => 'checkbox',
Util_Ui::config_item(
array(
'key' => 'stats.slot_seconds',
'label' => __( 'Slot time (seconds):', 'w3-total-cache' ),
'control' => 'textbox',
'textbox_type' => 'number',
'description' => __( 'The duration of time in seconds to collect statistics per interval.', 'w3-total-cache' ),
'show_in_free' => false,
)
);
Util_Ui::config_item(
array(
'key' => 'stats.slots_count',
'label' => __( 'Slots collected:', 'w3-total-cache' ),
'control' => 'textbox',
'textbox_type' => 'number',
'description' => __( 'The number of intervals that are represented in the graph.', 'w3-total-cache' ),
'show_in_free' => false,
)
);
Util_Ui::config_item(
array(
'key' => 'stats.cpu.enabled',
'control' => 'checkbox',
'checkbox_label' => __( 'Use the system reported averages of CPU resource usage.', 'w3-total-cache' ),
'description' => __( 'Collect CPU usage', 'w3-total-cache' ),
'show_in_free' => false,
) );
Util_Ui::config_item( array(
'key' => 'stats.access_log.enabled',
'control' => 'checkbox',
'description' => __( 'Collect CPU usage', 'w3-total-cache' ),
'show_in_free' => false,
)
);
Util_Ui::config_item(
array(
'key' => 'stats.access_log.enabled',
'control' => 'checkbox',
'checkbox_label' => __( 'Parse server access log', 'w3-total-cache' ),
'disabled' => ( $is_pro ? null : true ),
'description' => __( 'Enable collecting statistics from an Access Log. This provides much more precise statistics.', 'w3-total-cache' ),
'show_in_free' => false,
) );
Util_Ui::config_item( array(
'key' => 'stats.access_log.webserver',
'label' => __( 'Webserver:', 'w3-total-cache' ),
'control' => 'selectbox',
'disabled' => ( $is_pro ? null : true ),
'description' => __( 'Enable collecting statistics from an Access Log. This provides much more precise statistics.', 'w3-total-cache' ),
'show_in_free' => false,
)
);
Util_Ui::config_item(
array(
'key' => 'stats.access_log.webserver',
'label' => __( 'Webserver:', 'w3-total-cache' ),
'control' => 'selectbox',
'selectbox_values' => array(
'apache' => 'Apache',
'nginx' => 'Nginx'
'nginx' => 'Nginx',
),
'description' => __( 'Webserver type generating access logs.' ,'w3-total-cache' ),
'description' => __( 'Webserver type generating access logs.', 'w3-total-cache' ),
'show_in_free' => false,
) );
Util_Ui::config_item( array(
'key' => 'stats.access_log.filename',
'label' => __( 'Access Log Filename:', 'w3-total-cache' ),
'control' => 'textbox',
'textbox_size' => 60,
'description' => __( 'Where your access log is located.', 'w3-total-cache' ),
'control_after' =>
'<input type="button" class="button" id="ustats_access_log_test" value="Test" /><span id="ustats_access_log_test_result" style="padding-left: 20px"></span>',
'show_in_free' => false,
) );
Util_Ui::config_item( array(
'key' => 'stats.access_log.format',
'label' => __( 'Access Log Format:', 'w3-total-cache' ),
'control' => 'textbox',
'textbox_size' => 60,
'description' => __( 'Format of your access log from webserver configuration.', 'w3-total-cache' ),
'control_after' =>
'<input type="button" class="button" id="ustats_access_log_format_reset" value="Reset to Default" />',
'show_in_free' => false,
) );
)
);
Util_Ui::config_item(
array(
'key' => 'stats.access_log.filename',
'label' => __( 'Access Log Filename:', 'w3-total-cache' ),
'control' => 'textbox',
'textbox_size' => 60,
'description' => __( 'Where your access log is located.', 'w3-total-cache' ),
'control_after' => '<input type="button" class="button" id="ustats_access_log_test" value="Test" /><span id="ustats_access_log_test_result" style="padding-left: 20px"></span>',
'show_in_free' => false,
)
);
Util_Ui::config_item(
array(
'key' => 'stats.access_log.format',
'label' => __( 'Access Log Format:', 'w3-total-cache' ),
'control' => 'textbox',
'textbox_size' => 60,
'description' => __( 'Format of your access log from webserver configuration.', 'w3-total-cache' ),
'control_after' => '<input type="button" class="button" id="ustats_access_log_format_reset" value="Reset to Default" />',
'show_in_free' => false,
)
);
?>
</table>
<?php
Util_Ui::button_config_save( 'stats' );
?>
<?php Util_Ui::postbox_footer(); ?>
<script>
@ -111,7 +147,7 @@ jQuery('#ustats_access_log_format_reset').click(function() {
var webserver = jQuery('#stats__access_log__webserver').val();
var v;
if (webserver == 'nginx') {
if ( webserver == 'nginx' ) {
v = '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
} else {
v = '%h %l %u %t \\"%r\\" %>s %O \\"%{Referer}i\\" \\"%{User-Agent}i\\"';

View File

@ -28,6 +28,7 @@ class UsageStatistics_Page {
} else {
include W3TC_DIR . '/UsageStatistics_Page_View_Disabled.php';
}
return;
}

View File

@ -12,7 +12,6 @@ require W3TC_INC_DIR . '/options/common/header.php';
<div class="ustats_ad">
<?php require __DIR__ . '/UsageStatistics_Page_View_Ad.php'; ?>
<input type="button" class="button-primary button-buy-plugin"
data-src="page_stats_bottom"
value="<?php esc_attr_e( 'upgrade', 'w3-total-cache' ); ?>" />

View File

@ -29,8 +29,8 @@ if ( ! defined( 'W3TC' ) ) {
</style>
<p class="w3tcuw_inactive">
<?php if ( ! Util_Environment::is_w3tc_pro( Dispatcher::config() ) ) : ?>
<input type="button"
class="button-primary button-buy-plugin {nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}" data-src="usagestatistics_widget" value="<?php esc_html_e( 'Upgrade to Pro', 'w3-total-cache' ); ?>" />
<input type="button" class="button-primary button-buy-plugin {nonce: '<?php echo esc_attr( wp_create_nonce( 'w3tc' ) ); ?>'}"
data-src="usagestatistics_widget" value="<?php esc_html_e( 'Upgrade to Pro', 'w3-total-cache' ); ?>" />
<?php else : ?>
<a href="admin.php?page=w3tc_general#stats" class="button-primary">Enable</a>
<?php endif ?>

View File

@ -0,0 +1,295 @@
<?php
/**
* File: UserExperience_DeferScripts_Extension.php
*
* Controls the defer JS feature.
*
* @since 2.4.2
*
* @package W3TC
*/
namespace W3TC;
/**
* UserExperience DeferScripts Extension.
*
* @since 2.4.2
*/
class UserExperience_DeferScripts_Extension {
/**
* Config.
*
* @var object
*/
private $config;
/**
* Mutator.
*
* @var object
*/
private $mutator;
/**
* User Experience DeferScripts constructor.
*
* @since 2.4.2
*/
public function __construct() {
$this->config = Dispatcher::config();
}
/**
* Runs User Experience DeferScripts feature.
*
* @since 2.4.2
*
* @return void
*/
public function run() {
if ( ! Util_Environment::is_w3tc_pro( $this->config ) ) {
$this->config->set_extension_active_frontend( 'user-experience-defer-scripts', false );
return;
}
Util_Bus::add_ob_callback( 'lazyload', array( $this, 'ob_callback' ) );
add_filter( 'w3tc_minify_js_script_tags', array( $this, 'w3tc_minify_js_script_tags' ) );
add_filter( 'w3tc_save_options', array( $this, 'w3tc_save_options' ) );
add_action( 'w3tc_userexperience_page', array( $this, 'w3tc_userexperience_page' ) );
/**
* This filter is documented in Generic_AdminActions_Default.php under the read_request method.
*/
add_filter( 'w3tc_config_key_descriptor', array( $this, 'w3tc_config_key_descriptor' ), 10, 2 );
}
/**
* Processes the page content buffer to defer JS.
*
* @since 2.4.2
*
* @param string $buffer page content buffer.
*
* @return string
*/
public function ob_callback( $buffer ) {
if ( '' === $buffer || ! \W3TC\Util_Content::is_html_xml( $buffer ) ) {
return $buffer;
}
$can_process = array(
'enabled' => true,
'buffer' => $buffer,
'reason' => null,
);
$can_process = $this->can_process( $can_process );
$can_process = apply_filters( 'w3tc_deferscripts_can_process', $can_process );
// set reject reason in comment.
if ( $can_process['enabled'] ) {
$reject_reason = '';
} else {
$reject_reason = empty( $can_process['reason'] ) ? ' (not specified)' : ' (' . $can_process['reason'] . ')';
}
$buffer = str_replace(
'{w3tc_deferscripts_reject_reason}',
$reject_reason,
$buffer
);
// processing.
if ( ! $can_process['enabled'] ) {
return $buffer;
}
$this->mutator = new UserExperience_DeferScripts_Mutator( $this->config );
$buffer = $this->mutator->run( $buffer );
// embed lazyload script.
if ( $this->mutator->content_modified() ) {
$buffer = apply_filters( 'w3tc_deferscripts_embed_script', $buffer );
$is_embed_script = apply_filters( 'w3tc_deferscripts_is_embed_script', true );
if ( $is_embed_script ) {
$buffer = $this->embed_script( $buffer );
}
}
return $buffer;
}
/**
* Checks if the request can be processed for defer JS.
*
* @since 2.4.2
*
* @param boolean $can_process flag representing if defer JS can be executed.
*
* @return boolean
*/
private function can_process( $can_process ) {
if ( defined( 'WP_ADMIN' ) ) {
$can_process['enabled'] = false;
$can_process['reason'] = 'WP_ADMIN';
return $can_process;
}
if ( defined( 'SHORTINIT' ) && SHORTINIT ) {
$can_process['enabled'] = false;
$can_process['reason'] = 'SHORTINIT';
return $can_process;
}
if ( function_exists( 'is_feed' ) && is_feed() ) {
$can_process['enabled'] = false;
$can_process['reason'] = 'feed';
return $can_process;
}
return $can_process;
}
/**
* Adds defer JS message to W3TC footer comment.
*
* @since 2.4.2
*
* @param array $strings array of W3TC footer comments.
*
* @return array
*/
public function w3tc_footer_comment( $strings ) {
$strings[] = __( 'Defer Scripts', 'w3-total-cache' ) . '{w3tc_deferscripts_reject_reason}';
return $strings;
}
/**
* Embeds the defer JS script in buffer.
*
* @since 2.4.2
*
* @param string $buffer page content buffer.
*
* @return string
*/
private function embed_script( $buffer ) {
$config_timeout = $this->config->get_integer(
array(
'user-experience-defer-scripts',
'timeout',
)
);
$content = file_get_contents( W3TC_DIR . '/UserExperience_DeferScripts_Script.js' );
$content = str_replace(
'{config_timeout}',
$config_timeout,
$content
);
$footer_script = '<script>' . $content . '</script>';
$buffer = preg_replace(
'~</body(\s+[^>]*)*>~Ui',
$footer_script . '\\0',
$buffer,
1
);
return $buffer;
}
/**
* Filters script tags that are flaged as deferred. This is used to prevent Minify from touching scripts deferred by this feature.
*
* @since 2.4.2
*
* @param array $script_tags array of script tags.
*
* @return array
*/
public function w3tc_minify_js_script_tags( $script_tags ) {
if ( ! is_null( $this->mutator ) ) {
$script_tags = $this->mutator->w3tc_minify_js_script_tags( $script_tags );
}
return $script_tags;
}
/**
* Renders the user experience defer JS settings page.
*
* @since 2.4.2
*
* @return void
*/
public function w3tc_userexperience_page() {
if ( Util_Environment::is_w3tc_pro( $this->config ) ) {
include __DIR__ . '/UserExperience_DeferScripts_Page_View.php';
}
}
/**
* Specify config key typing for fields that need it.
*
* @since 2.4.2
*
* @param mixed $descriptor Descriptor.
* @param mixed $key Compound key array.
*
* @return array
*/
public function w3tc_config_key_descriptor( $descriptor, $key ) {
if ( is_array( $key ) && 'user-experience-defer-scripts.includes' === implode( '.', $key ) ) {
$descriptor = array( 'type' => 'array' );
}
return $descriptor;
}
/**
* Performs actions on save.
*
* @since 2.4.2
*
* @param array $data Array of save data.
*
* @return array
*/
public function w3tc_save_options( $data ) {
$new_config = $data['new_config'];
$old_config = $data['old_config'];
if (
$new_config->get_array( array( 'user-experience-defer-scripts', 'timeout' ) ) !== $old_config->get_array( array( 'user-experience-defer-scripts', 'timeout' ) )
|| $new_config->get_array( array( 'user-experience-defer-scripts', 'includes' ) ) !== $old_config->get_array( array( 'user-experience-defer-scripts', 'includes' ) )
) {
$minify_enabled = $this->config->get_boolean( 'minify.enabled' );
$pgcache_enabled = $this->config->get_boolean( 'pgcache.enabled' );
if ( $minify_enabled || $pgcache_enabled ) {
$state = Dispatcher::config_state();
if ( $minify_enabled ) {
$state->set( 'minify.show_note.need_flush', true );
}
if ( $pgcache_enabled ) {
$state->set( 'common.show_note.flush_posts_needed', true );
}
$state->save();
}
}
return $data;
}
}
$o = new UserExperience_DeferScripts_Extension();
$o->run();

View File

@ -0,0 +1,175 @@
<?php
/**
* File: UserExperience_DeferScripts_Mutator.php
*
* JS feature mutator for buffer processing.
*
* @since 2.4.2
*
* @package W3TC
*/
namespace W3TC;
/**
* UserExperience DeferScripts Mutator.
*
* @since 2.4.2
*/
class UserExperience_DeferScripts_Mutator {
/**
* Config.
*
* @var object
*/
private $config;
/**
* Modified flag.
*
* @var boolean
*/
private $modified = false;
/**
* Array of includes.
*
* @var array
*/
private $includes = array();
/**
* User Experience DeferScripts Mutator constructor.
*
* @since 2.4.2
*
* @param object $config Config object.
*
* @return void
*/
public function __construct( $config ) {
$this->config = $config;
}
/**
* Runs User Experience DeferScripts Mutator.
*
* @since 2.4.2
*
* @param string $buffer Buffer string containing browser output.
*
* @return string
*/
public function run( $buffer ) {
$r = apply_filters(
'w3tc_deferscripts_mutator_before',
array(
'buffer' => $buffer,
'modified' => $this->modified,
)
);
$buffer = $r['buffer'];
$this->modified = $r['modified'];
$this->includes = $this->config->get_array(
array(
'user-experience-defer-scripts',
'includes',
)
);
$buffer = preg_replace_callback(
'~<script\s[^>]+>~is',
array(
$this,
'tag_script',
),
$buffer
);
return $buffer;
}
/**
* Get modified status flag.
*
* @since 2.4.2
*
* @return boolean
*/
public function content_modified() {
return $this->modified;
}
/**
* Modifies script tag for script matched to be deferred.
*
* @since 2.4.2
*
* @param array $matches array of matched JS entries.
*
* @return string
*/
public function tag_script( $matches ) {
$content = $matches[0];
if ( $this->is_content_included( $content ) ) {
$count = 0;
$content = preg_replace(
'~(\s)src=~is',
'$1data-lazy="w3tc" data-src=',
$content,
-1,
$count
);
if ( $count > 0 ) {
$this->modified = true;
}
}
return $content;
}
/**
* Checks if content has already been deferred.
*
* @since 2.4.2
*
* @param string $content script tag string.
*
* @return boolean
*/
private function is_content_included( $content ) {
foreach ( $this->includes as $w ) {
if ( ! empty( $w ) ) {
if ( strpos( $content, $w ) !== false ) {
return true;
}
}
}
return false;
}
/**
* Filters out scripts so Minify doesn't touch deferred scripts.
*
* @since 2.4.2
*
* @param array $script_tags array of script tags.
*
* @return array
*/
public function w3tc_minify_js_script_tags( $script_tags ) {
return array_values(
array_filter(
$script_tags,
function( $i ) {
return ! preg_match( '~\sdata-lazy="w3tc"\s~', $i );
}
)
);
}
}

View File

@ -0,0 +1,69 @@
<?php
/**
* File: UserExperience_DeferScripts_Page_View.php
*
* Renders the delay scripts setting block on the UserExperience advanced settings page.
*
* @since 2.4.2
*
* @package W3TC
*/
namespace W3TC;
if ( ! defined( 'W3TC' ) ) {
die();
}
$c = Dispatcher::config();
if ( is_null( $c->get( array( 'user-experience-defer-scripts', 'timeout' ) ) ) ) {
$c->set( array( 'user-experience-defer-scripts', 'timeout' ), 5000 );
$c->save();
}
?>
<?php Util_Ui::postbox_header( esc_html__( 'Delay Scripts', 'w3-total-cache' ), '', 'application' ); ?>
<p><?php esc_html_e( 'For best results it is recommended to enable the Minify feature to optimize internal sources and to then use this feature to handle external sources and/or any internal sources excluded from Minify.', 'w3-total-cache' ); ?></p>
<p>
<?php
echo wp_kses(
sprintf(
__(
'To identify render-blocking JavaScript sources, use the %1$sGoogle PageSpeed%2$s tool and add appropirate URLs from the "Eliminate render-blocking resources" section to the Delay List textarea below.',
'w3-total-cache'
),
'<a href="' . Util_Ui::admin_url( 'admin.php?page=w3tc_pagespeed' ) . '" target="_blank">',
'</a>'
),
array(
'a' => array(
'href' => array(),
'target' => array(),
),
)
);
?>
</p>
<table class="form-table">
<?php
Util_Ui::config_item(
array(
'key' => array( 'user-experience-defer-scripts', 'timeout' ),
'label' => esc_html__( 'Timeout:', 'w3-total-cache' ),
'control' => 'textbox',
'description' => esc_html__( 'Timeout (in milliseconds) to delay the loading of delayed scripts if no user action is taken during page load', 'w3-total-cache' ),
)
);
Util_Ui::config_item(
array(
'key' => array( 'user-experience-defer-scripts', 'includes' ),
'label' => esc_html__( 'Delay list:', 'w3-total-cache' ),
'control' => 'textarea',
'description' => esc_html__( 'Specify keywords to match any attribute of script tags containing the "src" attribute. Include one entry per line, e.g. (googletagmanager.com, gtag/js, myscript.js, and name="myscript")', 'w3-total-cache' ),
)
);
?>
</table>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -0,0 +1,9 @@
(function(w,k,o) {
var t=setTimeout(f,{config_timeout});
k.forEach(function(e){w.addEventListener(e,f,o)});
function f(){
document.querySelectorAll("script[data-lazy='w3tc']").forEach(function(i){i.src = i.dataset.src})
clearTimeout(t);
k.forEach(function(e){w.removeEventListener(e,f,o)})
}
})(window,["keydown","mouseover","touchmove","touchstart","wheel"],{passive:!0})

View File

@ -1,13 +1,35 @@
<?php
/**
* File: UserExperience_GeneralPage_View.php
*
* @package W3TC
*/
namespace W3TC;
if ( ! defined( 'W3TC' ) ) {
die();
}
$config = Dispatcher::config();
?>
<?php
Util_Ui::postbox_header( esc_html__( 'User Experience', 'w3-total-cache' ), '', 'userexperience' );
Util_Ui::postbox_header_tabs(
esc_html__( 'User Experience', 'w3-total-cache' ),
esc_html__(
'User Experience (UX) is a setting that focuses on enhancing the overall browsing experience for visitors
of your website. By enabling this feature, you can optimize your website\'s performance by minimizing
load times, reducing server requests, and delivering content more efficiently. This ultimately leads
to faster page loading, improved user satisfaction, and increased engagement, resulting in a speedier
and more enjoyable WordPress website.',
'w3-total-cache'
),
'',
'userexperience',
Util_UI::admin_url( 'admin.php?page=w3tc_userexperience' )
);
Util_Ui::config_overloading_button( array( 'key' => 'lazyload.configuration_overloaded' ) );
?>
<table class="form-table">
@ -17,6 +39,7 @@ Util_Ui::config_overloading_button( array( 'key' => 'lazyload.configuration_over
'key' => 'lazyload.enabled',
'control' => 'checkbox',
'checkbox_label' => esc_html__( 'Lazy Load Images', 'w3-total-cache' ),
'label_class' => 'w3tc_single_column',
'description' => esc_html__( 'Defer loading offscreen images.', 'w3-total-cache' ),
)
);
@ -25,6 +48,7 @@ Util_Ui::config_overloading_button( array( 'key' => 'lazyload.configuration_over
array(
'key' => 'lazyload_googlemaps_general_settings',
'control' => 'none',
'label_class' => 'w3tc_single_column',
'none_label' => esc_html__( 'Lazy Load Google Maps', 'w3-total-cache' ),
'excerpt' => wp_kses(
sprintf(
@ -38,7 +62,7 @@ Util_Ui::config_overloading_button( array( 'key' => 'lazyload.configuration_over
'</strong>',
'<strong>',
'</strong>',
'<a href="' . admin_url( 'admin.php?page=w3tc_userexperience' ) . '">',
'<a href="' . Util_Ui::admin_url( 'admin.php?page=w3tc_userexperience#lazy-loading' ) . '">',
'</a>'
),
array(
@ -56,16 +80,50 @@ Util_Ui::config_overloading_button( array( 'key' => 'lazyload.configuration_over
array(
'extension_id' => 'user-experience-emoji',
'checkbox_label' => esc_html__( 'Disable Emoji', 'w3-total-cache' ),
'description' => esc_html__( 'Remove emojis support from your website.', 'w3-total-cache' )
'description' => esc_html__( 'Remove emojis support from your website.', 'w3-total-cache' ),
'label_class' => 'w3tc_single_column',
)
);
?>
<?php
Util_Ui::config_item_extension_enabled(
array(
'extension_id' => 'user-experience-defer-scripts',
'checkbox_label' => esc_html__( 'Delay Scripts', 'w3-total-cache' ),
'description' => __(
'Delay the loading of specified interal/external JavaScript sources on your pages separate from Minify. For best results it is recommended to enable the Minify feature to optimize internal sources and to then use the Delay JavaScript feature to handle external sources and/or any internal sources excluded from Minify.',
'w3-total-cache'
) . (
Util_Environment::is_w3tc_pro( $config ) && $config->is_extension_active( 'user-experience-defer-scripts' )
? wp_kses(
sprintf(
// translators: 1 opening HTML a tag to W3TC User Experience page, 2 closing HTML a tag.
__(
' Settings can be found on the %1$sUser Experience page%2$s.',
'w3-total-cache'
),
'<a href="' . Util_Ui::admin_url( 'admin.php?page=w3tc_userexperience#application' ) . '">',
'</a>'
),
array(
'a' => array(
'href' => array(),
),
)
)
: ''
),
'label_class' => 'w3tc_single_column',
'pro' => true,
'disabled' => ! Util_Environment::is_w3tc_pro( $config ) ? true : false,
)
);
Util_Ui::config_item_extension_enabled(
array(
'extension_id' => 'user-experience-oembed',
'checkbox_label' => esc_html__( 'Disable wp-embed script', 'w3-total-cache' ),
'description' => esc_html__( 'Remove wp-embed.js script from your website. oEmbed functionality still works but you will not be able to embed other WordPress posts on your pages.', 'w3-total-cache' )
'description' => esc_html__( 'Remove wp-embed.js script from your website. oEmbed functionality still works but you will not be able to embed other WordPress posts on your pages.', 'w3-total-cache' ),
'label_class' => 'w3tc_single_column',
)
);
@ -74,11 +132,11 @@ Util_Ui::config_overloading_button( array( 'key' => 'lazyload.configuration_over
'key' => 'jquerymigrate.disabled',
'control' => 'checkbox',
'checkbox_label' => esc_html__( 'Disable jquery-migrate on the front-end', 'w3-total-cache' ),
'label_class' => 'w3tc_single_column',
'description' => esc_html__( 'Remove jquery-migrate support from your website front-end.', 'w3-total-cache' ),
)
);
?>
</table>
<?php Util_Ui::button_config_save( 'general_userexperience' ); ?>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -14,7 +14,7 @@ $is_wp_google_map_plugin = ( in_array( 'wp-google-map-plugin/wp-google-map-plugi
$is_google_maps_easy = ( in_array( 'google-maps-easy/gmp.php', $plugins, true ) );
?>
<?php Util_Ui::postbox_header( esc_html__( 'Lazy Loading', 'w3-total-cache' ), '', 'application' ); ?>
<?php Util_Ui::postbox_header( esc_html__( 'Lazy Loading', 'w3-total-cache' ), '', 'lazy-loading' ); ?>
<table class="form-table">
<?php
Util_Ui::config_item(
@ -108,7 +108,7 @@ $is_google_maps_easy = ( in_array( 'google-maps-easy/gmp.php', $plugins, tru
?>
</table>
<table class="<?php echo esc_attr( Util_Ui::table_class() ); ?>">
<table class="form-table">
<tr>
<th><?php esc_html_e( 'Google Maps', 'w3-total-cache' ); ?></th>
<td>
@ -211,8 +211,5 @@ $is_google_maps_easy = ( in_array( 'google-maps-easy/gmp.php', $plugins, tru
</td>
</tr>
</table>
<p class="submit">
<?php Util_Ui::button_config_save( 'lazyload' ); ?>
</p>
<?php Util_Ui::postbox_footer(); ?>

View File

@ -8,16 +8,17 @@ if ( !defined( 'W3TC' ) )
<p>
Lazy loading is currently
<?php if ( $c->get_boolean( 'lazyload.enabled' ) ): ?>
<span class="w3tc-enabled">enabled</span>
<span class="w3tc-enabled">enabled</span>.
<?php else: ?>
<span class="w3tc-disabled">disabled</span>
<span class="w3tc-disabled">disabled</span>.
<?php endif ?>
.
<p>
<form action="admin.php?page=w3tc_userexperience" method="post">
<div class="metabox-holder">
<?php /* decouple it when too much */ ?>
<?php include W3TC_DIR . '/UserExperience_LazyLoad_Page_View.php' ?>
</div>
<?php Util_UI::print_control_bar( 'pagecache_form_control' ); ?>
<div class="metabox-holder">
<?php /* decouple it when too much */ ?>
<?php include W3TC_DIR . '/UserExperience_LazyLoad_Page_View.php' ?>
<?php do_action( 'w3tc_userexperience_page' ) ?>
</div>
</form>

View File

@ -2,53 +2,69 @@
namespace W3TC;
class UserExperience_Plugin_Admin {
function run() {
/**
* Runs the user experience feature.
*
* @return void
*/
public function run() {
add_filter( 'w3tc_admin_menu', array( $this, 'w3tc_admin_menu' ) );
add_action( 'w3tc_settings_page-w3tc_userexperience',
array( $this, 'w3tc_settings_page_w3tc_userexperience' ) );
add_action( 'admin_init_w3tc_general',
array( '\W3TC\UserExperience_GeneralPage', 'admin_init_w3tc_general' ) );
add_filter( 'w3tc_extensions', array(
'\W3TC\UserExperience_Plugin_Admin',
'w3tc_extensions' ),
10, 2 );
add_action( 'w3tc_settings_page-w3tc_userexperience', array( $this, 'w3tc_settings_page_w3tc_userexperience' ) );
add_action( 'admin_init_w3tc_general', array( '\W3TC\UserExperience_GeneralPage', 'admin_init_w3tc_general' ) );
add_filter( 'w3tc_extensions', array( '\W3TC\UserExperience_Plugin_Admin', 'w3tc_extensions' ), 10, 2 );
}
/**
* Set user experience admin menu item.
*
* @param array $menu
*
* @return array
*/
public function w3tc_admin_menu( $menu ) {
$c = Dispatcher::config();
$menu['w3tc_userexperience'] = array(
'page_title' => __( 'User Experience', 'w3-total-cache' ),
'menu_text' => __( 'User Experience', 'w3-total-cache' ),
'page_title' => __( 'User Experience', 'w3-total-cache' ),
'menu_text' => __( 'User Experience', 'w3-total-cache' ),
'visible_always' => false,
'order' => 1200
'order' => 1200,
);
return $menu;
}
static public function w3tc_extensions( $extensions, $config ) {
/**
* Configures extensions for user experience.
*
* @param array $extensions
* @param object $config
*
* @return array
*/
public static function w3tc_extensions( $extensions, $config ) {
$extensions['user-experience-defer-scripts'] = array(
'public' => false,
'extension_id' => 'user-experience-defer-scripts',
'path' => 'w3-total-cache/UserExperience_DeferScripts_Extension.php',
);
$extensions['user-experience-emoji'] = array(
'public' => false,
'public' => false,
'extension_id' => 'user-experience-emoji',
'path' => 'w3-total-cache/UserExperience_Emoji_Extension.php'
'path' => 'w3-total-cache/UserExperience_Emoji_Extension.php',
);
$extensions['user-experience-oembed'] = array(
'public' => false,
'public' => false,
'extension_id' => 'user-experience-oembed',
'path' => 'w3-total-cache/UserExperience_OEmbed_Extension.php'
'path' => 'w3-total-cache/UserExperience_OEmbed_Extension.php',
);
return $extensions;
}
/**
* Render user experience advanced settings page.
*
* @return void
*/
public function w3tc_settings_page_w3tc_userexperience() {
$v = new UserExperience_Page();
$v->render_content();

View File

@ -1,27 +1,40 @@
<?php
/**
* File: Util_Admin.php
*
* @package W3TC
*/
namespace W3TC;
/**
* Class: Util_Admin
*/
class Util_Admin {
/**
* Redirects when in WP Admin
* Redirects when in WP Admin.
*
* @param array $params
* @param bool $check_referrer
* @param string $page
* @static
*
* @param array $params Parameters.
* @param bool $check_referrer Check referrer.
* @param string $page Page.
*/
static public function redirect( $params = array(), $check_referrer = false, $page = '' ) {
$url = Util_Request::get_string( 'redirect' );
public static function redirect( $params = array(), $check_referrer = false, $page = '' ) {
$url = Util_Request::get_string( 'redirect' );
$page_url = Util_Request::get_string( 'page' );
if ( $url == '' ) {
if ( $check_referrer && !empty( $_SERVER['HTTP_REFERER'] ) ) {
if ( empty( $url ) ) {
if ( $check_referrer && ! empty( $_SERVER['HTTP_REFERER'] ) ) {
$url = isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
} else {
$url = 'admin.php';
if ( empty( $page ) )
if ( empty( $page ) ) {
$page = $page_url;
$params = array_merge( array(
'page' => $page
), $params );
}
$params = array_merge( array( 'page' => $page ), $params );
}
}
@ -29,164 +42,207 @@ class Util_Admin {
}
/**
* Redirect function to current admin page with errors and messages specified
* Redirect function to current admin page with errors and messages specified.
*
* @param array $params
* @param array $errors
* @param array $notes
* @param bool $check_referrer
* @static
*
* @param array $params Parameters.
* @param array $errors Errors.
* @param array $notes Notes.
* @param bool $check_referrer Check referrer.
* @return void
*/
static public function redirect_with_custom_messages( $params, $errors = null,
$notes = null, $check_referrer = false ) {
if ( empty( $errors ) && Util_Admin::single_system_item( $notes ) ) {
Util_Admin::redirect( array_merge( $params, array(
'w3tc_note' => $notes[0] ) ), $check_referrer );
public static function redirect_with_custom_messages( $params, $errors = null, $notes = null, $check_referrer = false ) {
if ( empty( $errors ) && self::single_system_item( $notes ) ) {
self::redirect( array_merge( $params, array( 'w3tc_note' => $notes[0] ) ), $check_referrer );
return;
}
if ( Util_Admin::single_system_item( $errors ) && empty( $notes ) ) {
Util_Admin::redirect( array_merge( $params, array(
'w3tc_error' => $errors[0] ) ), $check_referrer );
if ( self::single_system_item( $errors ) && empty( $notes ) ) {
self::redirect( array_merge( $params, array( 'w3tc_error' => $errors[0] ) ), $check_referrer );
return;
}
$message_id = uniqid();
set_transient( 'w3tc_message',
update_option(
'w3tc_message',
array(
$message_id => array( 'errors' => $errors, 'notes' => $notes )
), 600 );
$message_id => array(
'errors' => $errors,
'notes' => $notes,
),
),
'yes'
);
Util_Admin::redirect( array_merge( $params, array(
'w3tc_message' => $message_id ) ), $check_referrer );
self::redirect( array_merge( $params, array( 'w3tc_message' => $message_id ) ), $check_referrer );
}
/**
* Special redirect with ability to pass custom_message_id based on $data
* Special redirect with ability to pass custom_message_id based on $data.
* query_string
* actions - which actions to call on render
* errors
* notes
*
* @static
*
* @param array $data Data.
*/
static public function redirect_with_custom_messages2( $data ) {
if ( !isset( $data['query_string']['page'] ) ) {
$data['query_string']['page'] =
Util_Request::get_string( 'page' );
if ( $data['query_string']['page'] == 'w3tc_extensions' ) {
$data['query_string']['extension'] =
Util_Request::get_string( 'extension' );
$data['query_string']['action'] =
Util_Request::get_string( 'action' );
public static function redirect_with_custom_messages2( $data ) {
if ( ! isset( $data['query_string']['page'] ) ) {
$data['query_string']['page'] = Util_Request::get_string( 'page' );
if ( 'w3tc_extensions' === $data['query_string']['page'] ) {
$data['query_string']['extension'] = Util_Request::get_string( 'extension' );
$data['query_string']['action'] = Util_Request::get_string( 'action' );
}
}
$message_id = uniqid();
set_transient( 'w3tc_message', array( $message_id => $data ), 600 );
update_option( 'w3tc_message', array( $message_id => $data ), 'yes' );
$data['query_string']['w3tc_message'] = $message_id;
Util_Environment::redirect( 'admin.php', $data['query_string'] );
}
static public function custom_message_id( $errors = null, $notes = null ) {
/**
* Custom message id.
*
* @static
*
* @param array $errors Errors.
* @param array $notes Notes.
*/
public static function custom_message_id( $errors = null, $notes = null ) {
$message_id = uniqid();
set_transient( 'w3tc_message',
update_option(
'w3tc_message',
array(
$message_id => array( 'errors' => $errors, 'notes' => $notes )
), 600 );
$message_id => array(
'errors' => $errors,
'notes' => $notes,
),
),
'yes'
);
return 'w3tc_message=' . $message_id;
}
/*
* Checks if contains single message item
/**
* Checks if contains single message item.
*
* @param $a array
* @return boolean
* @static
*
* @param array $a Array.
* @return bool
*/
static public function single_system_item( $a ) {
if ( !is_array( $a ) || count( $a ) != 1 )
public static function single_system_item( $a ) {
if ( ! is_array( $a ) || count( $a ) !== 1 ) {
return false;
}
$first_key = array_keys( $a );
$first_key = $first_key[0];
$pos = strpos( $a[$first_key], ' ' );
if ( $pos === false )
$pos = strpos( $a[ $first_key ], ' ' );
if ( false === $pos ) {
return true;
}
return false;
}
/**
* Save config, can't decline save process. (difference from action_save)
* Save config, can't decline save process. (difference from action_save).
*
* Do some actions on config keys update.
*
* Do some actions on config keys update
* Used in several places such as:
*
* 1. common config save
* 2. import settings
*
* @param Config $current_config
* @param Config $new_config
* @static
*
* @param Config $current_config Current config.
* @param Config $new_config New config.
* @return bool
* @throws Exception
* @throws \Exception Exception.
*/
static public function config_save( $current_config, $new_config ) {
public static function config_save( $current_config, $new_config ) {
$master_config = ( $new_config->is_master() ? $new_config : Dispatcher::config_master() );
if ( $master_config->get_integer( 'common.instance_id', 0 ) == 0 ) {
$master_config->set( 'common.instance_id', mt_rand() );
if ( !$new_config->is_master() )
if ( ! $new_config->is_master() ) {
$master_config->save();
}
}
$old_config = new Config();
$browsercache_dependencies = array();
if ( $new_config->get_boolean( 'browsercache.enabled' ) ) {
$browsercache_dependencies = array_merge( $browsercache_dependencies, array(
$browsercache_dependencies = array_merge(
$browsercache_dependencies,
array(
'browsercache.rewrite',
'browsercache.cssjs.replace',
'browsercache.html.replace',
'browsercache.other.replace'
) );
'browsercache.other.replace',
)
);
if ( $new_config->get_boolean( 'browsercache.cssjs.replace' ) ) {
$browsercache_dependencies = array_merge( $browsercache_dependencies, array(
$browsercache_dependencies = array_merge(
$browsercache_dependencies,
array(
'browsercache.cssjs.compression',
'browsercache.cssjs.expires',
'browsercache.cssjs.lifetime',
'browsercache.cssjs.cache.control',
'browsercache.cssjs.cache.policy',
'browsercache.cssjs.etag',
'browsercache.cssjs.w3tc'
) );
'browsercache.cssjs.w3tc',
)
);
}
if ( $new_config->get_boolean( 'browsercache.html.replace' ) ) {
$browsercache_dependencies = array_merge( $browsercache_dependencies, array(
$browsercache_dependencies = array_merge(
$browsercache_dependencies,
array(
'browsercache.html.compression',
'browsercache.html.expires',
'browsercache.html.lifetime',
'browsercache.html.cache.control',
'browsercache.html.cache.policy',
'browsercache.html.etag',
'browsercache.html.w3tc'
) );
'browsercache.html.w3tc',
)
);
}
if ( $new_config->get_boolean( 'browsercache.other.replace' ) ) {
$browsercache_dependencies = array_merge( $browsercache_dependencies, array(
$browsercache_dependencies = array_merge(
$browsercache_dependencies,
array(
'browsercache.other.compression',
'browsercache.other.expires',
'browsercache.other.lifetime',
'browsercache.other.cache.control',
'browsercache.other.cache.policy',
'browsercache.other.etag',
'browsercache.other.w3tc'
) );
'browsercache.other.w3tc',
)
);
}
$old_bc_dependencies_values = array();
@ -209,7 +265,9 @@ class Util_Admin {
$cache_flush = Dispatcher::component( 'CacheFlush' );
if ( $cache_flush->flushable_posts() ) {
$pgcache_dependencies = array_merge( $browsercache_dependencies, array(
$pgcache_dependencies = array_merge(
$browsercache_dependencies,
array(
'pgcache.debug',
'pgcache.cache.query',
'pgcache.cache.home',
@ -236,27 +294,25 @@ class Util_Admin {
'objectcache.enabled',
'minify.enabled',
'mobile.enabled',
'referrer.enabled'
) );
'referrer.enabled',
)
);
if ( $new_config->get_boolean( 'pgcache.mirrors.enabled' ) ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array(
'pgcache.mirrors.home_urls'
) );
$pgcache_dependencies = array_merge( $pgcache_dependencies, array( 'pgcache.mirrors.home_urls' ) );
}
if ( $new_config->get_boolean( 'dbcache.enabled' ) ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array(
'dbcache.debug'
) );
$pgcache_dependencies = array_merge( $pgcache_dependencies, array( 'dbcache.debug' ) );
}
if ( $new_config->get_boolean( 'objectcache.enabled' ) ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array(
'objectcache.debug'
) );
if ( $new_config->getf_boolean( 'objectcache.enabled' ) ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array( 'objectcache.debug' ) );
}
if ( $new_config->get_boolean( 'minify.enabled' ) ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array(
$pgcache_dependencies = array_merge(
$pgcache_dependencies,
array(
'minify.auto',
'minify.debug',
'minify.rewrite',
@ -277,17 +333,16 @@ class Util_Admin {
'minify.htmltidy.options.wrap',
'minify.reject.logged',
'minify.reject.ua',
'minify.reject.uri'
) );
'minify.reject.uri',
)
);
}
/**
*
*
* @var W3_ModuleStatus $modules
*/
$modules = Dispatcher::component( 'ModuleStatus' );
if ( $modules->is_running( 'cdn' ) ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array(
$pgcache_dependencies = array_merge(
$pgcache_dependencies,
array(
'cdn.enabled',
'cdn.debug',
'cdn.engine',
@ -323,31 +378,29 @@ class Util_Admin {
'cdn.reject.roles',
'cdn.reject.ua',
'cdn.reject.uri',
'cdn.reject.files'
) );
} elseif ( $old_config->get_boolean( 'cdn.enabled' ) && !$new_config->get_boolean( 'cdn.enabled' ) ) {
'cdn.reject.files',
)
);
} elseif ( $old_config->get_boolean( 'cdn.enabled' ) && ! $new_config->get_boolean( 'cdn.enabled' ) ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array( 'cdn.enabled' ) );
}
if ( $new_config->get_boolean( 'mobile.enabled' ) ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array(
'mobile.rgroups'
) );
$pgcache_dependencies = array_merge( $pgcache_dependencies, array( 'mobile.rgroups' ) );
}
if ( $new_config->get_boolean( 'referrer.enabled' ) ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array(
'referrer.rgroups'
) );
$pgcache_dependencies = array_merge( $pgcache_dependencies, array( 'referrer.rgroups' ) );
}
if ( $new_config->get_boolean( 'browsercache.enabled' ) &&
$new_config->get_string( 'pgcache.engine' ) == 'file_generic' ) {
$pgcache_dependencies = array_merge( $pgcache_dependencies, array(
if ( $new_config->get_boolean( 'browsercache.enabled' ) && $new_config->get_string( 'pgcache.engine' ) === 'file_generic' ) {
$pgcache_dependencies = array_merge(
$pgcache_dependencies,
array(
'browsercache.html.last_modified',
'browsercache.other.last_modified'
) );
'browsercache.other.last_modified',
)
);
}
$old_pgcache_dependencies_values = array();
@ -368,17 +421,22 @@ class Util_Admin {
* Show need empty minify notification
*/
if ( $current_config->get_boolean( 'minify.enabled' ) && $new_config->get_boolean( 'minify.enabled' ) && ( ( $new_config->get_boolean( 'minify.css.enable' ) && ( $new_config->get_boolean( 'minify.auto' ) || count( $new_config->get_array( 'minify.css.groups' ) ) ) ) || ( $new_config->get_boolean( 'minify.js.enable' ) && ( $new_config->get_boolean( 'minify.auto' ) || count( $new_config->get_array( 'minify.js.groups' ) ) ) ) ) ) {
$minify_dependencies = array_merge( $browsercache_dependencies, array(
$minify_dependencies = array_merge(
$browsercache_dependencies,
array(
'minify.auto',
'minify.debug',
'minify.options',
'minify.symlinks',
'minify.css.enable',
'minify.js.enable'
) );
'minify.js.enable',
)
);
if ( $new_config->get_boolean( 'minify.css.enable' ) && ( $new_config->get_boolean( 'minify.auto' ) || count( $new_config->get_array( 'minify.css.groups' ) ) ) ) {
$minify_dependencies = array_merge( $minify_dependencies, array(
$minify_dependencies = array_merge(
$minify_dependencies,
array(
'minify.css.engine',
'minify.css.method',
'minify.css.strip.comments',
@ -404,12 +462,15 @@ class Util_Admin {
'minify.csstidy.options.css_level',
'minify.csstidy.options.preserve_css',
'minify.csstidy.options.timestamp',
'minify.csstidy.options.template'
) );
'minify.csstidy.options.template',
)
);
}
if ( $new_config->get_boolean( 'minify.js.enable' ) && ( $new_config->get_boolean( 'minify.auto' ) || count( $new_config->get_array( 'minify.js.groups' ) ) ) ) {
$minify_dependencies = array_merge( $minify_dependencies, array(
$minify_dependencies = array_merge(
$minify_dependencies,
array(
'minify.js.engine',
'minify.js.method',
'minify.js.combine.header',
@ -427,21 +488,15 @@ class Util_Admin {
'minify.ccjs.path.java',
'minify.ccjs.path.jar',
'minify.ccjs.options.compilation_level',
'minify.ccjs.options.formatting'
) );
'minify.ccjs.options.formatting',
)
);
}
/**
*
*
* @var W3_ModuleStatus $modules
*/
$modules = Dispatcher::component( 'ModuleStatus' );
if ( $modules->is_running( 'cdn' ) ) {
$minify_dependencies = array_merge( $minify_dependencies, array(
'cdn.engine', 'cdn.enabled'
) );
} elseif ( $old_config->get_boolean( 'cdn.enabled' ) && !$new_config->get_boolean( 'cdn.enabled' ) ) {
$minify_dependencies = array_merge( $minify_dependencies, array( 'cdn.engine', 'cdn.enabled' ) );
} elseif ( $old_config->get_boolean( 'cdn.enabled' ) && ! $new_config->get_boolean( 'cdn.enabled' ) ) {
$minify_dependencies = array_merge( $minify_dependencies, array( 'cdn.enabled' ) );
}
@ -459,11 +514,11 @@ class Util_Admin {
}
}
if ( $new_config->get_boolean( 'cdn.enabled' ) && !Cdn_Util::is_engine_mirror( $new_config->get_string( 'cdn.engine' ) ) ) {
if ( $new_config->get_boolean( 'cdn.enabled' ) && ! Cdn_Util::is_engine_mirror( $new_config->get_string( 'cdn.engine' ) ) ) {
/**
* Show notification when CDN enabled
*/
if ( !$old_config->get_boolean( 'cdn.enabled' ) ) {
if ( ! $old_config->get_boolean( 'cdn.enabled' ) ) {
$state = Dispatcher::config_state();
$state->set( 'cdn.show_note_cdn_upload', true );
$state->save();
@ -472,9 +527,7 @@ class Util_Admin {
/**
* Show notification when Browser Cache settings changes
*/
$cdn_dependencies = array(
'browsercache.enabled'
);
$cdn_dependencies = array( 'browsercache.enabled' );
if ( $new_config->get_boolean( 'cdn.enabled' ) ) {
$cdn_dependencies = array(
@ -498,7 +551,7 @@ class Util_Admin {
'browsercache.other.cache.control',
'browsercache.other.cache.policy',
'browsercache.other.etag',
'browsercache.other.w3tc'
'browsercache.other.w3tc',
);
}
@ -510,7 +563,7 @@ class Util_Admin {
$new_cdn_dependencies_values[] = $new_config->get( $cdn_dependency );
}
if ( serialize( $old_cdn_dependencies_values ) != serialize( $new_cdn_dependencies_values ) ) {
if ( serialize( $old_cdn_dependencies_values ) !== serialize( $new_cdn_dependencies_values ) ) {
$state = Dispatcher::config_state();
$state->set( 'cdn.show_note_cdn_reupload', true );
$state->save();
@ -520,10 +573,10 @@ class Util_Admin {
/**
* Show need empty object cache notification
*/
if ( $current_config->get_boolean( 'objectcache.enabled' ) ) {
if ( $current_config->getf_boolean( 'objectcache.enabled' ) ) {
$objectcache_dependencies = array(
'objectcache.groups.global',
'objectcache.groups.nonpersistent'
'objectcache.groups.nonpersistent',
);
$old_objectcache_dependencies_values = array();
@ -548,22 +601,21 @@ class Util_Admin {
try {
$new_config->save();
} catch ( \Exception $ex ) {
// try to fix environment, it potentially can be fixed silently
// dont show error here, it will be called again later
// in admin_notices
// try to fix environment, it potentially can be fixed silently don't show error here, it will be called again later in admin_notices.
try {
$environment = Dispatcher::component( 'Root_Environment' );
$environment->fix_in_wpadmin( $new_config );
} catch ( \Exception $ex ) {
} catch ( \Exception $ex ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
// Do nothing.
}
// retry save process and complain now on failure
// Retry save process and complain now on failure.
try {
$new_config->save();
} catch ( \Exception $ex ) {
throw new \Exception(
'<strong>Can\'t change configuration</strong>: ' .
$ex->getMessage() );
'<strong>Can\'t change configuration</strong>: ' . $ex->getMessage()
);
}
}
@ -584,7 +636,7 @@ class Util_Admin {
w3tc_dbcache_flush();
}
if ( $old_config->get_string( 'objectcache.engine' ) != $new_config->get_string( 'objectcache.engine' ) || $old_config->get_string( 'objectcache.enabled' ) != $new_config->get_string( 'objectcache.enabled' ) ) {
if ( $old_config->get_string( 'objectcache.engine' ) != $new_config->get_string( 'objectcache.engine' ) || $old_config->getf_boolean( 'objectcache.enabled' ) !== $new_config->getf_boolean( 'objectcache.enabled' ) ) {
w3tc_objectcache_flush();
}
@ -620,8 +672,8 @@ class Util_Admin {
* Auto upload browsercache files to CDN
*/
if ( $new_config->get_boolean( 'cdn.enabled' ) && $new_config->get_string( 'cdn.engine' ) == 'ftp' ) {
Util_Admin::cdn_delete_browsercache( $current_config );
Util_Admin::cdn_upload_browsercache( $current_config );
self::cdn_delete_browsercache( $current_config );
self::cdn_upload_browsercache( $current_config );
}
return true;
@ -630,11 +682,13 @@ class Util_Admin {
/**
* Uploads minify files to CDN
* Uploads minify files to CDN.
*
* @static
*
* @return void
*/
static public function cdn_upload_minify() {
public static function cdn_upload_minify() {
$w3_plugin_cdn = Dispatcher::component( 'Cdn_Plugin' );
$common = Dispatcher::component( 'Cdn_Core' );
@ -644,22 +698,27 @@ class Util_Admin {
$results = array();
foreach ( $files as $file ) {
$upload[] = $common->build_file_descriptor( $common->docroot_filename_to_absolute_path( $file ),
$common->uri_to_cdn_uri( $common->docroot_filename_to_uri( $file ) ) );
$upload[] = $common->build_file_descriptor(
$common->docroot_filename_to_absolute_path( $file ),
$common->uri_to_cdn_uri( $common->docroot_filename_to_uri( $file ) )
);
}
$common->upload( $upload, true, $results );
}
/**
* Uploads Browser Cache .htaccess to FTP
* Uploads Browser Cache .htaccess to FTP.
*
* @var Config $config
* @static
*
* @param Config $config Config.
* @return void
*/
static public function cdn_upload_browsercache( $config ) {
public static function cdn_upload_browsercache( $config ) {
$common = Dispatcher::component( 'Cdn_Core' );
$Cdn_Core_Admin = Dispatcher::component( 'Cdn_Core_Admin' );
Dispatcher::component( 'Cdn_Core_Admin' );
$ce = Dispatcher::component( 'Cdn_Environment' );
$rules = $ce->rules_generate_for_ftp( $config );
@ -681,59 +740,84 @@ class Util_Admin {
}
/**
* Deletes Browser Cache .htaccess from FTP
* Deletes Browser Cache .htaccess from FTP.
*
* @static
*
* @return void
*/
static public function cdn_delete_browsercache() {
$common = Dispatcher::component( 'Cdn_Core' );
public static function cdn_delete_browsercache() {
$common = Dispatcher::component( 'Cdn_Core' );
$cdn_path = Util_Rule::get_cdn_rules_path();
$tmp_path = W3TC_CACHE_TMP_DIR . '/' . $cdn_path;
$results = array();
$delete = array(
$common->build_file_descriptor( $tmp_path, $cdn_path )
);
$results = array();
$delete = array( $common->build_file_descriptor( $tmp_path, $cdn_path ) );
$common->delete( $delete, false, $results );
}
/**
* Returns cookie domain
* Returns cookie domain.
*
* @static
*
* @return string
*/
static public function get_cookie_domain() {
public static function get_cookie_domain() {
$site_url = get_option( 'siteurl' );
$parse_url = @parse_url( $site_url );
if ( $parse_url && !empty( $parse_url['host'] ) ) {
if ( $parse_url && ! empty( $parse_url['host'] ) ) {
return $parse_url['host'];
}
return isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
}
/*
* Returns current w3tc admin page
/**
* Returns current w3tc admin page.
*
* @static
*
* @return string
*/
static public function get_current_page() {
public static function get_current_page() {
$page = Util_Request::get_string( 'page' );
if ( substr( $page, 0, 5 ) == 'w3tc_' )
if ( substr( $page, 0, 5 ) === 'w3tc_' ) {
return $page;
}
return 'w3tc_dashboard';
}
/**
* Check if current page is a W3TC admin page
* Returns current w3tc extension id.
*
* @static
*
* @return string
*/
public static function get_current_extension() {
$page = Util_Request::get_string( 'page' );
$extension = Util_Request::get_string( 'extension' );
if ( substr( $page, 0, 5 ) === 'w3tc_' && ! empty( $extension ) ) {
return $extension;
}
return '';
}
/**
* Check if current page is a W3TC admin page.
*
* @static
*
* @return bool
*/
static public function is_w3tc_admin_page() {
public static function is_w3tc_admin_page() {
$page_val = Util_Request::get_string( 'page' );
if ( ! empty( $page_val ) && 'w3tc_' === substr( $page_val, 0, 5 ) ) {
return true;
@ -749,11 +833,13 @@ class Util_Admin {
/**
* Returns current WordPress page
* Returns current WordPress page.
*
* @static
*
* @return string
*/
static public function get_current_wp_page() {
public static function get_current_wp_page() {
return Util_Request::get_string( 'page' );
}
}

View File

@ -49,7 +49,8 @@ class Util_AttachToActions {
// multisite.
if ( Util_Environment::is_wpmu() ) {
add_action( 'delete_blog', array( $o, 'on_change' ), 0 );
add_action( 'wp_uninitialize_site', array( $o, 'on_change' ), 0 );
add_action( 'wp_update_site', array( $o, 'on_change' ), 0 );
}
}

View File

@ -173,8 +173,13 @@ class Util_Environment {
*
* @return bool
*/
public static function is_dbcluster() {
if ( ! defined( 'W3TC_PRO' ) || ! W3TC_PRO ) {
public static function is_dbcluster( $config = null ) {
if ( is_null( $config ) ) {
// fallback for compatibility with older wp-content/db.php
$config = \W3TC\Dispatcher::config();
}
if ( !self::is_w3tc_pro( $config ) ) {
return false;
}
@ -1555,4 +1560,56 @@ class Util_Environment {
self::$is_using_master_config = null;
}
/**
* Removes blank lines, trim values, removes duplicates, and sorts array.
*
* @since 2.4.3
*
* @param array $values Array of values.
*
* @return array
*/
public static function clean_array( $values ) {
if ( ! empty( $values ) && is_array( $values ) ) {
$values = array_unique(
array_filter(
array_map(
'trim',
$values
),
'strlen'
)
);
sort( $values );
}
return $values;
}
/**
* Parses textarea setting value from string to array.
*
* @since 2.4.3
*
* @param string $value Value.
*
* @return array
*/
public static function textarea_to_array( $value ) {
$values_array = array();
if ( ! empty( $value ) ) {
$values_array = self::clean_array(
preg_split(
'/\R/',
$value,
0,
PREG_SPLIT_NO_EMPTY
)
);
}
return $values_array;
}
}

Some files were not shown because too many files have changed in this diff Show More