Created
May 18, 2017 13:04
-
-
Save aiiddqd/2b4069fb50359dd31b1e4cd32dd5bd4f to your computer and use it in GitHub Desktop.
Check rules for endpoint and reset rewrite rule
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 Endpoint for URL Callback OAuth2 | |
*/ | |
class HAWP_Endpoint_Callback { | |
function __construct() { | |
add_action( 'init', array($this, 'add_endpoint') ); | |
add_action( 'wp_loaded', array($this, 'flush_rewrite_rules_hack') ); | |
} | |
function flush_rewrite_rules_hack(){ | |
$rules = get_option( 'rewrite_rules' ); | |
if ( ! isset( $rules['hawp(/(.*))?/?$'] ) ) { | |
flush_rewrite_rules( $hard = false ); | |
} | |
} | |
function add_endpoint() { | |
add_rewrite_endpoint( 'hawp', EP_ROOT ); | |
} | |
} | |
new HAWP_Endpoint_Callback; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment