admin-post.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * WordPress Generic Request (POST/GET) Handler
  4. *
  5. * Intended for form submission handling in themes and plugins.
  6. *
  7. * @package WordPress
  8. * @subpackage Administration
  9. */
  10. /** We are located in WordPress Administration Screens */
  11. if ( ! defined( 'WP_ADMIN' ) ) {
  12. define( 'WP_ADMIN', true );
  13. }
  14. if ( defined('ABSPATH') )
  15. require_once(ABSPATH . 'wp-load.php');
  16. else
  17. require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
  18. /** Allow for cross-domain requests (from the front end). */
  19. send_origin_headers();
  20. require_once(ABSPATH . 'wp-admin/includes/admin.php');
  21. nocache_headers();
  22. /** This action is documented in wp-admin/admin.php */
  23. do_action( 'admin_init' );
  24. $action = empty( $_REQUEST['action'] ) ? '' : $_REQUEST['action'];
  25. if ( ! wp_validate_auth_cookie() ) {
  26. if ( empty( $action ) ) {
  27. /**
  28. * Fires on a non-authenticated admin post request where no action was supplied.
  29. *
  30. * @since 2.6.0
  31. */
  32. do_action( 'admin_post_nopriv' );
  33. } else {
  34. /**
  35. * Fires on a non-authenticated admin post request for the given action.
  36. *
  37. * The dynamic portion of the hook name, `$action`, refers to the given
  38. * request action.
  39. *
  40. * @since 2.6.0
  41. */
  42. do_action( "admin_post_nopriv_{$action}" );
  43. }
  44. } else {
  45. if ( empty( $action ) ) {
  46. /**
  47. * Fires on an authenticated admin post request where no action was supplied.
  48. *
  49. * @since 2.6.0
  50. */
  51. do_action( 'admin_post' );
  52. } else {
  53. /**
  54. * Fires on an authenticated admin post request for the given action.
  55. *
  56. * The dynamic portion of the hook name, `$action`, refers to the given
  57. * request action.
  58. *
  59. * @since 2.6.0
  60. */
  61. do_action( "admin_post_{$action}" );
  62. }
  63. }