| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
function get_comment_author() { |
|---|
| 7 |
global $comment; |
|---|
| 8 |
if ( empty($comment->comment_author) ) |
|---|
| 9 |
$author = __('Anonymous'); |
|---|
| 10 |
else |
|---|
| 11 |
$author = $comment->comment_author; |
|---|
| 12 |
return apply_filters('get_comment_author', $author); |
|---|
| 13 |
} |
|---|
| 14 |
|
|---|
| 15 |
function comment_author() { |
|---|
| 16 |
$author = apply_filters('comment_author', get_comment_author() ); |
|---|
| 17 |
echo $author; |
|---|
| 18 |
} |
|---|
| 19 |
|
|---|
| 20 |
function get_comment_author_email() { |
|---|
| 21 |
global $comment; |
|---|
| 22 |
return apply_filters('get_comment_author_email', $comment->comment_author_email); |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
function comment_author_email() { |
|---|
| 26 |
echo apply_filters('author_email', get_comment_author_email() ); |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
function comment_author_email_link($linktext='', $before='', $after='') { |
|---|
| 30 |
global $comment; |
|---|
| 31 |
$email = apply_filters('comment_email', $comment->comment_author_email); |
|---|
| 32 |
if ((!empty($email)) && ($email != '@')) { |
|---|
| 33 |
$display = ($linktext != '') ? $linktext : $email; |
|---|
| 34 |
echo $before; |
|---|
| 35 |
echo "<a href='mailto:$email'>$display</a>"; |
|---|
| 36 |
echo $after; |
|---|
| 37 |
} |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
function get_comment_author_link() { |
|---|
| 41 |
global $comment; |
|---|
| 42 |
$url = get_comment_author_url(); |
|---|
| 43 |
$author = get_comment_author(); |
|---|
| 44 |
|
|---|
| 45 |
if ( empty( $url ) || 'http://' == $url ) |
|---|
| 46 |
$return = $author; |
|---|
| 47 |
else |
|---|
| 48 |
$return = "<a href='$url' rel='external nofollow'>$author</a>"; |
|---|
| 49 |
return apply_filters('get_comment_author_link', $return); |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
function comment_author_link() { |
|---|
| 53 |
echo get_comment_author_link(); |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
function get_comment_author_IP() { |
|---|
| 57 |
global $comment; |
|---|
| 58 |
return apply_filters('get_comment_author_IP', $comment->comment_author_IP); |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
function comment_author_IP() { |
|---|
| 62 |
echo get_comment_author_IP(); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
function get_comment_author_url() { |
|---|
| 66 |
global $comment; |
|---|
| 67 |
return apply_filters('get_comment_author_url', $comment->comment_author_url); |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
function comment_author_url() { |
|---|
| 71 |
echo apply_filters('comment_url', get_comment_author_url()); |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { |
|---|
| 75 |
global $comment; |
|---|
| 76 |
$url = get_comment_author_url(); |
|---|
| 77 |
$display = ($linktext != '') ? $linktext : $url; |
|---|
| 78 |
$display = str_replace( 'http://www.', '', $display ); |
|---|
| 79 |
$display = str_replace( 'http://', '', $display ); |
|---|
| 80 |
if ( '/' == substr($display, -1) ) |
|---|
| 81 |
$display = substr($display, 0, -1); |
|---|
| 82 |
$return = "$before<a href='$url' rel='external'>$display</a>$after"; |
|---|
| 83 |
return apply_filters('get_comment_author_url_link', $return); |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
function comment_author_url_link( $linktext = '', $before = '', $after = '' ) { |
|---|
| 87 |
echo get_comment_author_url_link( $linktext, $before, $after ); |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
function get_comment_date( $d = '' ) { |
|---|
| 91 |
global $comment; |
|---|
| 92 |
if ( '' == $d ) |
|---|
| 93 |
$date = mysql2date( get_option('date_format'), $comment->comment_date); |
|---|
| 94 |
else |
|---|
| 95 |
$date = mysql2date($d, $comment->comment_date); |
|---|
| 96 |
return apply_filters('get_comment_date', $date, $d); |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
function comment_date( $d = '' ) { |
|---|
| 100 |
echo get_comment_date( $d ); |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
function get_comment_excerpt() { |
|---|
| 104 |
global $comment; |
|---|
| 105 |
$comment_text = strip_tags($comment->comment_content); |
|---|
| 106 |
$blah = explode(' ', $comment_text); |
|---|
| 107 |
if (count($blah) > 20) { |
|---|
| 108 |
$k = 20; |
|---|
| 109 |
$use_dotdotdot = 1; |
|---|
| 110 |
} else { |
|---|
| 111 |
$k = count($blah); |
|---|
| 112 |
$use_dotdotdot = 0; |
|---|
| 113 |
} |
|---|
| 114 |
$excerpt = ''; |
|---|
| 115 |
for ($i=0; $i<$k; $i++) { |
|---|
| 116 |
$excerpt .= $blah[$i] . ' '; |
|---|
| 117 |
} |
|---|
| 118 |
$excerpt .= ($use_dotdotdot) ? '...' : ''; |
|---|
| 119 |
return apply_filters('get_comment_excerpt', $excerpt); |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
function comment_excerpt() { |
|---|
| 123 |
echo apply_filters('comment_excerpt', get_comment_excerpt() ); |
|---|
| 124 |
} |
|---|
| 125 |
|
|---|
| 126 |
function get_comment_ID() { |
|---|
| 127 |
global $comment; |
|---|
| 128 |
return apply_filters('get_comment_ID', $comment->comment_ID); |
|---|
| 129 |
} |
|---|
| 130 |
|
|---|
| 131 |
function comment_ID() { |
|---|
| 132 |
echo get_comment_ID(); |
|---|
| 133 |
} |
|---|
| 134 |
|
|---|
| 135 |
function get_comment_link() { |
|---|
| 136 |
global $comment; |
|---|
| 137 |
return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID; |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
function get_comments_link() { |
|---|
| 141 |
return get_permalink() . '#comments'; |
|---|
| 142 |
} |
|---|
| 143 |
|
|---|
| 144 |
function comments_link( $file = '', $echo = true ) { |
|---|
| 145 |
echo get_comments_link(); |
|---|
| 146 |
} |
|---|
| 147 |
|
|---|
| 148 |
function get_comments_number( $post_id = 0 ) { |
|---|
| 149 |
global $wpdb, $id; |
|---|
| 150 |
$post_id = (int) $post_id; |
|---|
| 151 |
|
|---|
| 152 |
if ( !$post_id ) |
|---|
| 153 |
$post_id = $id; |
|---|
| 154 |
|
|---|
| 155 |
$post = get_post($post_id); |
|---|
| 156 |
if ( ! isset($post->comment_count) ) |
|---|
| 157 |
$count = 0; |
|---|
| 158 |
else |
|---|
| 159 |
$count = $post->comment_count; |
|---|
| 160 |
|
|---|
| 161 |
return apply_filters('get_comments_number', $count); |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
function comments_number( $zero = false, $one = false, $more = false, $number = '' ) { |
|---|
| 165 |
global $id; |
|---|
| 166 |
$number = get_comments_number($id); |
|---|
| 167 |
|
|---|
| 168 |
if ( $number > 1 ) |
|---|
| 169 |
$output = str_replace('%', $number, ( false === $more ) ? __('% Comments') : $more); |
|---|
| 170 |
elseif ( $number == 0 ) |
|---|
| 171 |
$output = ( false === $zero ) ? __('No Comments') : $zero; |
|---|
| 172 |
else |
|---|
| 173 |
$output = ( false === $one ) ? __('1 Comment') : $one; |
|---|
| 174 |
|
|---|
| 175 |
echo apply_filters('comments_number', $output, $number); |
|---|
| 176 |
} |
|---|
| 177 |
|
|---|
| 178 |
function get_comment_text() { |
|---|
| 179 |
global $comment; |
|---|
| 180 |
return apply_filters('get_comment_text', $comment->comment_content); |
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
function comment_text() { |
|---|
| 184 |
echo apply_filters('comment_text', get_comment_text() ); |
|---|
| 185 |
} |
|---|
| 186 |
|
|---|
| 187 |
function get_comment_time( $d = '', $gmt = false ) { |
|---|
| 188 |
global $comment; |
|---|
| 189 |
$comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date; |
|---|
| 190 |
if ( '' == $d ) |
|---|
| 191 |
$date = mysql2date(get_option('time_format'), $comment_date); |
|---|
| 192 |
else |
|---|
| 193 |
$date = mysql2date($d, $comment_date); |
|---|
| 194 |
return apply_filters('get_comment_time', $date, $d, $gmt); |
|---|
| 195 |
} |
|---|
| 196 |
|
|---|
| 197 |
function comment_time( $d = '' ) { |
|---|
| 198 |
echo get_comment_time($d); |
|---|
| 199 |
} |
|---|
| 200 |
|
|---|
| 201 |
function get_comment_type() { |
|---|
| 202 |
global $comment; |
|---|
| 203 |
|
|---|
| 204 |
if ( '' == $comment->comment_type ) |
|---|
| 205 |
$comment->comment_type = 'comment'; |
|---|
| 206 |
|
|---|
| 207 |
return apply_filters('get_comment_type', $comment->comment_type); |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') { |
|---|
| 211 |
$type = get_comment_type(); |
|---|
| 212 |
switch( $type ) { |
|---|
| 213 |
case 'trackback' : |
|---|
| 214 |
echo $trackbacktxt; |
|---|
| 215 |
break; |
|---|
| 216 |
case 'pingback' : |
|---|
| 217 |
echo $pingbacktxt; |
|---|
| 218 |
break; |
|---|
| 219 |
default : |
|---|
| 220 |
echo $commenttxt; |
|---|
| 221 |
} |
|---|
| 222 |
} |
|---|
| 223 |
|
|---|
| 224 |
function get_trackback_url() { |
|---|
| 225 |
global $id; |
|---|
| 226 |
$tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id; |
|---|
| 227 |
|
|---|
| 228 |
if ( '' != get_option('permalink_structure') ) |
|---|
| 229 |
$tb_url = trailingslashit(get_permalink()) . 'trackback/'; |
|---|
| 230 |
|
|---|
| 231 |
return $tb_url; |
|---|
| 232 |
} |
|---|
| 233 |
function trackback_url( $display = true ) { |
|---|
| 234 |
if ( $display) |
|---|
| 235 |
echo get_trackback_url(); |
|---|
| 236 |
else |
|---|
| 237 |
return get_trackback_url(); |
|---|
| 238 |
} |
|---|
| 239 |
|
|---|
| 240 |
function trackback_rdf($timezone = 0) { |
|---|
| 241 |
global $id; |
|---|
| 242 |
if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) { |
|---|
| 243 |
echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
|---|
| 244 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
|---|
| 245 |
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> |
|---|
| 246 |
<rdf:Description rdf:about="'; |
|---|
| 247 |
the_permalink(); |
|---|
| 248 |
echo '"'."\n"; |
|---|
| 249 |
echo ' dc:identifier="'; |
|---|
| 250 |
the_permalink(); |
|---|
| 251 |
echo '"'."\n"; |
|---|
| 252 |
echo ' dc:title="'.str_replace('--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n"; |
|---|
| 253 |
echo ' trackback:ping="'.trackback_url(0).'"'." />\n"; |
|---|
| 254 |
echo '</rdf:RDF>'; |
|---|
| 255 |
} |
|---|
| 256 |
} |
|---|
| 257 |
|
|---|
| 258 |
function comments_open() { |
|---|
| 259 |
global $post; |
|---|
| 260 |
if ( 'open' == $post->comment_status ) |
|---|
| 261 |
return true; |
|---|
| 262 |
else |
|---|
| 263 |
return false; |
|---|
| 264 |
} |
|---|
| 265 |
|
|---|
| 266 |
function pings_open() { |
|---|
| 267 |
global $post; |
|---|
| 268 |
if ( 'open' == $post->ping_status ) |
|---|
| 269 |
return true; |
|---|
| 270 |
else |
|---|
| 271 |
return false; |
|---|
| 272 |
} |
|---|
| 273 |
|
|---|
| 274 |
function comments_template( $file = '/comments.php' ) { |
|---|
| 275 |
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity; |
|---|
| 276 |
|
|---|
| 277 |
if ( ! (is_single() || is_page() || $withcomments) ) |
|---|
| 278 |
return; |
|---|
| 279 |
|
|---|
| 280 |
$req = get_option('require_name_email'); |
|---|
| 281 |
$commenter = wp_get_current_commenter(); |
|---|
| 282 |
extract($commenter); |
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
if ( empty($comment_author) ) { |
|---|
| 286 |
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date"); |
|---|
| 287 |
} else { |
|---|
| 288 |
$author_db = $wpdb->escape($comment_author); |
|---|
| 289 |
$email_db = $wpdb->escape($comment_author_email); |
|---|
| 290 |
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date"); |
|---|
| 291 |
} |
|---|
| 292 |
|
|---|
| 293 |
$comments = apply_filters( 'comments_array', $comments, $post->ID ); |
|---|
| 294 |
|
|---|
| 295 |
define('COMMENTS_TEMPLATE', true); |
|---|
| 296 |
$include = apply_filters('comments_template', TEMPLATEPATH . $file ); |
|---|
| 297 |
if ( file_exists( $include ) ) |
|---|
| 298 |
require( $include ); |
|---|
| 299 |
else |
|---|
| 300 |
require( ABSPATH . 'wp-content/themes/default/comments.php'); |
|---|
| 301 |
} |
|---|
| 302 |
|
|---|
| 303 |
function comments_popup_script($width=400, $height=400, $file='') { |
|---|
| 304 |
global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript; |
|---|
| 305 |
|
|---|
| 306 |
if (empty ($file)) { |
|---|
| 307 |
$wpcommentspopupfile = ''; |
|---|
| 308 |
} else { |
|---|
| 309 |
$wpcommentspopupfile = $file; |
|---|
| 310 |
} |
|---|
| 311 |
|
|---|
| 312 |
$wpcommentsjavascript = 1; |
|---|
| 313 |
$javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n"; |
|---|
| 314 |
echo $javascript; |
|---|
| 315 |
} |
|---|
| 316 |
|
|---|
| 317 |
function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { |
|---|
| 318 |
global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb; |
|---|
| 319 |
|
|---|
| 320 |
if ( is_single() || is_page() ) |
|---|
| 321 |
return; |
|---|
| 322 |
|
|---|
| 323 |
$number = get_comments_number($id); |
|---|
| 324 |
|
|---|
| 325 |
if ( 0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status ) { |
|---|
| 326 |
echo $none; |
|---|
| 327 |
return; |
|---|
| 328 |
} |
|---|
| 329 |
|
|---|
| 330 |
if ( !empty($post->post_password) ) { |
|---|
| 331 |
if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { |
|---|
| 332 |
echo(__('Enter your password to view comments')); |
|---|
| 333 |
return; |
|---|
| 334 |
} |
|---|
| 335 |
} |
|---|
| 336 |
|
|---|
| 337 |
echo '<a href="'; |
|---|
| 338 |
if ($wpcommentsjavascript) { |
|---|
| 339 |
if ( empty($wpcommentspopupfile) ) |
|---|
| 340 |
$home = get_option('home'); |
|---|
| 341 |
else |
|---|
| 342 |
$home = get_option('siteurl'); |
|---|
| 343 |
echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id; |
|---|
| 344 |
echo '" onclick="wpopen(this.href); return false"'; |
|---|
| 345 |
} else { |
|---|
| 346 |
if ( 0 == $number ) |
|---|
| 347 |
echo get_permalink() . '#respond'; |
|---|
| 348 |
else |
|---|
| 349 |
comments_link(); |
|---|
| 350 |
echo '"'; |
|---|
| 351 |
} |
|---|
| 352 |
|
|---|
| 353 |
if (!empty($CSSclass)) { |
|---|
| 354 |
echo ' class="'.$CSSclass.'"'; |
|---|
| 355 |
} |
|---|
| 356 |
$title = attribute_escape(apply_filters('the_title', get_the_title())); |
|---|
| 357 |
echo ' title="' . sprintf( __('Comment on %s'), $title ) .'">'; |
|---|
| 358 |
comments_number($zero, $one, $more, $number); |
|---|
| 359 |
echo '</a>'; |
|---|
| 360 |
} |
|---|
| 361 |
|
|---|
| 362 |
?> |
|---|
| 363 |
|
|---|