Skip to content

Commit

Permalink
Fix Disable index Route from WordPress rest api #7
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrshaddarzi committed Feb 20, 2020
1 parent 1b5b3ec commit 2a60b7b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Package/Arguments/Rest_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function remove_all_default_route()
$t = "# Remove All WordPress Default Rest API Route\n";
$t .= "remove_action('rest_api_init', 'create_initial_rest_routes', 99);" . "\n"; // Remove WP namespace and default route
$t .= "remove_action('rest_api_init', 'wp_oembed_register_route');" . "\n"; // Remove Oembed namespace and route
$t .= 'add_filter( \'rest_endpoints\', function ( $endpoints ) { return $endpoints = array(); });' . "\n"; // Remove "/" route from Rest API
$t .= self::disable_custom_route(array("/")); // Remove "/" route from REST API
return $t;
}

Expand Down Expand Up @@ -75,7 +75,8 @@ public static function complete_disable_rest_api()
*
* add_filter( 'rest_authentication_errors', function( $access ){ return new WP_Error( 'rest_cannot_access', 'Bye', array( 'status' => 403 ) ); } );
*/
$t = self::remove_all_default_route();
$t = "# Disable all WordPress REST API Routes" . "\n";
$t .= 'add_filter( \'rest_endpoints\', function ( $endpoints ) { return $endpoints = array(); });' . "\n";
$t .= "# Remove Action in WordPress Theme" . "\n";
$t .= 'remove_action( \'wp_head\', \'rest_output_link_wp_head\', \'10\' );' . "\n";
$t .= 'remove_action( \'wp_head\', \'wp_oembed_add_discovery_links\' );' . "\n";
Expand All @@ -92,7 +93,7 @@ public static function complete_disable_rest_api()
*/
public static function disable_custom_route($array)
{
$t = "# Disable Custom Route From WordPress Rest API\n";
$t = "# Disable Custom Route From WordPress REST API\n";
$t .= 'add_filter(\'rest_endpoints\', function($endpoints) {' . "\n";
foreach ($array as $route) {
//Sanitize Route
Expand Down

0 comments on commit 2a60b7b

Please sign in to comment.