~canonical-sysadmins/wordpress/4.7.4

« back to all changes in this revision

Viewing changes to wp-admin/admin-post.php

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
11
/** We are located in WordPress Administration Screens */
 
12
if ( ! defined( 'WP_ADMIN' ) ) {
 
13
        define( 'WP_ADMIN', true );
 
14
}
 
15
 
 
16
if ( defined('ABSPATH') )
 
17
        require_once(ABSPATH . 'wp-load.php');
 
18
else
 
19
        require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
 
20
 
 
21
/** Allow for cross-domain requests (from the frontend). */
 
22
send_origin_headers();
 
23
 
 
24
require_once(ABSPATH . 'wp-admin/includes/admin.php');
 
25
 
 
26
nocache_headers();
 
27
 
 
28
/** This action is documented in wp-admin/admin.php */
 
29
do_action( 'admin_init' );
 
30
 
 
31
$action = empty( $_REQUEST['action'] ) ? '' : $_REQUEST['action'];
 
32
 
 
33
if ( ! wp_validate_auth_cookie() ) {
 
34
        if ( empty( $action ) ) {
 
35
                /**
 
36
                 * Fires on a non-authenticated admin post request where no action was supplied.
 
37
                 *
 
38
                 * @since 2.6.0
 
39
                 */
 
40
                do_action( 'admin_post_nopriv' );
 
41
        } else {
 
42
                /**
 
43
                 * Fires on a non-authenticated admin post request for the given action.
 
44
                 *
 
45
                 * The dynamic portion of the hook name, $action, refers to the given
 
46
                 * request action.
 
47
                 *
 
48
                 * @since 2.6.0
 
49
                 */
 
50
                do_action( "admin_post_nopriv_{$action}" );
 
51
        }
 
52
} else {
 
53
        if ( empty( $action ) ) {
 
54
                /**
 
55
                 * Fires on an authenticated admin post request where no action was supplied.
 
56
                 *
 
57
                 * @since 2.6.0
 
58
                 */
 
59
                do_action( 'admin_post' );
 
60
        } else {
 
61
                /**
 
62
                 * Fires on an authenticated admin post request for the given action.
 
63
                 *
 
64
                 * The dynamic portion of the hook name, $action, refers to the given
 
65
                 * request action.
 
66
                 *
 
67
                 * @since 2.6.0
 
68
                 */
 
69
                do_action( "admin_post_{$action}" );
 
70
        }
 
71
}