From 0b025952f5c4a54a3a29bd009e9eea7f2e0d2e38 Mon Sep 17 00:00:00 2001 From: Micah Wood Date: Fri, 27 Oct 2023 16:56:05 -0400 Subject: [PATCH] Remove old mojo performance code (needs to be done across all brands) --- 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 8d3e6520c..605708cb3 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -199,7 +199,6 @@ function () { require BLUEHOST_PLUGIN_DIR . '/inc/jetpack.php'; require BLUEHOST_PLUGIN_DIR . '/inc/LoginRedirect.php'; require BLUEHOST_PLUGIN_DIR . '/inc/partners.php'; -require BLUEHOST_PLUGIN_DIR . '/inc/performance.php'; require BLUEHOST_PLUGIN_DIR . '/inc/RestApi/CachingController.php'; require BLUEHOST_PLUGIN_DIR . '/inc/RestApi/SettingsController.php'; require BLUEHOST_PLUGIN_DIR . '/inc/RestApi/rest-api.php'; diff --git a/inc/performance.php b/inc/performance.php deleted file mode 100644 index a3e218210..000000000 --- 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; -} -