[wp-trac] [WordPress Trac] #62960: Delete wp-json

WordPress Trac noreply at wordpress.org
Thu Feb 13 21:37:07 UTC 2025


#62960: Delete wp-json
--------------------------+----------------------
 Reporter:  pistoletoff   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  REST API      |     Version:
 Severity:  normal        |  Resolution:  wontfix
 Keywords:                |     Focuses:
--------------------------+----------------------
Changes (by peterwilsoncc):

 * status:  new => closed
 * version:  6.7.2 =>
 * resolution:   => wontfix
 * milestone:  Awaiting Review =>


Comment:

 There are no plans to remove the REST API from WordPress as doing so would
 break a number of core features, including the block editor.

 Only information WordPress considers public is available via the REST API
 for logged out users.

 If you wish to limit access on your site, you can do so with a plugin:

 {{{#!php
 <?php
 add_filter(
         'rest_authentication_errors',
         function ( $authorized ) {
                 if ( null !== $authorized ) {
                         // Return early if the request is already
 authenticated/blocked.
                         return $authorized;
                 }

                 if ( ! is_user_logged_in() ) {
                         // Block the request if the user is not logged in.
                         return new \WP_Error(
                                 'rest_not_logged_in',
                                 __( 'Only logged in users can access the
 REST API.', 'ticket-62960-plugin' ),
                                 array( 'status' => 401 )
                         );
                 }

                 // Continue with the request if the user is logged in.
                 return $authorized;
         }
 );

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62960#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list