[32] | 1 | <?php
|
---|
[527] | 2 | function xpress_user_access_level(){
|
---|
| 3 | global $current_user;
|
---|
| 4 |
|
---|
| 5 | $level = @$current_user->user_level;
|
---|
| 6 | $role = @$current_user->roles[0];
|
---|
| 7 | switch ($role){
|
---|
| 8 | case 'administrator':
|
---|
| 9 | $role_level = 10;
|
---|
| 10 | break;
|
---|
| 11 | case 'editor':
|
---|
| 12 | $role_level = 7;
|
---|
| 13 | break;
|
---|
| 14 | case 'author':
|
---|
| 15 | $role_level = 2;
|
---|
| 16 | break;
|
---|
| 17 | case 'contributor':
|
---|
| 18 | $role_level = 1;
|
---|
| 19 | break;
|
---|
| 20 | default:
|
---|
| 21 | $role_level = 0;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | if ($level > $role_level){
|
---|
| 25 | return $level;
|
---|
| 26 | } else {
|
---|
| 27 | return $role_level;
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 |
|
---|
[273] | 31 | function xpress_is_contributor()
|
---|
| 32 | {
|
---|
| 33 | global $current_user;
|
---|
| 34 | get_currentuserinfo();
|
---|
[527] | 35 | if (xpress_user_access_level() > 3)
|
---|
[273] | 36 | return true;
|
---|
| 37 | else
|
---|
| 38 | return false;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
[524] | 41 | function xpress_is_multiblog() {
|
---|
| 42 | global $xoops_config;
|
---|
| 43 |
|
---|
[534] | 44 | if (function_exists('is_multisite') && is_multisite()) return true;
|
---|
[531] | 45 | return false;
|
---|
[524] | 46 | }
|
---|
| 47 |
|
---|
[527] | 48 | function xpress_is_multiblog_root() {
|
---|
| 49 | global $blog_id;
|
---|
[567] | 50 | if ( xpress_is_multiblog() && $blog_id == BLOG_ID_CURRENT_SITE){
|
---|
[527] | 51 | return true;
|
---|
| 52 | } else {
|
---|
| 53 | return false;
|
---|
| 54 | }
|
---|
| 55 | }
|
---|
| 56 |
|
---|
[360] | 57 | function xpress_is_wp_version($operator='==',$comp_version){
|
---|
[273] | 58 | global $xoops_config;
|
---|
[360] | 59 | return version_compare($xoops_config->wp_version, $comp_version, $operator);
|
---|
[273] | 60 | }
|
---|
| 61 |
|
---|
| 62 | function xpress_is_theme_sidebar_disp(){
|
---|
| 63 | global $xpress_config;
|
---|
| 64 | if (is_wordpress_style()) return true;
|
---|
| 65 | return $xpress_config->is_theme_sidebar_disp;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | function xpress_is_author_view_count(){
|
---|
| 69 | global $xpress_config;
|
---|
| 70 | return $xpress_config->is_author_view_count;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | function xpress_is_multi_user(){
|
---|
| 74 | global $xpress_config;
|
---|
| 75 | return $xpress_config->is_multi_user;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 |
|
---|
[272] | 79 | function xpress_the_title($args = '')
|
---|
[165] | 80 | {
|
---|
[272] | 81 | $defaults = array(
|
---|
| 82 | 'echo' => 1
|
---|
| 83 | );
|
---|
| 84 | $r = wp_parse_args( $args, $defaults );
|
---|
| 85 |
|
---|
| 86 | extract( $r );
|
---|
| 87 |
|
---|
[165] | 88 | $output = '<div class ="xpress-post-header">' . "\n";
|
---|
| 89 |
|
---|
| 90 | if (function_exists('hotDates')) {
|
---|
| 91 | ob_start();
|
---|
| 92 | hotDates();
|
---|
| 93 | $output .= ob_get_contents();
|
---|
| 94 | ob_end_clean();
|
---|
| 95 | }
|
---|
| 96 | $output .= '<div class ="xpress-post-title">' . "\n";
|
---|
| 97 | $output .= '<h2><a href="';
|
---|
| 98 | ob_start();
|
---|
| 99 | the_permalink();
|
---|
| 100 | $output .= ob_get_contents();
|
---|
| 101 | ob_end_clean();
|
---|
[262] | 102 |
|
---|
| 103 | if(function_exists('the_title_attribute')){
|
---|
| 104 | $title = the_title_attribute('echo=0');
|
---|
| 105 | } else {
|
---|
| 106 | ob_start();
|
---|
| 107 | the_title();
|
---|
| 108 | $title = ob_get_contents();
|
---|
| 109 | ob_end_clean();
|
---|
| 110 | }
|
---|
[165] | 111 |
|
---|
| 112 | $output .= '" rel="bookmark" title="';
|
---|
[262] | 113 | $output .= sprintf(__('Permanent Link to %s', 'xpress'), $title);
|
---|
[165] | 114 | $output .= '">';
|
---|
[262] | 115 | $output .= $title;
|
---|
[165] | 116 | $output .= '</a></h2>' . "\n";
|
---|
| 117 | $output .= '</div>' . "\n";
|
---|
| 118 | $output .= '</div>' . "\n";
|
---|
| 119 |
|
---|
[272] | 120 | if ($echo)
|
---|
| 121 | echo $output;
|
---|
| 122 | else
|
---|
[165] | 123 | return $output;
|
---|
| 124 |
|
---|
| 125 | }
|
---|
| 126 |
|
---|
[272] | 127 | function xpress_selected_author($args ='' ) {
|
---|
| 128 | $defaults = array(
|
---|
| 129 | 'echo' => 1
|
---|
| 130 | );
|
---|
| 131 | $r = wp_parse_args( $args, $defaults );
|
---|
| 132 |
|
---|
| 133 | extract( $r );
|
---|
| 134 |
|
---|
[155] | 135 | $output = '';
|
---|
[477] | 136 | $author_cookie = 'select_' . get_xpress_dir_name() . "_author" ;
|
---|
[155] | 137 | if (!empty($_COOKIE[$author_cookie])){
|
---|
| 138 | $uid = intval($_COOKIE[$author_cookie]);
|
---|
| 139 | $user_info = get_userdata($uid);
|
---|
| 140 | $output = $user_info->display_name;
|
---|
| 141 | }
|
---|
[272] | 142 | if ($echo)
|
---|
| 143 | echo $output;
|
---|
| 144 | else
|
---|
[155] | 145 | return $output;
|
---|
| 146 |
|
---|
| 147 | }
|
---|
[272] | 148 | function xpress_selected_author_id($args ='' ) {
|
---|
| 149 | $defaults = array(
|
---|
| 150 | 'echo' => 1
|
---|
| 151 | );
|
---|
| 152 | $r = wp_parse_args( $args, $defaults );
|
---|
| 153 |
|
---|
| 154 | extract( $r );
|
---|
[157] | 155 | $output = '';
|
---|
[477] | 156 | $author_cookie = 'select_' . get_xpress_dir_name() . "_author" ;
|
---|
[157] | 157 | if (!empty($_COOKIE[$author_cookie])){
|
---|
| 158 | $output = intval($_COOKIE[$author_cookie]);
|
---|
| 159 | } else {
|
---|
| 160 | $output = '';
|
---|
| 161 | }
|
---|
[272] | 162 | if ($echo)
|
---|
| 163 | echo $output;
|
---|
[157] | 164 | else
|
---|
[272] | 165 | return $output;
|
---|
[157] | 166 | }
|
---|
[164] | 167 |
|
---|
[272] | 168 | function xpress_now_user_level($args ='' ) {
|
---|
[164] | 169 | global $current_user;
|
---|
[272] | 170 | $defaults = array(
|
---|
| 171 | 'echo' => 1
|
---|
| 172 | );
|
---|
| 173 | $r = wp_parse_args( $args, $defaults );
|
---|
| 174 |
|
---|
| 175 | extract( $r );
|
---|
| 176 |
|
---|
[527] | 177 | $output = xpress_user_access_level();
|
---|
[272] | 178 | if ($echo)
|
---|
| 179 | echo $output;
|
---|
| 180 | else
|
---|
[164] | 181 | return $output;
|
---|
| 182 | }
|
---|
[147] | 183 |
|
---|
[272] | 184 | function xpress_credit($args ='')
|
---|
[32] | 185 | {
|
---|
[113] | 186 | global $wp_version , $xoops_config;
|
---|
[214] | 187 | if ($xoops_config->is_wpmu) {
|
---|
| 188 | global $wpmu_version;
|
---|
| 189 | }
|
---|
[32] | 190 |
|
---|
[272] | 191 | $defaults = array(
|
---|
[317] | 192 | 'echo' => 1,
|
---|
| 193 | 'no_link' => 0
|
---|
[272] | 194 | );
|
---|
| 195 | $r = wp_parse_args( $args, $defaults );
|
---|
| 196 |
|
---|
| 197 | extract( $r );
|
---|
| 198 |
|
---|
[113] | 199 | $xpress_version = $xoops_config->module_version;
|
---|
| 200 | $xpress_codename = $xoops_config->module_codename;
|
---|
[317] | 201 | if ($no_link){
|
---|
| 202 | if ($xoops_config->is_wpmu) {
|
---|
[490] | 203 | $output = 'XPressMU Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename);
|
---|
[317] | 204 | $output .= '(included WordPress MU ' . $wpmu_version. ')';
|
---|
| 205 | } else {
|
---|
[490] | 206 | $output = 'XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename);
|
---|
[317] | 207 | if (strstr($wp_version,'ME')){
|
---|
| 208 | $output .= '(included WordPress ' . $wp_version . ')';
|
---|
| 209 | } else {
|
---|
| 210 | $output .= '(included WordPress ' . $wp_version . ')';
|
---|
| 211 | }
|
---|
| 212 | }
|
---|
[32] | 213 | } else {
|
---|
[317] | 214 | if ($xoops_config->is_wpmu) {
|
---|
[490] | 215 | $output = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressMU Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>';
|
---|
[317] | 216 | $output .= '(included <a href="http://mu.wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress MU ' . $wpmu_version . '</a>)';
|
---|
[214] | 217 | } else {
|
---|
[490] | 218 | $output = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>';
|
---|
[317] | 219 | if (strstr($wp_version,'ME')){
|
---|
| 220 | $output .= '(included <a href="http://wpme.sourceforge.jp/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)';
|
---|
| 221 | } else {
|
---|
| 222 | $output .= '(included <a href="http://wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)';
|
---|
| 223 | }
|
---|
[214] | 224 | }
|
---|
[317] | 225 | }
|
---|
[272] | 226 | if ($echo)
|
---|
| 227 | echo $output;
|
---|
[32] | 228 | else
|
---|
[272] | 229 | return $output;
|
---|
[32] | 230 | }
|
---|
| 231 |
|
---|
[272] | 232 | function xpress_convert_time($args ='')
|
---|
[32] | 233 | {
|
---|
[272] | 234 | $defaults = array(
|
---|
| 235 | 'echo' => 1,
|
---|
| 236 | 'format' => '(%.3f sec.)'
|
---|
| 237 | );
|
---|
| 238 | $r = wp_parse_args( $args, $defaults );
|
---|
| 239 |
|
---|
| 240 | extract( $r );
|
---|
| 241 |
|
---|
| 242 | $output = sprintf($format,timer_stop(0));
|
---|
| 243 | if ($echo)
|
---|
| 244 | echo $output;
|
---|
[32] | 245 | else
|
---|
[272] | 246 | return $output;
|
---|
[32] | 247 | }
|
---|
| 248 |
|
---|
[272] | 249 | function xpress_left_arrow_post_link($args ='')
|
---|
[32] | 250 | {
|
---|
[144] | 251 | global $xpress_config;
|
---|
[272] | 252 | $defaults = array(
|
---|
| 253 | 'echo' => 1
|
---|
| 254 | );
|
---|
| 255 | $r = wp_parse_args( $args, $defaults );
|
---|
| 256 |
|
---|
| 257 | extract( $r );
|
---|
| 258 |
|
---|
[33] | 259 | $ret = '';
|
---|
| 260 |
|
---|
[144] | 261 | if($xpress_config->is_left_postnavi_old){
|
---|
| 262 | $link_title = $xpress_config->old_post_link_text;
|
---|
[32] | 263 | ob_start();
|
---|
[144] | 264 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 265 | previous_post_link('« %link');
|
---|
| 266 | else
|
---|
| 267 | previous_post_link('« %link',$link_title);
|
---|
| 268 | $ret = ob_get_contents();
|
---|
| 269 | ob_end_clean();
|
---|
[164] | 270 | ob_start();
|
---|
| 271 | previous_post_link('%link',$link_title);
|
---|
| 272 | $GLOBALS['left_arrow_post_link'] = ob_get_contents();
|
---|
| 273 | ob_end_clean();
|
---|
| 274 |
|
---|
[32] | 275 | } else {
|
---|
[144] | 276 | $link_title = $xpress_config->newer_post_link_text;
|
---|
[32] | 277 | ob_start();
|
---|
[144] | 278 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 279 | next_post_link('« %link');
|
---|
| 280 | else
|
---|
[223] | 281 | next_post_link('« %link',$link_title);
|
---|
[32] | 282 | $ret = ob_get_contents();
|
---|
| 283 | ob_end_clean();
|
---|
[164] | 284 | ob_start();
|
---|
| 285 | next_post_link('%link',$link_title);
|
---|
| 286 | $GLOBALS['left_arrow_post_link'] = ob_get_contents();
|
---|
| 287 | ob_end_clean();
|
---|
| 288 |
|
---|
[32] | 289 | }
|
---|
[33] | 290 |
|
---|
[144] | 291 | if ($xpress_config->is_postnavi_title_disp){
|
---|
[33] | 292 | $on_mouse_show = $link_title;
|
---|
| 293 | } else {
|
---|
[144] | 294 | if($xpress_config->is_left_postnavi_old){
|
---|
[33] | 295 | ob_start();
|
---|
| 296 | previous_post_link('%link');
|
---|
| 297 | $on_mouse_show = ob_get_contents();
|
---|
| 298 | ob_end_clean();
|
---|
| 299 | } else {
|
---|
| 300 | ob_start();
|
---|
| 301 | next_post_link('%link');
|
---|
| 302 | $on_mouse_show = ob_get_contents();
|
---|
| 303 | ob_end_clean();
|
---|
| 304 | }
|
---|
| 305 | $pattern = "<a[^>]*?>(.*)<\/a>";
|
---|
| 306 | preg_match("/".$pattern."/s", $on_mouse_show, $body_matches);
|
---|
| 307 | $on_mouse_show = $body_matches[1];
|
---|
| 308 | }
|
---|
[272] | 309 | $output = str_replace('">','" title="'.$on_mouse_show . '">' , $ret);
|
---|
[32] | 310 |
|
---|
[272] | 311 | if ($echo)
|
---|
| 312 | echo $output;
|
---|
[32] | 313 | else
|
---|
[272] | 314 | return $output;
|
---|
[32] | 315 | }
|
---|
| 316 |
|
---|
[272] | 317 | function xpress_right_arrow_post_link($args ='')
|
---|
[32] | 318 | {
|
---|
[144] | 319 | global $xpress_config;
|
---|
[272] | 320 | $defaults = array(
|
---|
| 321 | 'echo' => 1
|
---|
| 322 | );
|
---|
| 323 | $r = wp_parse_args( $args, $defaults );
|
---|
| 324 |
|
---|
| 325 | extract( $r );
|
---|
| 326 |
|
---|
[32] | 327 | $ret = '';
|
---|
| 328 |
|
---|
[144] | 329 | if($xpress_config->is_left_postnavi_old){
|
---|
| 330 | $link_title = $xpress_config->newer_post_link_text;
|
---|
[32] | 331 | ob_start();
|
---|
[144] | 332 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 333 | next_post_link('%link »');
|
---|
| 334 | else
|
---|
| 335 | next_post_link('%link »',$link_title);
|
---|
| 336 | $ret = ob_get_contents();
|
---|
| 337 | ob_end_clean();
|
---|
[164] | 338 | ob_start();
|
---|
| 339 | next_post_link('%link',$link_title);
|
---|
| 340 | $GLOBALS['right_arrow_post_link'] = ob_get_contents();
|
---|
| 341 | ob_end_clean();
|
---|
| 342 |
|
---|
[32] | 343 | } else {
|
---|
[144] | 344 | $link_title = $xpress_config->old_post_link_text;
|
---|
[32] | 345 | ob_start();
|
---|
[144] | 346 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[32] | 347 | previous_post_link('%link »');
|
---|
| 348 | else
|
---|
| 349 | previous_post_link('%link »',$link_title);
|
---|
| 350 | $ret = ob_get_contents();
|
---|
| 351 | ob_end_clean();
|
---|
[164] | 352 | ob_start();
|
---|
| 353 | previous_post_link('%link',$link_title);
|
---|
| 354 | $GLOBALS['right_arrow_post_link'] = ob_get_contents();
|
---|
| 355 | ob_end_clean();
|
---|
| 356 |
|
---|
[32] | 357 | }
|
---|
[33] | 358 |
|
---|
[144] | 359 | if ($xpress_config->is_postnavi_title_disp){
|
---|
[33] | 360 | $on_mouse_show = $link_title;
|
---|
| 361 | } else {
|
---|
[144] | 362 | if($xpress_config->is_left_postnavi_old){
|
---|
[33] | 363 | ob_start();
|
---|
| 364 | next_post_link('%link');
|
---|
| 365 | $on_mouse_show = ob_get_contents();
|
---|
| 366 | ob_end_clean();
|
---|
| 367 | } else {
|
---|
| 368 | ob_start();
|
---|
| 369 | previous_post_link('%link');
|
---|
| 370 | $on_mouse_show = ob_get_contents();
|
---|
| 371 | ob_end_clean();
|
---|
| 372 | }
|
---|
| 373 | $pattern = "<a[^>]*?>(.*)<\/a>";
|
---|
| 374 | preg_match("/".$pattern."/s", $on_mouse_show, $body_matches);
|
---|
| 375 | $on_mouse_show = $body_matches[1];
|
---|
| 376 | }
|
---|
[272] | 377 | $output = str_replace('">','" title="'.$on_mouse_show . '">' , $ret);
|
---|
[32] | 378 |
|
---|
[272] | 379 | if ($echo)
|
---|
| 380 | echo $output;
|
---|
[32] | 381 | else
|
---|
[272] | 382 | return $output;
|
---|
[32] | 383 | }
|
---|
[143] | 384 | // page link
|
---|
[272] | 385 | function xpress_left_arrow_posts_link($args ='')
|
---|
[143] | 386 | {
|
---|
[144] | 387 | global $xpress_config;
|
---|
[272] | 388 | $defaults = array(
|
---|
| 389 | 'echo' => 1
|
---|
| 390 | );
|
---|
| 391 | $r = wp_parse_args( $args, $defaults );
|
---|
| 392 |
|
---|
| 393 | extract( $r );
|
---|
| 394 |
|
---|
| 395 | $output = '';
|
---|
[143] | 396 |
|
---|
[144] | 397 | if($xpress_config->is_left_page_navi_old){
|
---|
| 398 | $link_title = $xpress_config->old_page_link_text;
|
---|
[143] | 399 | ob_start();
|
---|
| 400 | next_posts_link("« $link_title");
|
---|
[272] | 401 | $output = ob_get_contents();
|
---|
[143] | 402 | ob_end_clean();
|
---|
| 403 | } else {
|
---|
[144] | 404 | $link_title = $xpress_config->newer_page_link_text;
|
---|
[143] | 405 | ob_start();
|
---|
| 406 | previous_posts_link("« $link_title");
|
---|
[272] | 407 | $output = ob_get_contents();
|
---|
[143] | 408 | ob_end_clean();
|
---|
| 409 | }
|
---|
[51] | 410 |
|
---|
[272] | 411 | if ($echo)
|
---|
| 412 | echo $output;
|
---|
[143] | 413 | else
|
---|
[272] | 414 | return $output;
|
---|
[143] | 415 | }
|
---|
| 416 |
|
---|
[272] | 417 | function xpress_right_arrow_posts_link($args ='')
|
---|
[143] | 418 | {
|
---|
[144] | 419 | global $xpress_config;
|
---|
[272] | 420 | $defaults = array(
|
---|
| 421 | 'echo' => 1
|
---|
| 422 | );
|
---|
| 423 | $r = wp_parse_args( $args, $defaults );
|
---|
| 424 |
|
---|
| 425 | extract( $r );
|
---|
| 426 |
|
---|
| 427 | $output = '';
|
---|
[143] | 428 |
|
---|
[144] | 429 | if($xpress_config->is_left_page_navi_old){
|
---|
| 430 | $link_title = $xpress_config->newer_page_link_text;
|
---|
[143] | 431 | ob_start();
|
---|
| 432 | previous_posts_link("$link_title »");
|
---|
[272] | 433 | $output = ob_get_contents();
|
---|
[143] | 434 | ob_end_clean();
|
---|
| 435 | } else {
|
---|
[144] | 436 | $link_title = $xpress_config->old_page_link_text;
|
---|
[143] | 437 | ob_start();
|
---|
| 438 | next_posts_link("$link_title »");
|
---|
[272] | 439 | $output = ob_get_contents();
|
---|
[143] | 440 | ob_end_clean();
|
---|
| 441 | }
|
---|
| 442 |
|
---|
[272] | 443 | if ($echo)
|
---|
| 444 | echo $output;
|
---|
[143] | 445 | else
|
---|
[272] | 446 | return $output;
|
---|
[143] | 447 | }
|
---|
| 448 |
|
---|
[46] | 449 | function xpress_substr($str, $start, $length, $trimmarker = '...')
|
---|
| 450 | {
|
---|
| 451 | if (function_exists('mb_substr')){
|
---|
| 452 | $str2 = mb_substr( $str , $start , $length);
|
---|
| 453 | return $str2 . ( mb_strlen($str)!=mb_strlen($str2) ? $trimmarker : '' );
|
---|
| 454 | } else {
|
---|
| 455 | return ( strlen($str) - $start <= $length ) ? substr( $str, $start, $length ) : substr( $str, $start, $length - strlen($trimmarker) ) . $trimmarker;
|
---|
| 456 | }
|
---|
| 457 | }
|
---|
| 458 |
|
---|
| 459 |
|
---|
[51] | 460 | // views count
|
---|
| 461 | // Set and retrieves post views given a post ID or post object.
|
---|
| 462 | // Retrieves post views given a post ID or post object.
|
---|
[272] | 463 | function xpress_post_views_count($args ='') {
|
---|
[56] | 464 | global $xoops_db,$wpdb;
|
---|
[428] | 465 | global $blog_id;
|
---|
[51] | 466 | static $post_cache_views;
|
---|
| 467 |
|
---|
[272] | 468 | $defaults = array(
|
---|
| 469 | 'post_id' => 0,
|
---|
| 470 | 'format'=> __('views :%d','xpressme'),
|
---|
| 471 | 'echo' => 1
|
---|
| 472 | );
|
---|
| 473 | $r = wp_parse_args( $args, $defaults );
|
---|
| 474 |
|
---|
| 475 | extract( $r );
|
---|
| 476 |
|
---|
[51] | 477 | if ( empty($post_id) ) {
|
---|
| 478 | if ( isset($GLOBALS['post']) )
|
---|
| 479 | $post_id = $GLOBALS['post']->ID;
|
---|
| 480 | }
|
---|
[545] | 481 | if ( empty($blogid) ) {
|
---|
| 482 | $blogid = $blog_id;
|
---|
| 483 | }
|
---|
[51] | 484 |
|
---|
| 485 | $post_id = intval($post_id);
|
---|
| 486 | if($post_id==0) return null;
|
---|
| 487 | if(!isset($post_cache_views[$post_id])){
|
---|
[545] | 488 | if (is_null($blogid)){
|
---|
[428] | 489 | $blog_where = '';
|
---|
| 490 | } else {
|
---|
[545] | 491 | $blog_where = ' AND blog_id = '. $blogid;
|
---|
[428] | 492 | }
|
---|
| 493 | $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id " . $blog_where;
|
---|
| 494 | $post_views = $xoops_db->get_var($sql);
|
---|
[54] | 495 | if (!$post_views) {
|
---|
[51] | 496 | $post_cache_views[$post_id] = 0;
|
---|
| 497 | }else{
|
---|
[54] | 498 | $post_cache_views[$post_id] = $post_views;
|
---|
[51] | 499 | }
|
---|
| 500 | }
|
---|
| 501 | $v_count = intval($post_cache_views[$post_id]);
|
---|
| 502 |
|
---|
| 503 | if (empty($format)) $format = __('views :%d','xpressme');
|
---|
| 504 |
|
---|
[272] | 505 | $output = sprintf($format,$v_count);
|
---|
[51] | 506 |
|
---|
[272] | 507 | if ($echo)
|
---|
| 508 | echo $output;
|
---|
| 509 | else
|
---|
| 510 | return $output;
|
---|
[51] | 511 | }
|
---|
| 512 |
|
---|
[469] | 513 | function set_post_views_count($content) {
|
---|
[51] | 514 | if ( empty($_GET["feed"]) && empty($GLOBALS["feed"]) && empty($GLOBALS["doing_trackback"]) && empty($GLOBALS["doing_rss"]) && empty($_POST) && is_single() ){
|
---|
| 515 | post_views_counting();
|
---|
| 516 | }
|
---|
| 517 | return $content;
|
---|
| 518 | }
|
---|
| 519 |
|
---|
| 520 | // Set post views given a post ID or post object.
|
---|
| 521 | function post_views_counting($post_id = 0) {
|
---|
[96] | 522 | global $xoops_db,$wpdb;
|
---|
[51] | 523 | global $table_prefix;
|
---|
[428] | 524 | global $blog_id;
|
---|
[51] | 525 | static $views;
|
---|
| 526 |
|
---|
| 527 | $post_id = intval($post_id);
|
---|
| 528 | if ( empty($post_id) && isset($GLOBALS['post']) ){
|
---|
| 529 | $post_id = $GLOBALS['post']->ID;
|
---|
| 530 | }
|
---|
| 531 |
|
---|
[96] | 532 | $views_db = get_wp_prefix() . 'views';
|
---|
[428] | 533 | if (is_null($blog_id)) $blog_id = 0;
|
---|
[51] | 534 |
|
---|
| 535 | if($post_id==0 || !empty($views[$post_id])) return null;
|
---|
| 536 |
|
---|
| 537 | if(!xpress_is_author_view_count()){
|
---|
| 538 | $current_user_id = $GLOBALS['current_user']->ID;
|
---|
| 539 | $post_author_id = $GLOBALS['post']->post_author;
|
---|
| 540 | if ($current_user_id ==$post_author_id) return null;
|
---|
| 541 | }
|
---|
[428] | 542 | if (is_null($blog_id)){
|
---|
| 543 | $blog_where = '';
|
---|
| 544 | } else {
|
---|
| 545 | $blog_where = ' AND blog_id = ' . $blog_id;
|
---|
| 546 | }
|
---|
| 547 | $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id" . $blog_where;
|
---|
[96] | 548 | $post_views_found = $xoops_db->get_var($sql);
|
---|
| 549 | if($post_views_found){
|
---|
[428] | 550 | $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id" . $blog_where;
|
---|
[51] | 551 | }else{
|
---|
[428] | 552 | if (is_null($blog_id)){
|
---|
| 553 | $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)";
|
---|
| 554 | } else {
|
---|
| 555 | $sql = "INSERT INTO " . $views_db . " (blog_id, post_id, post_views) VALUES ($blog_id, $post_id, 1)";
|
---|
| 556 | }
|
---|
[51] | 557 | }
|
---|
[96] | 558 | $xoops_db->query($sql);
|
---|
[51] | 559 | return true;
|
---|
| 560 | }
|
---|
| 561 |
|
---|
[145] | 562 | function get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text = '') {
|
---|
| 563 | global $post,$xpress_config;
|
---|
| 564 |
|
---|
| 565 | $blog_encoding = get_option('blog_charset');
|
---|
| 566 | $text = get_the_content('');
|
---|
[252] | 567 | if (function_exists('strip_shortcodes')){ //@since WP2.5
|
---|
| 568 | $text = strip_shortcodes( $text );
|
---|
| 569 | }
|
---|
[145] | 570 | $text = apply_filters('the_content', $text);
|
---|
| 571 | $text = str_replace(']]>', ']]>', $text);
|
---|
| 572 | $text = strip_tags($text);
|
---|
| 573 | $is_almost_ascii = ($xpress_config->ascii_judged_rate < round(@(mb_strlen($text, $blog_encoding) / strlen($text)) * 100)) ? true : false;
|
---|
| 574 | if($is_almost_ascii) {
|
---|
| 575 | $words = explode(' ', $text, $excerpt_length_word + 1);
|
---|
[51] | 576 |
|
---|
[145] | 577 | if(count($words) > $excerpt_length_word) {
|
---|
| 578 | array_pop($words);
|
---|
| 579 | array_push($words, ' ... ');
|
---|
| 580 | $text = implode(' ', $words);
|
---|
[606] | 581 | if (!empty($more_link_text)) $text .= '<div class="xpress-more-link"><a href="'. get_permalink() . "\">".$more_link_text .'</a></div>';
|
---|
[57] | 582 |
|
---|
| 583 | }
|
---|
| 584 | }
|
---|
[145] | 585 | elseif(mb_strlen($text, $blog_encoding) > $excerpt_length_character) {
|
---|
| 586 | $text = mb_substr($text, 0, $xpress_config->excerpt_length_character, $blog_encoding) . ' ... ';
|
---|
[606] | 587 | if (!empty($more_link_text)) $text .= '<div class="xpress-more-link"><a href="'. get_permalink() . "\">".$more_link_text .'</a></div>';
|
---|
[145] | 588 | }
|
---|
| 589 |
|
---|
| 590 | return $text;
|
---|
| 591 | }
|
---|
| 592 |
|
---|
[274] | 593 | function xpress_the_content($args ='')
|
---|
[145] | 594 | {
|
---|
| 595 | global $post,$xpress_config;
|
---|
| 596 |
|
---|
[274] | 597 | $defaults = array(
|
---|
[350] | 598 | 'more_link_text'=> $xpress_config->more_link_text,
|
---|
[274] | 599 | 'stripteaser' => 0,
|
---|
| 600 | 'more_file' => '',
|
---|
| 601 | 'configration_select' => 1,
|
---|
| 602 | 'do_excerpt' => 0,
|
---|
| 603 | 'excerpt_length_word' => $xpress_config->excerpt_length_word ,
|
---|
| 604 | 'excerpt_length_character' => $xpress_config->excerpt_length_character ,
|
---|
[350] | 605 | 'excerpt_more_link_text' => $xpress_config->excerpt_more_link_text ,
|
---|
[274] | 606 | 'echo' => 1
|
---|
| 607 | );
|
---|
| 608 | $r = wp_parse_args( $args, $defaults );
|
---|
| 609 |
|
---|
| 610 | extract( $r );
|
---|
[145] | 611 |
|
---|
[274] | 612 | if ($configration_select){
|
---|
| 613 | if ($xpress_config->is_content_excerpt)
|
---|
| 614 | $do_excerpt = 1;
|
---|
| 615 | else
|
---|
| 616 | $do_excerpt = 0;
|
---|
| 617 | }
|
---|
| 618 |
|
---|
| 619 | if ($do_excerpt){
|
---|
| 620 | $content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$excerpt_more_link_text);
|
---|
[145] | 621 | } else {
|
---|
| 622 | $content = get_the_content($more_link_text,$stripteaser,$more_file);
|
---|
| 623 | $content = apply_filters('the_content', $content);
|
---|
| 624 | $content = str_replace(']]>', ']]>', $content);
|
---|
| 625 | }
|
---|
[274] | 626 | if ($echo)
|
---|
| 627 | echo $content;
|
---|
| 628 | else
|
---|
| 629 | return $content;
|
---|
[57] | 630 | }
|
---|
| 631 |
|
---|
[272] | 632 | function xpress_post_new_link($args ='')
|
---|
[140] | 633 | {
|
---|
[252] | 634 | global $xoops_config;
|
---|
| 635 |
|
---|
[272] | 636 | $defaults = array(
|
---|
| 637 | 'link_title'=> 'Post New',
|
---|
| 638 | 'echo' => 1
|
---|
| 639 | );
|
---|
| 640 | $r = wp_parse_args( $args, $defaults );
|
---|
| 641 |
|
---|
| 642 | extract( $r );
|
---|
| 643 |
|
---|
| 644 |
|
---|
[363] | 645 | if (xpress_is_wp_version('>=','2.1')){
|
---|
[400] | 646 | $output = '<a href="'. get_bloginfo('url') . '/wp-admin/post-new.php' . '">' . $link_title . '</a>';
|
---|
[252] | 647 | } else {
|
---|
[400] | 648 | $output = '<a href="'. get_bloginfo('url') . '/wp-admin/post.php' . '">' . $link_title . '</a>';
|
---|
[252] | 649 | }
|
---|
[272] | 650 | if ($echo)
|
---|
[140] | 651 | echo $output;
|
---|
| 652 | else
|
---|
| 653 | return $output;
|
---|
| 654 | }
|
---|
| 655 |
|
---|
[272] | 656 | function xpress_conditional_title($args ='')
|
---|
[140] | 657 | {
|
---|
[272] | 658 | $defaults = array(
|
---|
| 659 | 'echo' => 1
|
---|
| 660 | );
|
---|
| 661 | $r = wp_parse_args( $args, $defaults );
|
---|
| 662 |
|
---|
| 663 | extract( $r );
|
---|
[155] | 664 |
|
---|
[272] | 665 | $selected_author = xpress_selected_author('echo=0');
|
---|
| 666 |
|
---|
[141] | 667 | $output = __('Main', 'xpressme');
|
---|
[163] | 668 | $output = '';
|
---|
[140] | 669 | if (is_category())
|
---|
[141] | 670 | $output = sprintf(__('Archive for the ‘%s’ Category', 'xpressme'), single_cat_title('', false));
|
---|
[252] | 671 | if (function_exists( 'is_tag' )){
|
---|
| 672 | if (is_tag())
|
---|
| 673 | $output = sprintf(__('Posts Tagged ‘%s’', 'xpressme'), single_tag_title('', false) );
|
---|
| 674 | }
|
---|
[140] | 675 | if (is_day())
|
---|
[141] | 676 | $output = sprintf(__('Archive for %s|Daily archive page', 'xpressme'), get_the_time(__('F jS, Y', 'xpressme')));
|
---|
[140] | 677 | if (is_month())
|
---|
[141] | 678 | $output = sprintf(__('Archive for %s|Monthly archive page', 'xpressme'), get_the_time(__('F, Y', 'xpressme')));
|
---|
[140] | 679 | if (is_year())
|
---|
[141] | 680 | $output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme')));
|
---|
[155] | 681 | if (is_author()){
|
---|
| 682 | if (empty($selected_author))
|
---|
| 683 | $output = sprintf(__('Archive for the ‘%s’ Author', 'xpressme'), get_author_name( get_query_var('author')));
|
---|
| 684 | }
|
---|
[140] | 685 | if (is_search())
|
---|
[143] | 686 | $output = sprintf(__('Search Results of word ‘%s’', 'xpressme'), get_search_query());
|
---|
[155] | 687 |
|
---|
[163] | 688 | if (!empty($selected_author)){
|
---|
[272] | 689 | $selected_id = xpress_selected_author_id('echo=0');
|
---|
[163] | 690 | // $output = get_avatar($selected_id,$size = '32') . sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
|
---|
| 691 | if (empty($output))
|
---|
| 692 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) ;
|
---|
| 693 | else
|
---|
| 694 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
|
---|
| 695 | }
|
---|
[272] | 696 | if ($echo)
|
---|
[140] | 697 | echo $output;
|
---|
| 698 | else
|
---|
| 699 | return $output;
|
---|
| 700 | }
|
---|
| 701 |
|
---|
[273] | 702 | // The content of the trackback/pingback to the post is returned by the list.
|
---|
[272] | 703 | function xpress_pings_list($args =''){
|
---|
| 704 | $defaults = array(
|
---|
| 705 | 'echo' => 1
|
---|
| 706 | );
|
---|
| 707 | $r = wp_parse_args( $args, $defaults );
|
---|
| 708 |
|
---|
| 709 | extract( $r );
|
---|
[150] | 710 |
|
---|
| 711 | $trackbacks = xpress_get_pings();
|
---|
[154] | 712 | if (! empty($trackbacks)) {
|
---|
| 713 | $output = '<ol id="xpress_pingslist"> ';
|
---|
[150] | 714 |
|
---|
[154] | 715 | foreach ($trackbacks as $trackback){
|
---|
| 716 | $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] | 717 |
|
---|
[154] | 718 | $output .= '<li>';
|
---|
| 719 | $output .= $list ;
|
---|
| 720 | $output .= '</li>';
|
---|
[150] | 721 |
|
---|
[154] | 722 | }
|
---|
| 723 | $output .= '</ol>' ;
|
---|
| 724 | } else {
|
---|
| 725 | $output = '';
|
---|
[150] | 726 | }
|
---|
[154] | 727 |
|
---|
[272] | 728 | if ($echo)
|
---|
| 729 | echo $output;
|
---|
| 730 | else
|
---|
| 731 | return $output;
|
---|
[150] | 732 | }
|
---|
| 733 |
|
---|
[273] | 734 | // The amount of the trackback/pingback to the post is returned.
|
---|
[272] | 735 | function xpress_pings_number( $args ='' ) {
|
---|
| 736 | $defaults = array(
|
---|
| 737 | 'zero' => __('No Trackback/Pingback', 'xpressme'),
|
---|
| 738 | 'one' => __('One Trackback/Pingback', 'xpressme'),
|
---|
| 739 | 'more' => __('% TrackBack/Pingback', 'xpressme'),
|
---|
| 740 | 'deprecated' => '',
|
---|
| 741 | 'echo' => 1
|
---|
| 742 | );
|
---|
| 743 | $r = wp_parse_args( $args, $defaults );
|
---|
| 744 |
|
---|
| 745 | extract( $r );
|
---|
| 746 |
|
---|
[150] | 747 | $pings = xpress_get_pings();
|
---|
| 748 | if (empty($pings)){
|
---|
| 749 | $number = 0;
|
---|
| 750 | }else {
|
---|
| 751 | $number = count($pings);
|
---|
| 752 | }
|
---|
| 753 | if ( $number > 1 )
|
---|
[272] | 754 | $output = str_replace('%', number_format_i18n($number), $more);
|
---|
[150] | 755 | elseif ( $number == 0 )
|
---|
[272] | 756 | $output = $zero;
|
---|
[150] | 757 | else // must be one
|
---|
[272] | 758 | $output = $one;
|
---|
[150] | 759 |
|
---|
[272] | 760 | if ($echo)
|
---|
| 761 | echo $output;
|
---|
| 762 | else
|
---|
| 763 | return $output;
|
---|
[150] | 764 | }
|
---|
| 765 |
|
---|
[273] | 766 | // xpress_get_pings() is a subfunction used with xpress_pings_number() and xpress_pings_list().
|
---|
[150] | 767 | function xpress_get_pings()
|
---|
| 768 | {
|
---|
| 769 | global $withcomments, $post, $wpdb, $id, $trackback, $user_login, $user_ID, $user_identity;
|
---|
| 770 |
|
---|
| 771 | if ( ! (is_single() || is_page() || $withcomments) )
|
---|
| 772 | return;
|
---|
| 773 |
|
---|
| 774 | /** @todo Use API instead of SELECTs. */
|
---|
| 775 | if ( $user_ID) {
|
---|
[225] | 776 | $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] | 777 | } else if ( empty($trackback_author) ) {
|
---|
[225] | 778 | $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] | 779 | } else {
|
---|
[225] | 780 | $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] | 781 | }
|
---|
| 782 |
|
---|
| 783 | if ($trackbacks){
|
---|
| 784 | $ret = array();
|
---|
| 785 | foreach ($trackbacks as $trackback){
|
---|
| 786 |
|
---|
| 787 | $pattern = '<strong>(.*)<\/strong>(.*)';
|
---|
| 788 | if ( preg_match ( "/".$pattern."/i", $trackback->comment_content , $match ) ){
|
---|
| 789 | $title = $match[1];
|
---|
| 790 | $content = $match[2];
|
---|
| 791 | }
|
---|
| 792 | if (empty($title)) $title = $trackback->comment_author;
|
---|
| 793 |
|
---|
| 794 |
|
---|
| 795 | $row_data = array(
|
---|
| 796 | 'ID' => $trackback->comment_ID ,
|
---|
| 797 | 'post_ID' => $trackback->comment_post_ID ,
|
---|
| 798 | 'site_name' => $trackback->comment_author ,
|
---|
| 799 | 'site_url' => $trackback->comment_author_url ,
|
---|
| 800 | 'title' => $title ,
|
---|
| 801 | 'content' => $content ,
|
---|
[225] | 802 | 'date' => $trackback->comment_timestamp ,
|
---|
| 803 | 'date_gmt' => $trackback->comment_timestamp_gmt ,
|
---|
[150] | 804 | 'agent' => $trackback->comment_agent ,
|
---|
| 805 | 'type' => $trackback->comment_type ,
|
---|
| 806 | 'IP' => $trackback->comment_author_IP ,
|
---|
| 807 | );
|
---|
| 808 | array_push($ret,$row_data);
|
---|
| 809 | }
|
---|
| 810 | return $ret;
|
---|
| 811 | }
|
---|
| 812 | return false;
|
---|
| 813 | }
|
---|
[198] | 814 |
|
---|
[272] | 815 | function xpress_get_calendar($args = '') {
|
---|
[252] | 816 | global $wpdb, $m, $monthnum, $year, $wp_locale, $posts , $xoops_config;
|
---|
[198] | 817 |
|
---|
[272] | 818 | $defaults = array(
|
---|
| 819 | sun_color => '#DB0000',
|
---|
| 820 | sat_color => '#004D99',
|
---|
| 821 | initial => true
|
---|
| 822 | );
|
---|
| 823 | $r = wp_parse_args( $args, $defaults );
|
---|
| 824 |
|
---|
| 825 | extract( $r );
|
---|
[338] | 826 |
|
---|
[198] | 827 | ob_start();
|
---|
[338] | 828 | get_calendar(true);
|
---|
| 829 | $calendar = ob_get_contents();
|
---|
| 830 | ob_end_clean();
|
---|
| 831 | $calendar = preg_replace('/<th abbr=/', '<th align="center" abbr=', $calendar); //week name align center
|
---|
| 832 | $calendar = preg_replace('/<td>/', '<td align="center">', $calendar); //days align center
|
---|
| 833 | $calendar = preg_replace('/<td id="today">/', '<td id="today" align="center">', $calendar); //today align center
|
---|
| 834 | $calendar = preg_replace('/<span style="color:[^>]*>/', '', $calendar); //wp2011 color delete
|
---|
| 835 | $calendar = preg_replace('/<\/span>/', '', $calendar); //wp2011 color delete
|
---|
[198] | 836 |
|
---|
| 837 | $week_begins = intval(get_option('start_of_week'));
|
---|
[444] | 838 | $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] | 839 | if(preg_match('/'. $head_pattrn . '/s' ,$calendar,$head_match)){
|
---|
| 840 | $sun_index = 1 - $week_begins;
|
---|
| 841 | if ($sun_index < 1) $sun_index = $sun_index +7;
|
---|
| 842 | $sat_index = 7 - $week_begins;
|
---|
| 843 | if ($sat_index < 1) $sat_index = $sat_index +7;
|
---|
[198] | 844 |
|
---|
[338] | 845 | $sun_head = $head_match[$sun_index];
|
---|
| 846 | $sat_head = $head_match[$sat_index];
|
---|
| 847 |
|
---|
| 848 | $pattrn = '(<th[^>]*>)(.*)(<\/th>)';
|
---|
| 849 | if(preg_match('/'. $pattrn . '/' ,$sun_head,$sun_match)){
|
---|
| 850 | $sun_head_after = $sun_match[1] . '<span style="color: ' . $sun_color . '">' . $sun_match[2] . '</span>'. $sun_match[3];
|
---|
| 851 | $calendar = str_replace($sun_head,$sun_head_after,$calendar);
|
---|
[198] | 852 | }
|
---|
[338] | 853 | if(preg_match('/'. $pattrn . '/' ,$sat_head,$sat_match)){
|
---|
| 854 | $sat_head_after = $sat_match[1] . '<span style="color: ' . $sat_color . '">' . $sat_match[2] . '</span>'. $sat_match[3];
|
---|
| 855 | $calendar = str_replace($sat_head,$sat_head_after,$calendar);
|
---|
[198] | 856 | }
|
---|
| 857 | }
|
---|
[338] | 858 | return $calendar;
|
---|
[198] | 859 | }
|
---|
[536] | 860 |
|
---|
| 861 | function xpress_grobal_recent_posts($num = 10,$post_list='')
|
---|
| 862 | {
|
---|
| 863 | global $wpdb, $wp_rewrite , $switched , $blog_id;
|
---|
| 864 | if (empty($date_format)) $date_format = get_settings('date_format');
|
---|
| 865 | if (empty($time_format)) $time_format = get_settings('time_format');
|
---|
| 866 |
|
---|
| 867 | $first_blogid = $blog_id;
|
---|
| 868 | $num = (int)$num;
|
---|
| 869 | // $wp_query->in_the_loop = true; //for use the_tags() in multi lopp
|
---|
| 870 | $data_array = array();
|
---|
| 871 | if (xpress_is_multiblog()){
|
---|
| 872 | $blogs = get_blog_list(0,'all');
|
---|
| 873 | foreach ($blogs AS $blog) {
|
---|
| 874 | switch_to_blog($blog['blog_id']);
|
---|
[544] | 875 | $wp_rewrite->init(); // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.
|
---|
[536] | 876 |
|
---|
| 877 | if (empty($num)){
|
---|
| 878 | query_posts("post_status=publish");
|
---|
| 879 | } else {
|
---|
| 880 | query_posts("showposts=$num&post_status=publish");
|
---|
| 881 | }
|
---|
| 882 | if (have_posts()){
|
---|
| 883 | while(have_posts()){
|
---|
| 884 | $data = new stdClass();
|
---|
| 885 |
|
---|
| 886 | the_post();
|
---|
| 887 | ob_start();
|
---|
| 888 | the_ID();
|
---|
| 889 | $data->post_id = ob_get_contents();
|
---|
| 890 | ob_end_clean();
|
---|
| 891 |
|
---|
| 892 | $data->brog_id = $blog['blog_id'];
|
---|
| 893 | $data->blog_name = get_bloginfo('name');
|
---|
| 894 | $data->blog_url = get_bloginfo('url');
|
---|
| 895 | $data->blog_link = '<a href="' . $data->blog_url . '">' . $data->blog_name . '</a>' ;
|
---|
| 896 |
|
---|
| 897 |
|
---|
| 898 | ob_start();
|
---|
| 899 | the_title();
|
---|
| 900 | $data->title = ob_get_contents();
|
---|
| 901 | ob_end_clean();
|
---|
| 902 | $data->post_permalink = get_blog_permalink($data->brog_id, $data->post_id);
|
---|
| 903 | $data->title_link = '<a href="' . $data->post_permalink . '">' . $data->title . '</a>' ;
|
---|
| 904 |
|
---|
| 905 | ob_start();
|
---|
| 906 | the_author_posts_link();
|
---|
| 907 | $data->post_author = ob_get_contents();
|
---|
| 908 | ob_end_clean();
|
---|
| 909 |
|
---|
| 910 | ob_start();
|
---|
| 911 | the_category(' • ');
|
---|
| 912 | $data->post_category = ob_get_contents();
|
---|
| 913 | ob_end_clean();
|
---|
| 914 |
|
---|
| 915 | if (function_exists('the_tags')){
|
---|
| 916 | ob_start();
|
---|
| 917 | the_tags(__('Tags:', 'xpress') . ' ',' • ','');
|
---|
| 918 | $data->post_tags = ob_get_contents();
|
---|
| 919 | ob_end_clean();
|
---|
| 920 | } else {
|
---|
| 921 | $data->tags = '';
|
---|
| 922 | }
|
---|
| 923 |
|
---|
| 924 | $data->the_content = xpress_the_content('echo=0');
|
---|
| 925 |
|
---|
| 926 | ob_start();
|
---|
| 927 | the_content();
|
---|
| 928 | $data->the_full_content = ob_get_contents();
|
---|
| 929 | ob_end_clean();
|
---|
| 930 |
|
---|
| 931 | ob_start();
|
---|
| 932 | the_modified_date($date_format);
|
---|
| 933 | $data->post_modified_date = ob_get_contents();
|
---|
| 934 | ob_end_clean();
|
---|
| 935 |
|
---|
| 936 | ob_start();
|
---|
| 937 | the_modified_date($time_format);
|
---|
| 938 | $data->post_modified_time = ob_get_contents();
|
---|
| 939 | ob_end_clean();
|
---|
| 940 | $data->post_modified_date_time = $data->post_modified_date . ' ' . $data->post_modified_time;
|
---|
| 941 |
|
---|
[545] | 942 | ob_start();
|
---|
| 943 | the_time('U');
|
---|
| 944 | $data->post_unix_time = ob_get_contents();
|
---|
| 945 | ob_end_clean();
|
---|
[536] | 946 |
|
---|
| 947 | ob_start();
|
---|
| 948 | the_time($date_format);
|
---|
| 949 | $data->post_date = ob_get_contents();
|
---|
| 950 | ob_end_clean();
|
---|
| 951 |
|
---|
| 952 | ob_start();
|
---|
| 953 | the_time($time_format);
|
---|
| 954 | $data->post_time = ob_get_contents();
|
---|
| 955 | ob_end_clean();
|
---|
| 956 |
|
---|
| 957 | $data->post_date_time = $data->post_date . ' ' . $data->post_time;
|
---|
| 958 |
|
---|
| 959 | ob_start();
|
---|
| 960 | comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
|
---|
| 961 | $data->comments_link = ob_get_contents();
|
---|
| 962 | ob_end_clean();
|
---|
[545] | 963 |
|
---|
| 964 | $data->post_views = xpress_post_views_count('post_id=' . $data->post_id . '&blogid=' . $data->brog_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
|
---|
| 965 |
|
---|
[536] | 966 | $data_array[] = $data;
|
---|
| 967 | } // end whilwe
|
---|
| 968 | } // end if
|
---|
| 969 | restore_current_blog();
|
---|
| 970 | // $wp_rewrite->init();
|
---|
| 971 | } // end foreach
|
---|
| 972 | // switch_to_blog($first_blogid);
|
---|
[544] | 973 | $wp_rewrite->init(); // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.
|
---|
[536] | 974 |
|
---|
| 975 | restore_current_blog();
|
---|
| 976 | usort($data_array, "the_time_cmp");
|
---|
| 977 | }
|
---|
| 978 |
|
---|
| 979 | if (!empty($num)){
|
---|
| 980 | $data_array = array_slice($data_array,0,$num);
|
---|
| 981 | }
|
---|
| 982 | return $data_array;
|
---|
| 983 | }
|
---|
| 984 | function the_time_cmp($a, $b)
|
---|
| 985 | {
|
---|
| 986 | return - strcasecmp($a->post_unix_time, $b->post_unix_time);
|
---|
| 987 | }
|
---|
| 988 |
|
---|
| 989 | function xpress_get_blog_option($option_name,$b_id = 1)
|
---|
| 990 | {
|
---|
| 991 | global $wpdb;
|
---|
| 992 | $db_prefix = get_wp_prefix();
|
---|
| 993 |
|
---|
| 994 | if (empty($b_id)) $b_id =1;
|
---|
| 995 | $blog_prefix = '';
|
---|
| 996 | if ($b_id >1) $blog_prefix = $b_id . '_';
|
---|
| 997 | $options_tb = $db_prefix . $blog_prefix .'options';
|
---|
| 998 |
|
---|
| 999 | $sql = "SELECT option_value FROM $options_tb WHERE option_name = $option_name";
|
---|
| 1000 | $ret_val = $wpdb->get_var($sql);
|
---|
| 1001 | return $ret_val;
|
---|
| 1002 | }
|
---|
| 1003 |
|
---|
[542] | 1004 | function xpress_create_new_blog_link($args ='' ) {
|
---|
| 1005 | global $xoops_config;
|
---|
[536] | 1006 |
|
---|
[542] | 1007 | global $current_user;
|
---|
| 1008 | $defaults = array(
|
---|
| 1009 | 'echo' => 1
|
---|
| 1010 | );
|
---|
| 1011 | $r = wp_parse_args( $args, $defaults );
|
---|
| 1012 |
|
---|
| 1013 | extract( $r );
|
---|
| 1014 | $result = xpress_create_new_blog();
|
---|
| 1015 | if (!empty($result)){
|
---|
| 1016 | $output = $result['link'];
|
---|
| 1017 | } else {
|
---|
| 1018 | $output = '';
|
---|
| 1019 | }
|
---|
| 1020 |
|
---|
| 1021 | if ($echo)
|
---|
| 1022 | echo $output;
|
---|
| 1023 | else
|
---|
| 1024 | return $output;
|
---|
| 1025 | }
|
---|
| 1026 |
|
---|
| 1027 | function xpress_create_new_blog() {
|
---|
| 1028 | global $xoops_config;
|
---|
| 1029 | global $current_user;
|
---|
| 1030 | $ret = array();
|
---|
| 1031 |
|
---|
| 1032 | if (xpress_is_multiblog() && is_user_logged_in()){
|
---|
[546] | 1033 | $primary_blog_id = @$current_user->primary_blog;
|
---|
| 1034 | if (!empty($primary_blog_id)) return $ret;
|
---|
[542] | 1035 | $active_signup = get_site_option( 'registration' );
|
---|
| 1036 | if ( !$active_signup ) $active_signup = 'none';
|
---|
| 1037 | switch ($active_signup){
|
---|
| 1038 | case 'all':
|
---|
| 1039 | case 'blog':
|
---|
| 1040 | $ret['url'] = $xoops_config->module_url . '/wp-signup.php';
|
---|
[546] | 1041 | $ret['menu_url'] = 'wp-signup.php';
|
---|
[542] | 1042 | $ret['title'] = __('Create New Blog','xpressme');
|
---|
| 1043 | $ret['link'] = '<a href="' . $ret['url'] . '">' . $ret['title'] . '</a>';
|
---|
| 1044 | break;
|
---|
| 1045 | case 'user':
|
---|
| 1046 | case 'none':
|
---|
| 1047 | default:
|
---|
| 1048 | }
|
---|
| 1049 | }
|
---|
| 1050 | return $ret;
|
---|
| 1051 | }
|
---|
[546] | 1052 | function xpress_primary_blog_link() {
|
---|
| 1053 | global $xoops_config;
|
---|
| 1054 | global $current_user;
|
---|
| 1055 | global $blog_id;
|
---|
| 1056 | $ret = array();
|
---|
[542] | 1057 |
|
---|
[546] | 1058 | if (xpress_is_multiblog() && is_user_logged_in()){
|
---|
[547] | 1059 | $blog_list = get_blog_list();
|
---|
| 1060 | $root_path = get_blog_status(1,'path');
|
---|
[546] | 1061 | $primary_blog_id = @$current_user->primary_blog;
|
---|
[565] | 1062 | if(empty($primary_blog_id)) return $ret;
|
---|
[546] | 1063 | $primary_path = get_blog_status($primary_blog_id,'path');
|
---|
| 1064 | $script = str_replace($root_path, "", $primary_path);
|
---|
| 1065 | if ($primary_blog_id !== $blog_id){
|
---|
| 1066 | $ret['url'] = get_blogaddress_by_id($primary_blog_id);
|
---|
| 1067 | $ret['menu_url'] = $script;
|
---|
| 1068 | $ret['title'] = __('Your Primary Blog','xpressme');
|
---|
| 1069 | $ret['link'] = '<a href="' . $ret['url'] . '">' . $ret['title'] . '</a>';
|
---|
| 1070 | }
|
---|
| 1071 | }
|
---|
| 1072 | return $ret;
|
---|
| 1073 | }
|
---|
| 1074 |
|
---|
[252] | 1075 | ?> |
---|