Make WordPress Core


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

Links widget options. Props DD32. see #9196

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.