- Timestamp:
- Apr 2, 2009, 6:37:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/plugins/xpressme/include/custom_functions.php
r147 r150 1 1 <?php 2 2 3 function xpress_list_pings($ comment, $args, $depth) {4 $GLOBALS['comment'] = $ comment;3 function xpress_list_pings($trackback, $args, $depth) { 4 $GLOBALS['comment'] = $trackback; 5 5 echo '<li id="comment-<?php comment_ID(); ?>">'; 6 6 comment_author_link(); … … 374 374 } 375 375 376 function xpress_pings_list($show = false){ 377 378 $trackbacks = xpress_get_pings(); 379 $output = '<ol id="xpress_pingslist"> '; 380 381 foreach ($trackbacks as $trackback){ 382 $list = date(get_settings('date_format'),$trackback['date']) . ' <a target="_blank" href="' . $trackback['site_url'] . '" rel="external nofollow">' . sprintf(__('From %1$s on site %2$s','xpressme'),$trackback['title'],$trackback['site_name']) . "</a>\n" ; 383 384 $output .= '<li>'; 385 $output .= $list ; 386 $output .= '</li>'; 387 388 } 389 $output .= '</ol>' ; 390 if ($show) echo $output; else return $output; 391 } 392 393 function xpress_pings_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { 394 $pings = xpress_get_pings(); 395 if (empty($pings)){ 396 $number = 0; 397 }else { 398 $number = count($pings); 399 } 400 if ( $number > 1 ) 401 $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% TrackBack/Pingback', 'xpressme') : $more); 402 elseif ( $number == 0 ) 403 $output = ( false === $zero ) ? __('No Trackback/Pingback', 'xpressme') : $zero; 404 else // must be one 405 $output = ( false === $one ) ? __('One Trackback/Pingback', 'xpressme') : $one; 406 407 echo $output; 408 } 409 410 411 function xpress_get_pings() 412 { 413 global $withcomments, $post, $wpdb, $id, $trackback, $user_login, $user_ID, $user_identity; 414 415 if ( ! (is_single() || is_page() || $withcomments) ) 416 return; 417 418 /** @todo Use API instead of SELECTs. */ 419 if ( $user_ID) { 420 $trackbacks = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ORDER BY comment_date", $post->ID, $user_ID)); 421 } else if ( empty($trackback_author) ) { 422 $trackbacks = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ORDER BY comment_date", $post->ID)); 423 } else { 424 $trackbacks = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ORDER BY comment_date", $post->ID, $trackback_author, $trackback_author_email)); 425 } 426 427 if ($trackbacks){ 428 $ret = array(); 429 foreach ($trackbacks as $trackback){ 430 431 $pattern = '<strong>(.*)<\/strong>(.*)'; 432 if ( preg_match ( "/".$pattern."/i", $trackback->comment_content , $match ) ){ 433 $title = $match[1]; 434 $content = $match[2]; 435 } 436 if (empty($title)) $title = $trackback->comment_author; 437 438 439 $row_data = array( 440 'ID' => $trackback->comment_ID , 441 'post_ID' => $trackback->comment_post_ID , 442 'site_name' => $trackback->comment_author , 443 'site_url' => $trackback->comment_author_url , 444 'title' => $title , 445 'content' => $content , 446 'date' => $trackback->comment_date , 447 'date_gmt' => $trackback->comment_date_gmt , 448 'agent' => $trackback->comment_agent , 449 'type' => $trackback->comment_type , 450 'IP' => $trackback->comment_author_IP , 451 ); 452 array_push($ret,$row_data); 453 } 454 return $ret; 455 } 456 return false; 457 } 376 458 ?>
Note: See TracChangeset
for help on using the changeset viewer.