3 * WordPress AJAX Process Execution.
6 * @subpackage Administration
8 * @link http://codex.wordpress.org/AJAX_in_Plugins
12 * Executing AJAX process.
16 define( 'DOING_AJAX', true );
17 define( 'WP_ADMIN', true );
19 /** Load WordPress Bootstrap */
20 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
22 /** Allow for cross-domain requests (from the frontend). */
23 send_origin_headers();
25 // Require an action parameter
26 if ( empty( $_REQUEST['action'] ) )
29 /** Load WordPress Administration APIs */
30 require_once( ABSPATH . 'wp-admin/includes/admin.php' );
32 /** Load Ajax Handlers for WordPress Core */
33 require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );
35 @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
36 @header( 'X-Robots-Tag: noindex' );
38 send_nosniff_header();
41 do_action( 'admin_init' );
43 $core_actions_get = array(
44 'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
45 'autocomplete-user', 'dashboard-widgets', 'logged-in',
48 $core_actions_post = array(
49 'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
50 'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
51 'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',
52 'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'autosave', 'closed-postboxes',
53 'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax',
54 'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink',
55 'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
56 'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post',
57 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
58 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
59 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
62 // Register core Ajax calls.
63 if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) )
64 add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );
66 if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) )
67 add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
69 add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
71 if ( is_user_logged_in() )
72 do_action( 'wp_ajax_' . $_REQUEST['action'] ); // Authenticated actions
74 do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] ); // Non-admin actions