📄 comment-functions.php
字号:
} if (!empty($CSSclass)) { echo ' class="'.$CSSclass.'"'; } $title = wp_specialchars(apply_filters('the_title', get_the_title()), true); echo ' title="' . sprintf( __('Comment on %s'), $title ) .'">'; comments_number($zero, $one, $more, $number); echo '</a>'; } }}function get_comment_ID() { global $comment; return apply_filters('get_comment_ID', $comment->comment_ID);}function comment_ID() { echo get_comment_ID();}function get_comment_author() { global $comment; if ( empty($comment->comment_author) ) $author = __('Anonymous'); else $author = $comment->comment_author; return apply_filters('get_comment_author', $author);}function comment_author() { $author = apply_filters('comment_author', get_comment_author() ); echo $author;}function get_comment_author_email() { global $comment; return apply_filters('get_comment_author_email', $comment->comment_author_email); }function comment_author_email() { echo apply_filters('author_email', get_comment_author_email() );}function get_comment_author_link() { global $comment; $url = get_comment_author_url(); $author = get_comment_author(); if ( empty( $url ) || 'http://' == $url ) $return = $author; else $return = "<a href='$url' rel='external nofollow'>$author</a>"; return apply_filters('get_comment_author_link', $return);}function comment_author_link() { echo get_comment_author_link();}function get_comment_type() { global $comment; if ( '' == $comment->comment_type ) $comment->comment_type = 'comment'; return apply_filters('get_comment_type', $comment->comment_type);}function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') { $type = get_comment_type(); switch( $type ) { case 'trackback' : echo $trackbacktxt; break; case 'pingback' : echo $pingbacktxt; break; default : echo $commenttxt; }}function get_comment_author_url() { global $comment; return apply_filters('get_comment_author_url', $comment->comment_author_url);}function comment_author_url() { echo apply_filters('comment_url', get_comment_author_url());}function comment_author_email_link($linktext='', $before='', $after='') { global $comment; $email = apply_filters('comment_email', $comment->comment_author_email); if ((!empty($email)) && ($email != '@')) { $display = ($linktext != '') ? $linktext : $email; echo $before; echo "<a href='mailto:$email'>$display</a>"; echo $after; }}function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { global $comment; $url = get_comment_author_url(); $display = ($linktext != '') ? $linktext : $url; $return = "$before<a href='$url' rel='external'>$display</a>$after"; return apply_filters('get_comment_author_url_link', $return);}function comment_author_url_link( $linktext = '', $before = '', $after = '' ) { echo get_comment_author_url_link( $linktext, $before, $after );}function get_comment_author_IP() { global $comment; return apply_filters('get_comment_author_IP', $comment->comment_author_IP);}function comment_author_IP() { echo get_comment_author_IP();}function get_comment_text() { global $comment; return apply_filters('get_comment_text', $comment->comment_content);}function comment_text() { echo apply_filters('comment_text', get_comment_text() );}function get_comment_excerpt() { global $comment; $comment_text = strip_tags($comment->comment_content); $blah = explode(' ', $comment_text); if (count($blah) > 20) { $k = 20; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } $excerpt = ''; for ($i=0; $i<$k; $i++) { $excerpt .= $blah[$i] . ' '; } $excerpt .= ($use_dotdotdot) ? '...' : ''; return apply_filters('get_comment_excerpt', $excerpt);}function comment_excerpt() { echo apply_filters('comment_excerpt', get_comment_excerpt() );}function get_comment_date( $d = '' ) { global $comment; if ( '' == $d ) $date = mysql2date( get_settings('date_format'), $comment->comment_date); else $date = mysql2date($d, $comment->comment_date); return apply_filters('get_comment_date', $date);}function comment_date( $d = '' ) { echo get_comment_date( $d );}function get_comment_time( $d = '', $gmt = false ) { global $comment; $comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date; if ( '' == $d ) $date = mysql2date(get_settings('time_format'), $comment_date); else $date = mysql2date($d, $comment_date); return apply_filters('get_comment_time', $date);}function comment_time( $d = '' ) { echo get_comment_time($d);}function get_trackback_url() { global $id; $tb_url = get_settings('siteurl') . '/wp-trackback.php?p=' . $id; if ( '' != get_settings('permalink_structure') ) $tb_url = trailingslashit(get_permalink()) . 'trackback/'; return $tb_url;}function trackback_url( $display = true ) { if ( $display) echo get_trackback_url(); else return get_trackback_url();}function trackback_rdf($timezone = 0) { global $id; if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) { echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> <rdf:Description rdf:about="'; the_permalink(); echo '"'."\n"; echo ' dc:identifier="'; the_permalink(); echo '"'."\n"; echo ' dc:title="'.str_replace('--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n"; echo ' trackback:ping="'.trackback_url(0).'"'." />\n"; echo '</rdf:RDF>'; }}function comments_open() { global $post; if ( 'open' == $post->comment_status ) return true; else return false;}function pings_open() { global $post; if ( 'open' == $post->ping_status ) return true; else return false;}// Non-template functionsfunction get_lastcommentmodified($timezone = 'server') { global $cache_lastcommentmodified, $pagenow, $wpdb; $add_seconds_blog = get_settings('gmt_offset') * 3600; $add_seconds_server = date('Z'); $now = current_time('mysql', 1); if ( !isset($cache_lastcommentmodified[$timezone]) ) { switch(strtolower($timezone)) { case 'gmt': $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); break; case 'blog': $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); break; case 'server': $lastcommentmodified = $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); break; } $cache_lastcommentmodified[$timezone] = $lastcommentmodified; } else { $lastcommentmodified = $cache_lastcommentmodified[$timezone]; } return $lastcommentmodified;}function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { // less flexible, but saves DB queries global $postc, $id, $commentdata, $wpdb; if ($no_cache) { $query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'"; if (false == $include_unapproved) { $query .= " AND comment_approved = '1'"; } $myrow = $wpdb->get_row($query, ARRAY_A); } else { $myrow['comment_ID'] = $postc->comment_ID; $myrow['comment_post_ID'] = $postc->comment_post_ID; $myrow['comment_author'] = $postc->comment_author; $myrow['comment_author_email'] = $postc->comment_author_email; $myrow['comment_author_url'] = $postc->comment_author_url; $myrow['comment_author_IP'] = $postc->comment_author_IP; $myrow['comment_date'] = $postc->comment_date; $myrow['comment_content'] = $postc->comment_content; $myrow['comment_karma'] = $postc->comment_karma; $myrow['comment_approved'] = $postc->comment_approved; $myrow['comment_type'] = $postc->comment_type; } return $myrow;}function pingback($content, $post_ID) { global $wp_version, $wpdb; include_once (ABSPATH . WPINC . '/class-IXR.php'); // original code by Mort (http://mort.mine.nu:8080) $log = debug_fopen(ABSPATH . '/pingback.log', 'a'); $post_links = array(); debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n"); $pung = get_pung($post_ID); // Variables $ltrs = '\w'; $gunk = '/#~:.?+=&%@!\-'; $punc = '.:?\-'; $any = $ltrs . $gunk . $punc; // Step 1 // Parsing the post, external links (if any) are stored in the $post_links array // This regexp comes straight from phpfreaks.com // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); // Debug debug_fwrite($log, 'Post contents:'); debug_fwrite($log, $content."\n"); // Step 2. // Walking thru the links array // first we get rid of links pointing to sites, not to specific files
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -