From 525f756a89119992e378091daf7b336564b7d5db Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 5 Aug 2024 16:19:27 +0400 Subject: [PATCH] Plugin: Remove leftover 'WP_Rest_Customizer_Nonces' controller (#64221) Co-authored-by: Mamaduka Co-authored-by: youknowriad --- .../class-wp-rest-customizer-nonces.php | 74 ------------------- lib/experimental/rest-api.php | 9 --- lib/load.php | 5 -- 3 files changed, 88 deletions(-) delete mode 100644 lib/experimental/class-wp-rest-customizer-nonces.php diff --git a/lib/experimental/class-wp-rest-customizer-nonces.php b/lib/experimental/class-wp-rest-customizer-nonces.php deleted file mode 100644 index f4202a672f520..0000000000000 --- a/lib/experimental/class-wp-rest-customizer-nonces.php +++ /dev/null @@ -1,74 +0,0 @@ -namespace = '__experimental'; - $this->rest_base = 'customizer-nonces'; - } - - /** - * Registers the necessary REST API routes. - * - * @access public - */ - public function register_routes() { - register_rest_route( - $this->namespace, - '/' . $this->rest_base . '/get-save-nonce', - array( - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_save_nonce' ), - 'permission_callback' => array( $this, 'permissions_check' ), - 'args' => $this->get_collection_params(), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ) - ); - } - - /** - * Checks if a given request has access to read menu items if they have access to edit them. - * - * @return true|WP_Error True if the request has read access, WP_Error object otherwise. - */ - public function permissions_check() { - $post_type = get_post_type_object( 'nav_menu_item' ); - if ( ! current_user_can( $post_type->cap->edit_posts ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit posts in this post type.', 'gutenberg' ), array( 'status' => rest_authorization_required_code() ) ); - } - return true; - } - - /** - * Returns the nonce required to request the customizer API endpoint. - * - * @access public - */ - public function get_save_nonce() { - require_once ABSPATH . 'wp-includes/class-wp-customize-manager.php'; - $wp_customize = new WP_Customize_Manager(); - $nonce = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ); - return array( - 'success' => true, - 'nonce' => $nonce, - 'stylesheet' => $wp_customize->get_stylesheet(), - ); - } - } -} diff --git a/lib/experimental/rest-api.php b/lib/experimental/rest-api.php index 77f7d091d2655..6bb2947f88914 100644 --- a/lib/experimental/rest-api.php +++ b/lib/experimental/rest-api.php @@ -10,15 +10,6 @@ die( 'Silence is golden.' ); } -/** - * Registers the customizer nonces REST API routes. - */ -function gutenberg_register_rest_customizer_nonces() { - $customizer_nonces = new WP_Rest_Customizer_Nonces(); - $customizer_nonces->register_routes(); -} -add_action( 'rest_api_init', 'gutenberg_register_rest_customizer_nonces' ); - /** * Registers the Block editor settings REST API routes. */ diff --git a/lib/load.php b/lib/load.php index 244b6a2d9e685..5a299f3b69696 100644 --- a/lib/load.php +++ b/lib/load.php @@ -45,12 +45,7 @@ function gutenberg_is_experiment_enabled( $name ) { require_once __DIR__ . '/class-wp-rest-edit-site-export-controller-gutenberg.php'; require_once __DIR__ . '/rest-api.php'; - // Experimental. - if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) { - require_once __DIR__ . '/experimental/class-wp-rest-customizer-nonces.php'; - } require_once __DIR__ . '/experimental/rest-api.php'; - require_once __DIR__ . '/experimental/kses-allowed-html.php'; }