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