From 4784d1e85b06f4fdb8cad6d84daf6c918a90ee34 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Tue, 14 Nov 2023 15:34:59 -0500 Subject: [PATCH] remove legacy performance code --- bootstrap.php | 1 - inc/performance.php | 136 -------------------------------------------- 2 files changed, 137 deletions(-) delete mode 100644 inc/performance.php diff --git a/bootstrap.php b/bootstrap.php index cd3a828..2403658 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -138,7 +138,6 @@ function() { require MOJO_PLUGIN_DIR . '/inc/base.php'; require MOJO_PLUGIN_DIR . '/inc/jetpack.php'; require MOJO_PLUGIN_DIR . '/inc/partners.php'; -require MOJO_PLUGIN_DIR . '/inc/performance.php'; require MOJO_PLUGIN_DIR . '/inc/RestApi/CachingController.php'; require MOJO_PLUGIN_DIR . '/inc/RestApi/SettingsController.php'; require MOJO_PLUGIN_DIR . '/inc/RestApi/rest-api.php'; diff --git a/inc/performance.php b/inc/performance.php deleted file mode 100644 index a88f0b4..0000000 --- a/inc/performance.php +++ /dev/null @@ -1,136 +0,0 @@ - 'success', - 'message' => 'Cache level updated successfully.', - ); - } else { - $response = array( - 'status' => 'error', - 'message' => 'Unable to update cache level.', - ); - } - } else { - $response = array( - 'status' => 'error', - 'message' => 'Unable to add cache plugin.', - ); - } - - echo wp_json_encode( $response ); - } - die; -} -add_action( 'wp_ajax_mm_cache', __NAMESPACE__ . '\\mojo_cache_toggle' ); - -/** - * Callback for adding caching MU plugins. - * - * @param string|null $type - Type of caching - * @return array - */ -function mojo_cache_add( $type = null ) { - $cache = array(); - if ( ! is_dir( WP_CONTENT_DIR . '/mu-plugins' ) ) { - mkdir( WP_CONTENT_DIR . '/mu-plugins' ); - } - switch ( $type ) { - case 'page': - $cache['code'] = 'https://raw.githubusercontent.com/bluehost/endurance-page-cache/production/endurance-page-cache.php'; - $cache['location'] = WP_CONTENT_DIR . '/mu-plugins/endurance-page-cache.php'; - break; - - case 'object': - if ( class_exists( 'memcached' ) || class_exists( 'memcache' ) ) { - $response = array( - 'status' => 'error', - 'message' => 'Object cache coming soon.', - ); - } else { - $response = array( - 'status' => 'error', - 'message' => 'Object cache not available on your hosting plan.', - ); - } - break; - } - if ( isset( $cache['code'] ) && isset( $cache['location'] ) ) { - $request = wp_remote_get( $cache['code'] ); - if ( ! is_wp_error( $request ) ) { - file_put_contents( $cache['location'], $request['body'] ); // phpcs:ignore - if ( file_exists( $cache['location'] ) ) { - $response = array( - 'status' => 'success', - 'message' => ucfirst( $type ) . ' cache added successfully.', - ); - } - } - } - - if ( ! isset( $response ) ) { - $response = array( - 'status' => 'error', - 'message' => 'Unable to add ' . ucfirst( $type ) . ' cache.', - ); - } - return $response; - -} - -/** - * Callback for removing caching MU plugins. - * - * @param string|null $type - Type of caching - * @return array - */ -function mojo_cache_remove( $type = null ) { - switch ( $type ) { - case 'browser': - // do not remove cache file since it powers both types and the CDN. - break; - case 'page': - // do not remove cache file since it powers both types and the CDN. - break; - case 'object': - $file = WP_CONTENT_DIR . '/object-cache.php'; - break; - } - if ( file_exists( $file ) ) { - if ( unlink( $file ) ) { - $response = array( - 'status' => 'success', - 'message' => ucfirst( $type ) . ' cache removed successfully.', - ); - } else { - $response = array( - 'status' => 'error', - 'message' => 'Could not remove cache file.', - ); - } - } else { - $response = array( - 'status' => 'error', - 'message' => 'Cache file does not exist.', - ); - } - return $response; -} -