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