Skip to content

Commit

Permalink
Fix notices and phpdoc, props hakre, fixes #10758
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.automattic.com/wordpress/trunk@12284 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
azaozz committed Nov 26, 2009
1 parent 281f46e commit c3f7df6
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 42 deletions.
24 changes: 13 additions & 11 deletions wp-admin/includes/post.php
Expand Up @@ -933,10 +933,10 @@ function postbox_classes( $id, $page ) {
*
* @since unknown
*
* @param unknown_type $id
* @param unknown_type $title
* @param unknown_type $name
* @return unknown
* @param int|object $id Post ID or post object.
* @param string $title (optional) Title
* @param string $name (optional) Name
* @return array With two entries of type string
*/
function get_sample_permalink($id, $title = null, $name = null) {
$post = &get_post($id);
Expand All @@ -951,15 +951,15 @@ function get_sample_permalink($id, $title = null, $name = null) {
// drafts, so we will fake, that our post is published
if (in_array($post->post_status, array('draft', 'pending'))) {
$post->post_status = 'publish';
$post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID);
$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
}

$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);

// If the user wants to set a new name -- override the current one
// Note: if empty name is supplied -- use the title instead, see #6072
if (!is_null($name)) {
$post->post_name = sanitize_title($name? $name : $title, $post->ID);
$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
}

$post->filter = 'sample';
Expand Down Expand Up @@ -987,14 +987,16 @@ function get_sample_permalink($id, $title = null, $name = null) {
}

/**
* {@internal Missing Short Description}}
* sample permalink html
*
* intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
*
* @since unknown
*
* @param unknown_type $id
* @param unknown_type $new_title
* @param unknown_type $new_slug
* @return unknown
* @param int|object $id Post ID or post object.
* @param string $new_title (optional) New title
* @param string $new_slug (optional) New slug
* @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
*/
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
$post = &get_post($id);
Expand Down
4 changes: 2 additions & 2 deletions wp-admin/includes/widgets.php
Expand Up @@ -190,8 +190,8 @@ function wp_widget_control( $sidebar_args ) {
</div>
<input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($id_format); ?>" />
<input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
<input type="hidden" name="widget-width" class="widget-width" value="<?php echo esc_attr($control['width']); ?>" />
<input type="hidden" name="widget-height" class="widget-height" value="<?php echo esc_attr($control['height']); ?>" />
<input type="hidden" name="widget-width" class="widget-width" value="<?php if (isset( $control['width'] )) echo esc_attr($control['width']); ?>" />
<input type="hidden" name="widget-height" class="widget-height" value="<?php if (isset( $control['height'] )) echo esc_attr($control['height']); ?>" />
<input type="hidden" name="widget_number" class="widget_number" value="<?php echo esc_attr($widget_number); ?>" />
<input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
<input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" />
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/upload.php
Expand Up @@ -308,7 +308,7 @@

if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) : ?>
<select name='m'>
<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
<option value='0'><?php _e('Show all dates'); ?></option>
<?php
foreach ($arc_result as $arc_row) {
if ( $arc_row->yyear == 0 )
Expand Down
2 changes: 1 addition & 1 deletion wp-comments-post.php
Expand Up @@ -17,7 +17,7 @@

nocache_headers();

$comment_post_ID = (int) $_POST['comment_post_ID'];
$comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;

$status = $wpdb->get_row( $wpdb->prepare("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/author-template.php
Expand Up @@ -22,7 +22,7 @@
*/
function get_the_author($deprecated = '') {
global $authordata;
return apply_filters('the_author', $authordata->display_name);
return apply_filters('the_author', is_object($authordata) ? $authordata->display_name : null);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/comment.php
Expand Up @@ -1137,7 +1137,7 @@ function wp_new_comment( $commentdata ) {
else
$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_id'];

$commentdata['comment_parent'] = absint($commentdata['comment_parent']);
$commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
$parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
$commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;

Expand Down
11 changes: 9 additions & 2 deletions wp-includes/post.php
Expand Up @@ -1941,6 +1941,8 @@ function check_and_publish_future_post($post_id) {
/**
* Given the desired slug and some post details computes a unique slug for the post.
*
* @global wpdb $wpdb
* @global WP_Rewrite $wp_rewrite
* @param string $slug the desired slug (post_name)
* @param integer $post_ID
* @param string $post_status no uniqueness checks are made if the post is still draft or pending
Expand All @@ -1953,13 +1955,18 @@ function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_pa
return $slug;

global $wpdb, $wp_rewrite;

$feeds = $wp_rewrite->feeds;
if ( !is_array($feeds) )
$feeds = array();

$hierarchical_post_types = apply_filters('hierarchical_post_types', array('page'));
if ( 'attachment' == $post_type ) {
// Attachment slugs must be unique across all types.
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID));

if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) {
if ( $post_name_check || in_array($slug, $feeds) ) {
$suffix = 2;
do {
$alt_post_name = substr($slug, 0, 200-(strlen($suffix)+1)). "-$suffix";
Expand All @@ -1974,7 +1981,7 @@ function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_pa
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode("', '", esc_sql($hierarchical_post_types)) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID, $post_parent));

if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) {
if ( $post_name_check || in_array($slug, $feeds) ) {
$suffix = 2;
do {
$alt_post_name = substr($slug, 0, 200-(strlen($suffix)+1)). "-$suffix";
Expand Down
34 changes: 18 additions & 16 deletions wp-includes/vars.php
Expand Up @@ -37,22 +37,24 @@
// Simple browser detection
$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;

if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) {
$is_lynx = true;
} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) {
$is_chrome = true;
} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false ) {
$is_safari = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) {
$is_gecko = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false) {
$is_winIE = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
$is_macIE = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) {
$is_opera = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false) {
$is_NS4 = true;
if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) {
$is_lynx = true;
} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) {
$is_chrome = true;
} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false ) {
$is_safari = true;
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ) {
$is_gecko = true;
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false ) {
$is_winIE = true;
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false ) {
$is_macIE = true;
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ) {
$is_opera = true;
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false ) {
$is_NS4 = true;
}
}

if ( $is_safari && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') !== false )
Expand Down
14 changes: 7 additions & 7 deletions wp-trackback.php
Expand Up @@ -36,18 +36,18 @@ function trackback_response($error = 0, $error_message = '') {
// trackback is done by a POST
$request_array = 'HTTP_POST_VARS';

if ( !$_GET['tb_id'] ) {
if ( !isset($_GET['tb_id']) || !$_GET['tb_id'] ) {
$tb_id = explode('/', $_SERVER['REQUEST_URI']);
$tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
}

$tb_url = $_POST['url'];
$charset = $_POST['charset'];
$tb_url = isset($_POST['url']) ? $_POST['url'] : '';
$charset = isset($_POST['charset']) ? $_POST['charset'] : '';

// These three are stripslashed here so that they can be properly escaped after mb_convert_encoding()
$title = stripslashes($_POST['title']);
$excerpt = stripslashes($_POST['excerpt']);
$blog_name = stripslashes($_POST['blog_name']);
$title = isset($_POST['title']) ? stripslashes($_POST['title']) : '';
$excerpt = isset($_POST['excerpt']) ? stripslashes($_POST['excerpt']) : '';
$blog_name = isset($_POST['blog_name']) ? stripslashes($_POST['blog_name']) : '';

if ($charset)
$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
Expand All @@ -72,7 +72,7 @@ function trackback_response($error = 0, $error_message = '') {
if ( is_single() || is_page() )
$tb_id = $posts[0]->ID;

if ( !intval( $tb_id ) )
if ( !isset($tb_id) || !intval( $tb_id ) )
trackback_response(1, 'I really need an ID for this to work.');

if (empty($title) && empty($tb_url) && empty($blog_name)) {
Expand Down

0 comments on commit c3f7df6

Please sign in to comment.