• Resolved Arnold Willems

    (@arnoldwillems)


    Hi,

    Would you be able to add an option to disable the JSON REST API same as we can disable XML-RPC

    Thanks in advance

Viewing 1 replies (of 1 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @arnoldwillems

    I hope you are doing well.

    I am afraid we don’t have this option, I found this was requested in the past by our developers and I added this ticket as an extra request letting our developers know you are also looking for it.

    However, to disable the Rest API you can use this filter:

    <?php
     add_filter( 'rest_authentication_errors', 'wp_snippet_disable_rest_api' );
       function wp_snippet_disable_rest_api( $access ) {
          return new WP_Error( 'rest_disabled', __('The WordPress REST API has been disabled.'), array( 'status' => rest_authorization_required_code()));
       }
    ?>

    Since Rest API is used by Gutenberg I suggest adding some extra validation to prevent issues with WP editor or other plugins.

    https://gist.github.com/danielbachhuber/8f92af4c6a8db784771c

    You can apply it as a mu-plugin https://wpmudev.com/blog/wordpress-mu-plugins/

    Best Regards
    Patrick Freitas

Viewing 1 replies (of 1 total)

The topic ‘Disable JSON REST API’ is closed to new replies.