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