Created
December 16, 2018 15:51
-
-
Save mcguffin/641dfa2cdff36357e714a21fb045267f to your computer and use it in GitHub Desktop.
This file contains hidden or 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: Fix core issue 42656 | |
Description: Fix PHP Warning undefined index pagenow on login popup. Place this into wp-content/mu-plugins/ | |
Author: McGuffin | |
Author URI: http://github.org/mcguffin | |
Version: 0.0.1 | |
*/ | |
// borrowed from wp-includes/vars.php | |
global $pagenow; | |
// On which page are we ? | |
if ( is_admin() ) { | |
// wp-admin pages are checked more carefully | |
if ( is_network_admin() ) | |
preg_match('#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches); | |
elseif ( is_user_admin() ) | |
preg_match('#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches); | |
else | |
preg_match('#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches); | |
$pagenow = $self_matches[1]; | |
$pagenow = trim($pagenow, '/'); | |
$pagenow = preg_replace('#\?.*?$#', '', $pagenow); | |
if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { | |
$pagenow = 'index.php'; | |
} else { | |
preg_match('#(.*?)(/|$)#', $pagenow, $self_matches); | |
$pagenow = strtolower($self_matches[1]); | |
if ( '.php' !== substr($pagenow, -4, 4) ) | |
$pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) | |
} | |
} else { | |
if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $_SERVER['PHP_SELF'], $self_matches) ) | |
$pagenow = strtolower($self_matches[1]); | |
else | |
$pagenow = 'index.php'; | |
} | |
unset($self_matches); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Last words: This is no longer necessary since https://core.trac.wordpress.org/changeset/44317/trunk/src/wp-includes/l10n.php