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