Created
January 31, 2018 09:27
-
-
Save walihassanjafferi/4f7e27eb7edcfd0054abbe4c5e46ced1 to your computer and use it in GitHub Desktop.
MMN
This file contains 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
/* | |
* Posts CSV API REWRITE | |
*/ | |
add_action( 'init', 'wpse9870_init_internal' ); | |
function wpse9870_init_internal() | |
{ | |
add_rewrite_rule( 'exportcsv.php$', 'index.php/exportcsv?api_key=123', 'top' ); | |
} | |
add_filter( 'query_vars', 'wpse9870_query_vars' ); | |
function wpse9870_query_vars( $query_vars ) | |
{ | |
$query_vars[] = 'api_key'; | |
return $query_vars; | |
} | |
add_action( 'parse_request', 'wpse9870_parse_request' ); | |
function wpse9870_parse_request( &$wp ) | |
{ | |
if ( array_key_exists( 'api_key', $wp->query_vars ) && ($wp->query_vars['api_key'] == '123') ){ | |
require_once( get_stylesheet_directory_uri() . '/exportcsv.php' ); | |
exit(); | |
} | |
return; | |
} | |
function bavotasan_word_count($post) { | |
return sprintf( | |
__( '%s words', 'text-domain' ), | |
str_word_count( strip_tags( get_post_field( 'post_content', $post->ID ) ) ) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment