Created
September 9, 2015 06:15
-
-
Save michaeluno/b8df5e5796980fcec8ad to your computer and use it in GitHub Desktop.
Restores the global $post variable in the admin area as some plugins modify it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Patch - Admin Page Framework Global Post Variable | |
Description: Restores the global $post variable in the admin area as some plugins modify it. | |
*/ | |
class Patch_AdminPageFramework_GlobalPostVariable { | |
public function __construct() { | |
if ( ! is_admin() ) { | |
return; | |
} | |
$this->storeGlobalPostVariable(); | |
add_action( | |
'current_screen', | |
array( $this, 'restoreGlobalPostVariable' ), | |
1 | |
); | |
} | |
static public $post; | |
public function storeGlobalPostVariable() { | |
global $post; | |
self::$post = $post; | |
} | |
public function restoreGlobalPostVariable() { | |
global $post; | |
$post = self::$post; | |
} | |
} | |
new Patch_AdminPageFramework_GlobalPostVariable; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment