public static function getPageNow() { if (isset(self::$_sPageNow)) { return self::$_sPageNow; } if (isset($GLOBALS['pagenow'])) { self::$_sPageNow = $GLOBALS['pagenow']; return self::$_sPageNow; } self::$_sPageNow = is_admin() ? self::_getPageNow_BackEnd() : self::_getPageNow_FrontEnd(); return self::$_sPageNow; }
public static function getPageNow() { if (isset(self::$_sPageNow)) { return self::$_sPageNow; } if (isset($GLOBALS['pagenow'])) { self::$_sPageNow = $GLOBALS['pagenow']; return self::$_sPageNow; } $_aMethodNames = array(0 => '_getPageNow_FrontEnd', 1 => '_getPageNow_BackEnd'); $_sMethodName = $_aMethodNames[(int) is_admin()]; self::$_sPageNow = self::$_sMethodName(); return self::$_sPageNow; }
public static function getPageNow() { if (isset(self::$_sPageNow)) { return self::$_sPageNow; } if (isset($GLOBALS['pagenow'])) { self::$_sPageNow = $GLOBALS['pagenow']; return self::$_sPageNow; } if (!is_admin()) { if (preg_match('#([^/]+\\.php)([?/].*?)?$#i', $_SERVER['PHP_SELF'], $_aMatches)) { self::$_sPageNow = strtolower($_aMatches[1]); return self::$_sPageNow; } self::$_sPageNow = 'index.php'; return self::$_sPageNow; } if (is_network_admin()) { preg_match('#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $_aMatches); } elseif (is_user_admin()) { preg_match('#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $_aMatches); } else { preg_match('#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $_aMatches); } $_sPageNow = $_aMatches[1]; $_sPageNow = trim($_sPageNow, '/'); $_sPageNow = preg_replace('#\\?.*?$#', '', $_sPageNow); if ('' === $_sPageNow || 'index' === $_sPageNow || 'index.php' === $_sPageNow) { self::$_sPageNow = 'index.php'; return self::$_sPageNow; } preg_match('#(.*?)(/|$)#', $_sPageNow, $_aMatches); $_sPageNow = strtolower($_aMatches[1]); if ('.php' !== substr($_sPageNow, -4, 4)) { $_sPageNow .= '.php'; self::$_sPageNow = $_sPageNow; } return self::$_sPageNow; }
public static function getQueryAdminURL($aAddingQueries = array(), $aRemovingQueryKeys = array(), $sSubjectURL = '') { $_sAdminURL = is_network_admin() ? network_admin_url(AdminPageFramework_WPUtility_Page::getPageNow()) : admin_url(AdminPageFramework_WPUtility_Page::getPageNow()); $sSubjectURL = $sSubjectURL ? $sSubjectURL : add_query_arg($_GET, $_sAdminURL); return self::getQueryURL($aAddingQueries, $aRemovingQueryKeys, $sSubjectURL); }
/** * Returns the base name of the current url. * * When a plugin is network activated, the global $pagenow variable sometimes is not set. Some framework's objects rely on the value of it. * So this method will provide an alternative mean when it is not set. * * @since 3.0.5 */ public static function getPageNow() { if (isset(self::$_sPageNow)) { return self::$_sPageNow; } // If already set, use that. if (isset($GLOBALS['pagenow'])) { self::$_sPageNow = $GLOBALS['pagenow']; return self::$_sPageNow; } // Front-end if (!is_admin()) { if (preg_match('#([^/]+\\.php)([?/].*?)?$#i', $_SERVER['PHP_SELF'], $_aMatches)) { self::$_sPageNow = strtolower($_aMatches[1]); return self::$_sPageNow; } self::$_sPageNow = 'index.php'; return self::$_sPageNow; } // Back-end - wp-admin pages are checked more carefully if (is_network_admin()) { preg_match('#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $_aMatches); } elseif (is_user_admin()) { preg_match('#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $_aMatches); } else { preg_match('#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $_aMatches); } $_sPageNow = $_aMatches[1]; $_sPageNow = trim($_sPageNow, '/'); $_sPageNow = preg_replace('#\\?.*?$#', '', $_sPageNow); if ('' === $_sPageNow || 'index' === $_sPageNow || 'index.php' === $_sPageNow) { self::$_sPageNow = 'index.php'; return self::$_sPageNow; } preg_match('#(.*?)(/|$)#', $_sPageNow, $_aMatches); $_sPageNow = strtolower($_aMatches[1]); if ('.php' !== substr($_sPageNow, -4, 4)) { $_sPageNow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) self::$_sPageNow = $_sPageNow; } return self::$_sPageNow; }