Posted by Rick Beckman on Fri 1 Aug 12:04 (modification of post by Rick Beckman view diff)
report abuse | download | new post
- /*
- Widget for Brian's Latest Comments
- */
- // Output the widget
- function brians_latest_comments_widget($args) {
- $options = get_option('brians_latest_comments_widget');
- $posts = $options['brians-latest-comments-posts'] - 1;
- 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";
- }
- 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');
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.