Last active
August 29, 2015 14:25
-
-
Save petenelson/d0cd422910835f779d44 to your computer and use it in GitHub Desktop.
WordPress REST API: Disallow non-SSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'rest_pre_dispatch', 'rest_api_disallow_non_ssl', 10, 3 ); | |
function rest_api_disallow_non_ssl( $response, $server, $request ) { | |
if ( ! is_ssl() ) { | |
$response = new WP_Error( 'rest_forbidden', __( "SSL is required to access the REST API" ), array( 'status' => 403 ) ); | |
} | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment