Admin functions cleanup, and change how we do titles and parents in the backend

git-svn-id: http://svn.automattic.com/wordpress/trunk@4478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2006-11-18 06:09:48 +00:00
parent a0dcbfac4e
commit 07126127e6
35 changed files with 800 additions and 875 deletions

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@ get_admin_page_title();
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
<title><?php bloginfo('name') ?> &rsaquo; <?php echo wp_specialchars( strip_tags( $title ) ); ?> &#8212; WordPress</title>
<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />

View File

@ -82,9 +82,7 @@ if (isset($plugin_page)) {
include(ABSPATH . "wp-admin/import/$importer.php");
$parent_file = 'edit.php';
$submenu_file = 'import.php';
$title = __('Import');
if (! isset($_GET['noheader']))
require_once(ABSPATH . 'wp-admin/admin-header.php');

View File

@ -1,9 +1,6 @@
<?php
require_once('admin.php');
$title = __('Categories');
$parent_file = 'edit.php';
wp_reset_vars(array('action', 'cat'));
switch($action) {

View File

@ -1,7 +1,6 @@
<?php
require_once('admin.php');
$parent_file = 'edit.php';
$submenu_file = 'edit-comments.php';
wp_reset_vars(array('action'));

View File

@ -1,8 +1,6 @@
<?php
require_once('admin.php');
$title = __('Edit Comments');
$parent_file = 'edit-comments.php';
wp_enqueue_script( 'admin-comments' );
require_once('admin-header.php');

View File

@ -1,7 +1,5 @@
<?php
require_once('admin.php');
$title = __('Pages');
$parent_file = 'edit.php';
wp_enqueue_script( 'listman' );
require_once('admin-header.php');
?>

View File

@ -1,8 +1,6 @@
<?php
require_once('admin.php');
$title = __('Posts');
$parent_file = 'edit.php';
wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' );
require_once('admin-header.php');

View File

@ -1,7 +1,5 @@
<?php
require_once ('admin.php');
$title = __('Export');
$parent_file = 'edit.php';
if ( isset( $_GET['download'] ) )
export_wp();

View File

@ -1,7 +1,5 @@
<?php
require_once ('admin.php');
$title = __('Import');
$parent_file = 'edit.php';
require_once ('admin-header.php');
?>

View File

@ -1,7 +1,5 @@
<?php
require_once('admin.php');
$title = __('Dashboard');
$parent_file = 'index.php';
require_once('admin-header.php');
require_once (ABSPATH . WPINC . '/rss.php');

View File

@ -1,10 +1,7 @@
<?php
require_once('admin.php');
$title = __('Add Bookmark');
$this_file = 'link-manager.php';
$parent_file = 'link-manager.php';
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
'description', 'visible', 'target', 'category', 'link_id',

View File

@ -3,8 +3,6 @@
// Copyright (C) 2002 Mike Little -- mike@zed1.com
require_once('admin.php');
$parent_file = 'link-manager.php';
$title = __('Import Blogroll');
$this_file = 'link-import.php';
$step = $_POST['step'];

View File

@ -6,7 +6,6 @@
require_once ('admin.php');
$title = __('Manage Bookmarks');
$this_file = $parent_file = 'link-manager.php';
wp_enqueue_script( 'listman' );

View File

@ -3,7 +3,13 @@
$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
$self = preg_replace('|^.*/plugins/|i', '', $self);
get_admin_page_parent();
foreach ( $submenu as $parent => $subpages ) {
foreach ( $subpages as $page ) {
// 0 menu title, 1 cap, 2 file or slug, 3 page title
if ( $self == $page[2] )
$parent_file = $parent;
}
}
foreach ($menu as $item) {
$class = '';
@ -62,4 +68,4 @@ endif;
do_action('admin_notices');
?>
?>

View File

@ -4,26 +4,31 @@
// Menu item name
// The minimum level the user needs to access the item: between 0 and 10
// The URL of the item's file
$menu[0] = array(__('Dashboard'), 'read', 'index.php');
// Slug
$menu[0] = array(__('Dashboard'), 'read', 'index.php', 'home');
// So when people switch between write and manage they go to the appropiate page/post mode they were on
if ( strstr($_SERVER['REQUEST_URI'], 'edit-pages.php') )
$menu[5] = array(__('Write'), 'edit_pages', 'page-new.php');
$menu[5] = array(__('Write'), 'edit_pages', 'page-new.php', 'write');
else
$menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
$menu[5] = array(__('Write'), 'edit_posts', 'post-new.php', 'write');
if ( strstr($_SERVER['REQUEST_URI'], 'page-new.php') )
$menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php');
$menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php', 'manage');
else
$menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
$menu[10] = array(__('Manage'), 'edit_posts', 'edit.php', 'manage');
$menu[15] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
$menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php');
$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
$menu[15] = array(__('Comments'), 'edit_posts', 'edit-comments.php', 'comments');
$menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php', 'blogroll');
$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php', 'themes');
$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php', 'plugins');
if ( current_user_can('edit_users') )
$menu[35] = array(__('Users'), 'edit_users', 'users.php');
$menu[35] = array(__('Users'), 'edit_users', 'users.php', 'users');
else
$menu[35] = array(__('Profile'), 'read', 'profile.php');
$menu[40] = array(__('Options'), 'manage_options', 'options-general.php');
$menu[35] = array(__('Profile'), 'read', 'profile.php', 'profile');
$menu[40] = array(__('Options'), 'manage_options', 'options-general.php', 'options');
$submenu['post-new.php'][5] = array(__('Write Post'), 'edit_posts', 'post-new.php');
@ -69,9 +74,8 @@ $submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
$submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
// Create list of page plugin hook names.
foreach ($menu as $menu_page) {
foreach ( $menu as $menu_page )
$admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
}
$_wp_submenu_nopriv = array();
$_wp_menu_nopriv = array();
@ -128,12 +132,11 @@ foreach ( $menu as $id => $data ) {
}
}
unset($id);
unset( $id );
uksort($menu, "strnatcasecmp"); // make it all pretty
uksort( $menu, 'strnatcasecmp' );
if (! user_can_access_admin_page()) {
if ( !user_can_access_admin_page() )
wp_die( __('You do not have sufficient permissions to access this page.') );
}
?>
?>

View File

@ -1,8 +1,6 @@
<?php
require_once('admin.php');
$title = __('Moderate comments');
$parent_file = 'edit-comments.php';
wp_enqueue_script( 'admin-comments' );
wp_reset_vars(array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky'));

View File

@ -1,9 +1,5 @@
<?php
require_once('admin.php');
$title = __('Discussion Options');
$parent_file = 'options-general.php';
include('admin-header.php');
?>

View File

@ -1,9 +1,5 @@
<?php
require_once('./admin.php');
$title = __('General Options');
$parent_file = 'options-general.php';
include('./admin-header.php');
?>

View File

@ -1,9 +1,5 @@
<?php
require_once('admin.php');
$title = __('Miscellaneous Options');
$parent_file = 'options-general.php';
include('admin-header.php');
?>

View File

@ -1,9 +1,5 @@
<?php
require_once('admin.php');
$title = __('Permalink Options');
$parent_file = 'options-general.php';
function add_js() {
?>
<script type="text/javascript">

View File

@ -1,9 +1,5 @@
<?php
require_once('./admin.php');
$title = __('Privacy Options');
$parent_file = 'options-general.php';
include('./admin-header.php');
?>

View File

@ -1,9 +1,5 @@
<?php
require_once('admin.php');
$title = __('Reading Options');
$parent_file = 'options-general.php';
include('admin-header.php');
?>

View File

@ -1,9 +1,5 @@
<?php
require_once('admin.php');
$title = __('Writing Options');
$parent_file = 'options-general.php';
include('admin-header.php');
?>

View File

@ -1,10 +1,6 @@
<?php
require_once('admin.php');
$title = __('Options');
$this_file = 'options.php';
$parent_file = 'options-general.php';
wp_reset_vars(array('action'));
if ( !current_user_can('manage_options') )

View File

@ -1,7 +1,5 @@
<?php
require_once('admin.php');
$title = __('New Page');
$parent_file = 'post-new.php';
$editing = true;
wp_enqueue_script('prototype');
wp_enqueue_script('autosave');

View File

@ -1,9 +1,5 @@
<?php
require_once('admin.php');
$title = __("Edit Plugins");
$parent_file = 'plugins.php';
wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
$plugins = get_plugins();

View File

@ -29,7 +29,6 @@ if ( isset($_GET['action']) ) {
exit;
}
$title = __('Manage Plugins');
require_once('admin-header.php');
// Clean up options

View File

@ -1,7 +1,5 @@
<?php
require_once('admin.php');
$title = __('Create New Post');
$parent_file = 'post-new.php';
$editing = true;
wp_enqueue_script('prototype');
wp_enqueue_script('autosave');

View File

@ -1,12 +1,5 @@
<?php
require_once('admin.php');
$title = __('Profile');
if ( current_user_can('edit_users') )
$parent_file = 'users.php';
else
$parent_file = 'profile.php';
include_once('admin-header.php');
$profileuser = get_user_to_edit($user_ID);

View File

@ -1,8 +1,5 @@
<?php
require_once('admin.php');
$title = __('Template &amp; File Editing');
$parent_file = 'edit.php';
wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
$recents = get_option('recently_edited');

View File

@ -1,9 +1,5 @@
<?php
require_once('admin.php');
$title = __("Edit Themes");
$parent_file = 'themes.php';
wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme'));
$themes = get_themes();

View File

@ -18,8 +18,6 @@ if ( isset($_GET['action']) ) {
}
}
$title = __('Manage Themes');
$parent_file = 'themes.php';
require_once('admin-header.php');
?>

View File

@ -1,11 +1,6 @@
<?php
require_once('admin.php');
$title = __('Edit User');
if ( current_user_can('edit_users') )
$parent_file = 'users.php';
else
$parent_file = 'profile.php';
$submenu_file = 'users.php';
wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));

View File

@ -2,12 +2,6 @@
require_once('admin.php');
require_once( ABSPATH . WPINC . '/registration.php');
$title = __('Users');
if ( current_user_can('edit_users') )
$parent_file = 'users.php';
else
$parent_file = 'profile.php';
$action = $_REQUEST['action'];
$update = '';