[32] | 1 | <?php
|
---|
[165] | 2 | function xpress_the_title($show = false)
|
---|
| 3 | {
|
---|
| 4 | $output = '<div class ="xpress-post-header">' . "\n";
|
---|
| 5 |
|
---|
| 6 | if (function_exists('hotDates')) {
|
---|
| 7 | ob_start();
|
---|
| 8 | hotDates();
|
---|
| 9 | $output .= ob_get_contents();
|
---|
| 10 | ob_end_clean();
|
---|
| 11 | }
|
---|
| 12 | $output .= '<div class ="xpress-post-title">' . "\n";
|
---|
| 13 | $output .= '<h2><a href="';
|
---|
| 14 | ob_start();
|
---|
| 15 | the_permalink();
|
---|
| 16 | $output .= ob_get_contents();
|
---|
| 17 | ob_end_clean();
|
---|
| 18 |
|
---|
| 19 | $output .= '" rel="bookmark" title="';
|
---|
| 20 | $output .= sprintf(__('Permanent Link to %s', 'xpress'), the_title_attribute('echo=0'));
|
---|
| 21 | $output .= '">';
|
---|
| 22 | ob_start();
|
---|
| 23 | the_title();
|
---|
| 24 | $output .= ob_get_contents();
|
---|
| 25 | ob_end_clean();
|
---|
| 26 | $output .= '</a></h2>' . "\n";
|
---|
| 27 | $output .= '</div>' . "\n";
|
---|
| 28 | $output .= '</div>' . "\n";
|
---|
| 29 |
|
---|
| 30 | if (empty($show))
|
---|
| 31 | return $output;
|
---|
| 32 | else
|
---|
| 33 | echo $output;
|
---|
| 34 |
|
---|
| 35 | }
|
---|
| 36 |
|
---|
[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 |
|
---|
[32] | 88 | function xpress_credit($show = false)
|
---|
| 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 |
|
---|
| 113 | function xpress_convert_time($show = false)
|
---|
| 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('');
|
---|
| 401 | $text = strip_shortcodes( $text );
|
---|
| 402 | $text = apply_filters('the_content', $text);
|
---|
| 403 | $text = str_replace(']]>', ']]>', $text);
|
---|
| 404 | $text = strip_tags($text);
|
---|
| 405 | $is_almost_ascii = ($xpress_config->ascii_judged_rate < round(@(mb_strlen($text, $blog_encoding) / strlen($text)) * 100)) ? true : false;
|
---|
| 406 | if($is_almost_ascii) {
|
---|
| 407 | $words = explode(' ', $text, $excerpt_length_word + 1);
|
---|
[51] | 408 |
|
---|
[145] | 409 | if(count($words) > $excerpt_length_word) {
|
---|
| 410 | array_pop($words);
|
---|
| 411 | array_push($words, ' ... ');
|
---|
| 412 | $text = implode(' ', $words);
|
---|
| 413 | if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>';
|
---|
[57] | 414 |
|
---|
| 415 | }
|
---|
| 416 | }
|
---|
[145] | 417 | elseif(mb_strlen($text, $blog_encoding) > $excerpt_length_character) {
|
---|
| 418 | $text = mb_substr($text, 0, $xpress_config->excerpt_length_character, $blog_encoding) . ' ... ';
|
---|
| 419 | if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>';
|
---|
| 420 | }
|
---|
| 421 |
|
---|
| 422 | return $text;
|
---|
| 423 | }
|
---|
| 424 |
|
---|
| 425 | function xpress_the_content($more_link_text = null, $stripteaser = 0, $more_file = '',$show = true)
|
---|
| 426 | {
|
---|
| 427 | global $post,$xpress_config;
|
---|
| 428 |
|
---|
| 429 |
|
---|
| 430 | if ($xpress_config->is_content_excerpt){
|
---|
| 431 | $excerpt_length_word = $xpress_config->excerpt_length_word;
|
---|
| 432 | $excerpt_length_character = $xpress_config->excerpt_length_character;
|
---|
| 433 | $more_link_text = $xpress_config->more_link_text;
|
---|
| 434 | $content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text);
|
---|
| 435 | } else {
|
---|
| 436 | $content = get_the_content($more_link_text,$stripteaser,$more_file);
|
---|
| 437 | $content = apply_filters('the_content', $content);
|
---|
| 438 | $content = str_replace(']]>', ']]>', $content);
|
---|
| 439 | }
|
---|
[57] | 440 | if(empty($show)) return $content;
|
---|
| 441 | echo $content;
|
---|
| 442 | }
|
---|
| 443 |
|
---|
[140] | 444 | function is_xpress_contributor()
|
---|
| 445 | {
|
---|
| 446 | global $current_user;
|
---|
| 447 | get_currentuserinfo();
|
---|
| 448 | if ($current_user->user_level > 3)
|
---|
| 449 | return true;
|
---|
| 450 | else
|
---|
| 451 | return false;
|
---|
| 452 | }
|
---|
| 453 |
|
---|
| 454 | function xpress_post_new_link($link_title,$display = true)
|
---|
| 455 | {
|
---|
| 456 | $output = '<a href="'. get_xpress_url() . '/wp-admin/post-new.php' . '">' . $link_title . '</a>';
|
---|
| 457 | if ($display)
|
---|
| 458 | echo $output;
|
---|
| 459 | else
|
---|
| 460 | return $output;
|
---|
| 461 | }
|
---|
| 462 |
|
---|
| 463 | function xpress_conditional_title($display = true)
|
---|
| 464 | {
|
---|
[155] | 465 | $selected_author = xpress_selected_author(false);
|
---|
| 466 |
|
---|
[141] | 467 | $output = __('Main', 'xpressme');
|
---|
[163] | 468 | $output = '';
|
---|
[140] | 469 | if (is_category())
|
---|
[141] | 470 | $output = sprintf(__('Archive for the ‘%s’ Category', 'xpressme'), single_cat_title('', false));
|
---|
[140] | 471 | if (is_tag())
|
---|
[141] | 472 | $output = sprintf(__('Posts Tagged ‘%s’', 'xpressme'), single_tag_title('', false) );
|
---|
[140] | 473 | if (is_day())
|
---|
[141] | 474 | $output = sprintf(__('Archive for %s|Daily archive page', 'xpressme'), get_the_time(__('F jS, Y', 'xpressme')));
|
---|
[140] | 475 | if (is_month())
|
---|
[141] | 476 | $output = sprintf(__('Archive for %s|Monthly archive page', 'xpressme'), get_the_time(__('F, Y', 'xpressme')));
|
---|
[140] | 477 | if (is_year())
|
---|
[141] | 478 | $output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme')));
|
---|
[155] | 479 | if (is_author()){
|
---|
| 480 | if (empty($selected_author))
|
---|
| 481 | $output = sprintf(__('Archive for the ‘%s’ Author', 'xpressme'), get_author_name( get_query_var('author')));
|
---|
| 482 | }
|
---|
[140] | 483 | if (is_search())
|
---|
[143] | 484 | $output = sprintf(__('Search Results of word ‘%s’', 'xpressme'), get_search_query());
|
---|
[155] | 485 |
|
---|
[163] | 486 | if (!empty($selected_author)){
|
---|
| 487 | $selected_id = xpress_selected_author_id(false);
|
---|
| 488 | // $output = get_avatar($selected_id,$size = '32') . sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
|
---|
| 489 | if (empty($output))
|
---|
| 490 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) ;
|
---|
| 491 | else
|
---|
| 492 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
|
---|
| 493 | }
|
---|
[140] | 494 | if ($display)
|
---|
| 495 | echo $output;
|
---|
| 496 | else
|
---|
| 497 | return $output;
|
---|
| 498 | }
|
---|
| 499 |
|
---|
[150] | 500 | function xpress_pings_list($show = false){
|
---|
| 501 |
|
---|
| 502 | $trackbacks = xpress_get_pings();
|
---|
[154] | 503 | if (! empty($trackbacks)) {
|
---|
| 504 | $output = '<ol id="xpress_pingslist"> ';
|
---|
[150] | 505 |
|
---|
[154] | 506 | foreach ($trackbacks as $trackback){
|
---|
| 507 | $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] | 508 |
|
---|
[154] | 509 | $output .= '<li>';
|
---|
| 510 | $output .= $list ;
|
---|
| 511 | $output .= '</li>';
|
---|
[150] | 512 |
|
---|
[154] | 513 | }
|
---|
| 514 | $output .= '</ol>' ;
|
---|
| 515 | } else {
|
---|
| 516 | $output = '';
|
---|
[150] | 517 | }
|
---|
[154] | 518 |
|
---|
[150] | 519 | if ($show) echo $output; else return $output;
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 | function xpress_pings_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
|
---|
| 523 | $pings = xpress_get_pings();
|
---|
| 524 | if (empty($pings)){
|
---|
| 525 | $number = 0;
|
---|
| 526 | }else {
|
---|
| 527 | $number = count($pings);
|
---|
| 528 | }
|
---|
| 529 | if ( $number > 1 )
|
---|
| 530 | $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% TrackBack/Pingback', 'xpressme') : $more);
|
---|
| 531 | elseif ( $number == 0 )
|
---|
| 532 | $output = ( false === $zero ) ? __('No Trackback/Pingback', 'xpressme') : $zero;
|
---|
| 533 | else // must be one
|
---|
| 534 | $output = ( false === $one ) ? __('One Trackback/Pingback', 'xpressme') : $one;
|
---|
| 535 |
|
---|
| 536 | echo $output;
|
---|
| 537 | }
|
---|
| 538 |
|
---|
| 539 |
|
---|
| 540 | function xpress_get_pings()
|
---|
| 541 | {
|
---|
| 542 | global $withcomments, $post, $wpdb, $id, $trackback, $user_login, $user_ID, $user_identity;
|
---|
| 543 |
|
---|
| 544 | if ( ! (is_single() || is_page() || $withcomments) )
|
---|
| 545 | return;
|
---|
| 546 |
|
---|
| 547 | /** @todo Use API instead of SELECTs. */
|
---|
| 548 | if ( $user_ID) {
|
---|
| 549 | $trackbacks = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ORDER BY comment_date", $post->ID, $user_ID));
|
---|
| 550 | } else if ( empty($trackback_author) ) {
|
---|
| 551 | $trackbacks = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ORDER BY comment_date", $post->ID));
|
---|
| 552 | } else {
|
---|
| 553 | $trackbacks = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ORDER BY comment_date", $post->ID, $trackback_author, $trackback_author_email));
|
---|
| 554 | }
|
---|
| 555 |
|
---|
| 556 | if ($trackbacks){
|
---|
| 557 | $ret = array();
|
---|
| 558 | foreach ($trackbacks as $trackback){
|
---|
| 559 |
|
---|
| 560 | $pattern = '<strong>(.*)<\/strong>(.*)';
|
---|
| 561 | if ( preg_match ( "/".$pattern."/i", $trackback->comment_content , $match ) ){
|
---|
| 562 | $title = $match[1];
|
---|
| 563 | $content = $match[2];
|
---|
| 564 | }
|
---|
| 565 | if (empty($title)) $title = $trackback->comment_author;
|
---|
| 566 |
|
---|
| 567 |
|
---|
| 568 | $row_data = array(
|
---|
| 569 | 'ID' => $trackback->comment_ID ,
|
---|
| 570 | 'post_ID' => $trackback->comment_post_ID ,
|
---|
| 571 | 'site_name' => $trackback->comment_author ,
|
---|
| 572 | 'site_url' => $trackback->comment_author_url ,
|
---|
| 573 | 'title' => $title ,
|
---|
| 574 | 'content' => $content ,
|
---|
| 575 | 'date' => $trackback->comment_date ,
|
---|
| 576 | 'date_gmt' => $trackback->comment_date_gmt ,
|
---|
| 577 | 'agent' => $trackback->comment_agent ,
|
---|
| 578 | 'type' => $trackback->comment_type ,
|
---|
| 579 | 'IP' => $trackback->comment_author_IP ,
|
---|
| 580 | );
|
---|
| 581 | array_push($ret,$row_data);
|
---|
| 582 | }
|
---|
| 583 | return $ret;
|
---|
| 584 | }
|
---|
| 585 | return false;
|
---|
| 586 | }
|
---|
[198] | 587 |
|
---|
| 588 | function get_xpress_calendar($sun_color = '#DB0000' ,$sat_color = '#004D99' ,$initial = true) {
|
---|
| 589 | global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
---|
| 590 |
|
---|
| 591 |
|
---|
| 592 |
|
---|
| 593 | ob_start();
|
---|
| 594 | // Quick check. If we have no posts at all, abort!
|
---|
| 595 | if ( !$posts ) {
|
---|
| 596 | $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
|
---|
| 597 | if ( !$gotsome )
|
---|
| 598 | return;
|
---|
| 599 | }
|
---|
| 600 |
|
---|
| 601 | if ( isset($_GET['w']) )
|
---|
| 602 | $w = ''.intval($_GET['w']);
|
---|
| 603 |
|
---|
| 604 | // week_begins = 0 stands for Sunday
|
---|
| 605 | $week_begins = intval(get_option('start_of_week'));
|
---|
| 606 |
|
---|
| 607 | // Let's figure out when we are
|
---|
| 608 | if ( !empty($monthnum) && !empty($year) ) {
|
---|
| 609 | $thismonth = ''.zeroise(intval($monthnum), 2);
|
---|
| 610 | $thisyear = ''.intval($year);
|
---|
| 611 | } elseif ( !empty($w) ) {
|
---|
| 612 | // We need to get the month from MySQL
|
---|
| 613 | $thisyear = ''.intval(substr($m, 0, 4));
|
---|
| 614 | $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
---|
| 615 | $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
---|
| 616 | } elseif ( !empty($m) ) {
|
---|
| 617 | $thisyear = ''.intval(substr($m, 0, 4));
|
---|
| 618 | if ( strlen($m) < 6 )
|
---|
| 619 | $thismonth = '01';
|
---|
| 620 | else
|
---|
| 621 | $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
|
---|
| 622 | } else {
|
---|
| 623 | $thisyear = gmdate('Y', current_time('timestamp'));
|
---|
| 624 | $thismonth = gmdate('m', current_time('timestamp'));
|
---|
| 625 | }
|
---|
| 626 |
|
---|
| 627 | $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
---|
| 628 |
|
---|
| 629 | // Get the next and previous month and year with at least one post
|
---|
| 630 | $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
|
---|
| 631 | FROM $wpdb->posts
|
---|
| 632 | WHERE post_date < '$thisyear-$thismonth-01'
|
---|
| 633 | AND post_type = 'post' AND post_status = 'publish'
|
---|
| 634 | ORDER BY post_date DESC
|
---|
| 635 | LIMIT 1");
|
---|
| 636 | $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
|
---|
| 637 | FROM $wpdb->posts
|
---|
| 638 | WHERE post_date > '$thisyear-$thismonth-01'
|
---|
| 639 | AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
|
---|
| 640 | AND post_type = 'post' AND post_status = 'publish'
|
---|
| 641 | ORDER BY post_date ASC
|
---|
| 642 | LIMIT 1");
|
---|
| 643 |
|
---|
| 644 | echo '<table summary="' . __('Calendar') . '">
|
---|
| 645 | <caption>' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
|
---|
| 646 | <thead>
|
---|
| 647 | <tr>';
|
---|
| 648 |
|
---|
| 649 | $myweek = array();
|
---|
| 650 |
|
---|
| 651 | for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
|
---|
| 652 | $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
|
---|
| 653 | }
|
---|
| 654 |
|
---|
| 655 | foreach ( $myweek as $wd ) {
|
---|
| 656 |
|
---|
| 657 | for($week_num=0;$week_num<=6;$week_num++){
|
---|
| 658 | $week_name = $wp_locale->get_weekday($week_num);
|
---|
| 659 | if ($week_name === $wd) break;
|
---|
| 660 | }
|
---|
| 661 |
|
---|
| 662 | $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
|
---|
| 663 | if ($week_num ==0) $day_name = '<span style="color: ' . $sun_color . '">' . $day_name . '</span>';
|
---|
| 664 | if ($week_num ==6) $day_name = '<span style="color: ' . $sat_color . '">' . $day_name . '</span>';
|
---|
| 665 | echo "\n\t\t<th align=\"center\" abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
|
---|
| 666 | }
|
---|
| 667 |
|
---|
| 668 | echo '
|
---|
| 669 | </tr>
|
---|
| 670 | </thead>
|
---|
| 671 |
|
---|
| 672 | <tfoot>
|
---|
| 673 | <tr>';
|
---|
| 674 |
|
---|
| 675 | if ( $previous ) {
|
---|
| 676 | echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
|
---|
| 677 | get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month),
|
---|
| 678 | date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
|
---|
| 679 | } else {
|
---|
| 680 | echo "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
|
---|
| 681 | }
|
---|
| 682 |
|
---|
| 683 | echo "\n\t\t".'<td class="pad"> </td>';
|
---|
| 684 |
|
---|
| 685 | if ( $next ) {
|
---|
| 686 | echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
|
---|
| 687 | get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month),
|
---|
| 688 | date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
|
---|
| 689 | } else {
|
---|
| 690 | echo "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
|
---|
| 691 | }
|
---|
| 692 |
|
---|
| 693 | echo '
|
---|
| 694 | </tr>
|
---|
| 695 | </tfoot>
|
---|
| 696 |
|
---|
| 697 | <tbody>
|
---|
| 698 | <tr>';
|
---|
| 699 |
|
---|
| 700 | // Get days with posts
|
---|
| 701 | $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
|
---|
| 702 | FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'
|
---|
| 703 | AND YEAR(post_date) = '$thisyear'
|
---|
| 704 | AND post_type = 'post' AND post_status = 'publish'
|
---|
| 705 | AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
|
---|
| 706 | if ( $dayswithposts ) {
|
---|
| 707 | foreach ( (array) $dayswithposts as $daywith ) {
|
---|
| 708 | $daywithpost[] = $daywith[0];
|
---|
| 709 | }
|
---|
| 710 | } else {
|
---|
| 711 | $daywithpost = array();
|
---|
| 712 | }
|
---|
| 713 |
|
---|
| 714 | if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false)
|
---|
| 715 | $ak_title_separator = "\n";
|
---|
| 716 | else
|
---|
| 717 | $ak_title_separator = ', ';
|
---|
| 718 |
|
---|
| 719 | $ak_titles_for_day = array();
|
---|
| 720 | $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
|
---|
| 721 | ."FROM $wpdb->posts "
|
---|
| 722 | ."WHERE YEAR(post_date) = '$thisyear' "
|
---|
| 723 | ."AND MONTH(post_date) = '$thismonth' "
|
---|
| 724 | ."AND post_date < '".current_time('mysql')."' "
|
---|
| 725 | ."AND post_type = 'post' AND post_status = 'publish'"
|
---|
| 726 | );
|
---|
| 727 | if ( $ak_post_titles ) {
|
---|
| 728 | foreach ( (array) $ak_post_titles as $ak_post_title ) {
|
---|
| 729 |
|
---|
| 730 | $post_title = apply_filters( "the_title", $ak_post_title->post_title );
|
---|
| 731 | $post_title = str_replace('"', '"', wptexturize( $post_title ));
|
---|
| 732 |
|
---|
| 733 | if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
|
---|
| 734 | $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
---|
| 735 | if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
|
---|
| 736 | $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
|
---|
| 737 | else
|
---|
| 738 | $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
|
---|
| 739 | }
|
---|
| 740 | }
|
---|
| 741 |
|
---|
| 742 |
|
---|
| 743 | // See how much we should pad in the beginning
|
---|
| 744 | $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
|
---|
| 745 | if ( 0 != $pad )
|
---|
| 746 | echo "\n\t\t".'<td colspan="'.$pad.'" class="pad"> </td>';
|
---|
| 747 |
|
---|
| 748 | $daysinmonth = intval(date('t', $unixmonth));
|
---|
| 749 | for ( $day = 1; $day <= $daysinmonth; ++$day ) {
|
---|
| 750 | if ( isset($newrow) && $newrow )
|
---|
| 751 | echo "\n\t</tr>\n\t<tr>\n\t\t";
|
---|
| 752 | $newrow = false;
|
---|
| 753 |
|
---|
| 754 | 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)) )
|
---|
| 755 | echo '<td id="today" align="center">';
|
---|
| 756 | else
|
---|
| 757 | echo '<td align="center">';
|
---|
| 758 |
|
---|
| 759 | if ( in_array($day, $daywithpost) ) // any posts today?
|
---|
| 760 | echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
|
---|
| 761 | else
|
---|
| 762 | echo $day;
|
---|
| 763 | echo '</td>';
|
---|
| 764 |
|
---|
| 765 | if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
|
---|
| 766 | $newrow = true;
|
---|
| 767 | }
|
---|
| 768 |
|
---|
| 769 | $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
|
---|
| 770 | if ( $pad != 0 && $pad != 7 )
|
---|
| 771 | echo "\n\t\t".'<td class="pad" colspan="'.$pad.'"> </td>';
|
---|
| 772 |
|
---|
| 773 | echo "\n\t</tr>\n\t</tbody>\n\t</table>";
|
---|
| 774 |
|
---|
| 775 | $output = ob_get_contents();
|
---|
| 776 | ob_end_clean();
|
---|
| 777 | // echo $output;
|
---|
| 778 | // $cache[ $key ] = $output;
|
---|
| 779 | // wp_cache_set( 'get_calendar', $cache, 'calendar' );
|
---|
| 780 | return $output;
|
---|
| 781 | }
|
---|
[150] | 782 | ?>
|
---|