Notice fixes. Props DD32. see #7509

git-svn-id: http://svn.automattic.com/wordpress/trunk@8646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-08-14 17:00:37 +00:00
parent 7f894ae416
commit 113c014920
12 changed files with 56 additions and 40 deletions

View File

@ -56,13 +56,13 @@ if ( is_single() ) {
$post_status_label = _c('Manage Posts|manage posts header'); $post_status_label = _c('Manage Posts|manage posts header');
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) )
$post_status_label = $post_stati[$_GET['post_status']][1]; $post_status_label = $post_stati[$_GET['post_status']][1];
if ( $post_listing_pageable && !is_archive() && !is_search() ) //if ( $post_listing_pageable && !is_archive() && !is_search() ) //Unreachable code: $post_listing_pageable is undefined, Similar code in upload.php
$h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_status_label) : sprintf(__('Latest %s'), $post_status_label); // $h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_status_label) : sprintf(__('Latest %s'), $post_status_label);
else //else
$h2_noun = $post_status_label; $h2_noun = $post_status_label;
// Use $_GET instead of is_ since they can override each other // Use $_GET instead of is_ since they can override each other
$h2_author = ''; $h2_author = '';
$_GET['author'] = (int) $_GET['author']; $_GET['author'] = isset($_GET['author']) ? (int) $_GET['author'] : 0;
if ( $_GET['author'] != 0 ) { if ( $_GET['author'] != 0 ) {
if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion
$h2_author = ' ' . __('by other authors'); $h2_author = ' ' . __('by other authors');
@ -93,7 +93,7 @@ foreach ( $post_stati as $status => $label ) {
if ( empty( $num_posts->$status ) ) if ( empty( $num_posts->$status ) )
continue; continue;
if ( $status == $_GET['post_status'] ) if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
$class = ' class="current"'; $class = ' class="current"';
$status_links[] = "<li><a href='edit.php?post_status=$status' $class>" . $status_links[] = "<li><a href='edit.php?post_status=$status' $class>" .
@ -146,16 +146,18 @@ $arc_result = $wpdb->get_results( $arc_query );
$month_count = count($arc_result); $month_count = count($arc_result);
if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
$m = isset($_GET['m']) ? (int)$_GET['m'] : 0;
?>
<select name='m'> <select name='m'>
<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option> <option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
<?php <?php
foreach ($arc_result as $arc_row) { foreach ($arc_result as $arc_row) {
if ( $arc_row->yyear == 0 ) if ( $arc_row->yyear == 0 )
continue; continue;
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) if ( $arc_row->yyear . $arc_row->mmonth == $m )
$default = ' selected="selected"'; $default = ' selected="selected"';
else else
$default = ''; $default = '';

View File

@ -490,8 +490,8 @@ function wp_edit_posts_query( $q = false ) {
global $wpdb; global $wpdb;
if ( false === $q ) if ( false === $q )
$q = $_GET; $q = $_GET;
$q['m'] = (int) $q['m']; $q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
$q['cat'] = (int) $q['cat']; $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
$post_stati = array( // array( adj, noun ) $post_stati = array( // array( adj, noun )
'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')), 'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')),
'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')), 'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')),
@ -510,10 +510,10 @@ function wp_edit_posts_query( $q = false ) {
$post_status_q .= '&perm=readable'; $post_status_q .= '&perm=readable';
} }
if ( 'pending' === $q['post_status'] ) { if ( isset($q['post_status']) && 'pending' === $q['post_status'] ) {
$order = 'ASC'; $order = 'ASC';
$orderby = 'modified'; $orderby = 'modified';
} elseif ( 'draft' === $q['post_status'] ) { } elseif ( isset($q['post_status']) && 'draft' === $q['post_status'] ) {
$order = 'DESC'; $order = 'DESC';
$orderby = 'modified'; $orderby = 'modified';
} else { } else {

View File

@ -343,9 +343,9 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) {
function wp_manage_posts_columns() { function wp_manage_posts_columns() {
$posts_columns = array(); $posts_columns = array();
$posts_columns['cb'] = '<input type="checkbox" />'; $posts_columns['cb'] = '<input type="checkbox" />';
if ( 'draft' === $_GET['post_status'] ) if ( isset($_GET['post_status']) && 'draft' === $_GET['post_status'] )
$posts_columns['modified'] = __('Modified'); $posts_columns['modified'] = __('Modified');
elseif ( 'pending' === $_GET['post_status'] ) elseif ( isset($_GET['post_status']) && 'pending' === $_GET['post_status'] )
$posts_columns['modified'] = __('Submitted'); $posts_columns['modified'] = __('Submitted');
else else
$posts_columns['date'] = __('Date'); $posts_columns['date'] = __('Date');
@ -353,7 +353,7 @@ function wp_manage_posts_columns() {
$posts_columns['author'] = __('Author'); $posts_columns['author'] = __('Author');
$posts_columns['categories'] = __('Categories'); $posts_columns['categories'] = __('Categories');
$posts_columns['tags'] = __('Tags'); $posts_columns['tags'] = __('Tags');
if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
$posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>'; $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
$posts_columns['status'] = __('Status'); $posts_columns['status'] = __('Status');
$posts_columns = apply_filters('manage_posts_columns', $posts_columns); $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
@ -1092,6 +1092,7 @@ function the_attachment_links( $id = false ) {
function wp_dropdown_roles( $default = false ) { function wp_dropdown_roles( $default = false ) {
global $wp_roles; global $wp_roles;
$p = '';
$r = ''; $r = '';
foreach( $wp_roles->role_names as $role => $name ) { foreach( $wp_roles->role_names as $role => $name ) {
$name = translate_with_context($name); $name = translate_with_context($name);

View File

@ -44,7 +44,7 @@ function get_page_templates() {
$description = $description[1]; $description = $description[1];
if ( !empty( $name ) ) { if ( !empty( $name ) ) {
$page_templates[trim( $name )] = basename( $template ); $page_templates[trim( $name )] = theme_basename( $template );
} }
} }
} }

View File

@ -301,6 +301,7 @@ class WP_User_Search {
var $total_users_for_query = 0; var $total_users_for_query = 0;
var $too_many_total_users = false; var $too_many_total_users = false;
var $search_errors; var $search_errors;
var $paging_text;
function WP_User_Search ($search_term = '', $page = '', $role = '') { // constructor function WP_User_Search ($search_term = '', $page = '', $role = '') { // constructor
$this->search_term = $search_term; $this->search_term = $search_term;

View File

@ -12,7 +12,7 @@ foreach( array('activate-selected', 'deactivate-selected', 'delete-selected', 'c
if( isset($_GET['action']) ) if( isset($_GET['action']) )
$action = $_GET['action']; $action = $_GET['action'];
$plugin = $_REQUEST['plugin']; $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
if( !empty($action) ) { if( !empty($action) ) {
switch( $action ) { switch( $action ) {

View File

@ -8,7 +8,7 @@ if ( !current_user_can('edit_users') )
$title = __('Users'); $title = __('Users');
$parent_file = 'users.php'; $parent_file = 'users.php';
$action = $_REQUEST['action']; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$update = ''; $update = '';
if ( empty($action) ) { if ( empty($action) ) {
@ -25,6 +25,7 @@ if ( empty($_REQUEST) ) {
$referer = '<input type="hidden" name="wp_http_referer" value="' . attribute_escape($redirect) . '" />'; $referer = '<input type="hidden" name="wp_http_referer" value="' . attribute_escape($redirect) . '" />';
} else { } else {
$redirect = 'users.php'; $redirect = 'users.php';
$referer = '';
} }
switch ($action) { switch ($action) {
@ -192,15 +193,19 @@ default:
include('admin-header.php'); include('admin-header.php');
$usersearch = isset($_GET['usersearch']) ? $_GET['usersearch'] : null;
$userspage = isset($_GET['userspage']) ? $_GET['userspage'] : null;
$role = isset($_GET['role']) ? $_GET['role'] : null;
// Query the users // Query the users
$wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage'], $_GET['role']); $wp_user_search = new WP_User_Search($usersearch, $userspage, $role);
if ( isset($_GET['update']) ) : if ( isset($_GET['update']) ) :
switch($_GET['update']) { switch($_GET['update']) {
case 'del': case 'del':
case 'del_many': case 'del_many':
?> ?>
<?php $delete_count = (int) $_GET['delete_count']; ?> <?php $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0; ?>
<div id="message" class="updated fade"><p><?php printf(__ngettext('%s user deleted', '%s users deleted', $delete_count), $delete_count); ?></p></div> <div id="message" class="updated fade"><p><?php printf(__ngettext('%s user deleted', '%s users deleted', $delete_count), $delete_count); ?></p></div>
<?php <?php
break; break;
@ -229,7 +234,7 @@ default:
} }
endif; ?> endif; ?>
<?php if ( is_wp_error( $errors ) ) : ?> <?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
<div class="error"> <div class="error">
<ul> <ul>
<?php <?php
@ -265,22 +270,22 @@ foreach ( (array) $users_of_blog as $b_user ) {
unset($users_of_blog); unset($users_of_blog);
$current_role = false; $current_role = false;
$class = empty($_GET['role']) ? ' class="current"' : ''; $class = empty($role) ? ' class="current"' : '';
$role_links[] = "<li><a href=\"users.php\"$class>" . __('All Users') . "</a>"; $role_links[] = "<li><a href=\"users.php\"$class>" . __('All Users') . "</a>";
foreach ( $wp_roles->get_names() as $role => $name ) { foreach ( $wp_roles->get_names() as $this_role => $name ) {
if ( !isset($avail_roles[$role]) ) if ( !isset($avail_roles[$role]) )
continue; continue;
$class = ''; $class = '';
if ( $role == $_GET['role'] ) { if ( $this_role == $role ) {
$current_role = $_GET['role']; $current_role = $role;
$class = ' class="current"'; $class = ' class="current"';
} }
$name = translate_with_context($name); $name = translate_with_context($name);
$name = sprintf(_c('%1$s (%2$s)|user role with count'), $name, $avail_roles[$role]); $name = sprintf(_c('%1$s (%2$s)|user role with count'), $name, $avail_roles[$this_role]);
$role_links[] = "<li><a href=\"users.php?role=$role\"$class>" . $name . '</a>'; $role_links[] = "<li><a href=\"users.php?role=$this_role\"$class>" . $name . '</a>';
} }
echo implode(' |</li>', $role_links) . '</li>'; echo implode(' |</li>', $role_links) . '</li>';
unset($role_links); unset($role_links);
@ -369,13 +374,11 @@ foreach ( $wp_user_search->get_results() as $userid ) {
</div> </div>
<?php <?php
if ( is_wp_error($add_user_errors) ) { foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) {
foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) { $var = 'new_' . $var;
$var = 'new_' . $var; $$var = isset($_REQUEST[$formpost]) ? attribute_escape(stripslashes($_REQUEST[$formpost])) : '';
$$var = attribute_escape(stripslashes($_REQUEST[$formpost]));
}
unset($name);
} }
unset($name);
?> ?>
<br class="clear" /> <br class="clear" />
@ -384,7 +387,7 @@ foreach ( $wp_user_search->get_results() as $userid ) {
<div class="wrap"> <div class="wrap">
<h2 id="add-new-user"><?php _e('Add New User') ?></h2> <h2 id="add-new-user"><?php _e('Add New User') ?></h2>
<?php if ( is_wp_error( $add_user_errors ) ) : ?> <?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?>
<div class="error"> <div class="error">
<?php <?php
foreach ( $add_user_errors->get_error_messages() as $message ) foreach ( $add_user_errors->get_error_messages() as $message )

View File

@ -138,6 +138,9 @@ class WP_User {
var $roles = array(); var $roles = array();
var $allcaps = array(); var $allcaps = array();
var $first_name = '';
var $last_name = '';
function WP_User( $id, $name = '' ) { function WP_User( $id, $name = '' ) {
if ( empty( $id ) && empty( $name ) ) if ( empty( $id ) && empty( $name ) )

View File

@ -110,7 +110,8 @@ class WP {
$query = preg_replace("!^.+\?!", '', $query); $query = preg_replace("!^.+\?!", '', $query);
// Substitute the substring matches into the query. // Substitute the substring matches into the query.
eval("\$query = \"" . addslashes($query) . "\";"); eval("@\$query = \"" . addslashes($query) . "\";");
$this->matched_query = $query; $this->matched_query = $query;
// Parse the query. // Parse the query.

View File

@ -1935,6 +1935,7 @@ function get_page_by_path($page_path, $output = OBJECT) {
$page_paths = '/' . trim($page_path, '/'); $page_paths = '/' . trim($page_path, '/');
$leaf_path = sanitize_title(basename($page_paths)); $leaf_path = sanitize_title(basename($page_paths));
$page_paths = explode('/', $page_paths); $page_paths = explode('/', $page_paths);
$full_path = '';
foreach( (array) $page_paths as $pathdir) foreach( (array) $page_paths as $pathdir)
$full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);

View File

@ -686,7 +686,7 @@ class WP_Query {
if ( empty($qv['taxonomy']) || empty($qv['term']) ) { if ( empty($qv['taxonomy']) || empty($qv['term']) ) {
$this->is_tax = false; $this->is_tax = false;
foreach ( $GLOBALS['wp_taxonomies'] as $t ) { foreach ( $GLOBALS['wp_taxonomies'] as $t ) {
if ( isset($t->query_var) && '' != $qv[$t->query_var] ) { if ( isset($t->query_var) && isset($qv[$t->query_var]) && '' != $qv[$t->query_var] ) {
$this->is_tax = true; $this->is_tax = true;
break; break;
} }

View File

@ -297,11 +297,15 @@ function get_objects_in_term( $terms, $taxonomies, $args = array() ) {
function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') { function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
global $wpdb; global $wpdb;
if ( empty($term) ) if ( empty($term) ) {
return null; $error = new WP_Error('invalid_term', __('Empty Term'));
return $error;
}
if ( ! is_taxonomy($taxonomy) ) if ( ! is_taxonomy($taxonomy) ) {
return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); $error = new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
return $error;
}
if ( is_object($term) ) { if ( is_object($term) ) {
wp_cache_add($term->term_id, $term, $taxonomy); wp_cache_add($term->term_id, $term, $taxonomy);