mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
AJAX: add a new function, wp_doing_ajax(), which can replace... (wait for it...) DOING_AJAX checks via the constant.
Props Mte90, sebastian.pisula, swissspidy. Fixes #25669. git-svn-id: https://develop.svn.wordpress.org/trunk@38334 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -94,7 +94,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
|
||||
$comments_per_page = $this->get_per_page( $comment_status );
|
||||
|
||||
$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
|
||||
$doing_ajax = wp_doing_ajax();
|
||||
|
||||
if ( isset( $_REQUEST['number'] ) ) {
|
||||
$number = (int) $_REQUEST['number'];
|
||||
@@ -600,7 +600,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
|
||||
|
||||
// Reply and quickedit need a hide-if-no-js span when not added with ajax
|
||||
if ( ( 'reply' === $action || 'quickedit' === $action ) && ! defined('DOING_AJAX') )
|
||||
if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() )
|
||||
$action .= ' hide-if-no-js';
|
||||
elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {
|
||||
if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
|
||||
|
||||
@@ -284,7 +284,7 @@ class WP_List_Table {
|
||||
$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
|
||||
|
||||
// Redirect if page number is invalid and headers are not already sent.
|
||||
if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
|
||||
if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
|
||||
wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
|
||||
$qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
|
||||
|
||||
$uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
|
||||
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
|
||||
|
||||
$edit_link = add_query_arg(
|
||||
'wp_http_referer',
|
||||
@@ -425,7 +425,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
$default_term = get_option( 'default_' . $taxonomy );
|
||||
|
||||
$uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
|
||||
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
|
||||
|
||||
$edit_link = add_query_arg(
|
||||
'wp_http_referer',
|
||||
|
||||
@@ -966,7 +966,7 @@ function wp_dashboard_rss_output( $widget_id ) {
|
||||
*/
|
||||
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
|
||||
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>';
|
||||
$doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX );
|
||||
$doing_ajax = wp_doing_ajax();
|
||||
|
||||
if ( empty($check_urls) ) {
|
||||
$widgets = get_option( 'dashboard_widget_options' );
|
||||
|
||||
@@ -40,7 +40,7 @@ function check_upload_size( $file ) {
|
||||
$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
|
||||
}
|
||||
|
||||
if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
|
||||
if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
|
||||
wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
|
||||
}
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ function themes_api( $action, $args = array() ) {
|
||||
$request = wp_remote_post( $url, $http_args );
|
||||
|
||||
if ( $ssl && is_wp_error( $request ) ) {
|
||||
if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
|
||||
if ( ! wp_doing_ajax() ) {
|
||||
trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
|
||||
}
|
||||
$request = wp_remote_post( $http_url, $http_args );
|
||||
|
||||
Reference in New Issue
Block a user