Merge pull request #473 from mainwp/mainwp-child-5.4.0.12-prepared

Mainwp child 5.4.0.12 prepared
This commit is contained in:
Thang Hoang Van 2025-08-12 22:27:33 +07:00 committed by GitHub
commit 491ad74103
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 1095 additions and 335 deletions

File diff suppressed because it is too large Load diff

View file

@ -147,7 +147,7 @@ class MainWP_Child_Cache_Purge { //phpcs:ignore -- NOSONAR - multi methods.
$cache_plugin_solution = 'CDN Cache Plugin';
}
if ( empty( $cache_plugin_solution ) && is_plugin_active( 'wp-optimize/wp-optimize.php' ) && class_exists( $this->wp_optimize_class ) ) {
if ( empty( $cache_plugin_solution ) && ( is_plugin_active( 'wp-optimize/wp-optimize.php' ) || is_plugin_active( 'wp-optimize-premium/wp-optimize.php' ) ) && class_exists( $this->wp_optimize_class ) ) {
$cache = \WP_Optimize()->get_page_cache();
if ( $cache->is_enabled() === true ) {
$cache_plugin_solution = 'WP Optimize';
@ -178,6 +178,7 @@ class MainWP_Child_Cache_Purge { //phpcs:ignore -- NOSONAR - multi methods.
'swis-performance/swis-performance.php' => 'Swis Performance',
'pressable-cache-management/pressable-cache-management.php' => 'Pressable Cache Management',
'runcloud-hub/runcloud-hub.php' => 'RunCloud Hub',
'clsop/clsop.php' => 'AccelerateWP',
);
if ( empty( $cache_plugin_solution ) ) {
@ -226,6 +227,9 @@ class MainWP_Child_Cache_Purge { //phpcs:ignore -- NOSONAR - multi methods.
case 'WP Rocket':
$information = $this->wprocket_auto_cache_purge();
break;
case 'AccelerateWP':
$information = $this->acceleratewp_auto_purge_cache(); // The plugin is a clone of WP-Rocket, with identical functionality—only the name has been changed.
break;
case 'Breeze':
$information = $this->breeze_auto_purge_cache();
break;
@ -713,6 +717,7 @@ class MainWP_Child_Cache_Purge { //phpcs:ignore -- NOSONAR - multi methods.
}
}
/**
* Purge Nginx Helper cache.
*
@ -1065,13 +1070,7 @@ class MainWP_Child_Cache_Purge { //phpcs:ignore -- NOSONAR - multi methods.
*/
public function wprocket_auto_cache_purge() {
// Purge Cache if action is set to "1".
$do_purge = get_option( 'mainwp_child_auto_purge_cache', false );
$purge_result = array();
if ( 1 === (int) $do_purge ) {
$purge_result = MainWP_Child_WP_Rocket::instance()->preload_purge_cache_all();
}
$purge_result = MainWP_Child_WP_Rocket::instance()->preload_purge_cache_all();
// Record results & return response.
if ( 'SUCCESS' === $purge_result['result'] ) {
@ -1092,6 +1091,34 @@ class MainWP_Child_Cache_Purge { //phpcs:ignore -- NOSONAR - multi methods.
}
}
/**
* Purge WP-Rocket cache.
*
* @return array Purge results array.
*/
public function acceleratewp_auto_purge_cache() {
$purge_result = MainWP_Child_WP_Rocket::instance()->preload_purge_cache_all();
// Record results & return response.
if ( 'SUCCESS' === $purge_result['result'] ) {
// Save last purge time to database on success.
update_option( 'mainwp_cache_control_last_purged', time() );
// Return success message.
$success_message = 'AccelerateWP => Cache auto cleared on: (' . current_time( 'mysql' ) . ')';
return $this->purge_result( $success_message, 'SUCCESS' );
} else {
// Return error message.
$error_message = 'AccelerateWP => There was an issue purging your cache.';
return $this->purge_result( $error_message, 'ERROR' );
}
}
/**
* Record last Purge.
*

View file

@ -250,7 +250,7 @@ class MainWP_Child_Callable { //phpcs:ignore -- NOSONAR - multi methods.
* @uses \MainWP\Child\MainWP_Child_Stats::get_site_stats()
*/
public function get_site_stats() {
MainWP_Child_Stats::get_instance()->get_site_stats();
MainWP_Child_Stats::get_instance()->get_site_stats( array(), true, array( 'site_stats' => true ) );
}
/**

View file

@ -133,6 +133,7 @@ class MainWP_Child_Stats { //phpcs:ignore -- NOSONAR - multi methods.
*
* @param array $information Holder for return array.
* @param bool $exit_done Whether or not to exit the method. Default: true.
* @param array $params Other params.
*
* @return array $information Child Site Stats.
*
@ -178,7 +179,11 @@ class MainWP_Child_Stats { //phpcs:ignore -- NOSONAR - multi methods.
* @uses \MainWP\Child\MainWP_Child_Users::get_all_users_int()
* @uses \MainWP\Child\MainWP_Connect::get_max_history()
*/
public function get_site_stats( $information = array(), $exit_done = true ) { //phpcs:ignore -- NOSONAR - complex.
public function get_site_stats( $information = array(), $exit_done = true, $params = array() ) { //phpcs:ignore -- NOSONAR - complex.
if ( ! is_array( $params ) ) {
$params = array();
}
if ( $exit_done ) {
$this->update_external_settings();
@ -289,7 +294,7 @@ class MainWP_Child_Stats { //phpcs:ignore -- NOSONAR - multi methods.
$information['extauth'] = ( is_array( $auths ) && isset( $auths[ $max_his ] ) ? $auths[ $max_his ] : null );
if ( $this->is_sync_data( 'plugins' ) ) {
$information['plugins'] = $this->get_all_plugins_int( false );
$information['plugins'] = $this->get_all_plugins_int( false, '', '', false, false, array( 'site_stats' => ! empty( $params['site_stats'] ) ? true : false ) );
}
if ( $this->is_sync_data( 'themes' ) ) {
@ -1283,14 +1288,21 @@ class MainWP_Child_Stats { //phpcs:ignore -- NOSONAR - multi methods.
* @param string $status Active or Inactive filed.
* @param boolean $get_un_criteria Get criteria or un-criteria items.
* @param boolean $check_inactive_only To check inactive plugins only.
* @param array $params Other params.
*
* @return array|bool $rslt Returned results.
*/
public function get_all_plugins_int( $filter, $keyword = '', $status = '', $get_un_criteria = false, $check_inactive_only = false ) { //phpcs:ignore -- NOSONAR - complex.
public function get_all_plugins_int( $filter, $keyword = '', $status = '', $get_un_criteria = false, $check_inactive_only = false, $params = array() ) { //phpcs:ignore -- NOSONAR - complex.
if ( ! function_exists( 'get_plugins' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php'; // NOSONAR -- WP compatible.
}
if ( ! is_array( $params ) ) {
$params = array();
}
$is_site_stats = ! empty( $params['site_stats'] );
/**
* MainWP Child instance.
*
@ -1310,7 +1322,12 @@ class MainWP_Child_Stats { //phpcs:ignore -- NOSONAR - multi methods.
$out['description'] = $plugin['Description'];
$out['version'] = $plugin['Version'];
$out['active'] = is_plugin_active( $pluginslug ) ? 1 : 0;
$rslt[] = $out;
if ( $is_site_stats ) {
$out = apply_filters( 'mainwp_child_stats_get_plugin_info', $out, $pluginslug );
}
$rslt[] = $out;
if ( 0 === $out['active'] ) {
$found_inactive = true;

View file

@ -161,7 +161,7 @@ class MainWP_Child_Updates { //phpcs:ignore -- NOSONAR - multi methods.
*
* @params $information.
*/
MainWP_Child_Cache_Purge::instance()->auto_purge_cache( $information );
MainWP_Child_Cache_Purge::instance()->auto_purge_cache();
if ( ! $plugin_update ) {
// Save Status results.
@ -1190,7 +1190,7 @@ class MainWP_Child_Updates { //phpcs:ignore -- NOSONAR - multi methods.
*
* @params $information.
*/
MainWP_Child_Cache_Purge::instance()->auto_purge_cache( $information );
MainWP_Child_Cache_Purge::instance()->auto_purge_cache();
// Send last purged time stamp to MainWP Dashboard.
$information['mainwp_cache_control_last_purged'] = get_option( 'mainwp_cache_control_last_purged', 0 );

View file

@ -30,7 +30,7 @@ class MainWP_Child {
*
* @var string MainWP Child plugin version.
*/
public static $version = '5.4.0.11'; // NOSONAR - not IP.
public static $version = '5.4.0.12'; // NOSONAR - not IP.
/**
* Private variable containing the latest MainWP Child update version.

View file

@ -12,7 +12,7 @@
* Author: MainWP
* Author URI: https://mainwp.com
* Text Domain: mainwp-child
* Version: 5.4.0.11
* Version: 5.4.0.12
* Requires at least: 5.4
* Requires PHP: 7.4
*/

View file

@ -7,7 +7,7 @@ Plugin URI: https://mainwp.com
Requires at least: 6.2
Tested up to: 6.8.1
Requires PHP: 7.4
Stable tag: 5.4.0.11
Stable tag: 5.4.0.12
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@ -111,6 +111,11 @@ We have an extensive FAQ with more questions and answers [here](https://mainwp.c
== Changelog ==
= 5.4.0.12 - Maintenance Release - 8-12-2025 =
* Fixed: Restored compatibility with BackWPup version 5 and later.
* Added: Support for the AccelerateWP plugin in the Cache Control system.
* Updated: Support for the WP-Optimize Premium plugin in the Cache Control system.
= 5.4.0.11 - Maintenance Release - 7-8-2025 =