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