<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[38334] trunk/src: AJAX: add a new function, `wp_doing_ajax()`, which can replace...</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/38334">38334</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/38334","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>wonderboymusic</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-08-23 14:32:18 +0000 (Tue, 23 Aug 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/ticket/25669">#25669</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswpcommentslisttablephp">trunk/src/wp-admin/includes/class-wp-comments-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswplisttablephp">trunk/src/wp-admin/includes/class-wp-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswptermslisttablephp">trunk/src/wp-admin/includes/class-wp-terms-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludesdashboardphp">trunk/src/wp-admin/includes/dashboard.php</a></li>
<li><a href="#trunksrcwpadminincludesmsphp">trunk/src/wp-admin/includes/ms.php</a></li>
<li><a href="#trunksrcwpadminincludesthemephp">trunk/src/wp-admin/includes/theme.php</a></li>
<li><a href="#trunksrcwpincludesclasswpajaxresponsephp">trunk/src/wp-includes/class-wp-ajax-response.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizemanagerphp">trunk/src/wp-includes/class-wp-customize-manager.php</a></li>
<li><a href="#trunksrcwpincludescommentphp">trunk/src/wp-includes/comment.php</a></li>
<li><a href="#trunksrcwpincludesfunctionsphp">trunk/src/wp-includes/functions.php</a></li>
<li><a href="#trunksrcwpincludesloadphp">trunk/src/wp-includes/load.php</a></li>
<li><a href="#trunksrcwpincludesoptionphp">trunk/src/wp-includes/option.php</a></li>
<li><a href="#trunksrcwpincludespluggablephp">trunk/src/wp-includes/pluggable.php</a></li>
<li><a href="#trunksrcwpincludesupdatephp">trunk/src/wp-includes/update.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesclasswpcommentslisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-comments-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-comments-list-table.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-admin/includes/class-wp-comments-list-table.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,7 +94,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comments_per_page = $this->get_per_page( $comment_status );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $doing_ajax = wp_doing_ajax();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_REQUEST['number'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $number = (int) $_REQUEST['number'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -600,7 +600,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Reply and quickedit need a hide-if-no-js span when not added with ajax
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ( 'reply' === $action || 'quickedit' === $action ) && ! defined('DOING_AJAX') )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() )
</ins><span class="cx" style="display: block; padding: 0 10px"> $action .= ' hide-if-no-js';
</span><span class="cx" style="display: block; padding: 0 10px"> elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswplisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-list-table.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-admin/includes/class-wp-list-table.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,7 +284,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Redirect if page number is invalid and headers are not already sent.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswptermslisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-terms-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-terms-list-table.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-admin/includes/class-wp-terms-list-table.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -367,7 +367,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $edit_link = add_query_arg(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp_http_referer',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -425,7 +425,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $tax = get_taxonomy( $taxonomy );
</span><span class="cx" style="display: block; padding: 0 10px"> $default_term = get_option( 'default_' . $taxonomy );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $edit_link = add_query_arg(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp_http_referer',
</span></span></pre></div>
<a id="trunksrcwpadminincludesdashboardphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/dashboard.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/dashboard.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-admin/includes/dashboard.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -966,7 +966,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $doing_ajax = wp_doing_ajax();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty($check_urls) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $widgets = get_option( 'dashboard_widget_options' );
</span></span></pre></div>
<a id="trunksrcwpadminincludesmsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/ms.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ms.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-admin/includes/ms.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,7 +40,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadminincludesthemephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/theme.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-admin/includes/theme.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -459,7 +459,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = wp_remote_post( $url, $http_args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $ssl && is_wp_error( $request ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp_doing_ajax() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> 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 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $request = wp_remote_post( $http_url, $http_args );
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpajaxresponsephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-ajax-response.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-ajax-response.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-includes/class-wp-ajax-response.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -149,7 +149,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $this->responses as $response )
</span><span class="cx" style="display: block; padding: 0 10px"> echo $response;
</span><span class="cx" style="display: block; padding: 0 10px"> echo '</wp_ajax>';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_doing_ajax() )
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px"> else
</span><span class="cx" style="display: block; padding: 0 10px"> die();
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizemanagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-customize-manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-manager.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-includes/class-wp-customize-manager.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -315,8 +315,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool True if it's an Ajax request, false otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function doing_ajax( $action = null ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX );
- if ( ! $doing_ajax ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp_doing_ajax() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludescommentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/comment.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/comment.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-includes/comment.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -632,7 +632,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $commentdata Comment data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'comment_duplicate_trigger', $commentdata );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( defined( 'DOING_AJAX' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_doing_ajax() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> die( __('Duplicate comment detected; it looks as though you’ve already said that!') );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -768,7 +768,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( defined('DOING_AJAX') )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_doing_ajax() )
</ins><span class="cx" style="display: block; padding: 0 10px"> die( __('You are posting comments too quickly. Slow down.') );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 );
</span></span></pre></div>
<a id="trunksrcwpincludesfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/functions.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-includes/functions.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2570,7 +2570,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $title = '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_doing_ajax() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the callback for killing WordPress execution for Ajax requests.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3064,7 +3064,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_send_json( $response ) {
</span><span class="cx" style="display: block; padding: 0 10px"> @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> echo wp_json_encode( $response );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_doing_ajax() )
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px"> else
</span><span class="cx" style="display: block; padding: 0 10px"> die;
</span></span></pre></div>
<a id="trunksrcwpincludesloadphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/load.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/load.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-includes/load.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -334,7 +334,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || wp_doing_ajax() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> @ini_set( 'display_errors', 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1027,3 +1027,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Determines whether the current request is a WordPress Ajax request.
+ *
+ * @since 4.7.0
+ *
+ * @return bool True if it's a WordPress Ajax request, false otherwise.
+ */
+function wp_doing_ajax() {
+ /**
+ * Filter whether the current request is a WordPress Ajax request.
+ *
+ * @since 4.7.0
+ *
+ * @param bool $wp_doing_ajax Whether the current request is a WordPress Ajax request.
+ */
+ return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX );
+}
</ins></span></pre></div>
<a id="trunksrcwpincludesoptionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/option.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/option.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-includes/option.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -786,7 +786,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_user_settings() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_admin() || wp_doing_ajax() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludespluggablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/pluggable.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/pluggable.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-includes/pluggable.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -603,7 +603,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expired = $expiration = $cookie_elements['expiration'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Allow a grace period for POST and Ajax requests
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_doing_ajax() || 'POST' == $_SERVER['REQUEST_METHOD'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $expired += HOUR_IN_SECONDS;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1104,7 +1104,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'check_ajax_referer', $action, $result );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $die && false === $result ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_doing_ajax() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> die( '-1' );
</span></span></pre></div>
<a id="trunksrcwpincludesupdatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/update.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/update.php 2016-08-23 14:23:41 UTC (rev 38333)
+++ trunk/src/wp-includes/update.php 2016-08-23 14:32:18 UTC (rev 38334)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -678,7 +678,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> delete_site_transient( 'update_core' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+if ( ( ! is_main_site() && ! is_network_admin() ) || wp_doing_ajax() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>