[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;
|
---|
[862] | 34 | xpress_get_current_user();
|
---|
[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 |
|
---|
[630] | 261 | $link_str = '« %link';
|
---|
| 262 |
|
---|
[144] | 263 | if($xpress_config->is_left_postnavi_old){
|
---|
| 264 | $link_title = $xpress_config->old_post_link_text;
|
---|
[32] | 265 | ob_start();
|
---|
[144] | 266 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[630] | 267 | previous_post_link($link_str);
|
---|
[32] | 268 | else
|
---|
[630] | 269 | previous_post_link($link_str,$link_title);
|
---|
[32] | 270 | $ret = ob_get_contents();
|
---|
| 271 | ob_end_clean();
|
---|
[164] | 272 | ob_start();
|
---|
| 273 | previous_post_link('%link',$link_title);
|
---|
| 274 | $GLOBALS['left_arrow_post_link'] = ob_get_contents();
|
---|
| 275 | ob_end_clean();
|
---|
| 276 |
|
---|
[32] | 277 | } else {
|
---|
[144] | 278 | $link_title = $xpress_config->newer_post_link_text;
|
---|
[32] | 279 | ob_start();
|
---|
[144] | 280 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[630] | 281 | next_post_link($link_str);
|
---|
[32] | 282 | else
|
---|
[630] | 283 | next_post_link($link_str,$link_title);
|
---|
[32] | 284 | $ret = ob_get_contents();
|
---|
| 285 | ob_end_clean();
|
---|
[164] | 286 | ob_start();
|
---|
| 287 | next_post_link('%link',$link_title);
|
---|
| 288 | $GLOBALS['left_arrow_post_link'] = ob_get_contents();
|
---|
| 289 | ob_end_clean();
|
---|
| 290 |
|
---|
[32] | 291 | }
|
---|
[33] | 292 |
|
---|
[144] | 293 | if ($xpress_config->is_postnavi_title_disp){
|
---|
[33] | 294 | $on_mouse_show = $link_title;
|
---|
| 295 | } else {
|
---|
[144] | 296 | if($xpress_config->is_left_postnavi_old){
|
---|
[33] | 297 | ob_start();
|
---|
| 298 | previous_post_link('%link');
|
---|
| 299 | $on_mouse_show = ob_get_contents();
|
---|
| 300 | ob_end_clean();
|
---|
| 301 | } else {
|
---|
| 302 | ob_start();
|
---|
| 303 | next_post_link('%link');
|
---|
| 304 | $on_mouse_show = ob_get_contents();
|
---|
| 305 | ob_end_clean();
|
---|
| 306 | }
|
---|
| 307 | $pattern = "<a[^>]*?>(.*)<\/a>";
|
---|
| 308 | preg_match("/".$pattern."/s", $on_mouse_show, $body_matches);
|
---|
| 309 | $on_mouse_show = $body_matches[1];
|
---|
| 310 | }
|
---|
[272] | 311 | $output = str_replace('">','" title="'.$on_mouse_show . '">' , $ret);
|
---|
[32] | 312 |
|
---|
[638] | 313 | if (icon_exists($xpress_config->post_left_arrow_image_link)){
|
---|
[649] | 314 | $img_link = str_replace($link_title,"<img src=\"$xpress_config->post_left_arrow_image_link\" alt=\"\" style=\"vertical-align:middle\"/>",$GLOBALS['left_arrow_post_link']);
|
---|
[630] | 315 | $img_link = str_replace('rel=','title="'.$on_mouse_show.'" rel=',$img_link);
|
---|
| 316 | $output = str_replace('«',$img_link , $output);
|
---|
| 317 | }
|
---|
| 318 |
|
---|
[272] | 319 | if ($echo)
|
---|
| 320 | echo $output;
|
---|
[32] | 321 | else
|
---|
[272] | 322 | return $output;
|
---|
[32] | 323 | }
|
---|
| 324 |
|
---|
[272] | 325 | function xpress_right_arrow_post_link($args ='')
|
---|
[32] | 326 | {
|
---|
[144] | 327 | global $xpress_config;
|
---|
[272] | 328 | $defaults = array(
|
---|
| 329 | 'echo' => 1
|
---|
| 330 | );
|
---|
| 331 | $r = wp_parse_args( $args, $defaults );
|
---|
| 332 |
|
---|
| 333 | extract( $r );
|
---|
| 334 |
|
---|
[630] | 335 | $ret = '';
|
---|
[32] | 336 |
|
---|
[630] | 337 | $link_str = '%link »';
|
---|
| 338 |
|
---|
[144] | 339 | if($xpress_config->is_left_postnavi_old){
|
---|
| 340 | $link_title = $xpress_config->newer_post_link_text;
|
---|
[32] | 341 | ob_start();
|
---|
[144] | 342 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[630] | 343 | next_post_link($link_str);
|
---|
[32] | 344 | else
|
---|
[630] | 345 | next_post_link($link_str,$link_title);
|
---|
[32] | 346 | $ret = ob_get_contents();
|
---|
| 347 | ob_end_clean();
|
---|
[164] | 348 | ob_start();
|
---|
| 349 | next_post_link('%link',$link_title);
|
---|
| 350 | $GLOBALS['right_arrow_post_link'] = ob_get_contents();
|
---|
| 351 | ob_end_clean();
|
---|
| 352 |
|
---|
[32] | 353 | } else {
|
---|
[144] | 354 | $link_title = $xpress_config->old_post_link_text;
|
---|
[32] | 355 | ob_start();
|
---|
[144] | 356 | if ($xpress_config->is_postnavi_title_disp)
|
---|
[630] | 357 | previous_post_link($link_str);
|
---|
[32] | 358 | else
|
---|
[630] | 359 | previous_post_link($link_str,$link_title);
|
---|
[32] | 360 | $ret = ob_get_contents();
|
---|
| 361 | ob_end_clean();
|
---|
[164] | 362 | ob_start();
|
---|
| 363 | previous_post_link('%link',$link_title);
|
---|
| 364 | $GLOBALS['right_arrow_post_link'] = ob_get_contents();
|
---|
| 365 | ob_end_clean();
|
---|
| 366 |
|
---|
[32] | 367 | }
|
---|
[33] | 368 |
|
---|
[144] | 369 | if ($xpress_config->is_postnavi_title_disp){
|
---|
[33] | 370 | $on_mouse_show = $link_title;
|
---|
| 371 | } else {
|
---|
[144] | 372 | if($xpress_config->is_left_postnavi_old){
|
---|
[33] | 373 | ob_start();
|
---|
| 374 | next_post_link('%link');
|
---|
| 375 | $on_mouse_show = ob_get_contents();
|
---|
| 376 | ob_end_clean();
|
---|
| 377 | } else {
|
---|
| 378 | ob_start();
|
---|
| 379 | previous_post_link('%link');
|
---|
| 380 | $on_mouse_show = ob_get_contents();
|
---|
| 381 | ob_end_clean();
|
---|
| 382 | }
|
---|
| 383 | $pattern = "<a[^>]*?>(.*)<\/a>";
|
---|
| 384 | preg_match("/".$pattern."/s", $on_mouse_show, $body_matches);
|
---|
| 385 | $on_mouse_show = $body_matches[1];
|
---|
| 386 | }
|
---|
[272] | 387 | $output = str_replace('">','" title="'.$on_mouse_show . '">' , $ret);
|
---|
[32] | 388 |
|
---|
[638] | 389 | if (icon_exists($xpress_config->post_right_arrow_image_link)){
|
---|
[649] | 390 | $img_link = str_replace($link_title,"<img src=\"$xpress_config->post_right_arrow_image_link\" alt=\"\" style=\"vertical-align:middle\"/>",$GLOBALS['right_arrow_post_link']);
|
---|
[630] | 391 | $img_link = str_replace('rel=','title="'.$on_mouse_show.'" rel=',$img_link);
|
---|
| 392 | $output = str_replace('»',$img_link , $output);
|
---|
| 393 | }
|
---|
| 394 |
|
---|
[272] | 395 | if ($echo)
|
---|
| 396 | echo $output;
|
---|
[32] | 397 | else
|
---|
[272] | 398 | return $output;
|
---|
[32] | 399 | }
|
---|
[143] | 400 | // page link
|
---|
[272] | 401 | function xpress_left_arrow_posts_link($args ='')
|
---|
[143] | 402 | {
|
---|
[144] | 403 | global $xpress_config;
|
---|
[272] | 404 | $defaults = array(
|
---|
| 405 | 'echo' => 1
|
---|
| 406 | );
|
---|
| 407 | $r = wp_parse_args( $args, $defaults );
|
---|
| 408 |
|
---|
| 409 | extract( $r );
|
---|
| 410 |
|
---|
| 411 | $output = '';
|
---|
[143] | 412 |
|
---|
[144] | 413 | if($xpress_config->is_left_page_navi_old){
|
---|
| 414 | $link_title = $xpress_config->old_page_link_text;
|
---|
[143] | 415 | ob_start();
|
---|
| 416 | next_posts_link("« $link_title");
|
---|
[272] | 417 | $output = ob_get_contents();
|
---|
[143] | 418 | ob_end_clean();
|
---|
| 419 | } else {
|
---|
[144] | 420 | $link_title = $xpress_config->newer_page_link_text;
|
---|
[143] | 421 | ob_start();
|
---|
| 422 | previous_posts_link("« $link_title");
|
---|
[272] | 423 | $output = ob_get_contents();
|
---|
[143] | 424 | ob_end_clean();
|
---|
| 425 | }
|
---|
[630] | 426 |
|
---|
[638] | 427 | if (icon_exists($xpress_config->page_left_arrow_image_link)){
|
---|
[630] | 428 | $output = $img_link . str_replace('«','' , $output);
|
---|
[649] | 429 | $img_link = str_replace($link_title,"<img src=\"$xpress_config->page_left_arrow_image_link\" alt=\"\" style=\"vertical-align:middle\"/>",$output);
|
---|
[630] | 430 | $output = $img_link . $output;
|
---|
| 431 | }
|
---|
[51] | 432 |
|
---|
[272] | 433 | if ($echo)
|
---|
| 434 | echo $output;
|
---|
[143] | 435 | else
|
---|
[272] | 436 | return $output;
|
---|
[143] | 437 | }
|
---|
| 438 |
|
---|
[638] | 439 |
|
---|
[272] | 440 | function xpress_right_arrow_posts_link($args ='')
|
---|
[143] | 441 | {
|
---|
[144] | 442 | global $xpress_config;
|
---|
[272] | 443 | $defaults = array(
|
---|
| 444 | 'echo' => 1
|
---|
| 445 | );
|
---|
| 446 | $r = wp_parse_args( $args, $defaults );
|
---|
| 447 |
|
---|
| 448 | extract( $r );
|
---|
| 449 |
|
---|
| 450 | $output = '';
|
---|
[143] | 451 |
|
---|
[144] | 452 | if($xpress_config->is_left_page_navi_old){
|
---|
| 453 | $link_title = $xpress_config->newer_page_link_text;
|
---|
[143] | 454 | ob_start();
|
---|
| 455 | previous_posts_link("$link_title »");
|
---|
[272] | 456 | $output = ob_get_contents();
|
---|
[143] | 457 | ob_end_clean();
|
---|
| 458 | } else {
|
---|
[144] | 459 | $link_title = $xpress_config->old_page_link_text;
|
---|
[143] | 460 | ob_start();
|
---|
| 461 | next_posts_link("$link_title »");
|
---|
[272] | 462 | $output = ob_get_contents();
|
---|
[143] | 463 | ob_end_clean();
|
---|
| 464 | }
|
---|
[630] | 465 |
|
---|
[638] | 466 | if (icon_exists($xpress_config->page_right_arrow_image_link)){
|
---|
[630] | 467 | $output = $img_link . str_replace('»','' , $output);
|
---|
[649] | 468 | $img_link = str_replace($link_title,"<img src=\"$xpress_config->page_right_arrow_image_link\" alt=\"\" style=\"vertical-align:middle\"/>",$output);
|
---|
[630] | 469 | $output = $output . $img_link;
|
---|
| 470 | }
|
---|
[272] | 471 | if ($echo)
|
---|
| 472 | echo $output;
|
---|
[143] | 473 | else
|
---|
[272] | 474 | return $output;
|
---|
[143] | 475 | }
|
---|
| 476 |
|
---|
[46] | 477 | function xpress_substr($str, $start, $length, $trimmarker = '...')
|
---|
| 478 | {
|
---|
[680] | 479 | if (function_exists('mb_substr') && function_exists('mb_strlen')){
|
---|
[46] | 480 | $str2 = mb_substr( $str , $start , $length);
|
---|
| 481 | return $str2 . ( mb_strlen($str)!=mb_strlen($str2) ? $trimmarker : '' );
|
---|
| 482 | } else {
|
---|
| 483 | return ( strlen($str) - $start <= $length ) ? substr( $str, $start, $length ) : substr( $str, $start, $length - strlen($trimmarker) ) . $trimmarker;
|
---|
| 484 | }
|
---|
| 485 | }
|
---|
| 486 |
|
---|
| 487 |
|
---|
[51] | 488 | // views count
|
---|
| 489 | // Set and retrieves post views given a post ID or post object.
|
---|
| 490 | // Retrieves post views given a post ID or post object.
|
---|
[272] | 491 | function xpress_post_views_count($args ='') {
|
---|
[56] | 492 | global $xoops_db,$wpdb;
|
---|
[428] | 493 | global $blog_id;
|
---|
[51] | 494 | static $post_cache_views;
|
---|
| 495 |
|
---|
[272] | 496 | $defaults = array(
|
---|
| 497 | 'post_id' => 0,
|
---|
| 498 | 'format'=> __('views :%d','xpressme'),
|
---|
| 499 | 'echo' => 1
|
---|
| 500 | );
|
---|
| 501 | $r = wp_parse_args( $args, $defaults );
|
---|
| 502 |
|
---|
| 503 | extract( $r );
|
---|
| 504 |
|
---|
[51] | 505 | if ( empty($post_id) ) {
|
---|
| 506 | if ( isset($GLOBALS['post']) )
|
---|
| 507 | $post_id = $GLOBALS['post']->ID;
|
---|
| 508 | }
|
---|
[545] | 509 | if ( empty($blogid) ) {
|
---|
| 510 | $blogid = $blog_id;
|
---|
| 511 | }
|
---|
[51] | 512 |
|
---|
| 513 | $post_id = intval($post_id);
|
---|
| 514 | if($post_id==0) return null;
|
---|
| 515 | if(!isset($post_cache_views[$post_id])){
|
---|
[545] | 516 | if (is_null($blogid)){
|
---|
[428] | 517 | $blog_where = '';
|
---|
| 518 | } else {
|
---|
[545] | 519 | $blog_where = ' AND blog_id = '. $blogid;
|
---|
[428] | 520 | }
|
---|
| 521 | $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id " . $blog_where;
|
---|
| 522 | $post_views = $xoops_db->get_var($sql);
|
---|
[54] | 523 | if (!$post_views) {
|
---|
[51] | 524 | $post_cache_views[$post_id] = 0;
|
---|
| 525 | }else{
|
---|
[54] | 526 | $post_cache_views[$post_id] = $post_views;
|
---|
[51] | 527 | }
|
---|
| 528 | }
|
---|
| 529 | $v_count = intval($post_cache_views[$post_id]);
|
---|
| 530 |
|
---|
| 531 | if (empty($format)) $format = __('views :%d','xpressme');
|
---|
| 532 |
|
---|
[272] | 533 | $output = sprintf($format,$v_count);
|
---|
[51] | 534 |
|
---|
[272] | 535 | if ($echo)
|
---|
| 536 | echo $output;
|
---|
| 537 | else
|
---|
| 538 | return $output;
|
---|
[51] | 539 | }
|
---|
| 540 |
|
---|
[469] | 541 | function set_post_views_count($content) {
|
---|
[51] | 542 | if ( empty($_GET["feed"]) && empty($GLOBALS["feed"]) && empty($GLOBALS["doing_trackback"]) && empty($GLOBALS["doing_rss"]) && empty($_POST) && is_single() ){
|
---|
| 543 | post_views_counting();
|
---|
| 544 | }
|
---|
| 545 | return $content;
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | // Set post views given a post ID or post object.
|
---|
| 549 | function post_views_counting($post_id = 0) {
|
---|
[96] | 550 | global $xoops_db,$wpdb;
|
---|
[51] | 551 | global $table_prefix;
|
---|
[428] | 552 | global $blog_id;
|
---|
[51] | 553 | static $views;
|
---|
| 554 |
|
---|
| 555 | $post_id = intval($post_id);
|
---|
| 556 | if ( empty($post_id) && isset($GLOBALS['post']) ){
|
---|
| 557 | $post_id = $GLOBALS['post']->ID;
|
---|
| 558 | }
|
---|
| 559 |
|
---|
[96] | 560 | $views_db = get_wp_prefix() . 'views';
|
---|
[428] | 561 | if (is_null($blog_id)) $blog_id = 0;
|
---|
[51] | 562 |
|
---|
| 563 | if($post_id==0 || !empty($views[$post_id])) return null;
|
---|
| 564 |
|
---|
| 565 | if(!xpress_is_author_view_count()){
|
---|
| 566 | $current_user_id = $GLOBALS['current_user']->ID;
|
---|
| 567 | $post_author_id = $GLOBALS['post']->post_author;
|
---|
| 568 | if ($current_user_id ==$post_author_id) return null;
|
---|
| 569 | }
|
---|
[428] | 570 | if (is_null($blog_id)){
|
---|
| 571 | $blog_where = '';
|
---|
| 572 | } else {
|
---|
| 573 | $blog_where = ' AND blog_id = ' . $blog_id;
|
---|
| 574 | }
|
---|
| 575 | $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id" . $blog_where;
|
---|
[96] | 576 | $post_views_found = $xoops_db->get_var($sql);
|
---|
| 577 | if($post_views_found){
|
---|
[428] | 578 | $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id" . $blog_where;
|
---|
[51] | 579 | }else{
|
---|
[428] | 580 | if (is_null($blog_id)){
|
---|
| 581 | $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)";
|
---|
| 582 | } else {
|
---|
| 583 | $sql = "INSERT INTO " . $views_db . " (blog_id, post_id, post_views) VALUES ($blog_id, $post_id, 1)";
|
---|
| 584 | }
|
---|
[51] | 585 | }
|
---|
[96] | 586 | $xoops_db->query($sql);
|
---|
[51] | 587 | return true;
|
---|
| 588 | }
|
---|
| 589 |
|
---|
[145] | 590 | function get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text = '') {
|
---|
| 591 | global $post,$xpress_config;
|
---|
| 592 |
|
---|
| 593 | $blog_encoding = get_option('blog_charset');
|
---|
| 594 | $text = get_the_content('');
|
---|
[252] | 595 | if (function_exists('strip_shortcodes')){ //@since WP2.5
|
---|
| 596 | $text = strip_shortcodes( $text );
|
---|
| 597 | }
|
---|
[145] | 598 | $text = apply_filters('the_content', $text);
|
---|
| 599 | $text = str_replace(']]>', ']]>', $text);
|
---|
| 600 | $text = strip_tags($text);
|
---|
[688] | 601 | if (function_exists('mb_strlen') && function_exists('mb_substr')){
|
---|
| 602 | $is_almost_ascii = ($xpress_config->ascii_judged_rate < round(@(mb_strlen($text, $blog_encoding) / strlen($text)) * 100)) ? true : false;
|
---|
| 603 | } else {
|
---|
| 604 | $is_almost_ascii = true;
|
---|
| 605 | }
|
---|
[145] | 606 | if($is_almost_ascii) {
|
---|
| 607 | $words = explode(' ', $text, $excerpt_length_word + 1);
|
---|
[51] | 608 |
|
---|
[145] | 609 | if(count($words) > $excerpt_length_word) {
|
---|
| 610 | array_pop($words);
|
---|
| 611 | array_push($words, ' ... ');
|
---|
| 612 | $text = implode(' ', $words);
|
---|
[606] | 613 | if (!empty($more_link_text)) $text .= '<div class="xpress-more-link"><a href="'. get_permalink() . "\">".$more_link_text .'</a></div>';
|
---|
[57] | 614 |
|
---|
| 615 | }
|
---|
| 616 | }
|
---|
[145] | 617 | elseif(mb_strlen($text, $blog_encoding) > $excerpt_length_character) {
|
---|
| 618 | $text = mb_substr($text, 0, $xpress_config->excerpt_length_character, $blog_encoding) . ' ... ';
|
---|
[606] | 619 | if (!empty($more_link_text)) $text .= '<div class="xpress-more-link"><a href="'. get_permalink() . "\">".$more_link_text .'</a></div>';
|
---|
[145] | 620 | }
|
---|
| 621 |
|
---|
| 622 | return $text;
|
---|
| 623 | }
|
---|
| 624 |
|
---|
[274] | 625 | function xpress_the_content($args ='')
|
---|
[145] | 626 | {
|
---|
| 627 | global $post,$xpress_config;
|
---|
| 628 |
|
---|
[274] | 629 | $defaults = array(
|
---|
[350] | 630 | 'more_link_text'=> $xpress_config->more_link_text,
|
---|
[274] | 631 | 'stripteaser' => 0,
|
---|
| 632 | 'more_file' => '',
|
---|
| 633 | 'configration_select' => 1,
|
---|
| 634 | 'do_excerpt' => 0,
|
---|
| 635 | 'excerpt_length_word' => $xpress_config->excerpt_length_word ,
|
---|
| 636 | 'excerpt_length_character' => $xpress_config->excerpt_length_character ,
|
---|
[350] | 637 | 'excerpt_more_link_text' => $xpress_config->excerpt_more_link_text ,
|
---|
[274] | 638 | 'echo' => 1
|
---|
| 639 | );
|
---|
| 640 | $r = wp_parse_args( $args, $defaults );
|
---|
| 641 |
|
---|
| 642 | extract( $r );
|
---|
[145] | 643 |
|
---|
[274] | 644 | if ($configration_select){
|
---|
| 645 | if ($xpress_config->is_content_excerpt)
|
---|
| 646 | $do_excerpt = 1;
|
---|
| 647 | else
|
---|
| 648 | $do_excerpt = 0;
|
---|
| 649 | }
|
---|
| 650 |
|
---|
| 651 | if ($do_excerpt){
|
---|
| 652 | $content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$excerpt_more_link_text);
|
---|
[145] | 653 | } else {
|
---|
| 654 | $content = get_the_content($more_link_text,$stripteaser,$more_file);
|
---|
| 655 | $content = apply_filters('the_content', $content);
|
---|
| 656 | $content = str_replace(']]>', ']]>', $content);
|
---|
| 657 | }
|
---|
[274] | 658 | if ($echo)
|
---|
| 659 | echo $content;
|
---|
| 660 | else
|
---|
| 661 | return $content;
|
---|
[57] | 662 | }
|
---|
| 663 |
|
---|
[272] | 664 | function xpress_post_new_link($args ='')
|
---|
[140] | 665 | {
|
---|
[252] | 666 | global $xoops_config;
|
---|
| 667 |
|
---|
[272] | 668 | $defaults = array(
|
---|
| 669 | 'link_title'=> 'Post New',
|
---|
| 670 | 'echo' => 1
|
---|
| 671 | );
|
---|
| 672 | $r = wp_parse_args( $args, $defaults );
|
---|
| 673 |
|
---|
| 674 | extract( $r );
|
---|
| 675 |
|
---|
| 676 |
|
---|
[363] | 677 | if (xpress_is_wp_version('>=','2.1')){
|
---|
[400] | 678 | $output = '<a href="'. get_bloginfo('url') . '/wp-admin/post-new.php' . '">' . $link_title . '</a>';
|
---|
[252] | 679 | } else {
|
---|
[400] | 680 | $output = '<a href="'. get_bloginfo('url') . '/wp-admin/post.php' . '">' . $link_title . '</a>';
|
---|
[252] | 681 | }
|
---|
[272] | 682 | if ($echo)
|
---|
[140] | 683 | echo $output;
|
---|
| 684 | else
|
---|
| 685 | return $output;
|
---|
| 686 | }
|
---|
| 687 |
|
---|
[272] | 688 | function xpress_conditional_title($args ='')
|
---|
[140] | 689 | {
|
---|
[272] | 690 | $defaults = array(
|
---|
| 691 | 'echo' => 1
|
---|
| 692 | );
|
---|
| 693 | $r = wp_parse_args( $args, $defaults );
|
---|
| 694 |
|
---|
| 695 | extract( $r );
|
---|
[155] | 696 |
|
---|
[272] | 697 | $selected_author = xpress_selected_author('echo=0');
|
---|
| 698 |
|
---|
[141] | 699 | $output = __('Main', 'xpressme');
|
---|
[163] | 700 | $output = '';
|
---|
[140] | 701 | if (is_category())
|
---|
[141] | 702 | $output = sprintf(__('Archive for the ‘%s’ Category', 'xpressme'), single_cat_title('', false));
|
---|
[252] | 703 | if (function_exists( 'is_tag' )){
|
---|
| 704 | if (is_tag())
|
---|
| 705 | $output = sprintf(__('Posts Tagged ‘%s’', 'xpressme'), single_tag_title('', false) );
|
---|
| 706 | }
|
---|
[140] | 707 | if (is_day())
|
---|
[141] | 708 | $output = sprintf(__('Archive for %s|Daily archive page', 'xpressme'), get_the_time(__('F jS, Y', 'xpressme')));
|
---|
[140] | 709 | if (is_month())
|
---|
[141] | 710 | $output = sprintf(__('Archive for %s|Monthly archive page', 'xpressme'), get_the_time(__('F, Y', 'xpressme')));
|
---|
[140] | 711 | if (is_year())
|
---|
[141] | 712 | $output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme')));
|
---|
[155] | 713 | if (is_author()){
|
---|
| 714 | if (empty($selected_author))
|
---|
| 715 | $output = sprintf(__('Archive for the ‘%s’ Author', 'xpressme'), get_author_name( get_query_var('author')));
|
---|
| 716 | }
|
---|
[140] | 717 | if (is_search())
|
---|
[143] | 718 | $output = sprintf(__('Search Results of word ‘%s’', 'xpressme'), get_search_query());
|
---|
[155] | 719 |
|
---|
[163] | 720 | if (!empty($selected_author)){
|
---|
[272] | 721 | $selected_id = xpress_selected_author_id('echo=0');
|
---|
[163] | 722 | // $output = get_avatar($selected_id,$size = '32') . sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
|
---|
| 723 | if (empty($output))
|
---|
| 724 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) ;
|
---|
| 725 | else
|
---|
| 726 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
|
---|
| 727 | }
|
---|
[272] | 728 | if ($echo)
|
---|
[140] | 729 | echo $output;
|
---|
| 730 | else
|
---|
| 731 | return $output;
|
---|
| 732 | }
|
---|
| 733 |
|
---|
[273] | 734 | // The content of the trackback/pingback to the post is returned by the list.
|
---|
[272] | 735 | function xpress_pings_list($args =''){
|
---|
| 736 | $defaults = array(
|
---|
| 737 | 'echo' => 1
|
---|
| 738 | );
|
---|
| 739 | $r = wp_parse_args( $args, $defaults );
|
---|
| 740 |
|
---|
| 741 | extract( $r );
|
---|
[150] | 742 |
|
---|
| 743 | $trackbacks = xpress_get_pings();
|
---|
[154] | 744 | if (! empty($trackbacks)) {
|
---|
| 745 | $output = '<ol id="xpress_pingslist"> ';
|
---|
[150] | 746 |
|
---|
[154] | 747 | foreach ($trackbacks as $trackback){
|
---|
| 748 | $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] | 749 |
|
---|
[154] | 750 | $output .= '<li>';
|
---|
| 751 | $output .= $list ;
|
---|
| 752 | $output .= '</li>';
|
---|
[150] | 753 |
|
---|
[154] | 754 | }
|
---|
| 755 | $output .= '</ol>' ;
|
---|
| 756 | } else {
|
---|
| 757 | $output = '';
|
---|
[150] | 758 | }
|
---|
[154] | 759 |
|
---|
[272] | 760 | if ($echo)
|
---|
| 761 | echo $output;
|
---|
| 762 | else
|
---|
| 763 | return $output;
|
---|
[150] | 764 | }
|
---|
| 765 |
|
---|
[273] | 766 | // The amount of the trackback/pingback to the post is returned.
|
---|
[272] | 767 | function xpress_pings_number( $args ='' ) {
|
---|
| 768 | $defaults = array(
|
---|
| 769 | 'zero' => __('No Trackback/Pingback', 'xpressme'),
|
---|
| 770 | 'one' => __('One Trackback/Pingback', 'xpressme'),
|
---|
| 771 | 'more' => __('% TrackBack/Pingback', 'xpressme'),
|
---|
| 772 | 'deprecated' => '',
|
---|
| 773 | 'echo' => 1
|
---|
| 774 | );
|
---|
| 775 | $r = wp_parse_args( $args, $defaults );
|
---|
| 776 |
|
---|
| 777 | extract( $r );
|
---|
| 778 |
|
---|
[150] | 779 | $pings = xpress_get_pings();
|
---|
| 780 | if (empty($pings)){
|
---|
| 781 | $number = 0;
|
---|
| 782 | }else {
|
---|
| 783 | $number = count($pings);
|
---|
| 784 | }
|
---|
| 785 | if ( $number > 1 )
|
---|
[272] | 786 | $output = str_replace('%', number_format_i18n($number), $more);
|
---|
[150] | 787 | elseif ( $number == 0 )
|
---|
[272] | 788 | $output = $zero;
|
---|
[150] | 789 | else // must be one
|
---|
[272] | 790 | $output = $one;
|
---|
[150] | 791 |
|
---|
[272] | 792 | if ($echo)
|
---|
| 793 | echo $output;
|
---|
| 794 | else
|
---|
| 795 | return $output;
|
---|
[150] | 796 | }
|
---|
| 797 |
|
---|
[273] | 798 | // xpress_get_pings() is a subfunction used with xpress_pings_number() and xpress_pings_list().
|
---|
[150] | 799 | function xpress_get_pings()
|
---|
| 800 | {
|
---|
| 801 | global $withcomments, $post, $wpdb, $id, $trackback, $user_login, $user_ID, $user_identity;
|
---|
| 802 |
|
---|
| 803 | if ( ! (is_single() || is_page() || $withcomments) )
|
---|
| 804 | return;
|
---|
| 805 |
|
---|
| 806 | /** @todo Use API instead of SELECTs. */
|
---|
| 807 | if ( $user_ID) {
|
---|
[225] | 808 | $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] | 809 | } else if ( empty($trackback_author) ) {
|
---|
[225] | 810 | $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] | 811 | } else {
|
---|
[225] | 812 | $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] | 813 | }
|
---|
| 814 |
|
---|
| 815 | if ($trackbacks){
|
---|
| 816 | $ret = array();
|
---|
| 817 | foreach ($trackbacks as $trackback){
|
---|
| 818 |
|
---|
| 819 | $pattern = '<strong>(.*)<\/strong>(.*)';
|
---|
| 820 | if ( preg_match ( "/".$pattern."/i", $trackback->comment_content , $match ) ){
|
---|
| 821 | $title = $match[1];
|
---|
| 822 | $content = $match[2];
|
---|
| 823 | }
|
---|
| 824 | if (empty($title)) $title = $trackback->comment_author;
|
---|
| 825 |
|
---|
| 826 |
|
---|
| 827 | $row_data = array(
|
---|
| 828 | 'ID' => $trackback->comment_ID ,
|
---|
| 829 | 'post_ID' => $trackback->comment_post_ID ,
|
---|
| 830 | 'site_name' => $trackback->comment_author ,
|
---|
| 831 | 'site_url' => $trackback->comment_author_url ,
|
---|
| 832 | 'title' => $title ,
|
---|
| 833 | 'content' => $content ,
|
---|
[225] | 834 | 'date' => $trackback->comment_timestamp ,
|
---|
| 835 | 'date_gmt' => $trackback->comment_timestamp_gmt ,
|
---|
[150] | 836 | 'agent' => $trackback->comment_agent ,
|
---|
| 837 | 'type' => $trackback->comment_type ,
|
---|
| 838 | 'IP' => $trackback->comment_author_IP ,
|
---|
| 839 | );
|
---|
| 840 | array_push($ret,$row_data);
|
---|
| 841 | }
|
---|
| 842 | return $ret;
|
---|
| 843 | }
|
---|
| 844 | return false;
|
---|
| 845 | }
|
---|
[198] | 846 |
|
---|
[272] | 847 | function xpress_get_calendar($args = '') {
|
---|
[252] | 848 | global $wpdb, $m, $monthnum, $year, $wp_locale, $posts , $xoops_config;
|
---|
[198] | 849 |
|
---|
[272] | 850 | $defaults = array(
|
---|
| 851 | sun_color => '#DB0000',
|
---|
| 852 | sat_color => '#004D99',
|
---|
| 853 | initial => true
|
---|
| 854 | );
|
---|
| 855 | $r = wp_parse_args( $args, $defaults );
|
---|
| 856 |
|
---|
| 857 | extract( $r );
|
---|
[338] | 858 |
|
---|
[198] | 859 | ob_start();
|
---|
[338] | 860 | get_calendar(true);
|
---|
| 861 | $calendar = ob_get_contents();
|
---|
| 862 | ob_end_clean();
|
---|
| 863 | $calendar = preg_replace('/<th abbr=/', '<th align="center" abbr=', $calendar); //week name align center
|
---|
| 864 | $calendar = preg_replace('/<td>/', '<td align="center">', $calendar); //days align center
|
---|
| 865 | $calendar = preg_replace('/<td id="today">/', '<td id="today" align="center">', $calendar); //today align center
|
---|
| 866 | $calendar = preg_replace('/<span style="color:[^>]*>/', '', $calendar); //wp2011 color delete
|
---|
| 867 | $calendar = preg_replace('/<\/span>/', '', $calendar); //wp2011 color delete
|
---|
[198] | 868 |
|
---|
| 869 | $week_begins = intval(get_option('start_of_week'));
|
---|
[444] | 870 | $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] | 871 | if(preg_match('/'. $head_pattrn . '/s' ,$calendar,$head_match)){
|
---|
| 872 | $sun_index = 1 - $week_begins;
|
---|
| 873 | if ($sun_index < 1) $sun_index = $sun_index +7;
|
---|
| 874 | $sat_index = 7 - $week_begins;
|
---|
| 875 | if ($sat_index < 1) $sat_index = $sat_index +7;
|
---|
[198] | 876 |
|
---|
[338] | 877 | $sun_head = $head_match[$sun_index];
|
---|
| 878 | $sat_head = $head_match[$sat_index];
|
---|
| 879 |
|
---|
| 880 | $pattrn = '(<th[^>]*>)(.*)(<\/th>)';
|
---|
| 881 | if(preg_match('/'. $pattrn . '/' ,$sun_head,$sun_match)){
|
---|
| 882 | $sun_head_after = $sun_match[1] . '<span style="color: ' . $sun_color . '">' . $sun_match[2] . '</span>'. $sun_match[3];
|
---|
| 883 | $calendar = str_replace($sun_head,$sun_head_after,$calendar);
|
---|
[198] | 884 | }
|
---|
[338] | 885 | if(preg_match('/'. $pattrn . '/' ,$sat_head,$sat_match)){
|
---|
| 886 | $sat_head_after = $sat_match[1] . '<span style="color: ' . $sat_color . '">' . $sat_match[2] . '</span>'. $sat_match[3];
|
---|
| 887 | $calendar = str_replace($sat_head,$sat_head_after,$calendar);
|
---|
[198] | 888 | }
|
---|
| 889 | }
|
---|
[338] | 890 | return $calendar;
|
---|
[198] | 891 | }
|
---|
[536] | 892 |
|
---|
[792] | 893 | function xpress_grobal_recent_posts($num = 10,$exclusion_blog = 0, $shown_for_each_blog = false)
|
---|
[536] | 894 | {
|
---|
| 895 | global $wpdb, $wp_rewrite , $switched , $blog_id;
|
---|
| 896 | if (empty($date_format)) $date_format = get_settings('date_format');
|
---|
| 897 | if (empty($time_format)) $time_format = get_settings('time_format');
|
---|
[792] | 898 | $exclusion = explode(',' , $exclusion_blog);
|
---|
[536] | 899 |
|
---|
[792] | 900 |
|
---|
[536] | 901 | $first_blogid = $blog_id;
|
---|
| 902 | $num = (int)$num;
|
---|
| 903 | // $wp_query->in_the_loop = true; //for use the_tags() in multi lopp
|
---|
| 904 | $data_array = array();
|
---|
| 905 | if (xpress_is_multiblog()){
|
---|
| 906 | $blogs = get_blog_list(0,'all');
|
---|
| 907 | foreach ($blogs AS $blog) {
|
---|
[792] | 908 | if (!in_array(0, $exclusion) && in_array($blog['blog_id'], $exclusion)) continue;
|
---|
[536] | 909 | switch_to_blog($blog['blog_id']);
|
---|
[544] | 910 | $wp_rewrite->init(); // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.
|
---|
[536] | 911 |
|
---|
| 912 | if (empty($num)){
|
---|
| 913 | query_posts("post_status=publish");
|
---|
| 914 | } else {
|
---|
| 915 | query_posts("showposts=$num&post_status=publish");
|
---|
| 916 | }
|
---|
| 917 | if (have_posts()){
|
---|
| 918 | while(have_posts()){
|
---|
| 919 | $data = new stdClass();
|
---|
| 920 |
|
---|
| 921 | the_post();
|
---|
| 922 | ob_start();
|
---|
| 923 | the_ID();
|
---|
| 924 | $data->post_id = ob_get_contents();
|
---|
| 925 | ob_end_clean();
|
---|
| 926 |
|
---|
[792] | 927 | $data->blog_id = $blog['blog_id'];
|
---|
[536] | 928 | $data->blog_name = get_bloginfo('name');
|
---|
| 929 | $data->blog_url = get_bloginfo('url');
|
---|
| 930 | $data->blog_link = '<a href="' . $data->blog_url . '">' . $data->blog_name . '</a>' ;
|
---|
| 931 |
|
---|
| 932 |
|
---|
| 933 | ob_start();
|
---|
| 934 | the_title();
|
---|
| 935 | $data->title = ob_get_contents();
|
---|
| 936 | ob_end_clean();
|
---|
| 937 | $data->post_permalink = get_blog_permalink($data->brog_id, $data->post_id);
|
---|
| 938 | $data->title_link = '<a href="' . $data->post_permalink . '">' . $data->title . '</a>' ;
|
---|
| 939 |
|
---|
| 940 | ob_start();
|
---|
| 941 | the_author_posts_link();
|
---|
| 942 | $data->post_author = ob_get_contents();
|
---|
| 943 | ob_end_clean();
|
---|
| 944 |
|
---|
| 945 | ob_start();
|
---|
| 946 | the_category(' • ');
|
---|
| 947 | $data->post_category = ob_get_contents();
|
---|
| 948 | ob_end_clean();
|
---|
| 949 |
|
---|
| 950 | if (function_exists('the_tags')){
|
---|
| 951 | ob_start();
|
---|
| 952 | the_tags(__('Tags:', 'xpress') . ' ',' • ','');
|
---|
| 953 | $data->post_tags = ob_get_contents();
|
---|
| 954 | ob_end_clean();
|
---|
| 955 | } else {
|
---|
| 956 | $data->tags = '';
|
---|
| 957 | }
|
---|
| 958 |
|
---|
| 959 | $data->the_content = xpress_the_content('echo=0');
|
---|
| 960 |
|
---|
| 961 | ob_start();
|
---|
| 962 | the_content();
|
---|
| 963 | $data->the_full_content = ob_get_contents();
|
---|
| 964 | ob_end_clean();
|
---|
| 965 |
|
---|
| 966 | ob_start();
|
---|
| 967 | the_modified_date($date_format);
|
---|
| 968 | $data->post_modified_date = ob_get_contents();
|
---|
| 969 | ob_end_clean();
|
---|
| 970 |
|
---|
| 971 | ob_start();
|
---|
| 972 | the_modified_date($time_format);
|
---|
| 973 | $data->post_modified_time = ob_get_contents();
|
---|
| 974 | ob_end_clean();
|
---|
| 975 | $data->post_modified_date_time = $data->post_modified_date . ' ' . $data->post_modified_time;
|
---|
| 976 |
|
---|
[545] | 977 | ob_start();
|
---|
| 978 | the_time('U');
|
---|
| 979 | $data->post_unix_time = ob_get_contents();
|
---|
| 980 | ob_end_clean();
|
---|
[536] | 981 |
|
---|
| 982 | ob_start();
|
---|
| 983 | the_time($date_format);
|
---|
| 984 | $data->post_date = ob_get_contents();
|
---|
| 985 | ob_end_clean();
|
---|
| 986 |
|
---|
| 987 | ob_start();
|
---|
| 988 | the_time($time_format);
|
---|
| 989 | $data->post_time = ob_get_contents();
|
---|
| 990 | ob_end_clean();
|
---|
| 991 |
|
---|
| 992 | $data->post_date_time = $data->post_date . ' ' . $data->post_time;
|
---|
| 993 |
|
---|
| 994 | ob_start();
|
---|
| 995 | comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
|
---|
| 996 | $data->comments_link = ob_get_contents();
|
---|
| 997 | ob_end_clean();
|
---|
[545] | 998 |
|
---|
| 999 | $data->post_views = xpress_post_views_count('post_id=' . $data->post_id . '&blogid=' . $data->brog_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
|
---|
[792] | 1000 | if (function_exists('the_qf_get_thumb_one')){
|
---|
| 1001 | $data->post_thumbnail = the_qf_get_thumb_one("num=0&width=120&tag=1","",$data->the_full_content);
|
---|
| 1002 | } else {
|
---|
| 1003 | $data->post_thumbnail = get_the_post_thumbnail(null,'thumbnail');
|
---|
| 1004 | }
|
---|
| 1005 | $data->author_avatar =get_avatar(get_the_author_meta('ID'),$size = '32');
|
---|
[545] | 1006 |
|
---|
[536] | 1007 | $data_array[] = $data;
|
---|
| 1008 | } // end whilwe
|
---|
| 1009 | } // end if
|
---|
| 1010 | restore_current_blog();
|
---|
| 1011 | // $wp_rewrite->init();
|
---|
| 1012 | } // end foreach
|
---|
| 1013 | // switch_to_blog($first_blogid);
|
---|
[544] | 1014 | $wp_rewrite->init(); // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.
|
---|
[536] | 1015 |
|
---|
| 1016 | restore_current_blog();
|
---|
[792] | 1017 | }
|
---|
| 1018 | if (!$shown_for_each_blog){
|
---|
[536] | 1019 | usort($data_array, "the_time_cmp");
|
---|
[792] | 1020 | if (!empty($num)){
|
---|
| 1021 | $data_array = array_slice($data_array,0,$num);
|
---|
| 1022 | }
|
---|
[536] | 1023 | }
|
---|
| 1024 | return $data_array;
|
---|
| 1025 | }
|
---|
| 1026 | function the_time_cmp($a, $b)
|
---|
| 1027 | {
|
---|
| 1028 | return - strcasecmp($a->post_unix_time, $b->post_unix_time);
|
---|
| 1029 | }
|
---|
| 1030 |
|
---|
| 1031 | function xpress_get_blog_option($option_name,$b_id = 1)
|
---|
| 1032 | {
|
---|
| 1033 | global $wpdb;
|
---|
| 1034 | $db_prefix = get_wp_prefix();
|
---|
| 1035 |
|
---|
| 1036 | if (empty($b_id)) $b_id =1;
|
---|
| 1037 | $blog_prefix = '';
|
---|
| 1038 | if ($b_id >1) $blog_prefix = $b_id . '_';
|
---|
| 1039 | $options_tb = $db_prefix . $blog_prefix .'options';
|
---|
| 1040 |
|
---|
| 1041 | $sql = "SELECT option_value FROM $options_tb WHERE option_name = $option_name";
|
---|
| 1042 | $ret_val = $wpdb->get_var($sql);
|
---|
| 1043 | return $ret_val;
|
---|
| 1044 | }
|
---|
| 1045 |
|
---|
[542] | 1046 | function xpress_create_new_blog_link($args ='' ) {
|
---|
| 1047 | global $xoops_config;
|
---|
[536] | 1048 |
|
---|
[542] | 1049 | global $current_user;
|
---|
| 1050 | $defaults = array(
|
---|
| 1051 | 'echo' => 1
|
---|
| 1052 | );
|
---|
| 1053 | $r = wp_parse_args( $args, $defaults );
|
---|
| 1054 |
|
---|
| 1055 | extract( $r );
|
---|
| 1056 | $result = xpress_create_new_blog();
|
---|
| 1057 | if (!empty($result)){
|
---|
| 1058 | $output = $result['link'];
|
---|
| 1059 | } else {
|
---|
| 1060 | $output = '';
|
---|
| 1061 | }
|
---|
| 1062 |
|
---|
| 1063 | if ($echo)
|
---|
| 1064 | echo $output;
|
---|
| 1065 | else
|
---|
| 1066 | return $output;
|
---|
| 1067 | }
|
---|
| 1068 |
|
---|
| 1069 | function xpress_create_new_blog() {
|
---|
| 1070 | global $xoops_config;
|
---|
| 1071 | global $current_user;
|
---|
| 1072 | $ret = array();
|
---|
| 1073 |
|
---|
| 1074 | if (xpress_is_multiblog() && is_user_logged_in()){
|
---|
[546] | 1075 | $primary_blog_id = @$current_user->primary_blog;
|
---|
| 1076 | if (!empty($primary_blog_id)) return $ret;
|
---|
[542] | 1077 | $active_signup = get_site_option( 'registration' );
|
---|
| 1078 | if ( !$active_signup ) $active_signup = 'none';
|
---|
| 1079 | switch ($active_signup){
|
---|
| 1080 | case 'all':
|
---|
| 1081 | case 'blog':
|
---|
| 1082 | $ret['url'] = $xoops_config->module_url . '/wp-signup.php';
|
---|
[546] | 1083 | $ret['menu_url'] = 'wp-signup.php';
|
---|
[542] | 1084 | $ret['title'] = __('Create New Blog','xpressme');
|
---|
| 1085 | $ret['link'] = '<a href="' . $ret['url'] . '">' . $ret['title'] . '</a>';
|
---|
| 1086 | break;
|
---|
| 1087 | case 'user':
|
---|
| 1088 | case 'none':
|
---|
| 1089 | default:
|
---|
| 1090 | }
|
---|
| 1091 | }
|
---|
| 1092 | return $ret;
|
---|
| 1093 | }
|
---|
[546] | 1094 | function xpress_primary_blog_link() {
|
---|
| 1095 | global $xoops_config;
|
---|
| 1096 | global $current_user;
|
---|
| 1097 | global $blog_id;
|
---|
| 1098 | $ret = array();
|
---|
[542] | 1099 |
|
---|
[546] | 1100 | if (xpress_is_multiblog() && is_user_logged_in()){
|
---|
[547] | 1101 | $blog_list = get_blog_list();
|
---|
| 1102 | $root_path = get_blog_status(1,'path');
|
---|
[546] | 1103 | $primary_blog_id = @$current_user->primary_blog;
|
---|
[565] | 1104 | if(empty($primary_blog_id)) return $ret;
|
---|
[546] | 1105 | $primary_path = get_blog_status($primary_blog_id,'path');
|
---|
| 1106 | $script = str_replace($root_path, "", $primary_path);
|
---|
| 1107 | if ($primary_blog_id !== $blog_id){
|
---|
| 1108 | $ret['url'] = get_blogaddress_by_id($primary_blog_id);
|
---|
| 1109 | $ret['menu_url'] = $script;
|
---|
| 1110 | $ret['title'] = __('Your Primary Blog','xpressme');
|
---|
| 1111 | $ret['link'] = '<a href="' . $ret['url'] . '">' . $ret['title'] . '</a>';
|
---|
| 1112 | }
|
---|
| 1113 | }
|
---|
| 1114 | return $ret;
|
---|
| 1115 | }
|
---|
| 1116 |
|
---|
[252] | 1117 | ?> |
---|