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