Make WordPress Core

Changeset 10712


Ignore:
Timestamp:
03/04/2009 11:49:21 PM (15 years ago)
Author:
ryan
Message:

Links widget options. Props DD32. see #9196

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/bookmark-template.php

    r10207 r10712  
    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'));
     
    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;
     
    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
     
    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";
  • trunk/wp-includes/widgets.php

    r10697 r10712  
    749749    extract($args, EXTR_SKIP);
    750750
     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
    751757    $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
    752758    wp_list_bookmarks(apply_filters('widget_links_args', array(
    753759        'title_before' => $before_title, 'title_after' => $after_title,
    754760        'category_before' => $before_widget, 'category_after' => $after_widget,
    755         'show_images' => true, 'class' => 'linkcat widget'
     761        'show_images' => $show_images, 'show_description' => $show_description,
     762        'show_name' => $show_name, 'show_rating' => $show_rating,
     763        'class' => 'linkcat widget'
    756764    )));
    757765}
     766
     767/**
     768 * Display and process links widget options form.
     769 *
     770 * @since 2.8.0
     771 */
     772function wp_widget_links_control() {
     773    $options = $newoptions = get_option('widget_links');
     774
     775    //Defaults
     776    if ( ! $newoptions )
     777        $newoptions = array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false);
     778
     779    if ( isset($_POST['links-submit']) ) {
     780        $newoptions['description'] = isset($_POST['links-description']);
     781        $newoptions['name'] = isset($_POST['links-name']);
     782        $newoptions['rating'] = isset($_POST['links-rating']);
     783        $newoptions['images'] = isset($_POST['links-images']);
     784    }
     785    if ( $options != $newoptions ) {
     786        $options = $newoptions;
     787        update_option('widget_links', $options);
     788    }
     789?>
     790            <p>
     791                <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>
     792                <br />
     793                <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>
     794                <br />
     795                <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>
     796                <br />
     797                <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>
     798            </p>
     799            <input type="hidden" id="links-submit" name="links-submit" value="1" />
     800<?php
     801}
     802
    758803
    759804/**
     
    19241969    $widget_ops = array('classname' => 'widget_links', 'description' => __( "Your blogroll") );
    19251970    wp_register_sidebar_widget('links', __('Links'), 'wp_widget_links', $widget_ops);
     1971    wp_register_widget_control('links', __('Links'), 'wp_widget_links_control' );
    19261972
    19271973    $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") );
Note: See TracChangeset for help on using the changeset viewer.