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