Created
March 29, 2013 08:32
-
-
Save ericrallen/5269488 to your computer and use it in GitHub Desktop.
Revisions
-
Eric Allen created this gist
Mar 29, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ <?php /*-------------------------------------------------------------------------- Better AJAX for WordPress inspired by: http:wordpress.stackexchange.com/questions/28342/is-there-a-way-to-use-the-wordpress-users-but-without-loading-the-entire-wordpre#answer-45011 --------------------------------------------------------------------------*/ //mimic the actuall admin-ajax define('DOING_AJAX', true); if(!isset($_POST['action'])) { die('1'); } else { ini_set('html_errors', 0); define('SHORTINIT', true); //Typical headers header('Content-Type: text/html'); //Disable caching header('Cache-Control: no-cache'); header('Pragma: no-cache'); require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php'); // Load most of WordPress. require_once( ABSPATH . WPINC .'/plugin.php'); require_once(ABSPATH . WPINC . '/l10n.php'); require_once( ABSPATH . WPINC . '/class-wp-walker.php' ); require_once( ABSPATH . WPINC . '/formatting.php' ); require_once( ABSPATH . WPINC . '/capabilities.php' ); require_once( ABSPATH . WPINC . '/query.php' ); require_once( ABSPATH . WPINC . '/theme.php' ); require_once( ABSPATH . WPINC . '/user.php' ); require_once( ABSPATH . WPINC . '/meta.php' ); require_once( ABSPATH . WPINC . '/general-template.php' ); require_once( ABSPATH . WPINC . '/link-template.php' ); require_once( ABSPATH . WPINC . '/post.php' ); require_once( ABSPATH . WPINC . '/comment.php' ); require_once( ABSPATH . WPINC . '/rewrite.php' ); require_once( ABSPATH . WPINC . '/kses.php' ); require_once( ABSPATH . WPINC . '/cron.php' ); require_once( ABSPATH . WPINC . '/script-loader.php' ); require_once( ABSPATH . WPINC . '/taxonomy.php' ); require_once( ABSPATH . WPINC . '/shortcodes.php' ); require_once( ABSPATH . WPINC . '/media.php' ); require_once( ABSPATH . WPINC . '/http.php' ); require_once( ABSPATH . WPINC . '/class-http.php' ); require_once( ABSPATH . WPINC . '/widgets.php' ); require_once( ABSPATH . WPINC . '/nav-menu.php' ); wp_plugin_directory_constants(); foreach ( wp_get_active_and_valid_plugins() as $plugin ) { include_once( $plugin ); } unset( $plugin ); //call action and exit $action = trim($_POST['action']); do_action('ia_custom_ajax_nopriv_' . $action); die('0'); }