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