Make WordPress Core

Ticket #9196: 9196.diff

File 9196.diff, 6.0 KB (added by DD32, 16 years ago)
  • wp-includes/bookmark-template.php

     
    7272                if ( !empty($bookmark->link_url) )
    7373                        $the_link = clean_url($bookmark->link_url);
    7474
    75                 $rel = $bookmark->link_rel;
    76                 if ( '' != $rel )
    77                         $rel = ' rel="' . $rel . '"';
    78 
    7975                $desc = attribute_escape(sanitize_bookmark_field('link_description', $bookmark->link_description, $bookmark->link_id, 'display'));
    8076                $name = attribute_escape(sanitize_bookmark_field('link_name', $bookmark->link_name, $bookmark->link_id, 'display'));
    8177                $title = $desc;
     
    8783                                $title .= ')';
    8884                        }
    8985
     86                $alt = ' alt="' . $name . ( $show_description ? ' ' . $title : '' ) . '"';
     87
    9088                if ( '' != $title )
    9189                        $title = ' title="' . $title . '"';
    9290
    93                 $alt = ' alt="' . $name . '"';
     91                $rel = $bookmark->link_rel;
     92                if ( '' != $rel )
     93                        $rel = ' rel="' . $rel . '"';
    9494
    9595                $target = $bookmark->link_target;
    9696                if ( '' != $target )
    9797                        $target = ' target="' . $target . '"';
    9898
    99                 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
     99                $output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';
    100100
    101101                $output .= $link_before;
    102102
    103103                if ( $bookmark->link_image != null && $show_images ) {
    104                         if ( strpos($bookmark->link_image, 'http') !== false )
     104                        if ( strpos($bookmark->link_image, 'http') === 0 )
    105105                                $output .= "<img src=\"$bookmark->link_image\" $alt $title />";
    106106                        else // If it's a relative path
    107107                                $output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />";
     
    121121                if ( $show_description && '' != $desc )
    122122                        $output .= $between . $desc;
    123123
    124                 if ($show_rating) {
     124                if ( $show_rating )
    125125                        $output .= $between . sanitize_bookmark_field('link_rating', $bookmark->link_rating, $bookmark->link_id, 'display');
    126                 }
    127126
    128127                $output .= "$after\n";
    129128        } // end while
  • wp-includes/widgets.php

     
    747747 */
    748748function wp_widget_links($args) {
    749749        extract($args, EXTR_SKIP);
     750       
     751        $link_options = get_option('widget_links');
     752        $show_description = isset($link_options['description']) ? $link_options['description'] : false;
     753        $show_name = isset($link_options['name']) ? $link_options['name'] : false;
     754        $show_rating = isset($link_options['rating']) ? $link_options['rating'] : false;
     755        $show_images = isset($link_options['images']) ? $link_options['images'] : true;
     756        $between = isset($link_options['sep']) ? $link_options['sep'] : "\n";
    750757
    751758        $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
    752759        wp_list_bookmarks(apply_filters('widget_links_args', array(
    753760                'title_before' => $before_title, 'title_after' => $after_title,
    754761                'category_before' => $before_widget, 'category_after' => $after_widget,
    755                 'show_images' => true, 'class' => 'linkcat widget'
     762                'show_images' => $show_images, 'show_description' => $show_description,
     763                'show_name' => $show_name, 'show_rating' => $show_rating,
     764                'between' => $between, 'class' => 'linkcat widget'
    756765        )));
    757766}
    758767
    759768/**
     769 * Display and process links widget options form.
     770 *
     771 * @since 2.8.0
     772 */
     773function wp_widget_links_control() {
     774        $options = $newoptions = get_option('widget_links');
     775
     776        //Defaults
     777        if ( ! $newoptions )
     778                $newoptions = array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'updated' => false, 'sep' => '<br />');
     779
     780        if ( isset($_POST['links-submit']) ) {
     781                $newoptions['description'] = isset($_POST['links-description']);
     782                $newoptions['name'] = isset($_POST['links-name']);
     783                $newoptions['rating'] = isset($_POST['links-rating']);
     784                $newoptions['images'] = isset($_POST['links-images']);
     785                $newoptions['updated'] = isset($_POST['links-updated']);
     786                $newoptions['sep'] = isset($_POST['links-sep']) ? stripslashes($_POST['links-sep']) : '';
     787        }
     788        if ( $options != $newoptions ) {
     789                $options = $newoptions;
     790                update_option('widget_links', $options);
     791        }
     792?>
     793                        <p>
     794                                <label for="links-images"><input class="checkbox" type="checkbox" <?php checked($options['images'], true) ?> id="links-images" name="links-images" /> <?php _e('Show Link Image'); ?></label>
     795                                <br />
     796                                <label for="links-name"><input class="checkbox" type="checkbox" <?php checked($options['name'], true) ?> id="links-name" name="links-name" /> <?php _e('Show Link Name'); ?></label>
     797                                <br />
     798                                <label for="links-description"><input class="checkbox" type="checkbox" <?php checked($options['description'], true) ?> id="links-description" name="links-description" /> <?php _e('Show Link Description'); ?></label>
     799                                <br />
     800                                <label for="links-rating"><input class="checkbox" type="checkbox" <?php checked($options['rating'], true) ?> id="links-rating" name="links-rating" /> <?php _e('Show Link Rating'); ?></label>
     801                                <br />
     802                                <label for="links-updated"><input class="checkbox" type="checkbox" <?php checked($options['updated'], true) ?> id="links-updated" name="links-updated" /> <?php _e('Show Link Last updated time'); ?></label>
     803                        </p>
     804                        <p><label for="links-sep"><?php _e('Separator to use between fields:'); ?> <input class="widefat" id="links-sep" name="links-sep" type="text" value="<?php echo attribute_escape($options['sep']) ?>" /></label></p>
     805                        <input type="hidden" id="links-submit" name="links-submit" value="1" />
     806<?php
     807}
     808
     809
     810/**
    760811 * Display search widget.
    761812 *
    762813 * @since 2.2.0
     
    19281979
    19291980        $widget_ops = array('classname' => 'widget_links', 'description' => __( "Your blogroll") );
    19301981        wp_register_sidebar_widget('links', __('Links'), 'wp_widget_links', $widget_ops);
     1982        wp_register_widget_control('links', __('Links'), 'wp_widget_links_control' );
    19311983
    19321984        $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") );
    19331985        wp_register_sidebar_widget('meta', __('Meta'), 'wp_widget_meta', $widget_ops);