0 && $_POST['gravatar_size'] < 81) { update_option('kjgrc_gravatar_size',$_POST['gravatar_size']); } update_option('kjgrc_gravatar_alt_url',$_POST['gravatar_alt_url']); update_option('kjgrc_gravatar_rating',$_POST['gravatar_rating']); } if ($function == 'grt' && isset($_POST['ignore_ip'])) { update_option('kjgrc_grt_ignore_ip',trim($_POST['ignore_ip'])); } } $kjgrc_subpage = 1; if (isset($_GET['subpage'])) { $kjgrc_subpage = $_GET['subpage']; } kjgrc_subpage_header($kjgrc_subpage); if ($kjgrc_subpage == 1) { kjgrc_subpage_grc(); } elseif ($kjgrc_subpage == 2) { kjgrc_subpage_grt(); } elseif ($kjgrc_subpage == 3) { kjgrc_subpage_instructions(); } elseif ($kjgrc_subpage == 4) { kjgrc_subpage_exclude_cat(); } elseif ($kjgrc_subpage == 5) { kjgrc_subpage_gravatar(); } } function kjgrc_add_options_page() { add_options_page('Get Recent Comments Plugin', 'Recent Comments', 8, 'get-recent-comments.php','kjgrc_options_page'); } function kjgrc_get_option($section,$option_name) { global $kjgrc_options_initialized; if ($kjgrc_options_initialized == 0) { add_option('kjgrc_grc_max_comments',5); add_option('kjgrc_grc_chars_per_comment',120); add_option('kjgrc_grc_chars_per_word',30); add_option('kjgrc_grc_format', '
  • %comment_author: %comment_excerpt
  • '); add_option('kjgrc_grt_max_comments',5); add_option('kjgrc_grt_chars_per_comment',120); add_option('kjgrc_grt_chars_per_word',30); add_option('kjgrc_grt_format', '
  • %comment_author: %trackback_title
  • '); add_option('kjgrc_misc_exclude_cat',''); add_option('kjgrc_gravatar_size',20); add_option('kjgrc_gravatar_alt_url',''); add_option('kjgrc_gravatar_rating',0); $kjgrc_options_initialized = 1; } $option = get_option("kjgrc_" . $section . "_" . $option_name); return $option; } function kjgrc_get_exclude_cat () { $exclude_cat = kjgrc_get_option('misc','exclude_cat'); if ($exclude_cat == '') { return FALSE; } #echo "cats: '". kjgrc_get_option('misc','exclude_cat') ."' "; return explode(" ",kjgrc_get_option('misc','exclude_cat')); } /* if (function_exists('get_recent_trackbacks')) { echo "Warning: You have multiple plugins with a function "get_recent_trackbacks()""; return; } */ function get_recent_trackbacks($sample=0) { global $tablecomments,$tableposts,$tablepost2cat; // WordPress 1.2.x has no is_plugin_page if (! function_exists("is_plugin_page")) { $chars_per_word = 30; } else { $max_comments = kjgrc_get_option("grt","max_comments"); $chars_per_comment = kjgrc_get_option("grt","chars_per_comment"); $chars_per_word = kjgrc_get_option("grt","chars_per_word"); $format = stripslashes(kjgrc_get_option("grt","format")); $exclude_cat = kjgrc_get_exclude_cat(); if ($exclude_cat) { $sql_join_post2cat = "LEFT JOIN $tablepost2cat ON $tablepost2cat.post_ID=$tablecomments.comment_post_ID "; foreach ($exclude_cat as $cat) { $sql_exlude_cat .= "AND category_id != '$cat' "; } } } if ($sample == 1) { $max_comments = 1; $echo = 0; } else { $echo = 1; } $sql_ignore_ip = ''; if (kjgrc_get_option("grt","ignore_ip") != '') { $sql_ignore_ip = "AND comment_author_IP != '". kjgrc_get_option("grt","ignore_ip") ."' "; } $query = "SELECT DISTINCT $tablecomments.* FROM $tablecomments ". "LEFT JOIN $tableposts ON $tableposts.ID=$tablecomments.comment_post_ID ". $sql_join_post2cat . "WHERE (post_status = 'publish' OR post_status = 'static') AND comment_approved= '1' AND post_password = '' ". $sql_exlude_cat . "AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ". $sql_ignore_ip . "ORDER BY comment_date DESC LIMIT $max_comments"; return kjgrc_get_entries($max_comments,$chars_per_comment,$chars_per_word,$format,$query,$echo); } /* if (function_exists('get_recent_comments')) { echo "Warning: You have multiple plugins with a function "get_recent_comments()""; return; } */ function get_recent_comments ($max_comments=5, $chars_per_comment=120, $format='
  • %comment_author: %comment_excerpt
  • ',$sample=0) { global $tablecomments,$tableposts,$tablepost2cat; // WordPress 1.2.x has no is_plugin_page if (! function_exists("is_plugin_page")) { $sql_comment_type = ''; // In WP1.2 select all comments (also trackbacks) $chars_per_word = 30; } else { $max_comments = kjgrc_get_option("grc","max_comments"); $chars_per_comment = kjgrc_get_option("grc","chars_per_comment"); $chars_per_word = kjgrc_get_option("grc","chars_per_word"); $format = stripslashes(kjgrc_get_option("grc","format")); $sql_comment_type = "AND comment_type = '' "; $exclude_cat = kjgrc_get_exclude_cat(); if ($exclude_cat) { $sql_join_post2cat = "LEFT JOIN $tablepost2cat ON $tablepost2cat.post_ID=$tablecomments.comment_post_ID "; foreach ($exclude_cat as $cat) { $sql_exlude_cat .= "AND category_id != '$cat' "; } } } if ($sample == 1) { $max_comments = 1; $echo = 0; } else { $echo = 1; } $query = "SELECT DISTINCT $tablecomments.* FROM $tablecomments ". "LEFT JOIN $tableposts ON $tableposts.ID=$tablecomments.comment_post_ID ". $sql_join_post2cat . "WHERE (post_status = 'publish' OR post_status = 'static') AND comment_approved= '1' AND post_password = '' ". $sql_exlude_cat . $sql_comment_type . "ORDER BY comment_date DESC LIMIT $max_comments"; return kjgrc_get_entries($max_comments,$chars_per_comment,$chars_per_word,$format,$query,$echo); } function kjgrc_get_entries ($max_comments,$chars_per_comment,$chars_per_word, $format,$query,$echo=1) { global $wpdb; if (!(strpos($format,"%gravatar") !== false)) $has_gravatar = 0; else { $has_gravatar = 1; $gravatar_alt_url = kjgrc_get_option('gravatar','alt_url'); $gravatar_size = kjgrc_get_option('gravatar','size'); $gravatar_rating = kjgrc_get_option('gravatar','rating'); $gravatar_mpaa[0] = 'G'; $gravatar_mpaa[1] = 'PG'; $gravatar_mpaa[2] = 'R'; $gravatar_mpaa[3] = 'X'; $gravatar_options .= "&size=$gravatar_size"; $gravatar_options .= "&rating=" . $gravatar_mpaa[$gravatar_rating]; if (kjgrc_get_option('gravatar','alt_url') != '') { $gravatar_options .= "&default=" . urlencode($gravatar_alt_url); } } $comments = $wpdb->get_results($query); if (! $comments) { echo "
  • "; return; } foreach ($comments as $comment) { $trackback_title = ''; $comment_excerpt = $comment->comment_content; if (function_exists("is_plugin_page")) // be compatible to wp 1.2.x { if ($comment->comment_type == 'pingback') { $trackback_title = $comment->comment_author; if (strpos($trackback_title,'»') !== false) { $trackback_title = substr($trackback_title, strpos($trackback_title,'»')+7,strlen($trackback_title)); } if (strpos($trackback_title,'»') !== false) { $trackback_title = substr($trackback_title, strpos($trackback_title,'»')+7,strlen($trackback_title)); } //$trackback_title .= " '$comment->comment_author [P]'"; //$trackback_title = "Pingback"; } elseif ($comment->comment_type == 'trackback') { $trackback_title = preg_replace("/^(.+?).*/s","$1",$comment->comment_content); $trackback_title = strip_tags($trackback_title); $trackback_title = preg_replace("/[ntr]/"," ",$trackback_title); $trackback_title = preg_replace("/s{2,}/"," ",$trackback_title); $trackback_title = wordwrap($trackback_title,$chars_per_word,' ',1); $comment_excerpt = preg_replace("/^.+?/","",$comment->comment_content,1); $comment_excerpt = strip_tags($comment_excerpt); //trackbacks need htmlspecialchars. strip //must come before $comment_excerpt = htmlspecialchars($comment_excerpt); } } $comment_excerpt = strip_tags($comment_excerpt); $comment_excerpt = preg_replace("/[ntr]/"," ",$comment_excerpt); $comment_excerpt = preg_replace("/s{2,}/"," ",$comment_excerpt); $comment_excerpt = wordwrap($comment_excerpt,$chars_per_word,' ',1); $post_link = get_permalink($comment->comment_post_ID); $comment_link = $post_link . "#comment-$comment->comment_ID"; $comment_date = mysql2date(get_settings('date_format'),$comment->comment_date); //$comment_time = substr($comment->comment_date,11,5); // 2005-03-09 22:23:53 $comment_time = mysql2date(get_settings('time_format'),$comment->comment_date); // Thanks to Keith $comment_author = $comment->comment_author; if ($has_gravatar && $comment_author != '') { if ($md5_cache && array_key_exists($comment->comment_author,$md5_cache)) { $gravatar_md5 = $md5_cache[$comment->comment_author]; } else { $gravatar_md5 = md5($comment->comment_author_email); $md5_cache[$comment->comment_author] = $gravatar_md5; } $comment_gravatar_url = "http://www.gravatar.com/avatar.php?" . "gravatar_id=$gravatar_md5" . $gravatar_options; $comment_gravatar = ""; } if ($comment->comment_type == 'pingback') { $comment_author = trim(substr($comment_author,0,strpos($comment_author,'»'))); } if (! $comment_author) $comment_author = 'Anonymous'; $post = get_postdata($comment->comment_post_ID); $post_date = mysql2date(get_settings('date_format'),$post['Date']); $output = $format; $output = str_replace("%comment_link", $comment_link, $output); $output = str_replace("%author_url", $comment->comment_author_url, $output); $output = str_replace("%userid", $comment->user_id,$output); $output = str_replace("%gravatar_url", $comment_gravatar_url, $output); $output = str_replace("%gravatar", $comment_gravatar, $output); $output = str_replace("%comment_author", $comment_author, $output); $output = str_replace("%comment_date", $comment_date, $output); $output = str_replace("%comment_time", $comment_time, $output); $output = str_replace("%post_title", trim(htmlspecialchars(stripslashes($post['Title']))), $output); $output = str_replace("%post_link", $post_link, $output); $output = str_replace("%post_date", $post_date, $output); //strip title or content? $visible = strip_tags($output); #echo "t$output [[".$visible."]]n"; if (strpos($visible,'%comment_excerpt') !== false) { $comment_excerpt = kjgrc_excerpt($comment_excerpt,$chars_per_comment,$chars_per_word,'%comment_excerpt',$output); } elseif (strpos($visible,'%trackback_title') !== false) { $trackback_title = kjgrc_excerpt($trackback_title,$chars_per_comment,$chars_per_word,'%trackback_title',$output); } #$comment_excerpt = kjgrc_excerpt($comment_excerpt,$len,$chars_per_word); #$trackback_title = kjgrc_excerpt($trackback_title,$len,$chars_per_word); $output = str_replace("%comment_excerpt", $comment_excerpt,$output); $output = str_replace("%trackback_title", $trackback_title, $output); #$len = strlen(strip_tags($output)); //$output .= " [$comment_time]"; if (! $echo) { return "$output"; } else { echo "t$outputn"; } } // foreach } function kjgrc_excerpt ($text,$chars_per_comment,$chars_per_word,$tag,$output) { $length = strlen(str_replace($tag,"",strip_tags($output))); $length = $chars_per_comment - $length; $length = $length -2; // we will add three dots at the end if ($length < 0) $length = 0; if (strlen($text) > $length) { $text = substr($text,0,$length); $text = substr($text,0,strrpos($text,' ')); // last word exceeds max word length: if ((strlen($text) - strrpos($text,' ')) > $chars_per_word) { $text = substr($text,0,strlen($text)-3); } $text = $text . "..."; } #$text = "[EXCERPT]: '$text'"; return "$text"; } add_action('admin_menu', 'kjgrc_add_options_page'); ?> /* Widgets and Etc */ .widget_search div { margin: 1.2em 0; } #sidebar #s { margin-bottom: 2px; width: 180px; }

    没有找到

    抱歉, 但是您所请求的页面无法找到.

    搜索