Skip to content

Commit

Permalink
Fix for conflict with WP REST API v2
Browse files Browse the repository at this point in the history
rest-api hooks into parse_request at the default priority (10); when
authorizer hooked into parse_request at priority 1, the removal of
authorizer’s action hook somehow clobbered the processing of rest-api’s
hook. This commit moves authorizer’s parse_request hook to priority 20,
so it fires after rest-api. Note that authorizer access permissions
will still apply to REST endpoints; however, if access is denied, html
will be returned as a response to the REST call instead of JSON.
https://wordpress.org/plugins/rest-api/
  • Loading branch information
figureone committed Jan 13, 2016
1 parent c90d1a1 commit 8527f06
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions authorizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function __construct() {
add_action( 'login_form', array( $this, 'login_form_add_external_service_links' ) );

// Verify current user has access to page they are visiting
add_action( 'parse_request', array( $this, 'restrict_access' ), 1 );
add_action( 'parse_request', array( $this, 'restrict_access' ), 20 );

// ajax save options from dashboard widget
add_action( 'wp_ajax_update_auth_user', array( $this, 'ajax_update_auth_user' ) );
Expand Down Expand Up @@ -1027,7 +1027,7 @@ public function custom_logout() {
* @return void
*/
public function restrict_access( $wp ) {
remove_action( 'parse_request', array( $this, 'restrict_access' ), 1 ); // only need it the first time
remove_action( 'parse_request', array( $this, 'restrict_access' ), 20 ); // only need it the first time

// Grab plugin settings.
$auth_settings = $this->get_plugin_options( 'single admin', 'allow override' );
Expand Down

0 comments on commit 8527f06

Please sign in to comment.