From 1eb795a89b83a5b3afb219c394d9b4e35739cda0 Mon Sep 17 00:00:00 2001 From: Alessio Torrisi Date: Fri, 21 Mar 2025 14:14:04 +0100 Subject: [PATCH] Remove: caching controller and cacheLevel option usage, both things are now managed at module level --- bootstrap.php | 1 - inc/RestApi/CachingController.php | 71 ------------------------------ inc/RestApi/SettingsController.php | 4 -- inc/RestApi/rest-api.php | 1 - 4 files changed, 77 deletions(-) delete mode 100644 inc/RestApi/CachingController.php diff --git a/bootstrap.php b/bootstrap.php index 720da295..a47a6587 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -138,7 +138,6 @@ function () { require WEB_PLUGIN_DIR . '/inc/base.php'; require WEB_PLUGIN_DIR . '/inc/jetpack.php'; require WEB_PLUGIN_DIR . '/inc/partners.php'; -require WEB_PLUGIN_DIR . '/inc/RestApi/CachingController.php'; require WEB_PLUGIN_DIR . '/inc/RestApi/SettingsController.php'; require WEB_PLUGIN_DIR . '/inc/RestApi/rest-api.php'; require WEB_PLUGIN_DIR . '/inc/settings.php'; diff --git a/inc/RestApi/CachingController.php b/inc/RestApi/CachingController.php deleted file mode 100644 index 8212cc98..00000000 --- a/inc/RestApi/CachingController.php +++ /dev/null @@ -1,71 +0,0 @@ -namespace, - '/caching', - array( - 'methods' => \WP_REST_Server::DELETABLE, - 'callback' => array( $this, 'purge_all' ), - 'permission_callback' => array( $this, 'check_permission' ), - ) - ); - - } - - /** - * Clears the entire cache - */ - public function purge_all() { - - container()->get( 'cachePurger' )->purgeAll(); - - return array( - 'status' => 'success', - 'message' => 'Cache purged', - ); - - } - - /** - * Check permissions for route. - * - * @return bool|\WP_Error - */ - public function check_permission() { - if ( ! current_user_can( 'manage_options' ) ) { - return new \WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to access this endpoint.', 'wp-plugin-web' ), array( 'status' => rest_authorization_required_code() ) ); - } - - return true; - } - -} diff --git a/inc/RestApi/SettingsController.php b/inc/RestApi/SettingsController.php index 67bc78e6..da6dc150 100644 --- a/inc/RestApi/SettingsController.php +++ b/inc/RestApi/SettingsController.php @@ -120,9 +120,6 @@ public function update_item( $request ) { case 'emptyTrashDays': update_option( 'nfd_empty_trash_days', intval( $new_value ) ); break; - case 'cacheLevel': - update_option( 'newfold_cache_level', $new_value ); - break; case 'hasSetHomepage': update_option( 'bh_has_set_homepage', (bool) $new_value ); break; @@ -181,7 +178,6 @@ public function get_current_settings() { 'commentsPerPage' => intval( get_option( 'comments_per_page', 50 ) ), 'contentRevisions' => intval( get_option( 'nfd_wp_post_revisions', 5 ) ), 'emptyTrashDays' => intval( get_option( 'nfd_empty_trash_days', 30 ) ), - 'cacheLevel' => intval( get_option( 'newfold_cache_level', 2 ) ), 'hasSetHomepage' => (bool) get_option( 'bh_has_set_homepage', false ), 'showOnFront' => (string) get_option( 'show_on_front' ), 'pageOnFront' => (int) get_option( 'page_on_front' ), diff --git a/inc/RestApi/rest-api.php b/inc/RestApi/rest-api.php index 3bd354f1..68d382fb 100644 --- a/inc/RestApi/rest-api.php +++ b/inc/RestApi/rest-api.php @@ -13,7 +13,6 @@ function init_rest_api() { $controllers = array( - 'Web\\RestApi\\CachingController', 'Web\\RestApi\\SettingsController', );