| 396 | | </select></label></p> |
|---|
| 397 | | <p><label for="pages-exclude"><?php _e( 'Exclude:' ); ?> <input type="text" value="<?php echo $exclude; ?>" name="pages-exclude" id="pages-exclude" style="width: 180px;" /></label><br /> |
|---|
| 398 | | <small><?php _e( 'Page IDs, separated by commas.' ); ?></small></p> |
|---|
| 399 | | <input type="hidden" id="pages-submit" name="pages-submit" value="1" /> |
|---|
| | 410 | </select> |
|---|
| | 411 | </label> |
|---|
| | 412 | </p> |
|---|
| | 413 | <p> |
|---|
| | 414 | <label for="pages-exclude"><?php _e( 'Exclude:' ); ?> <input type="text" value="<?php echo $exclude; ?>" name="pages-exclude" id="pages-exclude" class="widefat" /></label> |
|---|
| | 415 | <br /> |
|---|
| | 416 | <small><?php _e( 'Page IDs, separated by commas.' ); ?></small> |
|---|
| | 417 | </p> |
|---|
| | 418 | <input type="hidden" id="pages-submit" name="pages-submit" value="1" /> |
|---|
| 466 | | <p><label for="archives-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="archives-title" name="archives-title" type="text" value="<?php echo $title; ?>" /></label></p> |
|---|
| 467 | | <p style="text-align:right;margin-right:40px;"><label for="archives-count"><?php _e('Show post counts'); ?> <input class="checkbox" type="checkbox" <?php echo $count; ?> id="archives-count" name="archives-count" /></label></p> |
|---|
| 468 | | <p style="text-align:right;margin-right:40px;"><label for="archives-dropdown"><?php _e('Display as a drop down'); ?> <input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="archives-dropdown" name="archives-dropdown" /></label></p> |
|---|
| | 485 | <p><label for="archives-title"><?php _e('Title:'); ?> <input class="widefat" id="archives-title" name="archives-title" type="text" value="<?php echo $title; ?>" /></label></p> |
|---|
| | 486 | <p> |
|---|
| | 487 | <label for="archives-count"><input class="checkbox" type="checkbox" <?php echo $count; ?> id="archives-count" name="archives-count" /> <?php _e('Show post counts'); ?></label> |
|---|
| | 488 | <br /> |
|---|
| | 489 | <label for="archives-dropdown"><input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="archives-dropdown" name="archives-dropdown" /> <?php _e('Display as a drop down'); ?></label> |
|---|
| | 490 | </p> |
|---|
| 535 | | function wp_widget_text($args, $number = 1) { |
|---|
| 536 | | extract($args); |
|---|
| | 557 | // See large comment section at end of this file |
|---|
| | 558 | function wp_widget_text($args, $widget_args = 1) { |
|---|
| | 559 | extract( $args, EXTR_SKIP ); |
|---|
| | 560 | if ( is_numeric($widget_args) ) |
|---|
| | 561 | $widget_args = array( 'number' => $widget_args ); |
|---|
| | 562 | $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
|---|
| | 563 | extract( $widget_args, EXTR_SKIP ); |
|---|
| | 564 | |
|---|
| 548 | | function wp_widget_text_control($number) { |
|---|
| 549 | | $options = $newoptions = get_option('widget_text'); |
|---|
| | 579 | function wp_widget_text_control($widget_args) { |
|---|
| | 580 | global $wp_registered_widgets; |
|---|
| | 581 | static $updated = false; |
|---|
| | 582 | |
|---|
| | 583 | if ( is_numeric($widget_args) ) |
|---|
| | 584 | $widget_args = array( 'number' => $widget_args ); |
|---|
| | 585 | $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
|---|
| | 586 | extract( $widget_args, EXTR_SKIP ); |
|---|
| | 587 | |
|---|
| | 588 | $options = get_option('widget_text'); |
|---|
| 551 | | $options = $newoptions = array(); |
|---|
| 552 | | if ( $_POST["text-submit-$number"] ) { |
|---|
| 553 | | $newoptions[$number]['title'] = strip_tags(stripslashes($_POST["text-title-$number"])); |
|---|
| 554 | | $newoptions[$number]['text'] = stripslashes($_POST["text-text-$number"]); |
|---|
| 555 | | if ( !current_user_can('unfiltered_html') ) |
|---|
| 556 | | $newoptions[$number]['text'] = stripslashes(wp_filter_post_kses($newoptions[$number]['text'])); |
|---|
| 557 | | } |
|---|
| 558 | | if ( $options != $newoptions ) { |
|---|
| 559 | | $options = $newoptions; |
|---|
| | 590 | $options = array(); |
|---|
| | 591 | |
|---|
| | 592 | if ( !$updated && !empty($_POST['sidebar']) ) { |
|---|
| | 593 | $sidebar = (string) $_POST['sidebar']; |
|---|
| | 594 | |
|---|
| | 595 | $sidebars_widgets = wp_get_sidebars_widgets(); |
|---|
| | 596 | if ( isset($sidebars_widgets[$sidebar]) ) |
|---|
| | 597 | $this_sidebar =& $sidebars_widgets[$sidebar]; |
|---|
| | 598 | else |
|---|
| | 599 | $this_sidebar = array(); |
|---|
| | 600 | |
|---|
| | 601 | foreach ( $this_sidebar as $_widget_id ) { |
|---|
| | 602 | if ( 'wp_widget_text' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { |
|---|
| | 603 | $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; |
|---|
| | 604 | unset($options[$widget_number]); |
|---|
| | 605 | } |
|---|
| | 606 | } |
|---|
| | 607 | |
|---|
| | 608 | foreach ( (array) $_POST['widget-text'] as $widget_number => $widget_text ) { |
|---|
| | 609 | $title = strip_tags(stripslashes($widget_text['title'])); |
|---|
| | 610 | if ( current_user_can('unfiltered_html') ) |
|---|
| | 611 | $text = stripslashes( $widget_text['text'] ); |
|---|
| | 612 | else |
|---|
| | 613 | $text = stripslashes(wp_filter_post_kses( $widget_text['text'] )); |
|---|
| | 614 | $options[$widget_number] = compact( 'title', 'text' ); |
|---|
| | 615 | } |
|---|
| | 616 | |
|---|
| 571 | | function wp_widget_text_setup() { |
|---|
| 572 | | $options = $newoptions = get_option('widget_text'); |
|---|
| 573 | | if ( isset($_POST['text-number-submit']) ) { |
|---|
| 574 | | $number = (int) $_POST['text-number']; |
|---|
| 575 | | if ( $number > 9 ) $number = 9; |
|---|
| 576 | | if ( $number < 1 ) $number = 1; |
|---|
| 577 | | $newoptions['number'] = $number; |
|---|
| | 621 | if ( -1 == $number ) { |
|---|
| | 622 | $title = ''; |
|---|
| | 623 | $text = ''; |
|---|
| | 624 | $number = '%i%'; |
|---|
| | 625 | } else { |
|---|
| | 626 | $title = attribute_escape($options[$number]['title']); |
|---|
| | 627 | $text = format_to_edit($options[$number]['text']); |
|---|
| 589 | | <div class="wrap"> |
|---|
| 590 | | <form method="POST"> |
|---|
| 591 | | <h2><?php _e('Text Widgets'); ?></h2> |
|---|
| 592 | | <p style="line-height: 30px;"><?php _e('How many text widgets would you like?'); ?> |
|---|
| 593 | | <select id="text-number" name="text-number" value="<?php echo $options['number']; ?>"> |
|---|
| 594 | | <?php for ( $i = 1; $i < 10; ++$i ) echo "<option value='$i' ".($options['number']==$i ? "selected='selected'" : '').">$i</option>"; ?> |
|---|
| 595 | | </select> |
|---|
| 596 | | <span class="submit"><input type="submit" name="text-number-submit" id="text-number-submit" value="<?php echo attribute_escape(__('Save')); ?>" /></span></p> |
|---|
| 597 | | </form> |
|---|
| 598 | | </div> |
|---|
| | 630 | <p> |
|---|
| | 631 | <input class="widefat" id="text-title-<?php echo $number; ?>" name="widget-text[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" /> |
|---|
| | 632 | <textarea class="widefat" rows="16" cols="20" id="text-text-<?php echo $number; ?>" name="widget-text[<?php echo $number; ?>][text]"><?php echo $text; ?></textarea> |
|---|
| | 633 | <input type="hidden" id="text-submit-<?php echo $number; ?>" name="text-submit-<?php echo $number; ?>" value="1" /> |
|---|
| | 634 | </p> |
|---|
| 604 | | $number = $options['number']; |
|---|
| 605 | | if ( $number < 1 ) $number = 1; |
|---|
| 606 | | if ( $number > 9 ) $number = 9; |
|---|
| 607 | | $dims = array('width' => 460, 'height' => 350); |
|---|
| 608 | | $class = array('classname' => 'widget_text'); |
|---|
| 609 | | for ($i = 1; $i <= 9; $i++) { |
|---|
| 610 | | $name = sprintf(__('Text %d'), $i); |
|---|
| 611 | | $id = "text-$i"; // Never never never translate an id |
|---|
| 612 | | wp_register_sidebar_widget($id, $name, $i <= $number ? 'wp_widget_text' : /* unregister */ '', $class, $i); |
|---|
| 613 | | wp_register_widget_control($id, $name, $i <= $number ? 'wp_widget_text_control' : /* unregister */ '', $dims, $i); |
|---|
| | 640 | $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML')); |
|---|
| | 641 | $control_ops = array('width' => 460, 'height' => 350, 'id_base' => 'text'); |
|---|
| | 642 | $name = __('Text'); |
|---|
| | 643 | |
|---|
| | 644 | // If there are none, we register the widget's existance with a generic template |
|---|
| | 645 | if ( !$options ) { |
|---|
| | 646 | wp_register_sidebar_widget( 'text-1', $name, 'wp_widget_text', $widget_ops, array( 'number' => -1 ) ); |
|---|
| | 647 | wp_register_widget_control( 'text-1', $name, 'wp_widget_text_control', $control_ops, array( 'number' => -1 ) ); |
|---|
| 615 | | add_action('sidebar_admin_setup', 'wp_widget_text_setup'); |
|---|
| 616 | | add_action('sidebar_admin_page', 'wp_widget_text_page'); |
|---|
| | 649 | |
|---|
| | 650 | foreach ( array_keys($options) as $o ) { |
|---|
| | 651 | // Old widgets can have null values for some reason |
|---|
| | 652 | if ( !isset($options[$o]['title']) || !isset($options[$o]['text']) ) |
|---|
| | 653 | continue; |
|---|
| | 654 | $id = "text-$o"; // Never never never translate an id |
|---|
| | 655 | wp_register_sidebar_widget($id, $name, 'wp_widget_text', $widget_ops, array( 'number' => $o )); |
|---|
| | 656 | wp_register_widget_control($id, $name, 'wp_widget_text_control', $control_ops, array( 'number' => $o )); |
|---|
| | 657 | } |
|---|
| 619 | | function wp_widget_categories($args, $number = 1) { |
|---|
| 620 | | extract($args); |
|---|
| | 660 | // See large comment section at end of this file |
|---|
| | 661 | function wp_widget_categories($args, $widget_args = 1) { |
|---|
| | 662 | extract($args, EXTR_SKIP); |
|---|
| | 663 | if ( is_numeric($widget_args) ) |
|---|
| | 664 | $widget_args = array( 'number' => $widget_args ); |
|---|
| | 665 | $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
|---|
| | 666 | extract($widget_args, EXTR_SKIP); |
|---|
| | 667 | |
|---|
| 674 | | if ( $options != $newoptions ) { |
|---|
| 675 | | $options = $newoptions; |
|---|
| | 722 | if ( !is_array( $options ) ) |
|---|
| | 723 | $options = array(); |
|---|
| | 724 | |
|---|
| | 725 | if ( !$updated && !empty($_POST['sidebar']) ) { |
|---|
| | 726 | $sidebar = (string) $_POST['sidebar']; |
|---|
| | 727 | |
|---|
| | 728 | $sidebars_widgets = wp_get_sidebars_widgets(); |
|---|
| | 729 | if ( isset($sidebars_widgets[$sidebar]) ) |
|---|
| | 730 | $this_sidebar =& $sidebars_widgets[$sidebar]; |
|---|
| | 731 | else |
|---|
| | 732 | $this_sidebar = array(); |
|---|
| | 733 | |
|---|
| | 734 | foreach ( $this_sidebar as $_widget_id ) { |
|---|
| | 735 | if ( 'wp_widget_categories' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { |
|---|
| | 736 | $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; |
|---|
| | 737 | unset($options[$widget_number]); |
|---|
| | 738 | } |
|---|
| | 739 | } |
|---|
| | 740 | |
|---|
| | 741 | foreach ( (array) $_POST['widget-categories'] as $widget_number => $widget_cat ) { |
|---|
| | 742 | $title = trim(strip_tags(stripslashes($widget_cat['title']))); |
|---|
| | 743 | $count = isset($widget_cat['count']); |
|---|
| | 744 | $hierarchical = isset($widget_cat['hierarchical']); |
|---|
| | 745 | $dropdown = isset($widget_cat['dropdown']); |
|---|
| | 746 | $options[$widget_number] = compact( 'title', 'count', 'hierarchical', 'dropdown' ); |
|---|
| | 747 | } |
|---|
| | 748 | |
|---|
| 685 | | <p><label for="categories-dropdown-<?php echo $number; ?>"> |
|---|
| 686 | | <input type="checkbox" class="checkbox" id="categories-dropdown-<?php echo $number; ?>" name="categories-dropdown-<?php echo $number; ?>"<?php echo $options[$number]['dropdown'] ? ' checked="checked"' : ''; ?> /> <?php _e( 'Show as dropdown' ); ?> |
|---|
| 687 | | </label></p> |
|---|
| | 773 | <p> |
|---|
| | 774 | <label for="categories-dropdown-<?php echo $number; ?>"> |
|---|
| | 775 | <input type="checkbox" class="checkbox" id="categories-dropdown-<?php echo $number; ?>" name="widget-categories[<?php echo $number; ?>][dropdown]"<?php checked( $dropdown, true ); ?> /> |
|---|
| | 776 | <?php _e( 'Show as dropdown' ); ?> |
|---|
| | 777 | </label> |
|---|
| | 778 | <br /> |
|---|
| | 779 | <label for="categories-count-<?php echo $number; ?>"> |
|---|
| | 780 | <input type="checkbox" class="checkbox" id="categories-count-<?php echo $number; ?>" name="widget-categories[<?php echo $number; ?>][count]"<?php checked( $count, true ); ?> /> |
|---|
| | 781 | <?php _e( 'Show post counts' ); ?> |
|---|
| | 782 | </label> |
|---|
| | 783 | <br /> |
|---|
| | 784 | <label for="categories-hierarchical-<?php echo $number; ?>"> |
|---|
| | 785 | <input type="checkbox" class="checkbox" id="categories-hierarchical-<?php echo $number; ?>" name="widget-categories[<?php echo $number; ?>][hierarchical]"<?php checked( $hierarchical, true ); ?> /> |
|---|
| | 786 | <?php _e( 'Show hierarchy' ); ?> |
|---|
| | 787 | </label> |
|---|
| | 788 | </p> |
|---|
| 713 | | $newoptions['number'] = $number; |
|---|
| | 803 | // If there are none, we register the widget's existance with a generic template |
|---|
| | 804 | if ( !$options ) { |
|---|
| | 805 | wp_register_sidebar_widget( 'categories-1', $name, 'wp_widget_categories', $widget_ops, array( 'number' => -1 ) ); |
|---|
| | 806 | wp_register_widget_control( 'categories-1', $name, 'wp_widget_categories_control', array( 'id_base' => 'categories' ), array( 'number' => -1 ) ); |
|---|
| 716 | | if ( $newoptions != $options ) { |
|---|
| 717 | | $options = $newoptions; |
|---|
| 718 | | update_option( 'widget_categories', $options ); |
|---|
| 719 | | wp_widget_categories_register( $options['number'] ); |
|---|
| | 809 | foreach ( array_keys($options) as $o ) { |
|---|
| | 810 | // Old widgets can have null values for some reason |
|---|
| | 811 | if ( !isset($options[$o]['title']) ) |
|---|
| | 812 | continue; |
|---|
| | 813 | $id = "categories-$o"; |
|---|
| | 814 | wp_register_sidebar_widget( $id, $name, 'wp_widget_categories', $widget_ops, array( 'number' => $o ) ); |
|---|
| | 815 | wp_register_widget_control( $id, $name, 'wp_widget_categories_control', array( 'id_base' => 'categories' ), array( 'number' => $o ) ); |
|---|
| 723 | | function wp_widget_categories_page() { |
|---|
| 724 | | $options = get_option( 'widget_categories' ); |
|---|
| 725 | | ?> |
|---|
| 726 | | <div class="wrap"> |
|---|
| 727 | | <form method="post"> |
|---|
| 728 | | <h2><?php _e( 'Categories Widgets' ); ?></h2> |
|---|
| 729 | | <p style="line-height: 30px;"><?php _e( 'How many categories widgets would you like?' ); ?> |
|---|
| 730 | | <select id="categories-number" name="categories-number" value="<?php echo attribute_escape( $options['number'] ); ?>"> |
|---|
| 731 | | <?php |
|---|
| 732 | | for ( $i = 1; $i < 10; $i++ ) { |
|---|
| 733 | | echo '<option value="' . $i . '"' . ( $i == $options['number'] ? ' selected="selected"' : '' ) . '>' . $i . "</option>\n"; |
|---|
| 734 | | } |
|---|
| 735 | | ?> |
|---|
| 736 | | </select> |
|---|
| 737 | | <span class="submit"> |
|---|
| 738 | | <input type="submit" value="<?php echo attribute_escape( __( 'Save' ) ); ?>" id="categories-number-submit" name="categories-number-submit" /> |
|---|
| 739 | | </span> |
|---|
| 740 | | </p> |
|---|
| 741 | | </form> |
|---|
| 742 | | </div> |
|---|
| 743 | | <?php |
|---|
| 767 | | if ( isset( $_POST['categories-submit'] ) ) { |
|---|
| 768 | | $_POST['categories-submit-1'] = $_POST['categories-submit']; |
|---|
| 769 | | $_POST['categories-count-1'] = $_POST['categories-count']; |
|---|
| 770 | | $_POST['categories-hierarchical-1'] = $_POST['categories-hierarchical']; |
|---|
| 771 | | $_POST['categories-dropdown-1'] = $_POST['categories-dropdown']; |
|---|
| 772 | | $_POST['categories-title-1'] = $_POST['categories-title']; |
|---|
| 773 | | foreach ( $_POST as $k => $v ) |
|---|
| 774 | | if ( substr($k, -5) == 'order' ) |
|---|
| 775 | | $_POST[$k] = str_replace('categories', 'categories-1', $v); |
|---|
| 776 | | } |
|---|
| 777 | | |
|---|
| 781 | | function wp_widget_categories_register() { |
|---|
| 782 | | $options = get_option( 'widget_categories' ); |
|---|
| 783 | | if ( !isset($options['number']) ) |
|---|
| 784 | | $options = wp_widget_categories_upgrade(); |
|---|
| 785 | | $number = (int) $options['number']; |
|---|
| 786 | | |
|---|
| 787 | | if ( $number > 9 ) { |
|---|
| 788 | | $number = 9; |
|---|
| 789 | | } elseif ( $number < 1 ) { |
|---|
| 790 | | $number = 1; |
|---|
| 791 | | } |
|---|
| 792 | | |
|---|
| 793 | | $dims = array( 'width' => 350, 'height' => 170 ); |
|---|
| 794 | | $class = array( 'classname' => 'widget_categories' ); |
|---|
| 795 | | |
|---|
| 796 | | for ( $i = 1; $i <= 9; $i++ ) { |
|---|
| 797 | | $name = sprintf( __( 'Categories %d' ), $i ); |
|---|
| 798 | | $id = 'categories-' . $i; |
|---|
| 799 | | |
|---|
| 800 | | $widget_callback = ( $i <= $number ) ? 'wp_widget_categories' : ''; |
|---|
| 801 | | $control_callback = ( $i <= $number ) ? 'wp_widget_categories_control' : ''; |
|---|
| 802 | | |
|---|
| 803 | | wp_register_sidebar_widget( $id, $name, $widget_callback, $class, $i ); |
|---|
| 804 | | wp_register_widget_control( $id, $name, $control_callback, $dims, $i ); |
|---|
| 805 | | } |
|---|
| 806 | | |
|---|
| 807 | | add_action( 'sidebar_admin_setup', 'wp_widget_categories_setup' ); |
|---|
| 808 | | add_action( 'sidebar_admin_page', 'wp_widget_categories_page' ); |
|---|
| 809 | | } |
|---|
| 810 | | |
|---|
| 932 | | $dims = array('width' => 320, 'height' => 90); |
|---|
| 933 | | $class = array('classname' => 'widget_recent_comments'); |
|---|
| 934 | | wp_register_sidebar_widget('recent-comments', __('Recent Comments'), 'wp_widget_recent_comments', $class); |
|---|
| 935 | | wp_register_widget_control('recent-comments', __('Recent Comments'), 'wp_widget_recent_comments_control', $dims); |
|---|
| | 977 | $widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'The most recent comments' ) ); |
|---|
| | 978 | wp_register_sidebar_widget('recent-comments', __('Recent Comments'), 'wp_widget_recent_comments', $widget_ops); |
|---|
| | 979 | wp_register_widget_control('recent-comments', __('Recent Comments'), 'wp_widget_recent_comments_control'); |
|---|
| 941 | | function wp_widget_rss($args, $number = 1) { |
|---|
| 942 | | require_once(ABSPATH . WPINC . '/rss.php'); |
|---|
| 943 | | extract($args); |
|---|
| | 985 | // See large comment section at end of this file |
|---|
| | 986 | function wp_widget_rss($args, $widget_args = 1) { |
|---|
| | 987 | extract($args, EXTR_SKIP); |
|---|
| | 988 | if ( is_numeric($widget_args) ) |
|---|
| | 989 | $widget_args = array( 'number' => $widegt_args ); |
|---|
| | 990 | $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
|---|
| | 991 | extract($widget_args, EXTR_SKIP); |
|---|
| | 992 | |
|---|
| 1005 | | function wp_widget_rss_control($number) { |
|---|
| 1006 | | $options = $newoptions = get_option('widget_rss'); |
|---|
| 1007 | | if ( $_POST["rss-submit-$number"] ) { |
|---|
| 1008 | | $newoptions[$number]['items'] = (int) $_POST["rss-items-$number"]; |
|---|
| 1009 | | $url = sanitize_url(strip_tags(stripslashes($_POST["rss-url-$number"]))); |
|---|
| 1010 | | $newoptions[$number]['title'] = trim(strip_tags(stripslashes($_POST["rss-title-$number"]))); |
|---|
| 1011 | | if ( $url !== $options[$number]['url'] ) { |
|---|
| 1012 | | require_once(ABSPATH . WPINC . '/rss.php'); |
|---|
| 1013 | | $rss = fetch_rss($url); |
|---|
| 1014 | | if ( is_object($rss) ) { |
|---|
| 1015 | | $newoptions[$number]['url'] = $url; |
|---|
| 1016 | | $newoptions[$number]['error'] = false; |
|---|
| 1017 | | } else { |
|---|
| 1018 | | $newoptions[$number]['error'] = true; |
|---|
| 1019 | | $newoptions[$number]['url'] = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1); |
|---|
| | 1062 | function wp_widget_rss_control($widget_args) { |
|---|
| | 1063 | global $wp_registered_widgets; |
|---|
| | 1064 | static $updated = false; |
|---|
| | 1065 | |
|---|
| | 1066 | if ( is_numeric($widget_args) ) |
|---|
| | 1067 | $widget_args = array( 'number' => $widget_args ); |
|---|
| | 1068 | $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
|---|
| | 1069 | extract($widget_args, EXTR_SKIP); |
|---|
| | 1070 | |
|---|
| | 1071 | $options = get_option('widget_rss'); |
|---|
| | 1072 | if ( !is_array($options) ) |
|---|
| | 1073 | $options = array(); |
|---|
| | 1074 | |
|---|
| | 1075 | $urls = array(); |
|---|
| | 1076 | foreach ( $options as $option ) |
|---|
| | 1077 | if ( isset($option['url']) ) |
|---|
| | 1078 | $urls[$option['url']] = true; |
|---|
| | 1079 | |
|---|
| | 1080 | if ( !$updated && !empty($_POST['sidebar']) ) { |
|---|
| | 1081 | $sidebar = (string) $_POST['sidebar']; |
|---|
| | 1082 | |
|---|
| | 1083 | $sidebars_widgets = wp_get_sidebars_widgets(); |
|---|
| | 1084 | if ( isset($sidebars_widgets[$sidebar]) ) |
|---|
| | 1085 | $this_sidebar =& $sidebars_widgets[$sidebar]; |
|---|
| | 1086 | else |
|---|
| | 1087 | $this_sidebar = array(); |
|---|
| | 1088 | |
|---|
| | 1089 | foreach ( $this_sidebar as $_widget_id ) { |
|---|
| | 1090 | if ( 'wp_widget_rss' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { |
|---|
| | 1091 | $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; |
|---|
| | 1092 | unset($options[$widget_number]); |
|---|
| 1022 | | } |
|---|
| 1023 | | if ( $options != $newoptions ) { |
|---|
| 1024 | | $options = $newoptions; |
|---|
| | 1095 | |
|---|
| | 1096 | foreach( (array) $_POST['widget-rss'] as $widget_number => $widget_rss ) { |
|---|
| | 1097 | $items = (int) $widget_rss['items']; |
|---|
| | 1098 | if ( $items < 1 ) |
|---|
| | 1099 | $items = 10; |
|---|
| | 1100 | $url = sanitize_url(strip_tags(stripslashes($widget_rss['url']))); |
|---|
| | 1101 | $title = trim(strip_tags(stripslashes($widget_rss['title']))); |
|---|
| | 1102 | |
|---|
| | 1103 | if ( !isset($urls[$url]) ) { |
|---|
| | 1104 | require_once(ABSPATH . WPINC . '/rss.php'); |
|---|
| | 1105 | $rss = fetch_rss($url); |
|---|
| | 1106 | $error = false; |
|---|
| | 1107 | if ( !is_object($rss) ) { |
|---|
| | 1108 | $url = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1); |
|---|
| | 1109 | $error = sprintf(__('Error in RSS %1$d'), $widget_number ); |
|---|
| | 1110 | } |
|---|
| | 1111 | } |
|---|
| | 1112 | $options[$widget_number] = compact( 'title', 'url', 'items', 'error' ); |
|---|
| | 1113 | } |
|---|
| | 1114 | |
|---|
| 1027 | | $url = attribute_escape($options[$number]['url']); |
|---|
| 1028 | | $items = (int) $options[$number]['items']; |
|---|
| 1029 | | $title = attribute_escape($options[$number]['title']); |
|---|
| 1030 | | if ( empty($items) || $items < 1 ) $items = 10; |
|---|
| 1031 | | ?> |
|---|
| 1032 | | <p style="text-align:center;"><?php _e('Enter the RSS feed URL here:'); ?></p> |
|---|
| 1033 | | <input style="width: 400px;" id="rss-url-<?php echo "$number"; ?>" name="rss-url-<?php echo "$number"; ?>" type="text" value="<?php echo $url; ?>" /> |
|---|
| 1034 | | <p style="text-align:center;"><?php _e('Give the feed a title (optional):'); ?></p> |
|---|
| 1035 | | <input style="width: 400px;" id="rss-title-<?php echo "$number"; ?>" name="rss-title-<?php echo "$number"; ?>" type="text" value="<?php echo $title; ?>" /> |
|---|
| 1036 | | <p style="text-align:center; line-height: 30px;"><?php _e('How many items would you like to display?'); ?> <select id="rss-items-<?php echo $number; ?>" name="rss-items-<?php echo $number; ?>"><?php for ( $i = 1; $i <= 10; ++$i ) echo "<option value='$i' ".($items==$i ? "selected='selected'" : '').">$i</option>"; ?></select></p> |
|---|
| 1037 | | <input type="hidden" id="rss-submit-<?php echo "$number"; ?>" name="rss-submit-<?php echo $number; ?>" value="1" /> |
|---|
| 1038 | | <?php |
|---|
| 1039 | | } |
|---|
| 1041 | | function wp_widget_rss_setup() { |
|---|
| 1042 | | $options = $newoptions = get_option('widget_rss'); |
|---|
| 1043 | | if ( isset($_POST['rss-number-submit']) ) { |
|---|
| 1044 | | $number = (int) $_POST['rss-number']; |
|---|
| 1045 | | if ( $number > 9 ) $number = 9; |
|---|
| 1046 | | if ( $number < 1 ) $number = 1; |
|---|
| 1047 | | $newoptions['number'] = $number; |
|---|
| | 1119 | if ( -1 == $number ) { |
|---|
| | 1120 | $title = ''; |
|---|
| | 1121 | $url = ''; |
|---|
| | 1122 | $items = 10; |
|---|
| | 1123 | $error = false; |
|---|
| | 1124 | $number = '%i%'; |
|---|
| | 1125 | } else { |
|---|
| | 1126 | $title = attribute_escape($options[$number]['title']); |
|---|
| | 1127 | $url = attribute_escape($options[$number]['url']); |
|---|
| | 1128 | |
|---|