PageRenderTime 44ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/wp-admin/admin-ajax.php

https://bitbucket.org/dkrzos/phc
PHP | 77 lines | 41 code | 16 blank | 20 comment | 6 complexity | f0e97ad3575a63d268400bbd40878b6e MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * WordPress AJAX Process Execution.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. *
  8. * @link http://codex.wordpress.org/AJAX_in_Plugins
  9. */
  10. /**
  11. * Executing AJAX process.
  12. *
  13. * @since 2.1.0
  14. */
  15. define( 'DOING_AJAX', true );
  16. define( 'WP_ADMIN', true );
  17. /** Load WordPress Bootstrap */
  18. require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
  19. /** Allow for cross-domain requests (from the frontend). */
  20. send_origin_headers();
  21. // Require an action parameter
  22. if ( empty( $_REQUEST['action'] ) )
  23. die( '0' );
  24. /** Load WordPress Administration APIs */
  25. require_once( ABSPATH . 'wp-admin/includes/admin.php' );
  26. /** Load Ajax Handlers for WordPress Core */
  27. require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );
  28. @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
  29. @header( 'X-Robots-Tag: noindex' );
  30. send_nosniff_header();
  31. nocache_headers();
  32. do_action( 'admin_init' );
  33. $core_actions_get = array(
  34. 'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
  35. 'autocomplete-user', 'dashboard-widgets', 'logged-in',
  36. );
  37. $core_actions_post = array(
  38. 'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
  39. 'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
  40. 'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',
  41. 'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'autosave', 'closed-postboxes',
  42. 'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax',
  43. 'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink',
  44. 'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
  45. 'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post',
  46. 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
  47. 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
  48. 'send-attachment-to-editor', 'save-attachment-order',
  49. );
  50. // Register core Ajax calls.
  51. if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) )
  52. add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );
  53. if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) )
  54. add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
  55. add_action( 'wp_ajax_nopriv_autosave', 'wp_ajax_nopriv_autosave', 1 );
  56. if ( is_user_logged_in() )
  57. do_action( 'wp_ajax_' . $_REQUEST['action'] ); // Authenticated actions
  58. else
  59. do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] ); // Non-admin actions
  60. // Default status
  61. die( '0' );