From 04786f267d9c028e2ceb80a5cfa3397d7dfc7ed6 Mon Sep 17 00:00:00 2001 From: rboren Date: Tue, 19 Oct 2004 03:03:06 +0000 Subject: [PATCH] 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 --- wp-admin/admin-functions.php | 61 ++++++++++++++++++++++++++-- wp-admin/admin-header.php | 59 +++++---------------------- wp-admin/admin.php | 71 +++++++++++++++++++++++++++++++++ wp-admin/categories.php | 31 +------------- wp-admin/edit-comments.php | 2 +- wp-admin/edit-pages.php | 3 +- wp-admin/edit.php | 2 +- wp-admin/link-add.php | 20 +--------- wp-admin/link-categories.php | 16 ++------ wp-admin/link-import.php | 5 +-- wp-admin/link-manager.php | 40 +------------------ wp-admin/menu-header.php | 51 +++++++++++++++++++++++ wp-admin/menu.php | 47 +--------------------- wp-admin/moderation.php | 22 +--------- wp-admin/options-discussion.php | 6 ++- wp-admin/options-general.php | 5 ++- wp-admin/options-head.php | 24 +---------- wp-admin/options-misc.php | 7 +++- wp-admin/options-permalink.php | 6 ++- wp-admin/options-reading.php | 6 ++- wp-admin/options-writing.php | 6 ++- wp-admin/options.php | 32 ++------------- wp-admin/plugins.php | 8 +--- wp-admin/post.php | 44 +------------------- wp-admin/profile.php | 21 +--------- wp-admin/templates.php | 25 +----------- wp-admin/theme-editor.php | 24 +---------- wp-admin/themes.php | 9 +---- wp-admin/user-edit.php | 23 +---------- wp-admin/users.php | 13 +----- wp-includes/functions.php | 10 +++++ 31 files changed, 254 insertions(+), 445 deletions(-) create mode 100644 wp-admin/admin.php create mode 100644 wp-admin/menu-header.php diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 0f9111bae..dd4d40cce 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -661,10 +661,65 @@ function user_can_access_admin_page() { return true; } -function add_options_menu($title, $access_level, $file) { +function get_admin_page_title() { + global $title; global $submenu; - - $submenu['options-general.php'][] = array($title, $access_level, $file); + 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; + + $file = basename($file); + + $submenu['options-general.php'][] = array($menu_title, $access_level, $file, $page_title); } ?> \ No newline at end of file diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index a3c9a6479..8c573a825 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -1,54 +1,10 @@ -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 + + <?php bloginfo('name') ?> › <?php echo $title; ?> — WordPress - - + + @@ -119,6 +75,9 @@ window.onload = blurry; \ No newline at end of file diff --git a/wp-admin/admin.php b/wp-admin/admin.php new file mode 100644 index 000000000..e903425c4 --- /dev/null +++ b/wp-admin/admin.php @@ -0,0 +1,71 @@ +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 \ No newline at end of file diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 04f7cfdb4..235ba2008 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -1,27 +1,10 @@ $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'); +$wpvarstoreset = array('action','cat'); for ($i=0; $iAsk for a promotion to your blog admin. :)"), get_settings('admin_email'))); diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 6d074bef6..21aed3465 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -1,5 +1,5 @@ \n"; } -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','cat_id', 'linkurl', 'name', 'image', +$wpvarstoreset = array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'); diff --git a/wp-admin/link-categories.php b/wp-admin/link-categories.php index 6a2972331..00a7e82cd 100644 --- a/wp-admin/link-categories.php +++ b/wp-admin/link-categories.php @@ -1,12 +1,12 @@ \n"; } -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','cat_id', 'linkurl', 'name', 'image', +$wpvarstoreset = array('action','cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'); @@ -83,9 +67,6 @@ if ('' != $_POST['move']) $action = 'move'; switch ($action) { case 'assign': { - $standalone = 1; - include_once('admin-header.php'); - check_admin_referer(); // check the current user's level first. @@ -116,9 +97,6 @@ switch ($action) { } case 'visibility': { - $standalone = 1; - include_once('admin-header.php'); - check_admin_referer(); // check the current user's level first. @@ -156,9 +134,6 @@ switch ($action) { } case 'move': { - $standalone = 1; - include_once('admin-header.php'); - check_admin_referer(); // check the current user's level first. @@ -180,9 +155,6 @@ switch ($action) { case 'Add': { - $standalone = 1; - include_once('admin-header.php'); - check_admin_referer(); $link_url = $_POST['linkurl']; @@ -230,9 +202,6 @@ switch ($action) { } $links_show_cat_id = $cat_id; - $standalone = 1; - include_once('admin-header.php'); - check_admin_referer(); $link_id = $_POST['link_id']; @@ -276,9 +245,6 @@ switch ($action) { case 'Delete': { - $standalone = 1; - include_once('admin-header.php'); - check_admin_referer(); $link_id = (int) $_GET['link_id']; @@ -303,7 +269,6 @@ switch ($action) { case 'linkedit': { - $standalone=0; $xfn = true; include_once ('admin-header.php'); 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_order_' . COOKIEHASH, $links_show_order, time()+600); - $standalone=0; include_once ("./admin-header.php"); if ($user_level < 5) { die(__("You do not have sufficient permissions to edit the links for this blog.")); diff --git a/wp-admin/menu-header.php b/wp-admin/menu-header.php new file mode 100644 index 000000000..7c1696e73 --- /dev/null +++ b/wp-admin/menu-header.php @@ -0,0 +1,51 @@ +
    += $item[1]) { + if ( +('upload.php' == $item[2] && +get_settings('use_fileupload') && +($user_level >= get_settings('fileupload_minlevel')) + ) || 'upload.php' != $item[2]) + echo "\n\t
  • {$item[0]}
  • "; + } +} + +?> +
  • +
+ + + + \ No newline at end of file diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 9b02ddf11..b03bf86b0 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -1,5 +1,3 @@ - -
    = $item[1]) { - if ( -('upload.php' == $item[2] && -get_settings('use_fileupload') && -($user_level >= get_settings('fileupload_minlevel')) - ) || 'upload.php' != $item[2]) - echo "\n\t
  • {$item[0]}
  • "; - } -} - -?> -
  • -
- - - - \ No newline at end of file +?> \ No newline at end of file diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php index 7555f1c0f..a35ec17fa 100644 --- a/wp-admin/moderation.php +++ b/wp-admin/moderation.php @@ -1,26 +1,9 @@ $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'); for ($i=0; $iYour level is not high enough to moderate comments.

')); } diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php index 837fa4491..dd87e9b58 100644 --- a/wp-admin/options-discussion.php +++ b/wp-admin/options-discussion.php @@ -1,8 +1,10 @@
diff --git a/wp-admin/options-head.php b/wp-admin/options-head.php index 032ea2cef..7fc54d6e7 100644 --- a/wp-admin/options-head.php +++ b/wp-admin/options-head.php @@ -1,24 +1,5 @@ $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'); for ($i=0; $i
- +

\ No newline at end of file diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php index c5e0f59cc..212665cc6 100644 --- a/wp-admin/options-misc.php +++ b/wp-admin/options-misc.php @@ -1,8 +1,11 @@
diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 4ed161291..ca783138a 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -1,8 +1,10 @@
diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php index d4901a9be..51af06172 100644 --- a/wp-admin/options-writing.php +++ b/wp-admin/options-writing.php @@ -1,8 +1,10 @@
diff --git a/wp-admin/options.php b/wp-admin/options.php index 610e54c85..5174f2fe9 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -1,28 +1,11 @@ $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'); +$wpvarstoreset = array('action'); for ($i=0; $i - - + include('admin-header.php'); ?>

All options

diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 958f361ad..acfc6a9f8 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -1,9 +1,7 @@ $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); -} +require_once('admin.php'); $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) { case 'post': - $standalone = 1; require_once('admin-header.php'); if (!user_can_create_draft($user_ID)) { @@ -183,7 +165,6 @@ case 'post': case 'edit': $title = __('Edit'); - $standalone = 0; require_once('admin-header.php'); $post = $post_ID = $p = (int) $_GET['post']; @@ -236,9 +217,6 @@ echo $content; case 'editpost': // die(var_dump('
', $_POST));
-	$standalone = 1;
-	require_once('./admin-header.php');
-
 	if (!isset($blog_ID)) {
 		$blog_ID = 1;
 	}
@@ -398,10 +376,6 @@ case 'editpost':
 	break;
 
 case 'delete':
-
-	$standalone = 1;
-	require_once('./admin-header.php');
-
 	check_admin_referer();
 
 	$post_id = intval($_GET['post']);
@@ -428,7 +402,6 @@ case 'delete':
 
 case 'editcomment':
 	$title = __('Edit Comment');
-	$standalone = 0;
 	$parent_file = 'edit.php';
 	require_once ('admin-header.php');
 
@@ -451,7 +424,6 @@ case 'editcomment':
 
 case 'confirmdeletecomment':
 
-$standalone = 0;
 require_once('./admin-header.php');
 
 $comment = $_GET['comment'];
@@ -487,9 +459,6 @@ break;
 
 case 'deletecomment':
 
-$standalone = 1;
-require_once('./admin-header.php');
-
 check_admin_referer();
 
 $comment = $_GET['comment'];
@@ -520,7 +489,6 @@ break;
 
 case 'unapprovecomment':
 
-$standalone = 1;
 require_once('./admin-header.php');
 
 check_admin_referer();
@@ -551,9 +519,6 @@ break;
 
 case 'mailapprovecomment':
 
-$standalone = 1;
-require_once('./admin-header.php');
-
 $comment = (int) $_GET['comment'];
 
 $commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID. Go back!'), 'edit.php'));
@@ -574,9 +539,6 @@ break;
 
 case 'approvecomment':
 
-$standalone = 1;
-require_once('./admin-header.php');
-
 $comment = $_GET['comment'];
 $p = $_GET['p'];
 if (isset($_GET['noredir'])) {
@@ -606,9 +568,6 @@ break;
 
 case 'editedcomment':
 
-	$standalone = 1;
-	require_once('./admin-header.php');
-
 	$comment_ID = $_POST['comment_ID'];
 	$comment_post_ID = $_POST['comment_post_ID'];
 	$newcomment_author = $_POST['newcomment_author'];
@@ -653,7 +612,6 @@ case 'editedcomment':
 	break;
 
 default:
-	$standalone = 0;
 	$title = __('Create New Post');
 	require_once ('./admin-header.php');
 
diff --git a/wp-admin/profile.php b/wp-admin/profile.php
index 4084ae439..b27cfd737 100644
--- a/wp-admin/profile.php
+++ b/wp-admin/profile.php
@@ -1,27 +1,10 @@
  $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');
+$wpvarstoreset = array('action','redirect','profile','user');
 for ($i=0; $i $v) {
-		if (is_array($v)) {
-			$array[$k] = add_magic_quotes($v);
-		} else {
-			$array[$k] = addslashes($v);
-		}
-	}
-	return $array;
-} 
-
 function validate_file($file) {
 	if ('..' == substr($file,0,2))
 		die (__('Sorry, can’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;
 }
 
-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','error','warning','a','file');
+$wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
 for ($i=0; $iYou have do not have sufficient permissions to edit templates for this blog.

')); } diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php index d7eebb0db..8df1f805f 100644 --- a/wp-admin/theme-editor.php +++ b/wp-admin/theme-editor.php @@ -1,20 +1,9 @@ $v) { - if (is_array($v)) { - $array[$k] = add_magic_quotes($v); - } else { - $array[$k] = addslashes($v); - } - } - return $array; -} - function validate_file($file) { if ('..' == substr($file,0,2)) die (__('Sorry, can’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; } -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','error','warning','a','file', 'theme'); +$wpvarstoreset = array('action','redirect','profile','error','warning','a','file', 'theme'); for ($i=0; $iYou have do not have sufficient permissions to edit templates for this blog.

')); } diff --git a/wp-admin/themes.php b/wp-admin/themes.php index ec605fa5d..a486920cc 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -1,9 +1,7 @@ -

diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php index 1166621f9..3524e4454 100644 --- a/wp-admin/user-edit.php +++ b/wp-admin/user-edit.php @@ -1,24 +1,9 @@ $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'); +$wpvarstoreset = array('action', 'redirect', 'profile', 'user_id'); for ($i=0; $i diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 8a73e7772..b1add00d4 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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; +} + ?>