mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Hooks: Standardize naming of dynamic hooks using values derived from superglobals to use interpolation vs concatenation.
This is a continuation of the work that happened in [38307] for #37748. Props ramiy. Fixes #42698. Built from https://develop.svn.wordpress.org/trunk@42349 git-svn-id: http://core.svn.wordpress.org/trunk@42178 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
216441356a
commit
36b3f1707c
@ -146,36 +146,38 @@ if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_po
|
|||||||
|
|
||||||
add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
|
add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
|
||||||
|
|
||||||
|
$action = ( isset( $_REQUEST['action'] ) ) ? $_REQUEST['action'] : '';
|
||||||
|
|
||||||
if ( is_user_logged_in() ) {
|
if ( is_user_logged_in() ) {
|
||||||
// If no action is registered, return a Bad Request response.
|
// If no action is registered, return a Bad Request response.
|
||||||
if ( ! has_action( 'wp_ajax_' . $_REQUEST['action'] ) ) {
|
if ( ! has_action( "wp_ajax_{$action}" ) ) {
|
||||||
wp_die( '0', 400 );
|
wp_die( '0', 400 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires authenticated Ajax actions for logged-in users.
|
* Fires authenticated Ajax actions for logged-in users.
|
||||||
*
|
*
|
||||||
* The dynamic portion of the hook name, `$_REQUEST['action']`,
|
* The dynamic portion of the hook name, `$action`, refers
|
||||||
* refers to the name of the Ajax action callback being fired.
|
* to the name of the Ajax action callback being fired.
|
||||||
*
|
*
|
||||||
* @since 2.1.0
|
* @since 2.1.0
|
||||||
*/
|
*/
|
||||||
do_action( 'wp_ajax_' . $_REQUEST['action'] );
|
do_action( "wp_ajax_{$action}" );
|
||||||
} else {
|
} else {
|
||||||
// If no action is registered, return a Bad Request response.
|
// If no action is registered, return a Bad Request response.
|
||||||
if ( ! has_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] ) ) {
|
if ( ! has_action( "wp_ajax_nopriv_{$action}" ) ) {
|
||||||
wp_die( '0', 400 );
|
wp_die( '0', 400 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires non-authenticated Ajax actions for logged-out users.
|
* Fires non-authenticated Ajax actions for logged-out users.
|
||||||
*
|
*
|
||||||
* The dynamic portion of the hook name, `$_REQUEST['action']`,
|
* The dynamic portion of the hook name, `$action`, refers
|
||||||
* refers to the name of the Ajax action callback being fired.
|
* to the name of the Ajax action callback being fired.
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
|
do_action( "wp_ajax_nopriv_{$action}" );
|
||||||
}
|
}
|
||||||
// Default status
|
// Default status
|
||||||
wp_die( '0' );
|
wp_die( '0' );
|
||||||
|
@ -372,13 +372,15 @@ if ( isset( $plugin_page ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $_REQUEST['action'] ) ) {
|
if ( ! empty( $_REQUEST['action'] ) ) {
|
||||||
|
$action = $_REQUEST['action'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires when an 'action' request variable is sent.
|
* Fires when an 'action' request variable is sent.
|
||||||
*
|
*
|
||||||
* The dynamic portion of the hook name, `$_REQUEST['action']`,
|
* The dynamic portion of the hook name, `$action`, refers to
|
||||||
* refers to the action derived from the `GET` or `POST` request.
|
* the action derived from the `GET` or `POST` request.
|
||||||
*
|
*
|
||||||
* @since 2.6.0
|
* @since 2.6.0
|
||||||
*/
|
*/
|
||||||
do_action( 'admin_action_' . $_REQUEST['action'] );
|
do_action( "admin_action_{$action}" );
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
/** Load WordPress Administration Bootstrap */
|
/** Load WordPress Administration Bootstrap */
|
||||||
require_once( dirname( __FILE__ ) . '/admin.php' );
|
require_once( dirname( __FILE__ ) . '/admin.php' );
|
||||||
|
|
||||||
if ( empty( $_GET['action'] ) ) {
|
$action = ( isset( $_GET['action'] ) ) ? $_GET['action'] : '';
|
||||||
|
|
||||||
|
if ( empty( $action ) ) {
|
||||||
wp_redirect( network_admin_url() );
|
wp_redirect( network_admin_url() );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -28,12 +30,12 @@ do_action( 'wpmuadminedit' );
|
|||||||
/**
|
/**
|
||||||
* Fires the requested handler action.
|
* Fires the requested handler action.
|
||||||
*
|
*
|
||||||
* The dynamic portion of the hook name, `$_GET['action']`, refers to the name
|
* The dynamic portion of the hook name, `$action`, refers to the name
|
||||||
* of the requested action.
|
* of the requested action derived from the `GET` request.
|
||||||
*
|
*
|
||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
do_action( 'network_admin_edit_' . $_GET['action'] );
|
do_action( "network_admin_edit_{$action}" );
|
||||||
|
|
||||||
wp_redirect( network_admin_url() );
|
wp_redirect( network_admin_url() );
|
||||||
exit();
|
exit();
|
||||||
|
@ -278,7 +278,9 @@ if ( isset( $_GET['action'] ) ) {
|
|||||||
|
|
||||||
$msg = '';
|
$msg = '';
|
||||||
if ( isset( $_GET['updated'] ) ) {
|
if ( isset( $_GET['updated'] ) ) {
|
||||||
switch ( $_GET['updated'] ) {
|
$action = $_GET['updated'];
|
||||||
|
|
||||||
|
switch ( $action ) {
|
||||||
case 'all_notspam':
|
case 'all_notspam':
|
||||||
$msg = __( 'Sites removed from spam.' );
|
$msg = __( 'Sites removed from spam.' );
|
||||||
break;
|
break;
|
||||||
@ -314,16 +316,16 @@ if ( isset( $_GET['updated'] ) ) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/**
|
/**
|
||||||
* Filters a specific, non-default site-updated message in the Network admin.
|
* Filters a specific, non-default, site-updated message in the Network admin.
|
||||||
*
|
*
|
||||||
* The dynamic portion of the hook name, `$_GET['updated']`, refers to the
|
* The dynamic portion of the hook name, `$action`, refers to the non-default
|
||||||
* non-default site update action.
|
* site update action.
|
||||||
*
|
*
|
||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
*
|
*
|
||||||
* @param string $msg The update message. Default 'Settings saved'.
|
* @param string $msg The update message. Default 'Settings saved'.
|
||||||
*/
|
*/
|
||||||
$msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) );
|
$msg = apply_filters( "network_sites_updated_message_{$action}", __( 'Settings saved.' ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.0-alpha-42348';
|
$wp_version = '5.0-alpha-42349';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user