Make WordPress Core

Ticket #6670: links.patch

File links.patch, 7.7 KB (added by simonwheatley, 17 years ago)

Patch to reduce Notices when creating, editing and managing links

  • wp-admin/edit-link-form.php

    diff -urN wordpress/wp-admin/edit-link-form.php site/wp-admin/edit-link-form.php
    old new  
    1414function xfn_check($class, $value = '', $deprecated = '') {
    1515        global $link;
    1616
    17         $link_rel = $link->link_rel;
     17        $link_rel = @ $link->link_rel;
    1818        $rels = preg_split('/\s+/', $link_rel);
    1919
    2020        if ('' != $value && in_array($value, $rels) ) {
     
    9292<div id="descriptiondiv" class="stuffbox">
    9393<h3><?php _e('Description') ?></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 @ $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>
    9898</div>
     
    139139<h3><?php _e('Target') ?></h3>
    140140<div class="inside">
    141141<label for="link_target_blank" class="selectit">
    142 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
     142<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo((@ $link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
    143143<code>_blank</code></label><br />
    144144<label for="link_target_top" class="selectit">
    145 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
     145<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo((@ $link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
    146146<code>_top</code></label><br />
    147147<label for="link_target_none" class="selectit">
    148 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
     148<input id="link_target_none" type="radio" name="link_target" value="" <?php echo((@ $link->link_target == '') ? 'checked="checked"' : ''); ?> />
    149149<?php _e('none') ?></label>
    150150<p><?php _e('Choose the frame your link targets. Essentially this means if you choose <code>_blank</code> your link will open in a new window.'); ?></p>
    151151</div>
     
    157157<table class="editform" style="width: 100%;" cellspacing="2" cellpadding="5">
    158158        <tr>
    159159                <th style="width: 20%;" scope="row"><?php _e('rel:') ?></th>
    160                 <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
     160                <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo @ $link->link_rel; ?>" /></td>
    161161        </tr>
    162162        <tr>
    163163                <td colspan="2">
     
    270270<table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
    271271        <tr class="form-field">
    272272                <th valign="top"  scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
    273                 <td><input type="text" name="link_image" id="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
     273                <td><input type="text" name="link_image" id="link_image" size="50" value="<?php echo @ $link->link_image; ?>" style="width: 95%" /></td>
    274274        </tr>
    275275        <tr class="form-field">
    276276                <th valign="top"  scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
    277                 <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
     277                <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo @ $link->link_rss; ?>" size="50" style="width: 95%" /></td>
    278278        </tr>
    279279        <tr class="form-field">
    280280                <th valign="top"  scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
    281                 <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
     281                <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo @ $link->link_notes; ?></textarea></td>
    282282        </tr>
    283283        <tr class="form-field">
    284284                <th valign="top"  scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
     
    286286                <?php
    287287                        for ($r = 0; $r < 10; $r++) {
    288288                                echo('            <option value="'.$r.'" ');
    289                                 if ($link->link_rating == $r)
     289                                if (isset($link->link_rating) && $link->link_rating == $r)
    290290                                        echo 'selected="selected"';
    291291                                echo('>'.$r.'</option>');
    292292                        }
  • wp-admin/includes/bookmark.php

    diff -urN wordpress/wp-admin/includes/bookmark.php site/wp-admin/includes/bookmark.php
    old new  
    1313        $_POST['link_name'] = wp_specialchars( $_POST['link_name'] );
    1414        $_POST['link_image'] = wp_specialchars( $_POST['link_image'] );
    1515        $_POST['link_rss'] = clean_url($_POST['link_rss']);
    16         if ( 'N' != $_POST['link_visible'] )
     16        if ( 'N' != @ $_POST['link_visible'] )
    1717                $_POST['link_visible'] = 'Y';
    1818
    1919        if ( !empty( $link_id ) ) {
  • wp-admin/link-add.php

    diff -urN wordpress/wp-admin/link-add.php site/wp-admin/link-add.php
    old new  
    1818require('admin-header.php');
    1919?>
    2020
    21 <?php if ($_GET['added'] && '' != $_POST['link_name']) : ?>
     21<?php $get_added = @ $_GET['added']; if ($get_added && '' != @ $_POST['link_name']) : ?>
    2222<div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
    2323<?php endif; ?>
    2424
  • wp-admin/link-manager.php

    diff -urN wordpress/wp-admin/link-manager.php site/wp-admin/link-manager.php
    old new  
    7878<h2><?php printf( __( 'Manage Links (<a href="%s">add new</a>)' ), 'link-add.php' ); ?></h2>
    7979
    8080<p id="post-search">
    81         <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
     81        <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes( @ $_GET['s'] )); ?>" />
    8282        <input type="submit" value="<?php _e( 'Search Links' ); ?>" class="button" />
    8383</p>
    8484
     
    149149        </thead>
    150150        <tbody>
    151151<?php
     152        $i = 0;
    152153        foreach ($links as $link) {
    153154                $link = sanitize_bookmark($link);
    154155                $link->link_name = attribute_escape($link->link_name);
  • wp-admin/link.php

    diff -urN wordpress/wp-admin/link.php site/wp-admin/link.php
    old new  
    66if ( ! current_user_can('manage_links') )
    77        wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
    88
    9 if ('' != $_POST['deletebookmarks'])
     9if ('' != @ $_POST['deletebookmarks'])
    1010        $action = 'deletebookmarks';
    11 if ('' != $_POST['move'])
     11if ('' != @ $_POST['move'])
    1212        $action = 'move';
    13 if ('' != $_POST['linkcheck'])
    14         $linkcheck = $_POST[linkcheck];
     13if ('' != @ $_POST['linkcheck'])
     14        $linkcheck = @ $_POST['linkcheck'];
    1515
    1616$this_file = 'link-manager.php';
    1717
  • wp-includes/bookmark.php

    diff -urN wordpress/wp-includes/bookmark.php site/wp-includes/bookmark.php
    old new  
    247247                if ( $do_object )
    248248                        $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context);
    249249                else
    250                         $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $bookmark['link_id'], $context);
     250                        $bookmark[$field] = sanitize_bookmark_field($field, @ $bookmark[$field], $bookmark['link_id'], $context);
    251251        }
    252252
    253253        return $bookmark;