Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion wordpress-hack-without-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ function restrict_page() {
* Disable Editing in Dashboard (add to wp-config.php)
*/
define( 'DISALLOW_FILE_EDIT', true );

add_filter( 'rest_authentication_errors', 'rest_authentication_errors');

/**
* Disable REST API for not users that are not logged in.
*/
function rest_authentication_errors( $result ) {
if ( ! empty( $result ) ) {
return $result;
}
if ( ! is_user_logged_in() ) {
return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) );
}
return $result;
}

?>

/*=== CSS ===*/
Expand All @@ -152,4 +168,4 @@ function restrict_page() {

<Files *.php>
deny from all
</Files>
</Files>