CoderDan;10917181 wrote:I basically understand what you want, but i meant more specifics on where you are stuck.
I mean, sure, I could write such a system, but this is a forum for solving problems, not requesting custom code snippets 🙂
Oh, sorry about that. Here is the clarified clarified ;
I think there won't be any need to modify the script that appends the comments rating button and the current rating to the comment?
I also think I should use this to Print the 10 top rated comments as UL?I am not too sure though - any better ideas?
function topc_highest_rated($num = 10) {
$top_rated = (array) get_option('topc-top-rated');
if ( $num < count($top_rated) )
$top_rated = array_slice($top_rated, 0, $num);
echo "<ul class='topc-comments'>\n";
foreach ( $top_rated as $row )
echo "\t<li>".stripslashes($row)."</li>\n";
echo "</ul>\n";
}
I plan on leaving this intact for my purposes as well? Its for preparing the top rated comments.
function topc_make_highest_rated() {
global $wpdb;
$limit = 10; // how many to include
$length = 75; // character lenght of the comment excerpt
$chars_per_word = 25; // max chars per word, will force-wrap longer words so they stay whitin the width of the sidebar
$comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_karma DESC LIMIT %d", $limit) );
if ( ! $comments ) return;
$top_rated = array();
foreach ($comments as $comment) {
$author = $comment->comment_author;
$author = wordwrap($author, $chars_per_word, ' ', true);
$text = $comment->comment_content;
$text = strip_tags(wptexturize($text));
if ( strlen($text) > $length ) {
$text = substr( $text, 0, $length );
$text = substr( $text, 0, strrpos($text, ' ') );
$text .= "…";
}
$text = wordwrap($text, $chars_per_word, ' ', true);
$text = preg_replace('/\s+/', ' ', $text); // spaces into 1
$row = __('Score: ', 'topc') . $comment->comment_karma . ', <a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . $author . ', ' . get_the_title($comment->comment_post_ID) . ':</a> ' . $text;
$top_rated[] = $wpdb->escape($row);
}
update_option( 'topc-top-rated', $top_rated );
update_option( 'topc-top-rated-last', $comment->comment_karma );
function topc_timelimit($m) {
global $topc_display_opt;
if ( ! isset($topc_display_opt) )
$topc_display_opt = (array) get_option('topc_display');
if ( ! isset($topc_display_opt['timelimit']) || ! $topc_display_opt['timelimit'] )
return true;
$i = mktime(
(int) substr( $m, 11, 2 ), (int) substr( $m, 14, 2 ), (int) substr( $m, 17, 2 ),
(int) substr( $m, 5, 2 ), (int) substr( $m, 8, 2 ), (int) substr( $m, 0, 4 )
);
if ( (time() - $topc_display_opt['timelimit']) < $i )
return true;
return false;
}
I recon this has something to do with the ammount of comments that I want to be present untill a status is set for the comment? If not, could you please direct me?
if ( !$number = (int) $options['number'] )
$number = 5;
else if ( $number < 1 )
$number = 1;
else if ( $number > 10 )
$number = 10;
I am really at sea with the CSS though, although it sounds simple enough...If you would just give me a model script or atleast a small lead, I will be very very thankful
Thanks again!