![]() |
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Brian's Latest Comments (BLC) is an excellent plugin for displaying recent comments in your sidebar, but if you want to use it with Thesis, you have to edit one of the sidebar files directly. Unfortunately, there isn't a widget for BLC.
Until now. I don't claim this is perfect -- it's the product of a late-night-desire to produce something. Place the following code (also available here) into your custom_functions.php file: Code:
/*
Widget for Brian's Latest Comments
*/
if (function_exists('blc_latest_comments')) {
// Output the widget
function brians_latest_comments_widget($args) {
extract($args, EXTR_SKIP);
$options = get_option('brians_latest_comments_widget');
$posts = $options['brians-latest-comments-posts'] - 1;
echo $before_widget . "\n";
echo $before_title . $options['brians-latest-comments-title'] . $after_title . "\n";
echo "<ul>\n";
blc_latest_comments($posts, $options['brians-latest-comments-commenters'], $options['brians-latest-comments-hide-tbpb'], ' <li>', '</li>', $options['brians-latest-comments-fade-old'], $options['brians-latest-comments-days'], $options['brians-latest-comments-fade-start'], $options['brians-latest-comments-fade-end']);
echo "</ul>\n";
echo $after_widget . "\n";
}
function wp_flush_widget_brians_latest_comments() {
wp_cache_delete('brians_latest_comments_widget', 'widget');
}
add_action('comment_post', 'wp_flush_widget_brians_latest_comments');
add_action('edit_comment', 'wp_flush_widget_brians_latest_comments');
add_action('delete_comment', 'wp_flush_widget_brians_latest_comments');
add_action('pingback_post', 'wp_flush_widget_brians_latest_comments');
add_action('trackback_post', 'wp_flush_widget_brians_latest_comments');
add_action('wp_set_comment_status', 'wp_flush_widget_brians_latest_comments');
// Widget control
function brians_latest_comments_control() {
$options = $newoptions = get_option('brians_latest_comments_widget');
if ($_POST['brians-latest-comments-submit']) {
$newoptions['brians-latest-comments-title'] = strip_tags(stripslashes($_POST['brians-latest-comments-title']));
$newoptions['brians-latest-comments-posts'] = (int) $_POST['brians-latest-comments-posts'];
$newoptions['brians-latest-comments-commenters'] = (int) $_POST['brians-latest-comments-commenters'];
$newoptions['brians-latest-comments-hide-tbpb'] = (int) $_POST['brians-latest-comments-hide-tbpb'];
$newoptions['brians-latest-comments-fade-old'] = (int) $_POST['brians-latest-comments-fade-old'];
$newoptions['brians-latest-comments-days'] = (int) $_POST['brians-latest-comments-days'];
$newoptions['brians-latest-comments-fade-start'] = strip_tags(stripslashes($_POST['brians-latest-comments-fade-start']));
$newoptions['brians-latest-comments-fade-end'] = strip_tags(stripslashes($_POST['brians-latest-comments-fade-end']));
}
if ($options != $newoptions) {
$options = $newoptions;
update_option('brians_latest_comments_widget', $options);
wp_flush_widget_brians_latest_comments();
}
$title = attribute_escape($options['brians-latest-comments-title']);
if (!$posts = (int) $options['brians-latest-comments-posts'])
$posts = 5;
if (!$commenters = (int) $options['brians-latest-comments-commenters'])
$commenters = 5;
$hide_tbpb = (int) $options['brians-latest-comments-hide-tbpb'];
$fade_old = (int) $options['brians-latest-comments-fade-old'];
if (!$days = (int) $options['brians-latest-comments-days'])
$days = 10;
$fade_start = attribute_escape($options['brians-latest-comments-fade-start']);
$fade_end = attribute_escape($options['brians-latest-comments-fade-end']);
?>
<p>
<label for="brians-latest-comments-title"><?php _e('Title:', 'thesis'); ?>
<input type="text" class="widefat" id="brians-latest-comments-title" name="brians-latest-comments-title" value="<?php echo $title; ?>" /></label>
</p>
<p>
<label for="brians-latest-comments-posts"><?php _e('Number of posts for which to show comments:', 'thesis'); ?> <input style="width: 25px; text-align: center;" id="brians-latest-comments-posts" name="brians-latest-comments-posts" type="text" value="<?php echo $posts; ?>" /></label>
<br />
<small><?php _e('(default is 5)', 'thesis'); ?></small>
</p>
<p>
<label for="brians-latest-comments-commenters"><?php _e('Number of commenters to show per post:', 'thesis'); ?> <input style="width: 25px; text-align: center;" id="brians-latest-comments-commenters" name="brians-latest-comments-commenters" type="text" value="<?php echo $commenters; ?>" /></label>
<br />
<small><?php _e('(default is 5)', 'thesis'); ?></small>
</p>
<p>
<label for="brians-latest-comments-hide-tbpb"><input id="brians-latest-comments-hide-tbpb" name="brians-latest-comments-hide-tbpb" type="checkbox" value="1" <?php if ($hide_tbpb) echo 'checked="checked" '; ?>/> <?php _e('Hide TrackBacks & PingBacks?', 'thesis'); ?></label>
</p>
<p>
<label for="brians-latest-comments-fade-old"><input id="brians-latest-comments-fade-old" name="brians-latest-comments-fade-old" type="checkbox" value="1" <?php if ($fade_old) echo 'checked="checked" '; ?>/> <?php _e('Fade older comments?', 'thesis'); ?></label>
</p>
<p>
<label for="brians-latest-comments-days"><?php _e('Number of days it takes for a comment to fade from newest to oldest:', 'thesis'); ?> <input style="width: 25px; text-align: center;" id="brians-latest-comments-days" name="brians-latest-comments-days" type="text" value="<?php echo $days; ?>" /></label>
<br />
<small><?php _e('(default is 10)', 'thesis'); ?></small>
</p>
<p>
<label for="brians-latest-comments-fade-start"><?php _e('Start color for commenter fading:', 'thesis'); ?>
<input class="widefat" type="text" id="brians-latest-comments-fade-start" name="brians-latest-comments-fade-start" value="<?php echo $fade_start; ?>" /></label>
<br />
<small><?php _e('(example: #000000)', 'thesis'); ?></small>
</p>
<p>
<label for="brians-latest-comments-fade-end"><?php _e('End color for commenter fading:', 'thesis'); ?>
<input class="widefat" type="text" id="brians-latest-comments-fade-end" name="brians-latest-comments-fade-end" value="<?php echo $fade_end; ?>" /></label>
<br />
<small><?php _e('(example: #DDDDDD)', 'thesis'); ?></small>
</p>
<input type="hidden" id="brians-latest-comments-submit" name="brians-latest-comments-submit" value="1" />
<?php
}
// Register this widget
register_sidebar_widget(__('Brian\'s Latest Comments', 'thesis'), 'brians_latest_comments_widget');
register_widget_control(__('Brian\'s Latest Comments', 'thesis'), 'brians_latest_comments_control');
}
I'm pretty sure that if you want to use the commenter-fading functionality, you'll need to put in both a start & end color as well. You shouldn't have to -- it should use some sort of default -- but that's something I'll work on later. That minor annoyance aside, this should be a nice addition for any BLC user -- whether using Thesis or not. ![]() (Users of any other theme can put the code into their theme's functions.php file, and they'll be able to use the widget as well!)
__________________
Rick Beckman, Kingdom Geek & Thesis Support Ninja (Forums Moderator) [ Thesis Manual | Help, my posts don't show up! ] Amazon Wishlist | My custom.css Get Thesis! | Earn Cash as a DIY Affiliate! |
|
|||
|
Rick,
This works wonderfully. A very helpful Thesis modification. ![]() Thank you. Alec
__________________
Making Project Management Better Effectiveness Blog with a People Skills Focus. Please visit: http://blog.alecsatin.com http://twitter.com/alecsatin |
![]() |
| Thread Tools | |
| Display Modes | |
|
|