fix new-fangled multi widgets. Props mdawaffe. see #6022

git-svn-id: http://svn.automattic.com/wordpress/trunk@7077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-27 23:57:00 +00:00
parent efd7c23c87
commit d0dfa68b6a
2 changed files with 53 additions and 24 deletions

View File

@ -122,6 +122,9 @@ endif;
<?php
$query_str = "post_type=page&orderby=menu_order title&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc";
if ( !empty($_GET['p']) ) {
$query_str .= "p=
}
$query_str = apply_filters('manage_pages_query', $query_str);
wp($query_str);
@ -160,6 +163,28 @@ if ($posts) {
<br style="clear:both;" />
</div>
<?php
if ( 1 == count($posts) && isset( $_GET['p'] ) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
if ($comments) {
// Make sure comments, post, and post_author are cached
update_comment_cache($comments);
$post = get_post($id);
$authordata = get_userdata($post->post_author);
?>
<h3 id="comments"><?php _e('Comments') ?></h3>
<ol id="the-comment-list" class="list:comment commentlist">
<?php
$i = 0;
foreach ( $comments as $comment ) {
_wp_comment_list_item( $comment->comment_ID, ++$i );
}
echo '</ol>';
} // end if comments
?>
<?php } ?>
</div>
<?php include('admin-footer.php'); ?>

View File

@ -647,12 +647,7 @@ function wp_widget_text_register() {
$control_ops = array('width' => 460, 'height' => 350, 'id_base' => 'text');
$name = __('Text');
// If there are none, we register the widget's existance with a generic template
if ( !$options ) {
wp_register_sidebar_widget( 'text-1', $name, 'wp_widget_text', $widget_ops, array( 'number' => -1 ) );
wp_register_widget_control( 'text-1', $name, 'wp_widget_text_control', $control_ops, array( 'number' => -1 ) );
}
$id = false;
foreach ( array_keys($options) as $o ) {
// Old widgets can have null values for some reason
if ( !isset($options[$o]['title']) || !isset($options[$o]['text']) )
@ -661,6 +656,12 @@ function wp_widget_text_register() {
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 ));
}
// If there are none, we register the widget's existance with a generic template
if ( !$id ) {
wp_register_sidebar_widget( 'text-1', $name, 'wp_widget_text', $widget_ops, array( 'number' => -1 ) );
wp_register_widget_control( 'text-1', $name, 'wp_widget_text_control', $control_ops, array( 'number' => -1 ) );
}
}
// See large comment section at end of this file
@ -808,12 +809,7 @@ function wp_widget_categories_register() {
$name = __( 'Categories' );
// If there are none, we register the widget's existance with a generic template
if ( !$options ) {
wp_register_sidebar_widget( 'categories-1', $name, 'wp_widget_categories', $widget_ops, array( 'number' => -1 ) );
wp_register_widget_control( 'categories-1', $name, 'wp_widget_categories_control', array( 'id_base' => 'categories' ), array( 'number' => -1 ) );
}
$id = false;
foreach ( array_keys($options) as $o ) {
// Old widgets can have null values for some reason
if ( !isset($options[$o]['title']) )
@ -823,6 +819,11 @@ function wp_widget_categories_register() {
wp_register_widget_control( $id, $name, 'wp_widget_categories_control', array( 'id_base' => 'categories' ), array( 'number' => $o ) );
}
// If there are none, we register the widget's existance with a generic template
if ( !$id ) {
wp_register_sidebar_widget( 'categories-1', $name, 'wp_widget_categories', $widget_ops, array( 'number' => -1 ) );
wp_register_widget_control( 'categories-1', $name, 'wp_widget_categories_control', array( 'id_base' => 'categories' ), array( 'number' => -1 ) );
}
}
function wp_widget_categories_upgrade() {
@ -1297,12 +1298,7 @@ function wp_widget_rss_register() {
$control_ops = array('width' => 410, 'height' => 200, 'id_base' => 'rss');
$name = __('RSS');
// If there are none, we register the widget's existance with a generic template
if ( !$options ) {
wp_register_sidebar_widget( 'rss-1', $name, 'wp_widget_rss', $widget_ops, array( 'number' => -1 ) );
wp_register_widget_control( 'rss-1', $name, 'wp_widget_rss_control', $control_ops, array( 'number' => -1 ) );
}
$id = false;
foreach ( array_keys($options) as $o ) {
// Old widgets can have null values for some reason
if ( !isset($options[$o]['url']) || !isset($options[$o]['title']) || !isset($options[$o]['items']) )
@ -1311,6 +1307,12 @@ function wp_widget_rss_register() {
wp_register_sidebar_widget($id, $name, 'wp_widget_rss', $widget_ops, array( 'number' => $o ));
wp_register_widget_control($id, $name, 'wp_widget_rss_control', $control_ops, array( 'number' => $o ));
}
// If there are none, we register the widget's existance with a generic template
if ( !$id ) {
wp_register_sidebar_widget( 'rss-1', $name, 'wp_widget_rss', $widget_ops, array( 'number' => -1 ) );
wp_register_widget_control( 'rss-1', $name, 'wp_widget_rss_control', $control_ops, array( 'number' => -1 ) );
}
}
function wp_widget_tag_cloud($args) {
@ -1489,12 +1491,7 @@ function widget_many_register() {
$control_ops = array('width' => 400, 'height' => 350, 'id_base' => 'many');
$name = __('Many');
// If there are none, we register the widget's existance with a generic template
if ( !$options ) {
wp_register_sidebar_widget( 'many-1', $name, 'widget_many', $widget_ops, array( 'number' => -1 ) );
wp_register_widget_control( 'many-1', $name, 'widget_many_control', $control_ops, array( 'number' => -1 ) );
}
$registered = false;
foreach ( array_keys($options) as $o ) {
// Old widgets can have null values for some reason
if ( !isset($options[$o]['something']) ) // we used 'something' above in our exampple. Replace with with whatever your real data are.
@ -1502,9 +1499,16 @@ function widget_many_register() {
// $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 ) );
}
// If there are none, we register the widget's existance with a generic template
if ( !$registered ) {
wp_register_sidebar_widget( 'many-1', $name, 'widget_many', $widget_ops, array( 'number' => -1 ) );
wp_register_widget_control( 'many-1', $name, 'widget_many_control', $control_ops, array( 'number' => -1 ) );
}
}
// This is important