pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

diythemes private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Rick Beckman on Fri 1 Aug 12:04 (modification of post by Rick Beckman view diff)
report abuse | download | new post

  1. /*
  2.         Widget for Brian's Latest Comments
  3. */
  4.  
  5. if (function_exists('blc_latest_comments')) {
  6.         // Output the widget
  7.         function brians_latest_comments_widget($args) {
  8.                 extract($args, EXTR_SKIP);
  9.                 $options = get_option('brians_latest_comments_widget');
  10.                 $posts = $options['brians-latest-comments-posts'] - 1;
  11.                
  12.                 echo $before_widget . "\n";
  13.                 echo $before_title . $options['brians-latest-comments-title'] . $after_title . "\n";
  14.                 echo "<ul>\n";
  15.                 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']);
  16.                 echo "</ul>\n";
  17.                 echo $after_widget . "\n";
  18.         }
  19.  
  20.         function wp_flush_widget_brians_latest_comments() {
  21.                 wp_cache_delete('brians_latest_comments_widget', 'widget');
  22.         }
  23.         add_action('comment_post', 'wp_flush_widget_brians_latest_comments');
  24.         add_action('edit_comment', 'wp_flush_widget_brians_latest_comments');
  25.         add_action('delete_comment', 'wp_flush_widget_brians_latest_comments');
  26.         add_action('pingback_post', 'wp_flush_widget_brians_latest_comments');
  27.         add_action('trackback_post', 'wp_flush_widget_brians_latest_comments');
  28.         add_action('wp_set_comment_status', 'wp_flush_widget_brians_latest_comments');
  29.  
  30.         // Widget control
  31.         function brians_latest_comments_control() {
  32.                 $options = $newoptions = get_option('brians_latest_comments_widget');
  33.                
  34.                 if ($_POST['brians-latest-comments-submit']) {
  35.                         $newoptions['brians-latest-comments-title'] = strip_tags(stripslashes($_POST['brians-latest-comments-title']));
  36.                         $newoptions['brians-latest-comments-posts'] = (int) $_POST['brians-latest-comments-posts'];
  37.                         $newoptions['brians-latest-comments-commenters'] = (int) $_POST['brians-latest-comments-commenters'];
  38.                         $newoptions['brians-latest-comments-hide-tbpb'] = (int) $_POST['brians-latest-comments-hide-tbpb'];
  39.                         $newoptions['brians-latest-comments-fade-old'] = (int) $_POST['brians-latest-comments-fade-old'];
  40.                         $newoptions['brians-latest-comments-days'] = (int) $_POST['brians-latest-comments-days'];
  41.                         $newoptions['brians-latest-comments-fade-start'] = strip_tags(stripslashes($_POST['brians-latest-comments-fade-start']));
  42.                         $newoptions['brians-latest-comments-fade-end'] = strip_tags(stripslashes($_POST['brians-latest-comments-fade-end']));
  43.                 }
  44.        
  45.                 if ($options != $newoptions) {
  46.                         $options = $newoptions;
  47.                         update_option('brians_latest_comments_widget', $options);
  48.                         wp_flush_widget_brians_latest_comments();
  49.                 }
  50.                
  51.                 $title = attribute_escape($options['brians-latest-comments-title']);
  52.                 if (!$posts = (int) $options['brians-latest-comments-posts'])
  53.                         $posts = 5;
  54.                 if (!$commenters = (int) $options['brians-latest-comments-commenters'])
  55.                         $commenters = 5;
  56.                 $hide_tbpb = (int) $options['brians-latest-comments-hide-tbpb'];
  57.                 $fade_old = (int) $options['brians-latest-comments-fade-old'];
  58.                 if (!$days = (int) $options['brians-latest-comments-days'])
  59.                         $days = 10;
  60.                 $fade_start = attribute_escape($options['brians-latest-comments-fade-start']);
  61.                 $fade_end = attribute_escape($options['brians-latest-comments-fade-end']);
  62.         ?>
  63.                         <p>
  64.                                 <label for="brians-latest-comments-title"><?php _e('Title:', 'thesis'); ?>
  65.                                 <input type="text" class="widefat" id="brians-latest-comments-title" name="brians-latest-comments-title" value="<?php echo $title; ?>" /></label>
  66.                         </p>
  67.                         <p>
  68.                                 <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>
  69.                                 <br />
  70.                                 <small><?php _e('(default is 5)', 'thesis'); ?></small>
  71.                         </p>
  72.                         <p>
  73.                                 <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>
  74.                                 <br />
  75.                                 <small><?php _e('(default is 5)', 'thesis'); ?></small>
  76.                         </p>
  77.                         <p>
  78.                                 <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 &amp; PingBacks?', 'thesis'); ?></label>
  79.                         </p>
  80.                         <p>
  81.                                 <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>
  82.                         </p>
  83.                         <p>
  84.                                 <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>
  85.                                 <br />
  86.                                 <small><?php _e('(default is 10)', 'thesis'); ?></small>
  87.                         </p>
  88.                         <p>
  89.                                 <label for="brians-latest-comments-fade-start"><?php _e('Start color for commenter fading:', 'thesis'); ?>
  90.                                 <input class="widefat" type="text" id="brians-latest-comments-fade-start" name="brians-latest-comments-fade-start" value="<?php echo $fade_start; ?>" /></label>
  91.                                 <br />
  92.                                 <small><?php _e('(example: #000000)', 'thesis'); ?></small>
  93.                         </p>
  94.                         <p>
  95.                                 <label for="brians-latest-comments-fade-end"><?php _e('End color for commenter fading:', 'thesis'); ?>
  96.                                 <input class="widefat" type="text" id="brians-latest-comments-fade-end" name="brians-latest-comments-fade-end" value="<?php echo $fade_end; ?>" /></label>
  97.                                 <br />
  98.                                 <small><?php _e('(example: #DDDDDD)', 'thesis'); ?></small>
  99.                         </p>
  100.                         <input type="hidden" id="brians-latest-comments-submit" name="brians-latest-comments-submit" value="1" />
  101.         <?php
  102.         }
  103.        
  104.         // Register this widget
  105.         register_sidebar_widget(__('Brian\'s Latest Comments', 'thesis'), 'brians_latest_comments_widget');
  106.         register_widget_control(__('Brian\'s Latest Comments', 'thesis'), 'brians_latest_comments_control');
  107. }

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.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post