[32] | 1 | <?php
|
---|
| 2 |
|
---|
[150] | 3 | function xpress_list_pings($trackback, $args, $depth) {
|
---|
| 4 | $GLOBALS['comment'] = $trackback;
|
---|
[147] | 5 | echo '<li id="comment-<?php comment_ID(); ?>">';
|
---|
| 6 | comment_author_link();
|
---|
| 7 | }
|
---|
| 8 |
|
---|
[32] | 9 | function xpress_credit($show = false)
|
---|
| 10 | {
|
---|
[113] | 11 | global $wp_version , $xoops_config;
|
---|
[32] | 12 |
|
---|
[113] | 13 | $xpress_version = $xoops_config->module_version;
|
---|
| 14 | $xpress_codename = $xoops_config->module_codename;
|
---|
[96] | 15 | $ret = '<a href="http://www.toemon.com"'. " target='_blank'" . '>XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>';
|
---|
[32] | 16 | if (strstr($wp_version,'ME')){
|
---|
| 17 | $ret .= '(included <a href="http://wpme.sourceforge.jp/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)';
|
---|
| 18 | } else {
|
---|
| 19 | $ret .= '(included <a href="http://ja.wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)';
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | if (empty($show))
|
---|
| 23 | return $ret;
|
---|
| 24 | else
|
---|
| 25 | echo $ret;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | function xpress_convert_time($show = false)
|
---|
| 29 | {
|
---|
| 30 | $ret = timer_stop(0) .'sec. ';
|
---|
| 31 | if (empty($show))
|
---|
| 32 | return $ret;
|
---|
| 33 | else
|
---|
| 34 | echo $ret;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | function xpress_is_theme_sidebar_disp(){
|
---|
[144] | 38 | global $xpress_config;
|
---|
[145] | 39 | if (is_wordpress_style()) return true;
|
---|
[144] | 40 | return $xpress_config->is_theme_sidebar_disp;
|
---|
[32] | 41 | }
|
---|
| 42 |
|
---|
| 43 | function xpress_left_arrow_post_link($show = false)
|
---|
| 44 | {
|
---|
[144] | 45 | global $xpress_config;
|
---|
[33] | 46 | $ret = '';
|
---|
| 47 |
|
---|
[144] | 48 | if($xpress_config->is_left_postnavi_old){
|
---|
| 49 | $link_title = $xpress_config->old_post_link_text;
|
---|
[32] | 50 | ob_start();
|
---|
[144] | 51 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 52 | previous_post_link('« %link');
|
---|
| 53 | else
|
---|
| 54 | previous_post_link('« %link',$link_title);
|
---|
| 55 | $ret = ob_get_contents();
|
---|
| 56 | ob_end_clean();
|
---|
| 57 | } else {
|
---|
[144] | 58 | $link_title = $xpress_config->newer_post_link_text;
|
---|
[32] | 59 | ob_start();
|
---|
[144] | 60 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 61 | next_post_link('« %link');
|
---|
| 62 | else
|
---|
| 63 | next_post_link('« %link',$link_title);
|
---|
| 64 | $ret = ob_get_contents();
|
---|
| 65 | ob_end_clean();
|
---|
| 66 | }
|
---|
[33] | 67 |
|
---|
[144] | 68 | if ($xpress_config->is_postnavi_title_disp){
|
---|
[33] | 69 | $on_mouse_show = $link_title;
|
---|
| 70 | } else {
|
---|
[144] | 71 | if($xpress_config->is_left_postnavi_old){
|
---|
[33] | 72 | ob_start();
|
---|
| 73 | previous_post_link('%link');
|
---|
| 74 | $on_mouse_show = ob_get_contents();
|
---|
| 75 | ob_end_clean();
|
---|
| 76 | } else {
|
---|
| 77 | ob_start();
|
---|
| 78 | next_post_link('%link');
|
---|
| 79 | $on_mouse_show = ob_get_contents();
|
---|
| 80 | ob_end_clean();
|
---|
| 81 | }
|
---|
| 82 | $pattern = "<a[^>]*?>(.*)<\/a>";
|
---|
| 83 | preg_match("/".$pattern."/s", $on_mouse_show, $body_matches);
|
---|
| 84 | $on_mouse_show = $body_matches[1];
|
---|
| 85 | }
|
---|
| 86 | $ret = str_replace('">','" title="'.$on_mouse_show . '">' , $ret);
|
---|
[32] | 87 |
|
---|
| 88 | if (empty($show))
|
---|
| 89 | return $ret;
|
---|
| 90 | else
|
---|
[51] | 91 | echo $ret;
|
---|
[32] | 92 | }
|
---|
| 93 |
|
---|
| 94 | function xpress_right_arrow_post_link($show = false)
|
---|
| 95 | {
|
---|
[144] | 96 | global $xpress_config;
|
---|
[32] | 97 | $ret = '';
|
---|
| 98 |
|
---|
[144] | 99 | if($xpress_config->is_left_postnavi_old){
|
---|
| 100 | $link_title = $xpress_config->newer_post_link_text;
|
---|
[32] | 101 | ob_start();
|
---|
[144] | 102 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 103 | next_post_link('%link »');
|
---|
| 104 | else
|
---|
| 105 | next_post_link('%link »',$link_title);
|
---|
| 106 | $ret = ob_get_contents();
|
---|
| 107 | ob_end_clean();
|
---|
| 108 | } else {
|
---|
[144] | 109 | $link_title = $xpress_config->old_post_link_text;
|
---|
[32] | 110 | ob_start();
|
---|
[144] | 111 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 112 | previous_post_link('%link »');
|
---|
| 113 | else
|
---|
| 114 | previous_post_link('%link »',$link_title);
|
---|
| 115 | $ret = ob_get_contents();
|
---|
| 116 | ob_end_clean();
|
---|
| 117 | }
|
---|
[33] | 118 |
|
---|
[144] | 119 | if ($xpress_config->is_postnavi_title_disp){
|
---|
[33] | 120 | $on_mouse_show = $link_title;
|
---|
| 121 | } else {
|
---|
[144] | 122 | if($xpress_config->is_left_postnavi_old){
|
---|
[33] | 123 | ob_start();
|
---|
| 124 | next_post_link('%link');
|
---|
| 125 | $on_mouse_show = ob_get_contents();
|
---|
| 126 | ob_end_clean();
|
---|
| 127 | } else {
|
---|
| 128 | ob_start();
|
---|
| 129 | previous_post_link('%link');
|
---|
| 130 | $on_mouse_show = ob_get_contents();
|
---|
| 131 | ob_end_clean();
|
---|
| 132 | }
|
---|
| 133 | $pattern = "<a[^>]*?>(.*)<\/a>";
|
---|
| 134 | preg_match("/".$pattern."/s", $on_mouse_show, $body_matches);
|
---|
| 135 | $on_mouse_show = $body_matches[1];
|
---|
| 136 | }
|
---|
| 137 | $ret = str_replace('">','" title="'.$on_mouse_show . '">' , $ret);
|
---|
[32] | 138 |
|
---|
| 139 | if (empty($show))
|
---|
| 140 | return $ret;
|
---|
| 141 | else
|
---|
| 142 | echo $ret;
|
---|
| 143 | }
|
---|
[143] | 144 | // page link
|
---|
| 145 | function xpress_left_arrow_posts_link($show = false)
|
---|
| 146 | {
|
---|
[144] | 147 | global $xpress_config;
|
---|
[143] | 148 | $ret = '';
|
---|
| 149 |
|
---|
[144] | 150 | if($xpress_config->is_left_page_navi_old){
|
---|
| 151 | $link_title = $xpress_config->old_page_link_text;
|
---|
[143] | 152 | ob_start();
|
---|
| 153 | next_posts_link("« $link_title");
|
---|
| 154 | $ret = ob_get_contents();
|
---|
| 155 | ob_end_clean();
|
---|
| 156 | } else {
|
---|
[144] | 157 | $link_title = $xpress_config->newer_page_link_text;
|
---|
[143] | 158 | ob_start();
|
---|
| 159 | previous_posts_link("« $link_title");
|
---|
| 160 | $ret = ob_get_contents();
|
---|
| 161 | ob_end_clean();
|
---|
| 162 | }
|
---|
[51] | 163 |
|
---|
[143] | 164 | if (empty($show))
|
---|
| 165 | return $ret;
|
---|
| 166 | else
|
---|
| 167 | echo $ret;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | function xpress_right_arrow_posts_link($show = false)
|
---|
| 171 | {
|
---|
[144] | 172 | global $xpress_config;
|
---|
[143] | 173 | $ret = '';
|
---|
| 174 |
|
---|
[144] | 175 | if($xpress_config->is_left_page_navi_old){
|
---|
| 176 | $link_title = $xpress_config->newer_page_link_text;
|
---|
[143] | 177 | ob_start();
|
---|
| 178 | previous_posts_link("$link_title »");
|
---|
| 179 | $ret = ob_get_contents();
|
---|
| 180 | ob_end_clean();
|
---|
| 181 | } else {
|
---|
[144] | 182 | $link_title = $xpress_config->old_page_link_text;
|
---|
[143] | 183 | ob_start();
|
---|
| 184 | next_posts_link("$link_title »");
|
---|
| 185 | $ret = ob_get_contents();
|
---|
| 186 | ob_end_clean();
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 | if (empty($show))
|
---|
| 190 | return $ret;
|
---|
| 191 | else
|
---|
| 192 | echo $ret;
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 |
|
---|
[51] | 196 | function xpress_is_author_view_count(){
|
---|
[144] | 197 | global $xpress_config;
|
---|
| 198 | return $xpress_config->is_author_view_count;
|
---|
[51] | 199 | }
|
---|
| 200 |
|
---|
[46] | 201 | function xpress_substr($str, $start, $length, $trimmarker = '...')
|
---|
| 202 | {
|
---|
| 203 | if (function_exists('mb_substr')){
|
---|
| 204 | $str2 = mb_substr( $str , $start , $length);
|
---|
| 205 | return $str2 . ( mb_strlen($str)!=mb_strlen($str2) ? $trimmarker : '' );
|
---|
| 206 | } else {
|
---|
| 207 | return ( strlen($str) - $start <= $length ) ? substr( $str, $start, $length ) : substr( $str, $start, $length - strlen($trimmarker) ) . $trimmarker;
|
---|
| 208 | }
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 |
|
---|
[51] | 212 | // views count
|
---|
| 213 | // Set and retrieves post views given a post ID or post object.
|
---|
| 214 | // Retrieves post views given a post ID or post object.
|
---|
| 215 | function xpress_post_views_count($post_id=0,$format= '',$show = true) {
|
---|
[56] | 216 | global $xoops_db,$wpdb;
|
---|
[51] | 217 |
|
---|
| 218 | static $post_cache_views;
|
---|
| 219 |
|
---|
| 220 | if ( empty($post_id) ) {
|
---|
| 221 | if ( isset($GLOBALS['post']) )
|
---|
| 222 | $post_id = $GLOBALS['post']->ID;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | $post_id = intval($post_id);
|
---|
| 226 | if($post_id==0) return null;
|
---|
| 227 | if(!isset($post_cache_views[$post_id])){
|
---|
[56] | 228 | $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id";
|
---|
[54] | 229 | $post_views = $xoops_db->get_var($sql);
|
---|
| 230 | if (!$post_views) {
|
---|
[51] | 231 | $post_cache_views[$post_id] = 0;
|
---|
| 232 | }else{
|
---|
[54] | 233 | $post_cache_views[$post_id] = $post_views;
|
---|
[51] | 234 | }
|
---|
| 235 | }
|
---|
| 236 | $v_count = intval($post_cache_views[$post_id]);
|
---|
| 237 |
|
---|
| 238 | if (empty($format)) $format = __('views :%d','xpressme');
|
---|
| 239 |
|
---|
| 240 | $ret = sprintf($format,$v_count);
|
---|
| 241 |
|
---|
| 242 | if ($show) echo $ret; else return $ret;
|
---|
| 243 | }
|
---|
| 244 |
|
---|
| 245 | function set_post_views_count(&$content) {
|
---|
| 246 | if ( empty($_GET["feed"]) && empty($GLOBALS["feed"]) && empty($GLOBALS["doing_trackback"]) && empty($GLOBALS["doing_rss"]) && empty($_POST) && is_single() ){
|
---|
| 247 | post_views_counting();
|
---|
| 248 | }
|
---|
| 249 | return $content;
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | // Set post views given a post ID or post object.
|
---|
| 253 | function post_views_counting($post_id = 0) {
|
---|
[96] | 254 | global $xoops_db,$wpdb;
|
---|
[51] | 255 | global $table_prefix;
|
---|
| 256 | static $views;
|
---|
| 257 |
|
---|
| 258 | $post_id = intval($post_id);
|
---|
| 259 | if ( empty($post_id) && isset($GLOBALS['post']) ){
|
---|
| 260 | $post_id = $GLOBALS['post']->ID;
|
---|
| 261 | }
|
---|
| 262 |
|
---|
| 263 |
|
---|
[96] | 264 | $views_db = get_wp_prefix() . 'views';
|
---|
[51] | 265 |
|
---|
| 266 | if($post_id==0 || !empty($views[$post_id])) return null;
|
---|
| 267 |
|
---|
| 268 | if(!xpress_is_author_view_count()){
|
---|
| 269 | $current_user_id = $GLOBALS['current_user']->ID;
|
---|
| 270 | $post_author_id = $GLOBALS['post']->post_author;
|
---|
| 271 | if ($current_user_id ==$post_author_id) return null;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id";
|
---|
[96] | 275 | $post_views_found = $xoops_db->get_var($sql);
|
---|
| 276 | if($post_views_found){
|
---|
[51] | 277 | $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id";
|
---|
| 278 | }else{
|
---|
| 279 | $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)";
|
---|
| 280 | }
|
---|
[96] | 281 | $xoops_db->query($sql);
|
---|
[51] | 282 | return true;
|
---|
| 283 | }
|
---|
| 284 |
|
---|
[145] | 285 | function get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text = '') {
|
---|
| 286 | global $post,$xpress_config;
|
---|
| 287 |
|
---|
| 288 | $blog_encoding = get_option('blog_charset');
|
---|
| 289 | $text = get_the_content('');
|
---|
| 290 | $text = strip_shortcodes( $text );
|
---|
| 291 | $text = apply_filters('the_content', $text);
|
---|
| 292 | $text = str_replace(']]>', ']]>', $text);
|
---|
| 293 | $text = strip_tags($text);
|
---|
| 294 | $is_almost_ascii = ($xpress_config->ascii_judged_rate < round(@(mb_strlen($text, $blog_encoding) / strlen($text)) * 100)) ? true : false;
|
---|
| 295 | if($is_almost_ascii) {
|
---|
| 296 | $words = explode(' ', $text, $excerpt_length_word + 1);
|
---|
[51] | 297 |
|
---|
[145] | 298 | if(count($words) > $excerpt_length_word) {
|
---|
| 299 | array_pop($words);
|
---|
| 300 | array_push($words, ' ... ');
|
---|
| 301 | $text = implode(' ', $words);
|
---|
| 302 | if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>';
|
---|
[57] | 303 |
|
---|
| 304 | }
|
---|
| 305 | }
|
---|
[145] | 306 | elseif(mb_strlen($text, $blog_encoding) > $excerpt_length_character) {
|
---|
| 307 | $text = mb_substr($text, 0, $xpress_config->excerpt_length_character, $blog_encoding) . ' ... ';
|
---|
| 308 | if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>';
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | return $text;
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | function xpress_the_content($more_link_text = null, $stripteaser = 0, $more_file = '',$show = true)
|
---|
| 315 | {
|
---|
| 316 | global $post,$xpress_config;
|
---|
| 317 |
|
---|
| 318 |
|
---|
| 319 | if ($xpress_config->is_content_excerpt){
|
---|
| 320 | $excerpt_length_word = $xpress_config->excerpt_length_word;
|
---|
| 321 | $excerpt_length_character = $xpress_config->excerpt_length_character;
|
---|
| 322 | $more_link_text = $xpress_config->more_link_text;
|
---|
| 323 | $content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text);
|
---|
| 324 | } else {
|
---|
| 325 | $content = get_the_content($more_link_text,$stripteaser,$more_file);
|
---|
| 326 | $content = apply_filters('the_content', $content);
|
---|
| 327 | $content = str_replace(']]>', ']]>', $content);
|
---|
| 328 | }
|
---|
[57] | 329 | if(empty($show)) return $content;
|
---|
| 330 | echo $content;
|
---|
| 331 | }
|
---|
| 332 |
|
---|
[140] | 333 | function is_xpress_contributor()
|
---|
| 334 | {
|
---|
| 335 | global $current_user;
|
---|
| 336 | get_currentuserinfo();
|
---|
| 337 | if ($current_user->user_level > 3)
|
---|
| 338 | return true;
|
---|
| 339 | else
|
---|
| 340 | return false;
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | function xpress_post_new_link($link_title,$display = true)
|
---|
| 344 | {
|
---|
| 345 | $output = '<a href="'. get_xpress_url() . '/wp-admin/post-new.php' . '">' . $link_title . '</a>';
|
---|
| 346 | if ($display)
|
---|
| 347 | echo $output;
|
---|
| 348 | else
|
---|
| 349 | return $output;
|
---|
| 350 | }
|
---|
| 351 |
|
---|
| 352 | function xpress_conditional_title($display = true)
|
---|
| 353 | {
|
---|
[141] | 354 | $output = __('Main', 'xpressme');
|
---|
[140] | 355 | if (is_category())
|
---|
[141] | 356 | $output = sprintf(__('Archive for the ‘%s’ Category', 'xpressme'), single_cat_title('', false));
|
---|
[140] | 357 | if (is_tag())
|
---|
[141] | 358 | $output = sprintf(__('Posts Tagged ‘%s’', 'xpressme'), single_tag_title('', false) );
|
---|
[140] | 359 | if (is_day())
|
---|
[141] | 360 | $output = sprintf(__('Archive for %s|Daily archive page', 'xpressme'), get_the_time(__('F jS, Y', 'xpressme')));
|
---|
[140] | 361 | if (is_month())
|
---|
[141] | 362 | $output = sprintf(__('Archive for %s|Monthly archive page', 'xpressme'), get_the_time(__('F, Y', 'xpressme')));
|
---|
[140] | 363 | if (is_year())
|
---|
[141] | 364 | $output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme')));
|
---|
[140] | 365 | if (is_author())
|
---|
[141] | 366 | $output = sprintf(__('Archive for the ‘%s’ Author', 'xpressme'), get_author_name( get_query_var('author')));
|
---|
[140] | 367 | if (is_search())
|
---|
[143] | 368 | $output = sprintf(__('Search Results of word ‘%s’', 'xpressme'), get_search_query());
|
---|
[140] | 369 |
|
---|
| 370 | if ($display)
|
---|
| 371 | echo $output;
|
---|
| 372 | else
|
---|
| 373 | return $output;
|
---|
| 374 | }
|
---|
| 375 |
|
---|
[150] | 376 | function xpress_pings_list($show = false){
|
---|
| 377 |
|
---|
| 378 | $trackbacks = xpress_get_pings();
|
---|
[154] | 379 | if (! empty($trackbacks)) {
|
---|
| 380 | $output = '<ol id="xpress_pingslist"> ';
|
---|
[150] | 381 |
|
---|
[154] | 382 | foreach ($trackbacks as $trackback){
|
---|
| 383 | $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" ;
|
---|
[150] | 384 |
|
---|
[154] | 385 | $output .= '<li>';
|
---|
| 386 | $output .= $list ;
|
---|
| 387 | $output .= '</li>';
|
---|
[150] | 388 |
|
---|
[154] | 389 | }
|
---|
| 390 | $output .= '</ol>' ;
|
---|
| 391 | } else {
|
---|
| 392 | $output = '';
|
---|
[150] | 393 | }
|
---|
[154] | 394 |
|
---|
[150] | 395 | if ($show) echo $output; else return $output;
|
---|
| 396 | }
|
---|
| 397 |
|
---|
| 398 | function xpress_pings_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
|
---|
| 399 | $pings = xpress_get_pings();
|
---|
| 400 | if (empty($pings)){
|
---|
| 401 | $number = 0;
|
---|
| 402 | }else {
|
---|
| 403 | $number = count($pings);
|
---|
| 404 | }
|
---|
| 405 | if ( $number > 1 )
|
---|
| 406 | $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% TrackBack/Pingback', 'xpressme') : $more);
|
---|
| 407 | elseif ( $number == 0 )
|
---|
| 408 | $output = ( false === $zero ) ? __('No Trackback/Pingback', 'xpressme') : $zero;
|
---|
| 409 | else // must be one
|
---|
| 410 | $output = ( false === $one ) ? __('One Trackback/Pingback', 'xpressme') : $one;
|
---|
| 411 |
|
---|
| 412 | echo $output;
|
---|
| 413 | }
|
---|
| 414 |
|
---|
| 415 |
|
---|
| 416 | function xpress_get_pings()
|
---|
| 417 | {
|
---|
| 418 | global $withcomments, $post, $wpdb, $id, $trackback, $user_login, $user_ID, $user_identity;
|
---|
| 419 |
|
---|
| 420 | if ( ! (is_single() || is_page() || $withcomments) )
|
---|
| 421 | return;
|
---|
| 422 |
|
---|
| 423 | /** @todo Use API instead of SELECTs. */
|
---|
| 424 | if ( $user_ID) {
|
---|
| 425 | $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));
|
---|
| 426 | } else if ( empty($trackback_author) ) {
|
---|
| 427 | $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));
|
---|
| 428 | } else {
|
---|
| 429 | $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));
|
---|
| 430 | }
|
---|
| 431 |
|
---|
| 432 | if ($trackbacks){
|
---|
| 433 | $ret = array();
|
---|
| 434 | foreach ($trackbacks as $trackback){
|
---|
| 435 |
|
---|
| 436 | $pattern = '<strong>(.*)<\/strong>(.*)';
|
---|
| 437 | if ( preg_match ( "/".$pattern."/i", $trackback->comment_content , $match ) ){
|
---|
| 438 | $title = $match[1];
|
---|
| 439 | $content = $match[2];
|
---|
| 440 | }
|
---|
| 441 | if (empty($title)) $title = $trackback->comment_author;
|
---|
| 442 |
|
---|
| 443 |
|
---|
| 444 | $row_data = array(
|
---|
| 445 | 'ID' => $trackback->comment_ID ,
|
---|
| 446 | 'post_ID' => $trackback->comment_post_ID ,
|
---|
| 447 | 'site_name' => $trackback->comment_author ,
|
---|
| 448 | 'site_url' => $trackback->comment_author_url ,
|
---|
| 449 | 'title' => $title ,
|
---|
| 450 | 'content' => $content ,
|
---|
| 451 | 'date' => $trackback->comment_date ,
|
---|
| 452 | 'date_gmt' => $trackback->comment_date_gmt ,
|
---|
| 453 | 'agent' => $trackback->comment_agent ,
|
---|
| 454 | 'type' => $trackback->comment_type ,
|
---|
| 455 | 'IP' => $trackback->comment_author_IP ,
|
---|
| 456 | );
|
---|
| 457 | array_push($ret,$row_data);
|
---|
| 458 | }
|
---|
| 459 | return $ret;
|
---|
| 460 | }
|
---|
| 461 | return false;
|
---|
| 462 | }
|
---|
| 463 | ?>
|
---|