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