Skip to content
Permalink
Browse files

Made the `setUp()` method not load when Ajax calls performed by the W…

…ordPress core.

- Added the `_isWordPressCoreAjaxRequest()` protected method that checks Ajax requests on `admin-ajax.php`.
  • Loading branch information...
michaeluno committed Feb 18, 2019
1 parent dbaef6e commit 0923f94654076710790500124405ce30afdaadcb
@@ -157,8 +157,6 @@ public function __construct( $oProp ) {
// Required sub-class objects
$this->oProp = $oProp;
// @deprecated 3.8.14
// if ( $this->oProp->bIsAdmin && ! $this->oProp->bIsAdminAjax ) {
if ( $this->oProp->bIsAdmin ) {
$this->oUtil->registerAction( 'current_screen', array( $this, '_replyToLoadComponents' ) );
}
@@ -241,8 +239,27 @@ protected function _setUp() {
* @internal
*/
protected function _isInstantiatable() {
if ( $this->_isWordPressCoreAjaxRequest() ) {
return false;
}
return true;
}
/**
* Checks whether the page call is by WordPress core ajax requests.
* @return boolean
* @remark Not using the property or utility object as this can be called prior to instantiating those.
* @since 3.8.19
*/
protected function _isWordPressCoreAjaxRequest() {
if ( ! isset( $GLOBALS[ 'pagenow' ] ) ) {
return false;
}
if ( 'admin-ajax.php' !== $GLOBALS[ 'pagenow' ] ) {
return false;
}
$_sAction = isset( $_POST[ 'action' ] ) ? $_POST[ 'action' ] : '';
return in_array( $_sAction, array( 'heartbeat', 'closed-postboxes', 'meta-box-order' ) );
}
/**
* Determines whether the instantiated object and its producing elements belong to the loading page.
@@ -295,11 +295,9 @@ private function _isPageLoadCall( $sMethodName, $sPageSlug, $osScreenORPageHook
*/
protected function _isInstantiatable() {
// @deprecated 3.8.14
// Disable in admin-ajax.php
// if ( isset( $GLOBALS[ 'pagenow' ] ) && 'admin-ajax.php' === $GLOBALS[ 'pagenow' ] ) {
// return false;
// }
if ( $this->_isWordPressCoreAjaxRequest() ) {
return false;
}
// Nothing to do in the network admin area.
return ! is_network_admin();
@@ -113,10 +113,9 @@ protected function _getPageLoadObject() {
*/
protected function _isInstantiatable() {
// @deprecated 3.8.14
// if ( isset( $GLOBALS[ 'pagenow' ] ) && 'admin-ajax.php' === $GLOBALS[ 'pagenow' ] ) {
// return false;
// }
if ( $this->_isWordPressCoreAjaxRequest() ) {
return false;
}
// Nothing to do in the non-network admin area.
if ( is_network_admin() ) {
@@ -26,11 +26,9 @@ abstract class AdminPageFramework_PageMetaBox_Router extends AdminPageFramework_
*/
protected function _isInstantiatable() {
// @deprecated 3.8.14
// Disable the functionality in admin-ajax.php
// if ( isset( $GLOBALS[ 'pagenow' ] ) && 'admin-ajax.php' === $GLOBALS[ 'pagenow' ] ) {
// return false;
// }
if ( $this->_isWordPressCoreAjaxRequest() ) {
return false;
}
return true;
}

0 comments on commit 0923f94

Please sign in to comment.
You can’t perform that action at this time.