Notice fixing for wp-includes. See #5607 props filosofo.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6592 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2008-01-10 20:51:07 +00:00
parent db44305ce1
commit 1aaec4ff30
8 changed files with 46 additions and 29 deletions

View File

@ -184,9 +184,7 @@ function get_bookmarks($args = '') {
$recently_updated_test = '';
}
if ($show_updated) {
$get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
}
$get_updated = ( $show_updated ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : '';
$orderby = strtolower($orderby);
$length = '';

View File

@ -990,9 +990,10 @@ function wp_original_referer_field() {
function wp_get_referer() {
foreach ( array( $_REQUEST['_wp_http_referer'], $_SERVER['HTTP_REFERER'] ) as $ref )
if ( !empty( $ref ) )
return $ref;
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
return $_REQUEST['_wp_http_referer'];
else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
return $_SERVER['HTTP_REFERER'];
return false;
}

View File

@ -142,7 +142,7 @@ function _get_page_link( $id = false ) {
$pagestruct = $wp_rewrite->get_page_permastruct();
if ( '' != $pagestruct && 'draft' != $post->post_status ) {
if ( '' != $pagestruct && isset($post->post_status) && 'draft' != $post->post_status ) {
$link = get_page_uri($id);
$link = str_replace('%pagename%', $link, $pagestruct);
$link = get_option('home') . "/$link";
@ -597,7 +597,7 @@ function get_pagenum_link($pagenum = 1) {
$request = remove_query_arg( 'paged' );
$home_root = parse_url(get_option('home'));
$home_root = $home_root['path'];
$home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
$home_root = preg_quote( trailingslashit( $home_root ), '|' );
$request = preg_replace('|^'. $home_root . '|', '', $request);

View File

@ -56,7 +56,7 @@ function get_the_title( $id = 0 ) {
$title = $post->post_title;
if ( !empty($post->post_password) )
$title = sprintf(__('Protected: %s'), $title);
else if ( 'private' == $post->post_status )
else if ( isset($post->post_status) && 'private' == $post->post_status )
$title = sprintf(__('Private: %s'), $title);
return apply_filters( 'the_title', $title );
@ -443,6 +443,8 @@ function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
$post->iconsize = array($imagesize[0], $imagesize[1]);
$constraint = '';
}
} else {
$constraint = '';
}
$post_title = attribute_escape($post->post_title);

View File

@ -157,12 +157,13 @@ function get_extended($post) {
*/
function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
global $wpdb;
$null = null;
if ( empty($post) ) {
if ( isset($GLOBALS['post']) )
$_post = & $GLOBALS['post'];
else
return null;
return $null;
} elseif ( is_object($post) ) {
wp_cache_add($post->ID, $post, 'posts');
$_post = &$post;

View File

@ -67,9 +67,11 @@ function url_to_postid($url) {
$url = apply_filters('url_to_postid', $url);
// First, check to see if there is a 'p=N' or 'page_id=N' to match against
preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
$id = intval($values[2]);
if ( $id ) return $id;
if ( preg_match('#[?&](p|page_id)=(\d+)#', $url, $values) ) {
$id = absint($values[2]);
if ($id)
return $id;
}
// Check to see if we are using rewrite rules
$rewrite = $wp_rewrite->wp_rewrite_rules();
@ -591,6 +593,8 @@ class WP_Rewrite {
for ($i = 0; $i < $num_tokens; ++$i) {
if (0 < $i) {
$queries[$i] = $queries[$i - 1] . '&';
} else {
$queries[$i] = '';
}
$query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1);
@ -628,7 +632,7 @@ class WP_Rewrite {
//make a list of tags, and store how many there are in $num_toks
$num_toks = preg_match_all('/%.+?%/', $struct, $toks);
//get the 'tagname=$matches[i]'
$query = $queries[$num_toks - 1];
$query = ( isset($queries) && is_array($queries) ) ? $queries[$num_toks - 1] : '';
//set up $ep_mask_specific which is used to match more specific URL types
switch ($dirs[$j]) {
@ -721,7 +725,7 @@ class WP_Rewrite {
$subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
//do endpoints for attachments
if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
if (! empty($endpoint) ) { foreach ($ep_query_append as $regex => $ep) {
if ($ep[0] & EP_ATTACHMENT) {
$rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
$rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);

View File

@ -506,6 +506,7 @@ function get_term_to_edit( $id, $taxonomy ) {
*/
function &get_terms($taxonomies, $args = '') {
global $wpdb;
$empty_array = array();
$single_taxonomy = false;
if ( !is_array($taxonomies) ) {
@ -545,13 +546,13 @@ function &get_terms($taxonomies, $args = '') {
if ( $child_of ) {
$hierarchy = _get_term_hierarchy($taxonomies[0]);
if ( !isset($hierarchy[$child_of]) )
return array();
return $empty_array;
}
if ( $parent ) {
$hierarchy = _get_term_hierarchy($taxonomies[0]);
if ( !isset($hierarchy[$parent]) )
return array();
return $empty_array;
}
$key = md5( serialize( $args ) . serialize( $taxonomies ) );
@ -1581,7 +1582,8 @@ function clean_term_cache($ids, $taxonomy = '') {
* @return bool|array Empty array if $terms found, but not $taxonomy. False if nothing is in cache for $taxonomy and $id.
*/
function &get_object_term_cache($id, $taxonomy) {
return wp_cache_get($id, "{$taxonomy}_relationships");
$cache = wp_cache_get($id, "{$taxonomy}_relationships");
return $cache;
}
/**
@ -1727,14 +1729,15 @@ function _get_term_hierarchy($taxonomy) {
* @return array Empty if $terms is empty else returns full list of child terms.
*/
function &_get_term_children($term_id, $terms, $taxonomy) {
$empty_array = array();
if ( empty($terms) )
return array();
return $empty_array;
$term_list = array();
$has_children = _get_term_hierarchy($taxonomy);
if ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) )
return array();
return $empty_array;
foreach ( $terms as $term ) {
$use_id = false;

View File

@ -76,9 +76,16 @@ function get_theme_data( $theme_file ) {
preg_match( '|Theme Name:(.*)$|mi', $theme_data, $theme_name );
preg_match( '|Theme URI:(.*)$|mi', $theme_data, $theme_uri );
preg_match( '|Description:(.*)$|mi', $theme_data, $description );
preg_match( '|Author:(.*)$|mi', $theme_data, $author_name );
preg_match( '|Author URI:(.*)$|mi', $theme_data, $author_uri );
preg_match( '|Template:(.*)$|mi', $theme_data, $template );
if ( preg_match( '|Author URI:(.*)$|mi', $theme_data, $author_uri ) )
$author_uri = clean_url( trim( $author_uri[1]) );
else
$author_uti = '';
if ( preg_match( '|Template:(.*)$|mi', $theme_data, $template ) )
$template = wp_kses( trim( $template[1], $themes_allowed_tags ) );
else
$template = '';
if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) )
$version = wp_kses( trim( $version[1] ), $themes_allowed_tags );
@ -98,15 +105,16 @@ function get_theme_data( $theme_file ) {
$name = $theme = wp_kses( trim( $theme_name[1] ), $themes_allowed_tags );
$theme_uri = clean_url( trim( $theme_uri[1] ) );
$description = wptexturize( wp_kses( trim( $description[1] ), $themes_allowed_tags ) );
$template = wp_kses( trim( $template[1] ), $themes_allowed_tags );
$author_uri = clean_url( trim( $author_uri[1] ) );
if ( empty( $author_uri[1] ) ) {
if ( preg_match( '|Author:(.*)$|mi', $theme_data, $author_name ) ) {
if ( empty( $author_uri ) ) {
$author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags );
} else {
$author = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __( 'Visit author homepage' ), wp_kses( trim( $author_name[1] ), $themes_allowed_tags ) );
}
} else {
$author = __('Anonymous');
}
return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Status' => $status, 'Tags' => $tags );
}