'after_title' => "</h2>\n",
);
- $sidebar = array_merge($defaults, $args);
+ $sidebar = array_merge($defaults, (array) $args);
$wp_registered_sidebars[$sidebar['id']] = $sidebar;
function wp_register_sidebar_widget($id, $name, $output_callback, $options = array()) {
global $wp_registered_widgets;
+ $id = strtolower($id);
+
if ( empty($output_callback) ) {
unset($wp_registered_widgets[$id]);
return;
*/
function wp_register_widget_control($id, $name, $control_callback, $options = array()) {
global $wp_registered_widget_controls;
+
+ $id = strtolower($id);
if ( empty($control_callback) ) {
unset($wp_registered_widget_controls[$id]);
$_sidebars_widgets[$index][$i] = $id;
continue;
}
-
+
$found = false;
-
+
foreach ( $wp_registered_widgets as $widget_id => $widget ) {
if ( strtolower($widget['name']) == strtolower($name) ) {
$_sidebars_widgets[$index][$i] = $widget['id'];
break;
}
}
-
+
if ( $found )
continue;
-
+
unset($_sidebars_widgets[$index][$i]);
}
$_sidebars_widgets['array_version'] = 2;
extract( $args );
$options = get_option( 'widget_pages' );
- $title = empty( $options['title'] ) ? __( 'Pages' ) : $options['title'];
+ $title = empty( $options['title'] ) ? __( 'Pages' ) : apply_filters('widget_title', $options['title']);
$sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby'];
$exclude = empty( $options['exclude'] ) ? '' : $options['exclude'];
extract($args, EXTR_SKIP);
$before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
- wp_list_bookmarks(array(
+ wp_list_bookmarks(apply_filters('widget_links_args', array(
'title_before' => $before_title, 'title_after' => $after_title,
'category_before' => $before_widget, 'category_after' => $after_widget,
'show_images' => true, 'class' => 'linkcat widget'
- ));
+ )));
}
function wp_widget_search($args) {
extract($args);
-?>
- <?php echo $before_widget; ?>
- <form id="searchform" method="get" action="<?php bloginfo('home'); ?>">
- <div>
- <input type="text" name="s" id="s" size="15" /><br />
+ $searchform_template = get_template_directory() . '/searchform.php';
+
+ echo $before_widget;
+
+ // Use current theme search form if it exists
+ if ( file_exists($searchform_template) ) {
+ include_once($searchform_template);
+ } else { ?>
+ <form id="searchform" method="get" action="<?php bloginfo('url'); ?>/"><div>
+ <label class="hidden" for="s"><?php _e('Search for:'); ?></label>
+ <input type="text" name="s" id="s" size="15" value="<?php the_search_query(); ?>" />
<input type="submit" value="<?php echo attribute_escape(__('Search')); ?>" />
- </div>
- </form>
- <?php echo $after_widget; ?>
-<?php
+ </div></form>
+ <?php }
+
+ echo $after_widget;
}
function wp_widget_archives($args) {
$options = get_option('widget_archives');
$c = $options['count'] ? '1' : '0';
$d = $options['dropdown'] ? '1' : '0';
- $title = empty($options['title']) ? __('Archives') : $options['title'];
+ $title = empty($options['title']) ? __('Archives') : apply_filters('widget_title', $options['title']);
echo $before_widget;
echo $before_title . $title . $after_title;
function wp_widget_meta($args) {
extract($args);
$options = get_option('widget_meta');
- $title = empty($options['title']) ? __('Meta') : $options['title'];
+ $title = empty($options['title']) ? __('Meta') : apply_filters('widget_title', $options['title']);
?>
<?php echo $before_widget; ?>
<?php echo $before_title . $title . $after_title; ?>
function wp_widget_calendar($args) {
extract($args);
$options = get_option('widget_calendar');
- $title = $options['title'];
+ $title = apply_filters('widget_title', $options['title']);
if ( empty($title) )
$title = ' ';
echo $before_widget . $before_title . $title . $after_title;
if ( !isset($options[$number]) )
return;
- $title = $options[$number]['title'];
+ $title = apply_filters('widget_title', $options[$number]['title']);
$text = apply_filters( 'widget_text', $options[$number]['text'] );
?>
<?php echo $before_widget; ?>
$h = $options[$number]['hierarchical'] ? '1' : '0';
$d = $options[$number]['dropdown'] ? '1' : '0';
- $title = empty($options[$number]['title']) ? __('Categories') : $options[$number]['title'];
+ $title = empty($options[$number]['title']) ? __('Categories') : apply_filters('widget_title', $options[$number]['title']);
echo $before_widget;
echo $before_title . $title . $after_title;
- $cat_args = "orderby=name&show_count={$c}&hierarchical={$h}";
+ $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
if ( $d ) {
- wp_dropdown_categories($cat_args . '&show_option_none= ' . __('Select Category'));
+ $cat_args['show_option_none'] = __('Select Category');
+ wp_dropdown_categories($cat_args);
?>
<script type='text/javascript'>
} else {
?>
<ul>
- <?php wp_list_categories($cat_args . '&title_li='); ?>
+ <?php
+ $cat_args['title_li'] = '';
+ wp_list_categories($cat_args);
+ ?>
</ul>
<?php
}
extract($args);
$options = get_option('widget_recent_entries');
- $title = empty($options['title']) ? __('Recent Posts') : $options['title'];
+ $title = empty($options['title']) ? __('Recent Posts') : apply_filters('widget_title', $options['title']);
if ( !$number = (int) $options['number'] )
$number = 10;
else if ( $number < 1 )
else if ( $number > 15 )
$number = 15;
- $r = new WP_Query("showposts=$number&what_to_show=posts&nopaging=0&post_status=publish");
+ $r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish'));
if ($r->have_posts()) :
?>
<?php echo $before_widget; ?>
global $wpdb, $comments, $comment;
extract($args, EXTR_SKIP);
$options = get_option('widget_recent_comments');
- $title = empty($options['title']) ? __('Recent Comments') : $options['title'];
+ $title = empty($options['title']) ? __('Recent Comments') : apply_filters('widget_title', $options['title']);
if ( !$number = (int) $options['number'] )
$number = 5;
else if ( $number < 1 )
function wp_widget_rss($args, $widget_args = 1) {
extract($args, EXTR_SKIP);
if ( is_numeric($widget_args) )
- $widget_args = array( 'number' => $widegt_args );
+ $widget_args = array( 'number' => $widget_args );
$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
extract($widget_args, EXTR_SKIP);
$title = $desc;
if ( empty($title) )
$title = __('Unknown Feed');
+ $title = apply_filters('widget_title', $title );
$url = clean_url(strip_tags($url));
if ( file_exists(dirname(__FILE__) . '/rss.png') )
- $icon = str_replace(ABSPATH, get_option('siteurl').'/', dirname(__FILE__)) . '/rss.png';
+ $icon = str_replace(ABSPATH, site_url() . '/', dirname(__FILE__)) . '/rss.png';
else
- $icon = get_option('siteurl').'/wp-includes/images/rss.png';
+ $icon = includes_url('images/rss.png');
$title = "<a class='rsswidget' href='$url' title='" . attribute_escape(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>";
echo $before_widget;
if ( empty($title) )
$title = __('Untitled');
$desc = '';
- if ( isset( $item['description'] ) && is_string( $item['description'] ) )
- $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
- elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) )
- $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES))));
-
$summary = '';
if ( isset( $item['description'] ) && is_string( $item['description'] ) )
- $summary = $item['description'];
+ $desc = $summary = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) )
- $summary = $item['summary'];
-
- $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($summary, ENT_QUOTES))));
+ $desc = $summary = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES))));
if ( $show_summary ) {
$desc = '';
if ( $date ) {
if ( $date_stamp = strtotime( $date ) )
- $date = '<span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>';
+ $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>';
else
$date = '';
}
$author = ' <cite>' . wp_specialchars( strip_tags( $item['author_name'] ) ) . '</cite>';
}
- echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
- }
+ if ( $link == '' ) {
+ echo "<li>$title{$date}{$summary}{$author}</li>";
+ } else {
+ echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
+ }
+}
echo '</ul>';
} else {
echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
function wp_widget_tag_cloud($args) {
extract($args);
$options = get_option('widget_tag_cloud');
- $title = empty($options['title']) ? __('Tags') : $options['title'];
+ $title = empty($options['title']) ? __('Tags') : apply_filters('widget_title', $options['title']);
echo $before_widget;
echo $before_title . $title . $after_title;
$options[$widget_number] = array( 'something' => $something ); // Even simple widgets should store stuff in array, rather than in scalar
}
- update_option('widget_text', $options);
+ update_option('widget_many', $options);
$updated = true; // So that we don't go through this more than once
}
// $id should look like {$id_base}-{$o}
$id = "many-$o"; // Never never never translate an id
$registered = true;
- wp_register_sidebar_widget( $id, $name, 'wp_widget_text', $widget_ops, array( 'number' => $o ) );
- wp_register_widget_control( $id, $name, 'wp_widget_text_control', $control_ops, array( 'number' => $o ) );
+ wp_register_sidebar_widget( $id, $name, 'widget_many', $widget_ops, array( 'number' => $o ) );
+ wp_register_widget_control( $id, $name, 'widget_many_control', $control_ops, array( 'number' => $o ) );
}
// If there are none, we register the widget's existance with a generic template