WordPress.org

Make WordPress Core

Changeset 8589


Ignore:
Timestamp:
08/08/08 17:05:10 (7 years ago)
Author:
westi
Message:

Lots of fixes for Notices when WP_DEBUG is set. See #6669 props santosj.

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r8577 r8589  
    11<?php 
     2 
     3if ( ! isset( $post_ID ) ) 
     4    $post_ID = 0; 
    25 
    36$action = isset($action) ? $action : ''; 
    47if ( isset($_GET['message']) ) 
    58    $_GET['message'] = absint( $_GET['message'] ); 
    6 $messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) ); 
     9$messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( ( isset( $_GET['_wp_original_http_referer'] ) ? $_GET['_wp_original_http_referer'] : '') ) ) ); 
    710$messages[2] = __('Custom field updated.'); 
    811$messages[3] = __('Custom field deleted.'); 
     
    1518$notices[1] = __( 'There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>.' ); 
    1619 
    17 if ( !isset($post_ID) || 0 == $post_ID ) { 
     20if ( 0 == $post_ID ) { 
    1821    $form_action = 'post'; 
    1922    $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() 
     
    5558<?php 
    5659 
    57 if ( !isset($post_ID) || 0 == $post_ID) 
     60if ( 0 == $post_ID) 
    5861    wp_nonce_field('add-post'); 
    5962else 
     
    124127<?php endif; ?> 
    125128<?php 
    126 if ($post_ID) { 
     129if ( 0 != $post_ID ) { 
    127130    if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date 
    128131        $stamp = __('Scheduled for:<br />%1$s at %2$s'); 
     
    168171?> 
    169172<br class="clear" /> 
    170 <?php if ($post_ID): ?> 
     173<?php if ( 0 != $post_ID ): ?> 
    171174<?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { 
    172175    $last_user = get_userdata($last_id); 
     
    186189 
    187190<ul> 
    188 <?php if ($post_ID): ?> 
     191<?php if ( 0 != $post_ID ): ?> 
    189192<li><a href="edit.php?p=<?php echo $post_ID ?>"><?php _e('See Comments on this Post') ?></a></li> 
    190193<?php endif; ?> 
     
    346349function post_password_meta_box($post) { 
    347350?> 
    348 <p><label class="hidden" for="post_password"><?php _e('Password Protect This Post') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p> 
     351<p><label class="hidden" for="post_password"><?php _e('Password Protect This Post') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php if ( isset( $post->post_password ) ) : echo attribute_escape( $post->post_password ); endif; ?>" /></p> 
    349352<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this post and its comments.'); ?></p> 
    350353<?php 
     
    375378endif; 
    376379 
    377 if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : 
     380if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : 
    378381function post_revisions_meta_box($post) { 
    379382    wp_list_post_revisions(); 
  • trunk/wp-admin/edit-link-form.php

    r8025 r8589  
    1515    global $link; 
    1616 
    17     $link_rel = $link->link_rel; 
     17    $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; 
    1818    $rels = preg_split('/\s+/', $link_rel); 
    1919 
     
    9393<h3><label for="link_description"><?php _e('Description') ?></label></h3> 
    9494<div class="inside"> 
    95     <input type="text" name="link_description" size="30" tabindex="1" value="<?php echo $link->link_description; ?>" id="link_description" /><br /> 
     95    <input type="text" name="link_description" size="30" tabindex="1" value="<?php echo ( isset( $link->link_description ) ? $link->link_description : ''); ?>" id="link_description" /><br /> 
    9696    <?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?> 
    9797</div> 
     
    117117<div id="categories-all" class="ui-tabs-panel"> 
    118118    <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 
    119         <?php wp_link_category_checklist($link->link_id); ?> 
     119        <?php  
     120        if ( isset($link->link_id) ) 
     121            wp_link_category_checklist($link->link_id); 
     122        else 
     123            wp_link_category_checklist(); 
     124        ?> 
    120125    </ul> 
    121126</div> 
     
    138143<fieldset><legend class="hidden"><?php _e('Target') ?></legend> 
    139144<label for="link_target_blank" class="selectit"> 
    140 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> 
     145<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> 
    141146<code>_blank</code></label><br /> 
    142147<label for="link_target_top" class="selectit"> 
    143 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> 
     148<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> 
    144149<code>_top</code></label><br /> 
    145150<label for="link_target_none" class="selectit"> 
    146 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> /> 
     151<input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> /> 
    147152<?php _e('none') ?></label> 
    148153</fieldset> 
     
    157162    <tr> 
    158163        <th style="width: 20%;" scope="row"><label for="link_rel"><?php _e('rel:') ?></label></th> 
    159         <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td> 
     164        <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo ( isset( $link->link_rel ) ? $link->link_rel : ''); ?>" /></td> 
    160165    </tr> 
    161166    <tr> 
     
    270275    <tr class="form-field"> 
    271276        <th valign="top"  scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th> 
    272         <td><input type="text" name="link_image" id="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td> 
     277        <td><input type="text" name="link_image" id="link_image" size="50" value="<?php echo ( isset( $link->link_image ) ? $link->link_image : ''); ?>" style="width: 95%" /></td> 
    273278    </tr> 
    274279    <tr class="form-field"> 
    275280        <th valign="top"  scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th> 
    276         <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td> 
     281        <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo  ( isset( $link->link_rss ) ? $link->link_rss : ''); ?>" size="50" style="width: 95%" /></td> 
    277282    </tr> 
    278283    <tr class="form-field"> 
    279284        <th valign="top"  scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th> 
    280         <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td> 
     285        <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo  ( isset( $link->link_notes ) ? $link->link_notes : ''); ?></textarea></td> 
    281286    </tr> 
    282287    <tr class="form-field"> 
     
    286291            for ($r = 0; $r < 10; $r++) { 
    287292                echo('            <option value="'.$r.'" '); 
    288                 if ($link->link_rating == $r) 
     293                if ( isset($link->link_rating) && $link->link_rating == $r) 
    289294                    echo 'selected="selected"'; 
    290295                echo('>'.$r.'</option>'); 
  • trunk/wp-admin/edit-page-form.php

    r8530 r8589  
    11<?php 
     2 
     3if ( ! isset( $post_ID ) ) 
     4    $post_ID = 0; 
     5 
    26if ( isset($_GET['message']) ) 
    37    $_GET['message'] = absint( $_GET['message'] ); 
    4 $messages[1] = sprintf( __( 'Page updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) ); 
     8$messages[1] = sprintf( __( 'Page updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( ( isset( $_GET['_wp_original_http_referer'] ) ? $_GET['_wp_original_http_referer'] : '') ) ) ); 
    59$messages[2] = __('Custom field updated.'); 
    610$messages[3] = __('Custom field deleted.'); 
     
    1317$notices[1] = __( 'There is an autosave of this page that is more recent than the version below.  <a href="%s">View the autosave</a>.' ); 
    1418 
    15 if (!isset($post_ID) || 0 == $post_ID) { 
     19if ( 0 == $post_ID) { 
    1620    $form_action = 'post'; 
    1721    $nonce_action = 'add-page'; 
     
    103107 
    104108<?php 
    105 if ($post_ID) { 
     109if ( 0 != $post_ID ) { 
    106110    if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date 
    107111        $stamp = __('Scheduled for:<br />%1$s at %2$s'); 
     
    145149?> 
    146150<br class="clear" /> 
    147 <?php if ($post_ID): ?> 
     151<?php if ( 0 != $post_ID ) : ?> 
    148152<?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { 
    149153    $last_user = get_userdata($last_id); 
     
    163167 
    164168<ul> 
    165 <?php if ($post_ID): ?> 
     169<?php if ( 0 != $post_ID ) : ?> 
    166170<li><a href="edit-pages.php?page_id=<?php echo $post_ID ?>"><?php _e('See Comments on this Page') ?></a></li> 
    167171<?php endif; ?> 
     
    241245function page_password_meta_box($post){ 
    242246?> 
    243 <p><label class="hidden" for="post_password"><?php _e('Password Protect This Page') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p> 
     247<p><label class="hidden" for="post_password"><?php _e('Password Protect This Page') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php echo ( isset( $post->post_password ) ? attribute_escape( $post->post_password ) : '' ); ?>" /></p> 
    244248<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this page and its comments.'); ?></p> 
    245249<?php 
     
    305309 
    306310 
    307 if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : 
     311if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : 
    308312function page_revisions_meta_box($post) { 
    309313    wp_list_post_revisions(); 
  • trunk/wp-admin/edit-pages.php

    r8484 r8589  
    9090        continue; 
    9191 
    92     if ( $status == $_GET['post_status'] ) 
     92    if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] ) 
    9393        $class = ' class="current"'; 
    9494 
     
    120120 
    121121<?php 
    122 $pagenum = absint( $_GET['pagenum'] ); 
     122$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; 
    123123if ( empty($pagenum) ) 
    124124    $pagenum = 1; 
    125 if( !$per_page || $per_page < 0 ) 
     125if( ! isset( $per_page ) || $per_page < 0 ) 
    126126    $per_page = 20; 
    127127 
  • trunk/wp-admin/includes/media.php

    r8416 r8589  
    296296 
    297297function media_upload_image() { 
     298    $errors = array(); 
     299    $id = 0; 
     300 
    298301    if ( isset($_POST['html-upload']) && !empty($_FILES) ) { 
    299302        // Upload File button was clicked 
     
    360363 
    361364function media_upload_audio() { 
     365    $errors = array(); 
     366    $id = 0; 
     367 
    362368    if ( isset($_POST['html-upload']) && !empty($_FILES) ) { 
    363369        // Upload File button was clicked 
     
    400406 
    401407function media_upload_video() { 
     408    $errors = array(); 
     409    $id = 0; 
     410 
    402411    if ( isset($_POST['html-upload']) && !empty($_FILES) ) { 
    403412        // Upload File button was clicked 
     
    440449 
    441450function media_upload_file() { 
     451    $errors = array(); 
     452    $id = 0; 
     453 
    442454    if ( isset($_POST['html-upload']) && !empty($_FILES) ) { 
    443455        // Upload File button was clicked 
     
    480492 
    481493function media_upload_gallery() { 
     494    $errors = array(); 
     495 
    482496    if ( !empty($_POST) ) { 
    483497        $return = media_upload_form_handler(); 
     
    494508 
    495509function media_upload_library() { 
     510    $errors = array(); 
    496511    if ( !empty($_POST) ) { 
    497512        $return = media_upload_form_handler(); 
     
    11281143    $form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=library&post_id=$post_id"); 
    11291144 
    1130     $_GET['paged'] = intval($_GET['paged']); 
     1145    $_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0; 
    11311146    if ( $_GET['paged'] < 1 ) 
    11321147        $_GET['paged'] = 1; 
  • trunk/wp-admin/includes/post.php

    r8577 r8589  
    538538    if ( false === $q ) 
    539539        $q = $_GET; 
    540     $q['m']   = (int) $q['m']; 
    541     $q['cat'] = (int) $q['cat']; 
     540 
     541    $q['m']   = isset( $q['m'] ) ? (int) $q['m'] : 0; 
     542    $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; 
    542543    $q['post_type'] = 'attachment'; 
    543544    $q['post_status'] = 'any'; 
  • trunk/wp-admin/includes/template.php

    r8484 r8589  
    264264 
    265265function wp_link_category_checklist( $link_id = 0 ) { 
     266    $default = 1; 
     267 
    266268    if ( $link_id ) { 
    267269        $checked_categories = wp_get_link_cats($link_id); 
     
    379381    $posts_columns = array(); 
    380382    $posts_columns['cb'] = '<input type="checkbox" />'; 
    381     if ( 'draft' === $_GET['post_status'] ) 
    382         $posts_columns['modified'] = __('Modified'); 
    383     elseif ( 'pending' === $_GET['post_status'] ) 
    384         $posts_columns['modified'] = __('Submitted'); 
    385     else 
    386         $posts_columns['date'] = __('Date'); 
     383 
     384    $post_status = isset( $_GET['post_status'] ) ? $_GET['post_status'] : ''; 
     385 
     386    switch( $post_status ) { 
     387        case 'draft': 
     388            $posts_columns['modified'] = __('Modified'); 
     389            break; 
     390        case 'pending': 
     391            $posts_columns['modified'] = __('Submitted'); 
     392            break; 
     393        default: 
     394            $posts_columns['date'] = __('Date'); 
     395    } 
     396 
    387397    $posts_columns['title'] = __('Title'); 
    388398    $posts_columns['author'] = __('Author'); 
    389     if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) 
     399    if ( !in_array($post_status, array('pending', 'draft', 'future')) ) 
    390400        $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>'; 
    391401    $posts_columns['status'] = __('Status'); 
     
    12111221 
    12121222    foreach ( array('high', 'core', 'default', 'low') as $priority ) { 
     1223        if ( ! isset( $wp_meta_boxes[$page][$context][$priority] ) ) 
     1224            continue; 
     1225 
    12131226        foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { 
    12141227            if ( false === $box ) 
  • trunk/wp-admin/includes/theme.php

    r8051 r8589  
    3636            $template_data = implode( '', file( WP_CONTENT_DIR.$template )); 
    3737 
    38             preg_match( '|Template Name:(.*)$|mi', $template_data, $name ); 
    39             preg_match( '|Description:(.*)$|mi', $template_data, $description ); 
     38            $name = ''; 
     39            if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) 
     40                $name = $name[1]; 
    4041 
    41             $name = $name[1]; 
    42             $description = $description[1]; 
     42            $description = ''; 
     43            if( preg_match( '|Description:(.*)$|mi', $template_data, $description ) ) 
     44                $description = $description[1]; 
    4345 
    4446            if ( !empty( $name ) ) { 
  • trunk/wp-admin/includes/update.php

    r8540 r8589  
    88 
    99    $cur = get_option( 'update_core' ); 
     10    if ( ! isset( $cur->current ) ) 
     11        $cur->current = ''; 
     12 
     13    if ( ! isset( $cur->url ) ) 
     14        $cur->url = ''; 
    1015 
    1116    switch ( $cur->response ) { 
  • trunk/wp-admin/link-add.php

    r7961 r8589  
    1818?> 
    1919 
    20 <?php if ($_GET['added'] && '' != $_POST['link_name']) : ?> 
     20<?php if ( isset( $_GET['added'] ) && '' != $_POST['link_name']) : ?> 
    2121<div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div> 
    2222<?php endif; ?> 
  • trunk/wp-admin/link-manager.php

    r7883 r8589  
    8080<p id="post-search"> 
    8181    <label class="hidden" for="post-search-input"><?php _e( 'Search Links' ); ?>:</label> 
    82     <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" /> 
     82    <input type="text" id="post-search-input" name="s" value="<?php echo ( isset( $_GET['s'] ) ? attribute_escape(stripslashes($_GET['s'])) : ''); ?>" /> 
    8383    <input type="submit" value="<?php _e( 'Search Links' ); ?>" class="button" /> 
    8484</p> 
     
    151151    <tbody> 
    152152<?php 
     153    $i = 0; // It is slower incrementing an undefined and valueless variable. 
     154 
    153155    foreach ($links as $link) { 
    154156        $link = sanitize_bookmark($link); 
  • trunk/wp-admin/menu.php

    r8540 r8589  
    2828 
    2929$update_plugins = get_option( 'update_plugins' ); 
    30 $update_count = count( $update_plugins->response ); 
     30$update_count = 0; 
     31if ( isset( $update_plugins->response ) ) 
     32    $update_count = count( $update_plugins->response ); 
     33 
    3134$menu[35] = array( sprintf( __('Plugins %s'), "<span id='update-plugins' class='count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'activate_plugins', 'plugins.php'); 
    3235if ( current_user_can('edit_users') ) 
  • trunk/wp-includes/canonical.php

    r7990 r8589  
    184184        $redirect['host'] = $original['host']; 
    185185 
    186     if ( array($original['host'], $original['port'], $original['path'], $original['query']) !== array($redirect['host'], $redirect['port'], $redirect['path'], $redirect['query']) ) { 
     186    $compare_original = array($original['host'], $original['path']); 
     187 
     188    if ( isset( $original['port'] ) ) 
     189        $compare_original[] = $original['port']; 
     190 
     191    if ( isset( $original['query'] ) ) 
     192        $compare_original[] = $original['query']; 
     193 
     194    $compare_redirect = array($redirect['host'], $redirect['path']); 
     195 
     196    if ( isset( $redirect['port'] ) ) 
     197        $compare_redirect[] = $redirect['port']; 
     198 
     199    if ( isset( $redirect['query'] ) ) 
     200        $compare_redirect[] = $redirect['query']; 
     201 
     202    if ( $compare_original !== $compare_redirect ) { 
    187203        $redirect_url = $redirect['scheme'] . '://' . $redirect['host']; 
    188204        if ( isset($redirect['port']) ) 
  • trunk/wp-includes/formatting.php

    r8540 r8589  
    2828        $curl = $textarr[$i]; 
    2929 
    30         if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag 
     30        if ( !empty($curl) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag 
    3131            // static strings 
    3232            $curl = str_replace($static_characters, $static_replacements, $curl); 
  • trunk/wp-includes/functions.php

    r8572 r8589  
    14121412 
    14131413function wp_get_referer() { 
     1414    $ref = ''; 
    14141415    if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) 
    14151416        $ref = $_REQUEST['_wp_http_referer']; 
  • trunk/wp-includes/query.php

    r8572 r8589  
    473473            , 'category_name' 
    474474            , 'tag' 
     475            , 'cat' 
    475476            , 'tag_id' 
    476477            , 'author_name' 
Note: See TracChangeset for help on using the changeset viewer.