[32] | 1 | <?php
|
---|
[165] | 2 | function xpress_the_title($show = false)
|
---|
| 3 | {
|
---|
| 4 | $output = '<div class ="xpress-post-header">' . "\n";
|
---|
| 5 |
|
---|
| 6 | if (function_exists('hotDates')) {
|
---|
| 7 | ob_start();
|
---|
| 8 | hotDates();
|
---|
| 9 | $output .= ob_get_contents();
|
---|
| 10 | ob_end_clean();
|
---|
| 11 | }
|
---|
| 12 | $output .= '<div class ="xpress-post-title">' . "\n";
|
---|
| 13 | $output .= '<h2><a href="';
|
---|
| 14 | ob_start();
|
---|
| 15 | the_permalink();
|
---|
| 16 | $output .= ob_get_contents();
|
---|
| 17 | ob_end_clean();
|
---|
| 18 |
|
---|
| 19 | $output .= '" rel="bookmark" title="';
|
---|
| 20 | $output .= sprintf(__('Permanent Link to %s', 'xpress'), the_title_attribute('echo=0'));
|
---|
| 21 | $output .= '">';
|
---|
| 22 | ob_start();
|
---|
| 23 | the_title();
|
---|
| 24 | $output .= ob_get_contents();
|
---|
| 25 | ob_end_clean();
|
---|
| 26 | $output .= '</a></h2>' . "\n";
|
---|
| 27 | $output .= '</div>' . "\n";
|
---|
| 28 | $output .= '</div>' . "\n";
|
---|
| 29 |
|
---|
| 30 | if (empty($show))
|
---|
| 31 | return $output;
|
---|
| 32 | else
|
---|
| 33 | echo $output;
|
---|
| 34 |
|
---|
| 35 | }
|
---|
| 36 |
|
---|
[155] | 37 | function xpress_selected_author($show=true ) {
|
---|
| 38 | $output = '';
|
---|
| 39 | $author_cookie = get_xpress_dir_name() . "_select_author" ;
|
---|
| 40 | if (!empty($_COOKIE[$author_cookie])){
|
---|
| 41 | $uid = intval($_COOKIE[$author_cookie]);
|
---|
| 42 | $user_info = get_userdata($uid);
|
---|
| 43 | $output = $user_info->display_name;
|
---|
| 44 | }
|
---|
| 45 | if (empty($show))
|
---|
| 46 | return $output;
|
---|
| 47 | else
|
---|
| 48 | echo $output;
|
---|
| 49 |
|
---|
| 50 | }
|
---|
[157] | 51 | function xpress_selected_author_id($show=true ) {
|
---|
| 52 | $output = '';
|
---|
| 53 | $author_cookie = get_xpress_dir_name() . "_select_author" ;
|
---|
| 54 | if (!empty($_COOKIE[$author_cookie])){
|
---|
| 55 | $output = intval($_COOKIE[$author_cookie]);
|
---|
| 56 | } else {
|
---|
| 57 | $output = '';
|
---|
| 58 | }
|
---|
| 59 | if (empty($show))
|
---|
| 60 | return $output;
|
---|
| 61 | else
|
---|
| 62 | echo $output;
|
---|
| 63 |
|
---|
| 64 | }
|
---|
[164] | 65 |
|
---|
| 66 | function xpress_now_user_level($show=true ) {
|
---|
| 67 | global $current_user;
|
---|
| 68 | $output = @$current_user->user_level;
|
---|
| 69 | if (empty($show))
|
---|
| 70 | return $output;
|
---|
| 71 | else
|
---|
| 72 | echo $output;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 |
|
---|
[150] | 76 | function xpress_list_pings($trackback, $args, $depth) {
|
---|
| 77 | $GLOBALS['comment'] = $trackback;
|
---|
[147] | 78 | echo '<li id="comment-<?php comment_ID(); ?>">';
|
---|
| 79 | comment_author_link();
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[32] | 82 | function xpress_credit($show = false)
|
---|
| 83 | {
|
---|
[113] | 84 | global $wp_version , $xoops_config;
|
---|
[32] | 85 |
|
---|
[113] | 86 | $xpress_version = $xoops_config->module_version;
|
---|
| 87 | $xpress_codename = $xoops_config->module_codename;
|
---|
[193] | 88 | $ret = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>';
|
---|
[32] | 89 | if (strstr($wp_version,'ME')){
|
---|
| 90 | $ret .= '(included <a href="http://wpme.sourceforge.jp/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)';
|
---|
| 91 | } else {
|
---|
| 92 | $ret .= '(included <a href="http://ja.wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)';
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | if (empty($show))
|
---|
| 96 | return $ret;
|
---|
| 97 | else
|
---|
| 98 | echo $ret;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | function xpress_convert_time($show = false)
|
---|
| 102 | {
|
---|
| 103 | $ret = timer_stop(0) .'sec. ';
|
---|
| 104 | if (empty($show))
|
---|
| 105 | return $ret;
|
---|
| 106 | else
|
---|
| 107 | echo $ret;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | function xpress_is_theme_sidebar_disp(){
|
---|
[144] | 111 | global $xpress_config;
|
---|
[145] | 112 | if (is_wordpress_style()) return true;
|
---|
[144] | 113 | return $xpress_config->is_theme_sidebar_disp;
|
---|
[32] | 114 | }
|
---|
| 115 |
|
---|
[184] | 116 | function xpress_left_arrow_post_link($show = true)
|
---|
[32] | 117 | {
|
---|
[144] | 118 | global $xpress_config;
|
---|
[33] | 119 | $ret = '';
|
---|
| 120 |
|
---|
[144] | 121 | if($xpress_config->is_left_postnavi_old){
|
---|
| 122 | $link_title = $xpress_config->old_post_link_text;
|
---|
[32] | 123 | ob_start();
|
---|
[144] | 124 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 125 | previous_post_link('« %link');
|
---|
| 126 | else
|
---|
| 127 | previous_post_link('« %link',$link_title);
|
---|
| 128 | $ret = ob_get_contents();
|
---|
| 129 | ob_end_clean();
|
---|
[164] | 130 | ob_start();
|
---|
| 131 | previous_post_link('%link',$link_title);
|
---|
| 132 | $GLOBALS['left_arrow_post_link'] = ob_get_contents();
|
---|
| 133 | ob_end_clean();
|
---|
| 134 |
|
---|
[32] | 135 | } else {
|
---|
[144] | 136 | $link_title = $xpress_config->newer_post_link_text;
|
---|
[32] | 137 | ob_start();
|
---|
[144] | 138 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 139 | next_post_link('« %link');
|
---|
| 140 | else
|
---|
[164] | 141 | $GLOBALS['left_arrow_post_link'] =
|
---|
[32] | 142 | $ret = ob_get_contents();
|
---|
| 143 | ob_end_clean();
|
---|
[164] | 144 | ob_start();
|
---|
| 145 | next_post_link('%link',$link_title);
|
---|
| 146 | $GLOBALS['left_arrow_post_link'] = ob_get_contents();
|
---|
| 147 | ob_end_clean();
|
---|
| 148 |
|
---|
[32] | 149 | }
|
---|
[33] | 150 |
|
---|
[144] | 151 | if ($xpress_config->is_postnavi_title_disp){
|
---|
[33] | 152 | $on_mouse_show = $link_title;
|
---|
| 153 | } else {
|
---|
[144] | 154 | if($xpress_config->is_left_postnavi_old){
|
---|
[33] | 155 | ob_start();
|
---|
| 156 | previous_post_link('%link');
|
---|
| 157 | $on_mouse_show = ob_get_contents();
|
---|
| 158 | ob_end_clean();
|
---|
| 159 | } else {
|
---|
| 160 | ob_start();
|
---|
| 161 | next_post_link('%link');
|
---|
| 162 | $on_mouse_show = ob_get_contents();
|
---|
| 163 | ob_end_clean();
|
---|
| 164 | }
|
---|
| 165 | $pattern = "<a[^>]*?>(.*)<\/a>";
|
---|
| 166 | preg_match("/".$pattern."/s", $on_mouse_show, $body_matches);
|
---|
| 167 | $on_mouse_show = $body_matches[1];
|
---|
| 168 | }
|
---|
| 169 | $ret = str_replace('">','" title="'.$on_mouse_show . '">' , $ret);
|
---|
[32] | 170 |
|
---|
| 171 | if (empty($show))
|
---|
| 172 | return $ret;
|
---|
| 173 | else
|
---|
[51] | 174 | echo $ret;
|
---|
[32] | 175 | }
|
---|
| 176 |
|
---|
[184] | 177 | function xpress_right_arrow_post_link($show = true)
|
---|
[32] | 178 | {
|
---|
[144] | 179 | global $xpress_config;
|
---|
[32] | 180 | $ret = '';
|
---|
| 181 |
|
---|
[144] | 182 | if($xpress_config->is_left_postnavi_old){
|
---|
| 183 | $link_title = $xpress_config->newer_post_link_text;
|
---|
[32] | 184 | ob_start();
|
---|
[144] | 185 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 186 | next_post_link('%link »');
|
---|
| 187 | else
|
---|
| 188 | next_post_link('%link »',$link_title);
|
---|
| 189 | $ret = ob_get_contents();
|
---|
| 190 | ob_end_clean();
|
---|
[164] | 191 | ob_start();
|
---|
| 192 | next_post_link('%link',$link_title);
|
---|
| 193 | $GLOBALS['right_arrow_post_link'] = ob_get_contents();
|
---|
| 194 | ob_end_clean();
|
---|
| 195 |
|
---|
[32] | 196 | } else {
|
---|
[144] | 197 | $link_title = $xpress_config->old_post_link_text;
|
---|
[32] | 198 | ob_start();
|
---|
[144] | 199 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 200 | previous_post_link('%link »');
|
---|
| 201 | else
|
---|
| 202 | previous_post_link('%link »',$link_title);
|
---|
| 203 | $ret = ob_get_contents();
|
---|
| 204 | ob_end_clean();
|
---|
[164] | 205 | ob_start();
|
---|
| 206 | previous_post_link('%link',$link_title);
|
---|
| 207 | $GLOBALS['right_arrow_post_link'] = ob_get_contents();
|
---|
| 208 | ob_end_clean();
|
---|
| 209 |
|
---|
[32] | 210 | }
|
---|
[33] | 211 |
|
---|
[144] | 212 | if ($xpress_config->is_postnavi_title_disp){
|
---|
[33] | 213 | $on_mouse_show = $link_title;
|
---|
| 214 | } else {
|
---|
[144] | 215 | if($xpress_config->is_left_postnavi_old){
|
---|
[33] | 216 | ob_start();
|
---|
| 217 | next_post_link('%link');
|
---|
| 218 | $on_mouse_show = ob_get_contents();
|
---|
| 219 | ob_end_clean();
|
---|
| 220 | } else {
|
---|
| 221 | ob_start();
|
---|
| 222 | previous_post_link('%link');
|
---|
| 223 | $on_mouse_show = ob_get_contents();
|
---|
| 224 | ob_end_clean();
|
---|
| 225 | }
|
---|
| 226 | $pattern = "<a[^>]*?>(.*)<\/a>";
|
---|
| 227 | preg_match("/".$pattern."/s", $on_mouse_show, $body_matches);
|
---|
| 228 | $on_mouse_show = $body_matches[1];
|
---|
| 229 | }
|
---|
| 230 | $ret = str_replace('">','" title="'.$on_mouse_show . '">' , $ret);
|
---|
[32] | 231 |
|
---|
| 232 | if (empty($show))
|
---|
| 233 | return $ret;
|
---|
| 234 | else
|
---|
| 235 | echo $ret;
|
---|
| 236 | }
|
---|
[143] | 237 | // page link
|
---|
[184] | 238 | function xpress_left_arrow_posts_link($show = true)
|
---|
[143] | 239 | {
|
---|
[144] | 240 | global $xpress_config;
|
---|
[143] | 241 | $ret = '';
|
---|
| 242 |
|
---|
[144] | 243 | if($xpress_config->is_left_page_navi_old){
|
---|
| 244 | $link_title = $xpress_config->old_page_link_text;
|
---|
[143] | 245 | ob_start();
|
---|
| 246 | next_posts_link("« $link_title");
|
---|
| 247 | $ret = ob_get_contents();
|
---|
| 248 | ob_end_clean();
|
---|
| 249 | } else {
|
---|
[144] | 250 | $link_title = $xpress_config->newer_page_link_text;
|
---|
[143] | 251 | ob_start();
|
---|
| 252 | previous_posts_link("« $link_title");
|
---|
| 253 | $ret = ob_get_contents();
|
---|
| 254 | ob_end_clean();
|
---|
| 255 | }
|
---|
[51] | 256 |
|
---|
[143] | 257 | if (empty($show))
|
---|
| 258 | return $ret;
|
---|
| 259 | else
|
---|
| 260 | echo $ret;
|
---|
| 261 | }
|
---|
| 262 |
|
---|
[184] | 263 | function xpress_right_arrow_posts_link($show = true)
|
---|
[143] | 264 | {
|
---|
[144] | 265 | global $xpress_config;
|
---|
[143] | 266 | $ret = '';
|
---|
| 267 |
|
---|
[144] | 268 | if($xpress_config->is_left_page_navi_old){
|
---|
| 269 | $link_title = $xpress_config->newer_page_link_text;
|
---|
[143] | 270 | ob_start();
|
---|
| 271 | previous_posts_link("$link_title »");
|
---|
| 272 | $ret = ob_get_contents();
|
---|
| 273 | ob_end_clean();
|
---|
| 274 | } else {
|
---|
[144] | 275 | $link_title = $xpress_config->old_page_link_text;
|
---|
[143] | 276 | ob_start();
|
---|
| 277 | next_posts_link("$link_title »");
|
---|
| 278 | $ret = ob_get_contents();
|
---|
| 279 | ob_end_clean();
|
---|
| 280 | }
|
---|
| 281 |
|
---|
| 282 | if (empty($show))
|
---|
| 283 | return $ret;
|
---|
| 284 | else
|
---|
| 285 | echo $ret;
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 |
|
---|
[51] | 289 | function xpress_is_author_view_count(){
|
---|
[144] | 290 | global $xpress_config;
|
---|
| 291 | return $xpress_config->is_author_view_count;
|
---|
[51] | 292 | }
|
---|
| 293 |
|
---|
[155] | 294 | function xpress_is_multi_user(){
|
---|
| 295 | global $xpress_config;
|
---|
| 296 | return $xpress_config->is_multi_user;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
| 299 |
|
---|
[46] | 300 | function xpress_substr($str, $start, $length, $trimmarker = '...')
|
---|
| 301 | {
|
---|
| 302 | if (function_exists('mb_substr')){
|
---|
| 303 | $str2 = mb_substr( $str , $start , $length);
|
---|
| 304 | return $str2 . ( mb_strlen($str)!=mb_strlen($str2) ? $trimmarker : '' );
|
---|
| 305 | } else {
|
---|
| 306 | return ( strlen($str) - $start <= $length ) ? substr( $str, $start, $length ) : substr( $str, $start, $length - strlen($trimmarker) ) . $trimmarker;
|
---|
| 307 | }
|
---|
| 308 | }
|
---|
| 309 |
|
---|
| 310 |
|
---|
[51] | 311 | // views count
|
---|
| 312 | // Set and retrieves post views given a post ID or post object.
|
---|
| 313 | // Retrieves post views given a post ID or post object.
|
---|
| 314 | function xpress_post_views_count($post_id=0,$format= '',$show = true) {
|
---|
[56] | 315 | global $xoops_db,$wpdb;
|
---|
[51] | 316 |
|
---|
| 317 | static $post_cache_views;
|
---|
| 318 |
|
---|
| 319 | if ( empty($post_id) ) {
|
---|
| 320 | if ( isset($GLOBALS['post']) )
|
---|
| 321 | $post_id = $GLOBALS['post']->ID;
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | $post_id = intval($post_id);
|
---|
| 325 | if($post_id==0) return null;
|
---|
| 326 | if(!isset($post_cache_views[$post_id])){
|
---|
[56] | 327 | $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id";
|
---|
[54] | 328 | $post_views = $xoops_db->get_var($sql);
|
---|
| 329 | if (!$post_views) {
|
---|
[51] | 330 | $post_cache_views[$post_id] = 0;
|
---|
| 331 | }else{
|
---|
[54] | 332 | $post_cache_views[$post_id] = $post_views;
|
---|
[51] | 333 | }
|
---|
| 334 | }
|
---|
| 335 | $v_count = intval($post_cache_views[$post_id]);
|
---|
| 336 |
|
---|
| 337 | if (empty($format)) $format = __('views :%d','xpressme');
|
---|
| 338 |
|
---|
| 339 | $ret = sprintf($format,$v_count);
|
---|
| 340 |
|
---|
| 341 | if ($show) echo $ret; else return $ret;
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 | function set_post_views_count(&$content) {
|
---|
| 345 | if ( empty($_GET["feed"]) && empty($GLOBALS["feed"]) && empty($GLOBALS["doing_trackback"]) && empty($GLOBALS["doing_rss"]) && empty($_POST) && is_single() ){
|
---|
| 346 | post_views_counting();
|
---|
| 347 | }
|
---|
| 348 | return $content;
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | // Set post views given a post ID or post object.
|
---|
| 352 | function post_views_counting($post_id = 0) {
|
---|
[96] | 353 | global $xoops_db,$wpdb;
|
---|
[51] | 354 | global $table_prefix;
|
---|
| 355 | static $views;
|
---|
| 356 |
|
---|
| 357 | $post_id = intval($post_id);
|
---|
| 358 | if ( empty($post_id) && isset($GLOBALS['post']) ){
|
---|
| 359 | $post_id = $GLOBALS['post']->ID;
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 |
|
---|
[96] | 363 | $views_db = get_wp_prefix() . 'views';
|
---|
[51] | 364 |
|
---|
| 365 | if($post_id==0 || !empty($views[$post_id])) return null;
|
---|
| 366 |
|
---|
| 367 | if(!xpress_is_author_view_count()){
|
---|
| 368 | $current_user_id = $GLOBALS['current_user']->ID;
|
---|
| 369 | $post_author_id = $GLOBALS['post']->post_author;
|
---|
| 370 | if ($current_user_id ==$post_author_id) return null;
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id";
|
---|
[96] | 374 | $post_views_found = $xoops_db->get_var($sql);
|
---|
| 375 | if($post_views_found){
|
---|
[51] | 376 | $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id";
|
---|
| 377 | }else{
|
---|
| 378 | $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)";
|
---|
| 379 | }
|
---|
[96] | 380 | $xoops_db->query($sql);
|
---|
[51] | 381 | return true;
|
---|
| 382 | }
|
---|
| 383 |
|
---|
[145] | 384 | function get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text = '') {
|
---|
| 385 | global $post,$xpress_config;
|
---|
| 386 |
|
---|
| 387 | $blog_encoding = get_option('blog_charset');
|
---|
| 388 | $text = get_the_content('');
|
---|
| 389 | $text = strip_shortcodes( $text );
|
---|
| 390 | $text = apply_filters('the_content', $text);
|
---|
| 391 | $text = str_replace(']]>', ']]>', $text);
|
---|
| 392 | $text = strip_tags($text);
|
---|
| 393 | $is_almost_ascii = ($xpress_config->ascii_judged_rate < round(@(mb_strlen($text, $blog_encoding) / strlen($text)) * 100)) ? true : false;
|
---|
| 394 | if($is_almost_ascii) {
|
---|
| 395 | $words = explode(' ', $text, $excerpt_length_word + 1);
|
---|
[51] | 396 |
|
---|
[145] | 397 | if(count($words) > $excerpt_length_word) {
|
---|
| 398 | array_pop($words);
|
---|
| 399 | array_push($words, ' ... ');
|
---|
| 400 | $text = implode(' ', $words);
|
---|
| 401 | if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>';
|
---|
[57] | 402 |
|
---|
| 403 | }
|
---|
| 404 | }
|
---|
[145] | 405 | elseif(mb_strlen($text, $blog_encoding) > $excerpt_length_character) {
|
---|
| 406 | $text = mb_substr($text, 0, $xpress_config->excerpt_length_character, $blog_encoding) . ' ... ';
|
---|
| 407 | if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>';
|
---|
| 408 | }
|
---|
| 409 |
|
---|
| 410 | return $text;
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | function xpress_the_content($more_link_text = null, $stripteaser = 0, $more_file = '',$show = true)
|
---|
| 414 | {
|
---|
| 415 | global $post,$xpress_config;
|
---|
| 416 |
|
---|
| 417 |
|
---|
| 418 | if ($xpress_config->is_content_excerpt){
|
---|
| 419 | $excerpt_length_word = $xpress_config->excerpt_length_word;
|
---|
| 420 | $excerpt_length_character = $xpress_config->excerpt_length_character;
|
---|
| 421 | $more_link_text = $xpress_config->more_link_text;
|
---|
| 422 | $content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text);
|
---|
| 423 | } else {
|
---|
| 424 | $content = get_the_content($more_link_text,$stripteaser,$more_file);
|
---|
| 425 | $content = apply_filters('the_content', $content);
|
---|
| 426 | $content = str_replace(']]>', ']]>', $content);
|
---|
| 427 | }
|
---|
[57] | 428 | if(empty($show)) return $content;
|
---|
| 429 | echo $content;
|
---|
| 430 | }
|
---|
| 431 |
|
---|
[140] | 432 | function is_xpress_contributor()
|
---|
| 433 | {
|
---|
| 434 | global $current_user;
|
---|
| 435 | get_currentuserinfo();
|
---|
| 436 | if ($current_user->user_level > 3)
|
---|
| 437 | return true;
|
---|
| 438 | else
|
---|
| 439 | return false;
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | function xpress_post_new_link($link_title,$display = true)
|
---|
| 443 | {
|
---|
| 444 | $output = '<a href="'. get_xpress_url() . '/wp-admin/post-new.php' . '">' . $link_title . '</a>';
|
---|
| 445 | if ($display)
|
---|
| 446 | echo $output;
|
---|
| 447 | else
|
---|
| 448 | return $output;
|
---|
| 449 | }
|
---|
| 450 |
|
---|
| 451 | function xpress_conditional_title($display = true)
|
---|
| 452 | {
|
---|
[155] | 453 | $selected_author = xpress_selected_author(false);
|
---|
| 454 |
|
---|
[141] | 455 | $output = __('Main', 'xpressme');
|
---|
[163] | 456 | $output = '';
|
---|
[140] | 457 | if (is_category())
|
---|
[141] | 458 | $output = sprintf(__('Archive for the ‘%s’ Category', 'xpressme'), single_cat_title('', false));
|
---|
[140] | 459 | if (is_tag())
|
---|
[141] | 460 | $output = sprintf(__('Posts Tagged ‘%s’', 'xpressme'), single_tag_title('', false) );
|
---|
[140] | 461 | if (is_day())
|
---|
[141] | 462 | $output = sprintf(__('Archive for %s|Daily archive page', 'xpressme'), get_the_time(__('F jS, Y', 'xpressme')));
|
---|
[140] | 463 | if (is_month())
|
---|
[141] | 464 | $output = sprintf(__('Archive for %s|Monthly archive page', 'xpressme'), get_the_time(__('F, Y', 'xpressme')));
|
---|
[140] | 465 | if (is_year())
|
---|
[141] | 466 | $output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme')));
|
---|
[155] | 467 | if (is_author()){
|
---|
| 468 | if (empty($selected_author))
|
---|
| 469 | $output = sprintf(__('Archive for the ‘%s’ Author', 'xpressme'), get_author_name( get_query_var('author')));
|
---|
| 470 | }
|
---|
[140] | 471 | if (is_search())
|
---|
[143] | 472 | $output = sprintf(__('Search Results of word ‘%s’', 'xpressme'), get_search_query());
|
---|
[155] | 473 |
|
---|
[163] | 474 | if (!empty($selected_author)){
|
---|
| 475 | $selected_id = xpress_selected_author_id(false);
|
---|
| 476 | // $output = get_avatar($selected_id,$size = '32') . sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
|
---|
| 477 | if (empty($output))
|
---|
| 478 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) ;
|
---|
| 479 | else
|
---|
| 480 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
|
---|
| 481 | }
|
---|
[140] | 482 | if ($display)
|
---|
| 483 | echo $output;
|
---|
| 484 | else
|
---|
| 485 | return $output;
|
---|
| 486 | }
|
---|
| 487 |
|
---|
[150] | 488 | function xpress_pings_list($show = false){
|
---|
| 489 |
|
---|
| 490 | $trackbacks = xpress_get_pings();
|
---|
[154] | 491 | if (! empty($trackbacks)) {
|
---|
| 492 | $output = '<ol id="xpress_pingslist"> ';
|
---|
[150] | 493 |
|
---|
[154] | 494 | foreach ($trackbacks as $trackback){
|
---|
| 495 | $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] | 496 |
|
---|
[154] | 497 | $output .= '<li>';
|
---|
| 498 | $output .= $list ;
|
---|
| 499 | $output .= '</li>';
|
---|
[150] | 500 |
|
---|
[154] | 501 | }
|
---|
| 502 | $output .= '</ol>' ;
|
---|
| 503 | } else {
|
---|
| 504 | $output = '';
|
---|
[150] | 505 | }
|
---|
[154] | 506 |
|
---|
[150] | 507 | if ($show) echo $output; else return $output;
|
---|
| 508 | }
|
---|
| 509 |
|
---|
| 510 | function xpress_pings_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
|
---|
| 511 | $pings = xpress_get_pings();
|
---|
| 512 | if (empty($pings)){
|
---|
| 513 | $number = 0;
|
---|
| 514 | }else {
|
---|
| 515 | $number = count($pings);
|
---|
| 516 | }
|
---|
| 517 | if ( $number > 1 )
|
---|
| 518 | $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% TrackBack/Pingback', 'xpressme') : $more);
|
---|
| 519 | elseif ( $number == 0 )
|
---|
| 520 | $output = ( false === $zero ) ? __('No Trackback/Pingback', 'xpressme') : $zero;
|
---|
| 521 | else // must be one
|
---|
| 522 | $output = ( false === $one ) ? __('One Trackback/Pingback', 'xpressme') : $one;
|
---|
| 523 |
|
---|
| 524 | echo $output;
|
---|
| 525 | }
|
---|
| 526 |
|
---|
| 527 |
|
---|
| 528 | function xpress_get_pings()
|
---|
| 529 | {
|
---|
| 530 | global $withcomments, $post, $wpdb, $id, $trackback, $user_login, $user_ID, $user_identity;
|
---|
| 531 |
|
---|
| 532 | if ( ! (is_single() || is_page() || $withcomments) )
|
---|
| 533 | return;
|
---|
| 534 |
|
---|
| 535 | /** @todo Use API instead of SELECTs. */
|
---|
| 536 | if ( $user_ID) {
|
---|
| 537 | $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));
|
---|
| 538 | } else if ( empty($trackback_author) ) {
|
---|
| 539 | $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));
|
---|
| 540 | } else {
|
---|
| 541 | $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));
|
---|
| 542 | }
|
---|
| 543 |
|
---|
| 544 | if ($trackbacks){
|
---|
| 545 | $ret = array();
|
---|
| 546 | foreach ($trackbacks as $trackback){
|
---|
| 547 |
|
---|
| 548 | $pattern = '<strong>(.*)<\/strong>(.*)';
|
---|
| 549 | if ( preg_match ( "/".$pattern."/i", $trackback->comment_content , $match ) ){
|
---|
| 550 | $title = $match[1];
|
---|
| 551 | $content = $match[2];
|
---|
| 552 | }
|
---|
| 553 | if (empty($title)) $title = $trackback->comment_author;
|
---|
| 554 |
|
---|
| 555 |
|
---|
| 556 | $row_data = array(
|
---|
| 557 | 'ID' => $trackback->comment_ID ,
|
---|
| 558 | 'post_ID' => $trackback->comment_post_ID ,
|
---|
| 559 | 'site_name' => $trackback->comment_author ,
|
---|
| 560 | 'site_url' => $trackback->comment_author_url ,
|
---|
| 561 | 'title' => $title ,
|
---|
| 562 | 'content' => $content ,
|
---|
| 563 | 'date' => $trackback->comment_date ,
|
---|
| 564 | 'date_gmt' => $trackback->comment_date_gmt ,
|
---|
| 565 | 'agent' => $trackback->comment_agent ,
|
---|
| 566 | 'type' => $trackback->comment_type ,
|
---|
| 567 | 'IP' => $trackback->comment_author_IP ,
|
---|
| 568 | );
|
---|
| 569 | array_push($ret,$row_data);
|
---|
| 570 | }
|
---|
| 571 | return $ret;
|
---|
| 572 | }
|
---|
| 573 | return false;
|
---|
| 574 | }
|
---|
[198] | 575 |
|
---|
| 576 | function get_xpress_calendar($sun_color = '#DB0000' ,$sat_color = '#004D99' ,$initial = true) {
|
---|
| 577 | global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
---|
| 578 |
|
---|
| 579 |
|
---|
| 580 |
|
---|
| 581 | ob_start();
|
---|
| 582 | // Quick check. If we have no posts at all, abort!
|
---|
| 583 | if ( !$posts ) {
|
---|
| 584 | $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
|
---|
| 585 | if ( !$gotsome )
|
---|
| 586 | return;
|
---|
| 587 | }
|
---|
| 588 |
|
---|
| 589 | if ( isset($_GET['w']) )
|
---|
| 590 | $w = ''.intval($_GET['w']);
|
---|
| 591 |
|
---|
| 592 | // week_begins = 0 stands for Sunday
|
---|
| 593 | $week_begins = intval(get_option('start_of_week'));
|
---|
| 594 |
|
---|
| 595 | // Let's figure out when we are
|
---|
| 596 | if ( !empty($monthnum) && !empty($year) ) {
|
---|
| 597 | $thismonth = ''.zeroise(intval($monthnum), 2);
|
---|
| 598 | $thisyear = ''.intval($year);
|
---|
| 599 | } elseif ( !empty($w) ) {
|
---|
| 600 | // We need to get the month from MySQL
|
---|
| 601 | $thisyear = ''.intval(substr($m, 0, 4));
|
---|
| 602 | $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
---|
| 603 | $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
---|
| 604 | } elseif ( !empty($m) ) {
|
---|
| 605 | $thisyear = ''.intval(substr($m, 0, 4));
|
---|
| 606 | if ( strlen($m) < 6 )
|
---|
| 607 | $thismonth = '01';
|
---|
| 608 | else
|
---|
| 609 | $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
|
---|
| 610 | } else {
|
---|
| 611 | $thisyear = gmdate('Y', current_time('timestamp'));
|
---|
| 612 | $thismonth = gmdate('m', current_time('timestamp'));
|
---|
| 613 | }
|
---|
| 614 |
|
---|
| 615 | $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
---|
| 616 |
|
---|
| 617 | // Get the next and previous month and year with at least one post
|
---|
| 618 | $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
|
---|
| 619 | FROM $wpdb->posts
|
---|
| 620 | WHERE post_date < '$thisyear-$thismonth-01'
|
---|
| 621 | AND post_type = 'post' AND post_status = 'publish'
|
---|
| 622 | ORDER BY post_date DESC
|
---|
| 623 | LIMIT 1");
|
---|
| 624 | $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
|
---|
| 625 | FROM $wpdb->posts
|
---|
| 626 | WHERE post_date > '$thisyear-$thismonth-01'
|
---|
| 627 | AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
|
---|
| 628 | AND post_type = 'post' AND post_status = 'publish'
|
---|
| 629 | ORDER BY post_date ASC
|
---|
| 630 | LIMIT 1");
|
---|
| 631 |
|
---|
| 632 | echo '<table summary="' . __('Calendar') . '">
|
---|
| 633 | <caption>' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
|
---|
| 634 | <thead>
|
---|
| 635 | <tr>';
|
---|
| 636 |
|
---|
| 637 | $myweek = array();
|
---|
| 638 |
|
---|
| 639 | for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
|
---|
| 640 | $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
|
---|
| 641 | }
|
---|
| 642 |
|
---|
| 643 | foreach ( $myweek as $wd ) {
|
---|
| 644 |
|
---|
| 645 | for($week_num=0;$week_num<=6;$week_num++){
|
---|
| 646 | $week_name = $wp_locale->get_weekday($week_num);
|
---|
| 647 | if ($week_name === $wd) break;
|
---|
| 648 | }
|
---|
| 649 |
|
---|
| 650 | $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
|
---|
| 651 | if ($week_num ==0) $day_name = '<span style="color: ' . $sun_color . '">' . $day_name . '</span>';
|
---|
| 652 | if ($week_num ==6) $day_name = '<span style="color: ' . $sat_color . '">' . $day_name . '</span>';
|
---|
| 653 | echo "\n\t\t<th align=\"center\" abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
|
---|
| 654 | }
|
---|
| 655 |
|
---|
| 656 | echo '
|
---|
| 657 | </tr>
|
---|
| 658 | </thead>
|
---|
| 659 |
|
---|
| 660 | <tfoot>
|
---|
| 661 | <tr>';
|
---|
| 662 |
|
---|
| 663 | if ( $previous ) {
|
---|
| 664 | echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
|
---|
| 665 | get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month),
|
---|
| 666 | date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
|
---|
| 667 | } else {
|
---|
| 668 | echo "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
|
---|
| 669 | }
|
---|
| 670 |
|
---|
| 671 | echo "\n\t\t".'<td class="pad"> </td>';
|
---|
| 672 |
|
---|
| 673 | if ( $next ) {
|
---|
| 674 | echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
|
---|
| 675 | get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month),
|
---|
| 676 | date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
|
---|
| 677 | } else {
|
---|
| 678 | echo "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
|
---|
| 679 | }
|
---|
| 680 |
|
---|
| 681 | echo '
|
---|
| 682 | </tr>
|
---|
| 683 | </tfoot>
|
---|
| 684 |
|
---|
| 685 | <tbody>
|
---|
| 686 | <tr>';
|
---|
| 687 |
|
---|
| 688 | // Get days with posts
|
---|
| 689 | $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
|
---|
| 690 | FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'
|
---|
| 691 | AND YEAR(post_date) = '$thisyear'
|
---|
| 692 | AND post_type = 'post' AND post_status = 'publish'
|
---|
| 693 | AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
|
---|
| 694 | if ( $dayswithposts ) {
|
---|
| 695 | foreach ( (array) $dayswithposts as $daywith ) {
|
---|
| 696 | $daywithpost[] = $daywith[0];
|
---|
| 697 | }
|
---|
| 698 | } else {
|
---|
| 699 | $daywithpost = array();
|
---|
| 700 | }
|
---|
| 701 |
|
---|
| 702 | if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false)
|
---|
| 703 | $ak_title_separator = "\n";
|
---|
| 704 | else
|
---|
| 705 | $ak_title_separator = ', ';
|
---|
| 706 |
|
---|
| 707 | $ak_titles_for_day = array();
|
---|
| 708 | $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
|
---|
| 709 | ."FROM $wpdb->posts "
|
---|
| 710 | ."WHERE YEAR(post_date) = '$thisyear' "
|
---|
| 711 | ."AND MONTH(post_date) = '$thismonth' "
|
---|
| 712 | ."AND post_date < '".current_time('mysql')."' "
|
---|
| 713 | ."AND post_type = 'post' AND post_status = 'publish'"
|
---|
| 714 | );
|
---|
| 715 | if ( $ak_post_titles ) {
|
---|
| 716 | foreach ( (array) $ak_post_titles as $ak_post_title ) {
|
---|
| 717 |
|
---|
| 718 | $post_title = apply_filters( "the_title", $ak_post_title->post_title );
|
---|
| 719 | $post_title = str_replace('"', '"', wptexturize( $post_title ));
|
---|
| 720 |
|
---|
| 721 | if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
|
---|
| 722 | $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
---|
| 723 | if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
|
---|
| 724 | $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
|
---|
| 725 | else
|
---|
| 726 | $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
|
---|
| 727 | }
|
---|
| 728 | }
|
---|
| 729 |
|
---|
| 730 |
|
---|
| 731 | // See how much we should pad in the beginning
|
---|
| 732 | $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
|
---|
| 733 | if ( 0 != $pad )
|
---|
| 734 | echo "\n\t\t".'<td colspan="'.$pad.'" class="pad"> </td>';
|
---|
| 735 |
|
---|
| 736 | $daysinmonth = intval(date('t', $unixmonth));
|
---|
| 737 | for ( $day = 1; $day <= $daysinmonth; ++$day ) {
|
---|
| 738 | if ( isset($newrow) && $newrow )
|
---|
| 739 | echo "\n\t</tr>\n\t<tr>\n\t\t";
|
---|
| 740 | $newrow = false;
|
---|
| 741 |
|
---|
| 742 | if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) )
|
---|
| 743 | echo '<td id="today" align="center">';
|
---|
| 744 | else
|
---|
| 745 | echo '<td align="center">';
|
---|
| 746 |
|
---|
| 747 | if ( in_array($day, $daywithpost) ) // any posts today?
|
---|
| 748 | echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
|
---|
| 749 | else
|
---|
| 750 | echo $day;
|
---|
| 751 | echo '</td>';
|
---|
| 752 |
|
---|
| 753 | if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
|
---|
| 754 | $newrow = true;
|
---|
| 755 | }
|
---|
| 756 |
|
---|
| 757 | $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
|
---|
| 758 | if ( $pad != 0 && $pad != 7 )
|
---|
| 759 | echo "\n\t\t".'<td class="pad" colspan="'.$pad.'"> </td>';
|
---|
| 760 |
|
---|
| 761 | echo "\n\t</tr>\n\t</tbody>\n\t</table>";
|
---|
| 762 |
|
---|
| 763 | $output = ob_get_contents();
|
---|
| 764 | ob_end_clean();
|
---|
| 765 | // echo $output;
|
---|
| 766 | // $cache[ $key ] = $output;
|
---|
| 767 | // wp_cache_set( 'get_calendar', $cache, 'calendar' );
|
---|
| 768 | return $output;
|
---|
| 769 | }
|
---|
[150] | 770 | ?>
|
---|