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