Split admin-header.php into admin.php and admin-header.php. Split menu.php into menu-header.php and menu.php. Add plugin admin page support.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-10-19 03:03:06 +00:00
parent c591d809f7
commit 04786f267d
31 changed files with 254 additions and 445 deletions

View File

@ -661,10 +661,65 @@ function user_can_access_admin_page() {
return true; return true;
} }
function add_options_menu($title, $access_level, $file) { function get_admin_page_title() {
global $title;
global $submenu;
global $pagenow;
global $plugin_page;
if (isset($title) && ! empty($title)) {
return $title;
}
foreach (array_keys($submenu) as $parent) {
foreach ($submenu[$parent] as $submenu_array) {
if (isset($submenu_array[3])) {
if ($submenu_array[2] == $pagenow) {
$title = $submenu_array[3];
return $submenu_array[3];
} else if (isset($plugin_page) && ($plugin_page == $submenu_array[2])) {
$title = $submenu_array[3];
return $submenu_array[3];
}
}
}
}
return '';
}
function get_admin_page_parent() {
global $parent_file;
global $submenu;
global $pagenow;
global $plugin_page;
if (isset($parent_file) && ! empty($parent_file)) {
return $parent_file;
}
foreach (array_keys($submenu) as $parent) {
foreach ($submenu[$parent] as $submenu_array) {
if ($submenu_array[2] == $pagenow) {
$parent_file = $parent;
return $parent;
} else if (isset($plugin_page) && ($plugin_page == $submenu_array[2])) {
$parent_file = $parent;
return $parent;
}
}
}
$parent_file = '';
return '';
}
function add_options_page($page_title, $menu_title, $access_level, $file) {
global $submenu; global $submenu;
$submenu['options-general.php'][] = array($title, $access_level, $file); $file = basename($file);
$submenu['options-general.php'][] = array($menu_title, $access_level, $file, $page_title);
} }
?> ?>

View File

@ -1,54 +1,10 @@
<?php <?php get_admin_page_title(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
if (strstr($_SERVER['PHP_SELF'], 'plugins/')) {
$wp_admin_path = '../../wp-admin/';
$wp_path = '../../';
} else {
$wp_admin_path = './';
$wp_path = '../';
}
require_once($wp_path . 'wp-config.php');
require_once(ABSPATH . '/wp-admin/auth.php');
require(ABSPATH . '/wp-admin/admin-functions.php');
$dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories");
foreach ($dogs as $catt) {
$cache_categories[$catt->cat_ID] = $catt;
}
get_currentuserinfo();
$posts_per_page = get_settings('posts_per_page');
$what_to_show = get_settings('what_to_show');
$date_format = get_settings('date_format');
$time_format = get_settings('time_format');
$wpvarstoreset = array('profile','standalone','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
if ($standalone == 0) :
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title> <title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
<link rel="stylesheet" href="<?php echo $wp_admin_path; ?>wp-admin.css" type="text/css" /> <link rel="stylesheet" href="wp-admin.css" type="text/css" />
<link rel="shortcut icon" href="<?php echo $wp_path; ?>wp-images/wp-favicon.png" /> <link rel="shortcut icon" href="../wp-images/wp-favicon.png" />
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_settings('blog_charset'); ?>" /> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_settings('blog_charset'); ?>" />
<?php if (isset($xfn)) : ?> <?php if (isset($xfn)) : ?>
@ -119,6 +75,9 @@ window.onload = blurry;
</div> </div>
<?php <?php
require(ABSPATH . '/wp-admin/menu.php'); require(ABSPATH . '/wp-admin/menu-header.php');
endif;
if ( $parent_file == 'options-general.php' ) {
require(ABSPATH . '/wp-admin/options-head.php');
}
?> ?>

71
wp-admin/admin.php Normal file
View File

@ -0,0 +1,71 @@
<?php
require_once('../wp-config.php');
require_once(ABSPATH . 'wp-includes/wp-l10n.php');
require_once(ABSPATH . 'wp-admin/auth.php');
require(ABSPATH . 'wp-admin/admin-functions.php');
$dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories");
foreach ($dogs as $catt) {
$cache_categories[$catt->cat_ID] = $catt;
}
get_currentuserinfo();
$posts_per_page = get_settings('posts_per_page');
$what_to_show = get_settings('what_to_show');
$date_format = get_settings('date_format');
$time_format = get_settings('time_format');
function add_magic_quotes($array) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('profile','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($_POST["$wpvar"])) {
if (empty($_GET["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $_GET["$wpvar"];
}
} else {
$$wpvar = $_POST["$wpvar"];
}
}
}
require(ABSPATH . '/wp-admin/menu.php');
// Handle plugin admin pages.
if (isset($_GET['page'])) {
$plugin_page = basename($_GET['page']);
if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page")) {
die(sprintf(__('Cannot load %s.'), $plugin_page));
}
if (! isset($_GET['noheader'])) {
require_once(ABSPATH . '/wp-admin/admin-header.php');
}
include(ABSPATH . "wp-content/plugins/$plugin_page");
include(ABSPATH . 'wp-admin/admin-footer.php');
}
?>

View File

@ -1,27 +1,10 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Categories'); $title = __('Categories');
$parent_file = 'edit.php'; $parent_file = 'edit.php';
function add_magic_quotes($array) { $wpvarstoreset = array('action','cat');
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action','standalone','cat');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) { if (!isset($$wpvar)) {
@ -41,9 +24,6 @@ switch($action) {
case 'addcat': case 'addcat':
$standalone = 1;
require_once('admin-header.php');
if ($user_level < 3) if ($user_level < 3)
die (__('Cheatin&#8217; uh?')); die (__('Cheatin&#8217; uh?'));
@ -61,9 +41,6 @@ break;
case 'Delete': case 'Delete':
$standalone = 1;
require_once('admin-header.php');
check_admin_referer(); check_admin_referer();
$cat_ID = intval($_GET["cat_ID"]); $cat_ID = intval($_GET["cat_ID"]);
@ -119,9 +96,6 @@ break;
case 'editedcat': case 'editedcat':
$standalone = 1;
require_once('admin-header.php');
if ($user_level < 3) if ($user_level < 3)
die (__('Cheatin&#8217; uh?')); die (__('Cheatin&#8217; uh?'));
@ -138,7 +112,6 @@ break;
default: default:
$standalone = 0;
require_once ('admin-header.php'); require_once ('admin-header.php');
if ($user_level < 3) { if ($user_level < 3) {
die(sprintf(__("You have no right to edit the categories for this blog.<br />Ask for a promotion to your <a href='mailto:%s'>blog admin</a>. :)"), get_settings('admin_email'))); die(sprintf(__("You have no right to edit the categories for this blog.<br />Ask for a promotion to your <a href='mailto:%s'>blog admin</a>. :)"), get_settings('admin_email')));

View File

@ -1,5 +1,5 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Edit Comments'); $title = __('Edit Comments');
$parent_file = 'edit.php'; $parent_file = 'edit.php';

View File

@ -1,6 +1,5 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Pages'); $title = __('Pages');
$parent_file = 'edit.php'; $parent_file = 'edit.php';
require_once('admin-header.php'); require_once('admin-header.php');

View File

@ -1,5 +1,5 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Posts'); $title = __('Posts');
$parent_file = 'edit.php'; $parent_file = 'edit.php';

View File

@ -1,5 +1,5 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = 'Add Link'; $title = 'Add Link';
$this_file = 'link-manager.php'; $this_file = 'link-manager.php';
@ -22,23 +22,7 @@ function category_dropdown($fieldname, $selected = 0) {
echo " </select>\n"; echo " </select>\n";
} }
function add_magic_quotes($array) { $wpvarstoreset = array('action', 'cat_id', 'linkurl', 'name', 'image',
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action','standalone','cat_id', 'linkurl', 'name', 'image',
'description', 'visible', 'target', 'category', 'link_id', 'description', 'visible', 'target', 'category', 'link_id',
'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
'notes', 'linkcheck[]'); 'notes', 'linkcheck[]');

View File

@ -1,12 +1,12 @@
<?php <?php
// Links // Links
// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com // Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Link Categories'); $title = __('Link Categories');
$this_file='link-categories.php'; $this_file='link-categories.php';
$parent_file = 'link-manager.php'; $parent_file = 'link-manager.php';
$wpvarstoreset = array('action','standalone','cat', 'auto_toggle'); $wpvarstoreset = array('action', 'cat', 'auto_toggle');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) { if (!isset($$wpvar)) {
@ -25,9 +25,6 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
switch ($action) { switch ($action) {
case 'addcat': case 'addcat':
{ {
$standalone = 1;
include_once('admin-header.php');
if ($user_level < 5) if ($user_level < 5)
die (__("Cheatin' uh ?")); die (__("Cheatin' uh ?"));
@ -82,9 +79,6 @@ switch ($action) {
} // end addcat } // end addcat
case 'Delete': case 'Delete':
{ {
$standalone = 1;
include_once('admin-header.php');
$cat_id = $_GET['cat_id']; $cat_id = $_GET['cat_id'];
$cat_name=get_linkcatname($cat_id); $cat_name=get_linkcatname($cat_id);
@ -204,9 +198,6 @@ switch ($action) {
} // end Edit } // end Edit
case "editedcat": case "editedcat":
{ {
$standalone = 1;
include_once("./admin-header.php");
if ($user_level < 5) if ($user_level < 5)
die (__("Cheatin' uh ?")); die (__("Cheatin' uh ?"));
@ -278,8 +269,7 @@ switch ($action) {
} // end editcat } // end editcat
default: default:
{ {
$standalone=0; include_once ("admin-header.php");
include_once ("./admin-header.php");
if ($user_level < 5) { if ($user_level < 5) {
die(__("You have do not have sufficient permissions to edit the link categories for this blog. :)")); die(__("You have do not have sufficient permissions to edit the link categories for this blog. :)"));
} }

View File

@ -2,8 +2,7 @@
// Links // Links
// Copyright (C) 2002 Mike Little -- mike@zed1.com // Copyright (C) 2002 Mike Little -- mike@zed1.com
require_once('../wp-config.php'); require_once('admin.php');
$parent_file = 'link-manager.php'; $parent_file = 'link-manager.php';
$title = __('Import Blogroll'); $title = __('Import Blogroll');
$this_file = 'link-import.php'; $this_file = 'link-import.php';
@ -15,7 +14,6 @@ if (!$step) $step = 0;
switch ($step) { switch ($step) {
case 0: case 0:
{ {
$standalone = 0;
include_once('admin-header.php'); include_once('admin-header.php');
if ($user_level < 5) if ($user_level < 5)
die (__("Cheatin&#8217; uh?")); die (__("Cheatin&#8217; uh?"));
@ -72,7 +70,6 @@ switch ($step) {
} // end case 0 } // end case 0
case 1: { case 1: {
$standalone = 0;
include_once('admin-header.php'); include_once('admin-header.php');
if ($user_level < 5) if ($user_level < 5)
die (__("Cheatin' uh ?")); die (__("Cheatin' uh ?"));

View File

@ -2,7 +2,7 @@
// Links // Links
// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com // Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
require_once('../wp-config.php'); require_once('admin.php');
$title = __('Manage Links'); $title = __('Manage Links');
$this_file = $parent_file = 'link-manager.php'; $this_file = $parent_file = 'link-manager.php';
@ -37,23 +37,7 @@ function category_dropdown($fieldname, $selected = 0) {
echo "\n</select>\n"; echo "\n</select>\n";
} }
function add_magic_quotes($array) { $wpvarstoreset = array('action','cat_id', 'linkurl', 'name', 'image',
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action','standalone','cat_id', 'linkurl', 'name', 'image',
'description', 'visible', 'target', 'category', 'link_id', 'description', 'visible', 'target', 'category', 'link_id',
'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
'notes', 'linkcheck[]'); 'notes', 'linkcheck[]');
@ -83,9 +67,6 @@ if ('' != $_POST['move']) $action = 'move';
switch ($action) { switch ($action) {
case 'assign': case 'assign':
{ {
$standalone = 1;
include_once('admin-header.php');
check_admin_referer(); check_admin_referer();
// check the current user's level first. // check the current user's level first.
@ -116,9 +97,6 @@ switch ($action) {
} }
case 'visibility': case 'visibility':
{ {
$standalone = 1;
include_once('admin-header.php');
check_admin_referer(); check_admin_referer();
// check the current user's level first. // check the current user's level first.
@ -156,9 +134,6 @@ switch ($action) {
} }
case 'move': case 'move':
{ {
$standalone = 1;
include_once('admin-header.php');
check_admin_referer(); check_admin_referer();
// check the current user's level first. // check the current user's level first.
@ -180,9 +155,6 @@ switch ($action) {
case 'Add': case 'Add':
{ {
$standalone = 1;
include_once('admin-header.php');
check_admin_referer(); check_admin_referer();
$link_url = $_POST['linkurl']; $link_url = $_POST['linkurl'];
@ -230,9 +202,6 @@ switch ($action) {
} }
$links_show_cat_id = $cat_id; $links_show_cat_id = $cat_id;
$standalone = 1;
include_once('admin-header.php');
check_admin_referer(); check_admin_referer();
$link_id = $_POST['link_id']; $link_id = $_POST['link_id'];
@ -276,9 +245,6 @@ switch ($action) {
case 'Delete': case 'Delete':
{ {
$standalone = 1;
include_once('admin-header.php');
check_admin_referer(); check_admin_referer();
$link_id = (int) $_GET['link_id']; $link_id = (int) $_GET['link_id'];
@ -303,7 +269,6 @@ switch ($action) {
case 'linkedit': case 'linkedit':
{ {
$standalone=0;
$xfn = true; $xfn = true;
include_once ('admin-header.php'); include_once ('admin-header.php');
if ($user_level < 5) { if ($user_level < 5) {
@ -569,7 +534,6 @@ switch ($action) {
setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600); setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600);
$standalone=0;
include_once ("./admin-header.php"); include_once ("./admin-header.php");
if ($user_level < 5) { if ($user_level < 5) {
die(__("You do not have sufficient permissions to edit the links for this blog.")); die(__("You do not have sufficient permissions to edit the links for this blog."));

51
wp-admin/menu-header.php Normal file
View File

@ -0,0 +1,51 @@
<ul id="adminmenu">
<?php
$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
$self = preg_replace('|^.*/plugins/|i', '', $self);
get_admin_page_parent();
foreach ($menu as $item) {
$class = '';
// 0 = name, 1 = user_level, 2 = file
if ((substr($self, -10) == substr($item[2], -10) && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
if ($user_level >= $item[1]) {
if (
('upload.php' == $item[2] &&
get_settings('use_fileupload') &&
($user_level >= get_settings('fileupload_minlevel'))
) || 'upload.php' != $item[2])
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
}
}
?>
<li class="last"><a href="<?php echo get_settings('siteurl')
?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php printf(__('Logout (%s)'), $user_nickname) ?></a></li>
</ul>
<?php
// Sub-menu
if ( isset($submenu["$parent_file"]) ) :
?>
<ul id="adminmenu2">
<?php
foreach ($submenu["$parent_file"] as $item) :
if ($user_level < $item[1]) {
continue;
}
if ( (substr($self, -10) == substr($item[2], -10)) || (isset($plugin_page) && $plugin_page == $item[2]) ) $class = ' class="current"';
else $class = '';
if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}"))
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
else
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
endforeach;
?>
</ul>
<?php endif; ?>

View File

@ -1,5 +1,3 @@
<ul id="adminmenu">
<?php <?php
// This array constructs the admin menu bar. // This array constructs the admin menu bar.
// //
@ -49,47 +47,4 @@ if (! user_can_access_admin_page()) {
die( __('You have do not have sufficient permissions to access this page.') ); die( __('You have do not have sufficient permissions to access this page.') );
} }
$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
$self = preg_replace('|^.*/plugins/|i', '', $self);
if (!isset($parent_file)) $parent_file = '';
foreach ($menu as $item) {
$class = '';
// 0 = name, 1 = user_level, 2 = file
if ((substr($self, -10) == substr($item[2], -10) && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
if ($user_level >= $item[1]) {
if (
('upload.php' == $item[2] &&
get_settings('use_fileupload') &&
($user_level >= get_settings('fileupload_minlevel'))
) || 'upload.php' != $item[2])
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
}
}
?> ?>
<li class="last"><a href="<?php echo get_settings('siteurl')
?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php printf(__('Logout (%s)'), $user_nickname) ?></a></li>
</ul>
<?php
// Sub-menu
if ( isset($submenu["$parent_file"]) ) :
?>
<ul id="adminmenu2">
<?php
foreach ($submenu["$parent_file"] as $item) :
if ($user_level < $item[1]) {
continue;
}
if ( substr($self, -10) == substr($item[2], -10) ) $class = ' class="current"';
else $class = '';
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
endforeach;
?>
</ul>
<?php endif; ?>

View File

@ -1,26 +1,9 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Moderate comments'); $title = __('Moderate comments');
$parent_file = 'edit.php'; $parent_file = 'edit.php';
function add_magic_quotes($array) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action','item_ignored','item_deleted','item_approved'); $wpvarstoreset = array('action','item_ignored','item_deleted','item_approved');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
@ -48,9 +31,6 @@ switch($action) {
case 'update': case 'update':
$standalone = 1;
require_once('admin-header.php');
if ($user_level < 3) { if ($user_level < 3) {
die(__('<p>Your level is not high enough to moderate comments.</p>')); die(__('<p>Your level is not high enough to moderate comments.</p>'));
} }

View File

@ -1,8 +1,10 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Discussion Options'); $title = __('Discussion Options');
include('options-head.php'); $parent_file = 'options-general.php';
include('admin-header.php');
if ($action == 'retrospam') { if ($action == 'retrospam') {
if ( $_GET['move'] == 'true' ) { if ( $_GET['move'] == 'true' ) {

View File

@ -1,9 +1,10 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('General Options'); $title = __('General Options');
$parent_file = 'options-general.php';
include('options-head.php'); include('admin-header.php');
?> ?>
<div class="wrap"> <div class="wrap">

View File

@ -1,24 +1,5 @@
<?php <?php
$parent_file = 'options-general.php';
function add_magic_quotes($array) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action','standalone', 'option_group_id'); $wpvarstoreset = array('action','standalone', 'option_group_id');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
@ -34,13 +15,10 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
} }
} }
} }
$standalone = 0;
include_once('admin-header.php');
?> ?>
<br clear="all" /> <br clear="all" />
<?php if (isset($updated)) : ?> <?php if (isset($_GET['updated'])) : ?>
<div class="updated"><p><strong><?php _e('Options saved.') ?></strong></p></div> <div class="updated"><p><strong><?php _e('Options saved.') ?></strong></p></div>
<?php endif; ?> <?php endif; ?>

View File

@ -1,8 +1,11 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Miscellaneous Options'); $title = __('Miscellaneous Options');
include('options-head.php'); $parent_file = 'options-general.php';
include('admin-header.php');
?> ?>
<div class="wrap"> <div class="wrap">

View File

@ -1,8 +1,10 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Permalink Options'); $title = __('Permalink Options');
require('./options-head.php'); $parent_file = 'options-general.php';
include('admin-header.php');
$home = get_settings('home'); $home = get_settings('home');
if ( $home != '' && $home != get_settings('siteurl') ) { if ( $home != '' && $home != get_settings('siteurl') ) {

View File

@ -1,8 +1,10 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Reading Options'); $title = __('Reading Options');
include('options-head.php'); $parent_file = 'options-general.php';
include('admin-header.php');
?> ?>
<div class="wrap"> <div class="wrap">

View File

@ -1,8 +1,10 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Writing Options'); $title = __('Writing Options');
include('./options-head.php'); $parent_file = 'options-general.php';
include('admin-header.php');
?> ?>
<div class="wrap"> <div class="wrap">

View File

@ -1,28 +1,11 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Options'); $title = __('Options');
$this_file = 'options.php'; $this_file = 'options.php';
$parent_file = 'options-general.php'; $parent_file = 'options-general.php';
function add_magic_quotes($array) { $wpvarstoreset = array('action');
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action','standalone');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) { if (!isset($$wpvar)) {
@ -41,8 +24,6 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
switch($action) { switch($action) {
case 'update': case 'update':
$standalone = 1;
include_once('./admin-header.php');
$any_changed = 0; $any_changed = 0;
if (!$_POST['page_options']) { if (!$_POST['page_options']) {
@ -91,14 +72,7 @@ case 'update':
break; break;
default: default:
$standalone = 0; include('admin-header.php'); ?>
include_once('./admin-header.php');
if ($user_level <= 6) {
die(__("You have do not have sufficient permissions to edit the options for this blog."));
}
?>
<?php include('options-head.php'); ?>
<div class="wrap"> <div class="wrap">
<h2>All options</h2> <h2>All options</h2>

View File

@ -1,9 +1,7 @@
<?php <?php
require_once('admin.php');
if ( isset($_GET['action']) ) { if ( isset($_GET['action']) ) {
$standalone = 1;
require_once('admin-header.php');
check_admin_referer(); check_admin_referer();
if ('activate' == $_GET['action']) { if ('activate' == $_GET['action']) {
@ -24,13 +22,9 @@ if ( isset($_GET['action']) ) {
} }
} }
require_once('../wp-includes/wp-l10n.php');
$title = __('Manage Plugins'); $title = __('Manage Plugins');
require_once('admin-header.php'); require_once('admin-header.php');
if ($user_level < 9) // Must be at least level 9
die (__('Sorry, you must be at least a level 8 user to modify plugins.'));
// Clean up options // Clean up options
// If any plugins don't exist, axe 'em // If any plugins don't exist, axe 'em

View File

@ -1,22 +1,5 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
function add_magic_quotes($array) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'poststart', 'postend', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder', 'enclosure_url' ); $wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'poststart', 'postend', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder', 'enclosure_url' );
@ -37,7 +20,6 @@ if (!isset($$wpvar)) {
switch($action) { switch($action) {
case 'post': case 'post':
$standalone = 1;
require_once('admin-header.php'); require_once('admin-header.php');
if (!user_can_create_draft($user_ID)) { if (!user_can_create_draft($user_ID)) {
@ -183,7 +165,6 @@ case 'post':
case 'edit': case 'edit':
$title = __('Edit'); $title = __('Edit');
$standalone = 0;
require_once('admin-header.php'); require_once('admin-header.php');
$post = $post_ID = $p = (int) $_GET['post']; $post = $post_ID = $p = (int) $_GET['post'];
@ -236,9 +217,6 @@ echo $content;
case 'editpost': case 'editpost':
// die(var_dump('<pre>', $_POST)); // die(var_dump('<pre>', $_POST));
$standalone = 1;
require_once('./admin-header.php');
if (!isset($blog_ID)) { if (!isset($blog_ID)) {
$blog_ID = 1; $blog_ID = 1;
} }
@ -398,10 +376,6 @@ case 'editpost':
break; break;
case 'delete': case 'delete':
$standalone = 1;
require_once('./admin-header.php');
check_admin_referer(); check_admin_referer();
$post_id = intval($_GET['post']); $post_id = intval($_GET['post']);
@ -428,7 +402,6 @@ case 'delete':
case 'editcomment': case 'editcomment':
$title = __('Edit Comment'); $title = __('Edit Comment');
$standalone = 0;
$parent_file = 'edit.php'; $parent_file = 'edit.php';
require_once ('admin-header.php'); require_once ('admin-header.php');
@ -451,7 +424,6 @@ case 'editcomment':
case 'confirmdeletecomment': case 'confirmdeletecomment':
$standalone = 0;
require_once('./admin-header.php'); require_once('./admin-header.php');
$comment = $_GET['comment']; $comment = $_GET['comment'];
@ -487,9 +459,6 @@ break;
case 'deletecomment': case 'deletecomment':
$standalone = 1;
require_once('./admin-header.php');
check_admin_referer(); check_admin_referer();
$comment = $_GET['comment']; $comment = $_GET['comment'];
@ -520,7 +489,6 @@ break;
case 'unapprovecomment': case 'unapprovecomment':
$standalone = 1;
require_once('./admin-header.php'); require_once('./admin-header.php');
check_admin_referer(); check_admin_referer();
@ -551,9 +519,6 @@ break;
case 'mailapprovecomment': case 'mailapprovecomment':
$standalone = 1;
require_once('./admin-header.php');
$comment = (int) $_GET['comment']; $comment = (int) $_GET['comment'];
$commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php')); $commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
@ -574,9 +539,6 @@ break;
case 'approvecomment': case 'approvecomment':
$standalone = 1;
require_once('./admin-header.php');
$comment = $_GET['comment']; $comment = $_GET['comment'];
$p = $_GET['p']; $p = $_GET['p'];
if (isset($_GET['noredir'])) { if (isset($_GET['noredir'])) {
@ -606,9 +568,6 @@ break;
case 'editedcomment': case 'editedcomment':
$standalone = 1;
require_once('./admin-header.php');
$comment_ID = $_POST['comment_ID']; $comment_ID = $_POST['comment_ID'];
$comment_post_ID = $_POST['comment_post_ID']; $comment_post_ID = $_POST['comment_post_ID'];
$newcomment_author = $_POST['newcomment_author']; $newcomment_author = $_POST['newcomment_author'];
@ -653,7 +612,6 @@ case 'editedcomment':
break; break;
default: default:
$standalone = 0;
$title = __('Create New Post'); $title = __('Create New Post');
require_once ('./admin-header.php'); require_once ('./admin-header.php');

View File

@ -1,27 +1,10 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = "Profile"; $title = "Profile";
$parent_file = 'profile.php'; $parent_file = 'profile.php';
function add_magic_quotes($array) { $wpvarstoreset = array('action','redirect','profile','user');
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action','standalone','redirect','profile','user');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) { if (!isset($$wpvar)) {

View File

@ -1,20 +1,8 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Template &amp; file editing'); $title = __('Template &amp; file editing');
$parent_file = 'themes.php'; $parent_file = 'themes.php';
function add_magic_quotes($array) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
function validate_file($file) { function validate_file($file) {
if ('..' == substr($file,0,2)) if ('..' == substr($file,0,2))
die (__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.')); die (__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
@ -31,13 +19,7 @@ function validate_file($file) {
return $file; return $file;
} }
if (!get_magic_quotes_gpc()) { $wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action','standalone','redirect','profile','error','warning','a','file');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) { if (!isset($$wpvar)) {
@ -57,9 +39,6 @@ switch($action) {
case 'update': case 'update':
$standalone = 1;
require_once('./admin-header.php');
if ($user_level < 5) { if ($user_level < 5) {
die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>')); die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
} }

View File

@ -1,20 +1,9 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __("Template &amp; file editing"); $title = __("Template &amp; file editing");
$parent_file = 'themes.php'; $parent_file = 'themes.php';
function add_magic_quotes($array) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
function validate_file($file) { function validate_file($file) {
if ('..' == substr($file,0,2)) if ('..' == substr($file,0,2))
die (__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.')); die (__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
@ -31,13 +20,7 @@ function validate_file($file) {
return $file; return $file;
} }
if (!get_magic_quotes_gpc()) { $wpvarstoreset = array('action','redirect','profile','error','warning','a','file', 'theme');
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$wpvarstoreset = array('action','standalone','redirect','profile','error','warning','a','file', 'theme');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) { if (!isset($$wpvar)) {
@ -57,9 +40,6 @@ switch($action) {
case 'update': case 'update':
$standalone = 1;
require_once("admin-header.php");
if ($user_level < 5) { if ($user_level < 5) {
die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>')); die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
} }

View File

@ -1,9 +1,7 @@
<?php <?php
require_once('admin.php');
if ( isset($_GET['action']) ) { if ( isset($_GET['action']) ) {
$standalone = 1;
require_once('admin-header.php');
check_admin_referer(); check_admin_referer();
if ('activate' == $_GET['action']) { if ('activate' == $_GET['action']) {
@ -21,15 +19,10 @@ if ( isset($_GET['action']) ) {
} }
} }
require_once('../wp-includes/wp-l10n.php');
$title = __('Manage Themes'); $title = __('Manage Themes');
$parent_file = 'themes.php'; $parent_file = 'themes.php';
require_once('admin-header.php'); require_once('admin-header.php');
if ($user_level < 9)
die (__('Sorry, you must be at least a level 9 user to modify themes.'));
?> ?>
<?php if ( ! validate_current_theme() ) : ?> <?php if ( ! validate_current_theme() ) : ?>
<div class="updated"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> <div class="updated"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
<?php elseif ( isset($activated) ) : ?> <?php elseif ( isset($activated) ) : ?>

View File

@ -1,24 +1,9 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Edit User'); $title = __('Edit User');
function add_magic_quotes($array) { $wpvarstoreset = array('action', 'redirect', 'profile', 'user_id');
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_POST = add_magic_quotes($_POST);
}
$wpvarstoreset = array('action', 'standalone', 'redirect', 'profile', 'user_id');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) { if (!isset($$wpvar)) {
@ -83,9 +68,6 @@ break;
case 'switchposts': case 'switchposts':
$standalone = 1;
require_once('admin-header.php');
check_admin_referer(); check_admin_referer();
/* TODO: Switch all posts from one user to another user */ /* TODO: Switch all posts from one user to another user */
@ -94,7 +76,6 @@ break;
default: default:
$standalone = 0;
include ('admin-header.php'); include ('admin-header.php');
$edituser = get_userdata($user_id); $edituser = get_userdata($user_id);

View File

@ -1,5 +1,5 @@
<?php <?php
require_once('../wp-includes/wp-l10n.php'); require_once('admin.php');
$title = __('Users'); $title = __('Users');
$parent_file = 'users.php'; $parent_file = 'users.php';
@ -22,9 +22,6 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
switch ($action) { switch ($action) {
case 'adduser': case 'adduser':
$standalone = 1;
require_once('admin-header.php');
check_admin_referer(); check_admin_referer();
function filter($value) { function filter($value) {
@ -100,10 +97,6 @@ case 'adduser':
break; break;
case 'promote': case 'promote':
$standalone = 1;
require_once('admin-header.php');
check_admin_referer(); check_admin_referer();
if (empty($_GET['prom'])) { if (empty($_GET['prom'])) {
@ -135,9 +128,6 @@ break;
case 'delete': case 'delete':
$standalone = 1;
require_once('admin-header.php');
check_admin_referer(); check_admin_referer();
$id = intval($_GET['id']); $id = intval($_GET['id']);
@ -176,7 +166,6 @@ break;
default: default:
$standalone = 0;
include ('admin-header.php'); include ('admin-header.php');
?> ?>

View File

@ -2235,4 +2235,14 @@ function wp_login($username, $password, $already_md5 = false) {
} }
} }
function is_plugin_page() {
global $plugin_page;
if (isset($plugin_page)) {
return true;
}
return false;
}
?> ?>