Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', 'wpse9870_init_external' );
- function wpse9870_init_external()
- {
- global $wp_rewrite;
- $plugin_url = plugins_url( 'api.php', __FILE__ );
- $plugin_url = substr( $plugin_url, strlen( home_url() ) + 1 );
- $wp_rewrite->add_external_rule( 'api.php$', $plugin_url );
- }
- add_action( 'init', 'wpse9870_init_internal' );
- function wpse9870_init_internal()
- {
- add_rewrite_rule( 'api.php$', 'index.php?wpse9870_api=1', 'top' );
- }
- add_filter( 'query_vars', 'wpse9870_query_vars' );
- function wpse9870_query_vars( $query_vars )
- {
- $query_vars[] = 'wpse9870_api';
- return $query_vars;
- }
- add_action( 'parse_request', 'wpse9870_parse_request' );
- function wpse9870_parse_request( &$wp )
- {
- if ( array_key_exists( 'wpse9870_api', $wp->query_vars ) ) {
- include 'api.php';
- exit();
- }
- return;
- }
- if(strpos($_SERVER['REQUEST_URI'], "index.php?wpse9870_api=1"))
- {
- header("HTTP/1.1 200 OK");
- echo "v1p";
- }
- $.ajax({
- type: 'POST',
- url: '/index.php?wpse9870_api=1',
- {"readyState":4,"responseText":"v1p","status":500,"statusText":"Internal Server Error"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement