' . "\n"; if (function_exists('hotDates')) { ob_start(); hotDates(); $output .= ob_get_contents(); ob_end_clean(); } $output .= '
' . "\n"; $output .= '

'; ob_start(); the_title(); $output .= ob_get_contents(); ob_end_clean(); $output .= '

' . "\n"; $output .= '
' . "\n"; $output .= '' . "\n"; if (empty($show)) return $output; else echo $output; } function xpress_is_wpmu() { global $xoops_config; return $xoops_config->is_wpmu; } function xpress_selected_author($show=true ) { $output = ''; $author_cookie = get_xpress_dir_name() . "_select_author" ; if (!empty($_COOKIE[$author_cookie])){ $uid = intval($_COOKIE[$author_cookie]); $user_info = get_userdata($uid); $output = $user_info->display_name; } if (empty($show)) return $output; else echo $output; } function xpress_selected_author_id($show=true ) { $output = ''; $author_cookie = get_xpress_dir_name() . "_select_author" ; if (!empty($_COOKIE[$author_cookie])){ $output = intval($_COOKIE[$author_cookie]); } else { $output = ''; } if (empty($show)) return $output; else echo $output; } function xpress_now_user_level($show=true ) { global $current_user; $output = @$current_user->user_level; if (empty($show)) return $output; else echo $output; } function xpress_list_pings($trackback, $args, $depth) { $GLOBALS['comment'] = $trackback; echo '
  • '; comment_author_link(); } function xpress_credit($show = true) { global $wp_version , $xoops_config; if ($xoops_config->is_wpmu) { global $wpmu_version; } $xpress_version = $xoops_config->module_version; $xpress_codename = $xoops_config->module_codename; $ret = 'XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .''; if ($xoops_config->is_wpmu) { $ret .= '(included WordPress MU ' . $wpmu_version . ')'; } else { if (strstr($wp_version,'ME')){ $ret .= '(included WordPress ' . $wp_version . ')'; } else { $ret .= '(included WordPress ' . $wp_version . ')'; } } if (empty($show)) return $ret; else echo $ret; } function xpress_convert_time($show = true) { $ret = timer_stop(0) .'sec. '; if (empty($show)) return $ret; else echo $ret; } function xpress_is_theme_sidebar_disp(){ global $xpress_config; if (is_wordpress_style()) return true; return $xpress_config->is_theme_sidebar_disp; } function xpress_left_arrow_post_link($show = true) { global $xpress_config; $ret = ''; if($xpress_config->is_left_postnavi_old){ $link_title = $xpress_config->old_post_link_text; ob_start(); if ($xpress_config->is_postnavi_title_disp) previous_post_link('« %link'); else previous_post_link('« %link',$link_title); $ret = ob_get_contents(); ob_end_clean(); ob_start(); previous_post_link('%link',$link_title); $GLOBALS['left_arrow_post_link'] = ob_get_contents(); ob_end_clean(); } else { $link_title = $xpress_config->newer_post_link_text; ob_start(); if ($xpress_config->is_postnavi_title_disp) next_post_link('« %link'); else next_post_link('« %link',$link_title); $ret = ob_get_contents(); ob_end_clean(); ob_start(); next_post_link('%link',$link_title); $GLOBALS['left_arrow_post_link'] = ob_get_contents(); ob_end_clean(); } if ($xpress_config->is_postnavi_title_disp){ $on_mouse_show = $link_title; } else { if($xpress_config->is_left_postnavi_old){ ob_start(); previous_post_link('%link'); $on_mouse_show = ob_get_contents(); ob_end_clean(); } else { ob_start(); next_post_link('%link'); $on_mouse_show = ob_get_contents(); ob_end_clean(); } $pattern = "]*?>(.*)<\/a>"; preg_match("/".$pattern."/s", $on_mouse_show, $body_matches); $on_mouse_show = $body_matches[1]; } $ret = str_replace('">','" title="'.$on_mouse_show . '">' , $ret); if (empty($show)) return $ret; else echo $ret; } function xpress_right_arrow_post_link($show = true) { global $xpress_config; $ret = ''; if($xpress_config->is_left_postnavi_old){ $link_title = $xpress_config->newer_post_link_text; ob_start(); if ($xpress_config->is_postnavi_title_disp) next_post_link('%link »'); else next_post_link('%link »',$link_title); $ret = ob_get_contents(); ob_end_clean(); ob_start(); next_post_link('%link',$link_title); $GLOBALS['right_arrow_post_link'] = ob_get_contents(); ob_end_clean(); } else { $link_title = $xpress_config->old_post_link_text; ob_start(); if ($xpress_config->is_postnavi_title_disp) previous_post_link('%link »'); else previous_post_link('%link »',$link_title); $ret = ob_get_contents(); ob_end_clean(); ob_start(); previous_post_link('%link',$link_title); $GLOBALS['right_arrow_post_link'] = ob_get_contents(); ob_end_clean(); } if ($xpress_config->is_postnavi_title_disp){ $on_mouse_show = $link_title; } else { if($xpress_config->is_left_postnavi_old){ ob_start(); next_post_link('%link'); $on_mouse_show = ob_get_contents(); ob_end_clean(); } else { ob_start(); previous_post_link('%link'); $on_mouse_show = ob_get_contents(); ob_end_clean(); } $pattern = "]*?>(.*)<\/a>"; preg_match("/".$pattern."/s", $on_mouse_show, $body_matches); $on_mouse_show = $body_matches[1]; } $ret = str_replace('">','" title="'.$on_mouse_show . '">' , $ret); if (empty($show)) return $ret; else echo $ret; } // page link function xpress_left_arrow_posts_link($show = true) { global $xpress_config; $ret = ''; if($xpress_config->is_left_page_navi_old){ $link_title = $xpress_config->old_page_link_text; ob_start(); next_posts_link("« $link_title"); $ret = ob_get_contents(); ob_end_clean(); } else { $link_title = $xpress_config->newer_page_link_text; ob_start(); previous_posts_link("« $link_title"); $ret = ob_get_contents(); ob_end_clean(); } if (empty($show)) return $ret; else echo $ret; } function xpress_right_arrow_posts_link($show = true) { global $xpress_config; $ret = ''; if($xpress_config->is_left_page_navi_old){ $link_title = $xpress_config->newer_page_link_text; ob_start(); previous_posts_link("$link_title »"); $ret = ob_get_contents(); ob_end_clean(); } else { $link_title = $xpress_config->old_page_link_text; ob_start(); next_posts_link("$link_title »"); $ret = ob_get_contents(); ob_end_clean(); } if (empty($show)) return $ret; else echo $ret; } function xpress_is_author_view_count(){ global $xpress_config; return $xpress_config->is_author_view_count; } function xpress_is_multi_user(){ global $xpress_config; return $xpress_config->is_multi_user; } function xpress_substr($str, $start, $length, $trimmarker = '...') { if (function_exists('mb_substr')){ $str2 = mb_substr( $str , $start , $length); return $str2 . ( mb_strlen($str)!=mb_strlen($str2) ? $trimmarker : '' ); } else { return ( strlen($str) - $start <= $length ) ? substr( $str, $start, $length ) : substr( $str, $start, $length - strlen($trimmarker) ) . $trimmarker; } } // views count // Set and retrieves post views given a post ID or post object. // Retrieves post views given a post ID or post object. function xpress_post_views_count($post_id=0,$format= '',$show = true) { global $xoops_db,$wpdb; static $post_cache_views; if ( empty($post_id) ) { if ( isset($GLOBALS['post']) ) $post_id = $GLOBALS['post']->ID; } $post_id = intval($post_id); if($post_id==0) return null; if(!isset($post_cache_views[$post_id])){ $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id"; $post_views = $xoops_db->get_var($sql); if (!$post_views) { $post_cache_views[$post_id] = 0; }else{ $post_cache_views[$post_id] = $post_views; } } $v_count = intval($post_cache_views[$post_id]); if (empty($format)) $format = __('views :%d','xpressme'); $ret = sprintf($format,$v_count); if ($show) echo $ret; else return $ret; } function set_post_views_count(&$content) { if ( empty($_GET["feed"]) && empty($GLOBALS["feed"]) && empty($GLOBALS["doing_trackback"]) && empty($GLOBALS["doing_rss"]) && empty($_POST) && is_single() ){ post_views_counting(); } return $content; } // Set post views given a post ID or post object. function post_views_counting($post_id = 0) { global $xoops_db,$wpdb; global $table_prefix; static $views; $post_id = intval($post_id); if ( empty($post_id) && isset($GLOBALS['post']) ){ $post_id = $GLOBALS['post']->ID; } $views_db = get_wp_prefix() . 'views'; if($post_id==0 || !empty($views[$post_id])) return null; if(!xpress_is_author_view_count()){ $current_user_id = $GLOBALS['current_user']->ID; $post_author_id = $GLOBALS['post']->post_author; if ($current_user_id ==$post_author_id) return null; } $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id"; $post_views_found = $xoops_db->get_var($sql); if($post_views_found){ $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id"; }else{ $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)"; } $xoops_db->query($sql); return true; } function get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text = '') { global $post,$xpress_config; $blog_encoding = get_option('blog_charset'); $text = get_the_content(''); $text = strip_shortcodes( $text ); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $is_almost_ascii = ($xpress_config->ascii_judged_rate < round(@(mb_strlen($text, $blog_encoding) / strlen($text)) * 100)) ? true : false; if($is_almost_ascii) { $words = explode(' ', $text, $excerpt_length_word + 1); if(count($words) > $excerpt_length_word) { array_pop($words); array_push($words, ' ... '); $text = implode(' ', $words); if (!empty($more_link_text)) $text .= '

    ".$more_link_text .'

    '; } } elseif(mb_strlen($text, $blog_encoding) > $excerpt_length_character) { $text = mb_substr($text, 0, $xpress_config->excerpt_length_character, $blog_encoding) . ' ... '; if (!empty($more_link_text)) $text .= '

    ".$more_link_text .'

    '; } return $text; } function xpress_the_content($more_link_text = null, $stripteaser = 0, $more_file = '',$show = true) { global $post,$xpress_config; if ($xpress_config->is_content_excerpt){ $excerpt_length_word = $xpress_config->excerpt_length_word; $excerpt_length_character = $xpress_config->excerpt_length_character; $more_link_text = $xpress_config->more_link_text; $content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text); } else { $content = get_the_content($more_link_text,$stripteaser,$more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); } if(empty($show)) return $content; echo $content; } function is_xpress_contributor() { global $current_user; get_currentuserinfo(); if ($current_user->user_level > 3) return true; else return false; } function xpress_post_new_link($link_title,$display = true) { $output = '' . $link_title . ''; if ($display) echo $output; else return $output; } function xpress_conditional_title($display = true) { $selected_author = xpress_selected_author(false); $output = __('Main', 'xpressme'); $output = ''; if (is_category()) $output = sprintf(__('Archive for the ‘%s’ Category', 'xpressme'), single_cat_title('', false)); if (is_tag()) $output = sprintf(__('Posts Tagged ‘%s’', 'xpressme'), single_tag_title('', false) ); if (is_day()) $output = sprintf(__('Archive for %s|Daily archive page', 'xpressme'), get_the_time(__('F jS, Y', 'xpressme'))); if (is_month()) $output = sprintf(__('Archive for %s|Monthly archive page', 'xpressme'), get_the_time(__('F, Y', 'xpressme'))); if (is_year()) $output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme'))); if (is_author()){ if (empty($selected_author)) $output = sprintf(__('Archive for the ‘%s’ Author', 'xpressme'), get_author_name( get_query_var('author'))); } if (is_search()) $output = sprintf(__('Search Results of word ‘%s’', 'xpressme'), get_search_query()); if (!empty($selected_author)){ $selected_id = xpress_selected_author_id(false); // $output = get_avatar($selected_id,$size = '32') . sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output; if (empty($output)) $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) ; else $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output; } if ($display) echo $output; else return $output; } function xpress_pings_list($show = true){ $trackbacks = xpress_get_pings(); if (! empty($trackbacks)) { $output = '
      '; foreach ($trackbacks as $trackback){ $list = date(get_settings('date_format'),$trackback['date']) . ' ' . sprintf(__('From %1$s on site %2$s','xpressme'),$trackback['title'],$trackback['site_name']) . "\n" ; $output .= '
    1. '; $output .= $list ; $output .= '
    2. '; } $output .= '
    ' ; } else { $output = ''; } if ($show) echo $output; else return $output; } function xpress_pings_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { $pings = xpress_get_pings(); if (empty($pings)){ $number = 0; }else { $number = count($pings); } if ( $number > 1 ) $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% TrackBack/Pingback', 'xpressme') : $more); elseif ( $number == 0 ) $output = ( false === $zero ) ? __('No Trackback/Pingback', 'xpressme') : $zero; else // must be one $output = ( false === $one ) ? __('One Trackback/Pingback', 'xpressme') : $one; echo $output; } function xpress_get_pings() { global $withcomments, $post, $wpdb, $id, $trackback, $user_login, $user_ID, $user_identity; if ( ! (is_single() || is_page() || $withcomments) ) return; /** @todo Use API instead of SELECTs. */ if ( $user_ID) { $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)); } else if ( empty($trackback_author) ) { $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)); } else { $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)); } if ($trackbacks){ $ret = array(); foreach ($trackbacks as $trackback){ $pattern = '(.*)<\/strong>(.*)'; if ( preg_match ( "/".$pattern."/i", $trackback->comment_content , $match ) ){ $title = $match[1]; $content = $match[2]; } if (empty($title)) $title = $trackback->comment_author; $row_data = array( 'ID' => $trackback->comment_ID , 'post_ID' => $trackback->comment_post_ID , 'site_name' => $trackback->comment_author , 'site_url' => $trackback->comment_author_url , 'title' => $title , 'content' => $content , 'date' => $trackback->comment_timestamp , 'date_gmt' => $trackback->comment_timestamp_gmt , 'agent' => $trackback->comment_agent , 'type' => $trackback->comment_type , 'IP' => $trackback->comment_author_IP , ); array_push($ret,$row_data); } return $ret; } return false; } function get_xpress_calendar($sun_color = '#DB0000' ,$sat_color = '#004D99' ,$initial = true) { global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; ob_start(); // Quick check. If we have no posts at all, abort! if ( !$posts ) { $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); if ( !$gotsome ) return; } if ( isset($_GET['w']) ) $w = ''.intval($_GET['w']); // week_begins = 0 stands for Sunday $week_begins = intval(get_option('start_of_week')); // Let's figure out when we are if ( !empty($monthnum) && !empty($year) ) { $thismonth = ''.zeroise(intval($monthnum), 2); $thisyear = ''.intval($year); } elseif ( !empty($w) ) { // We need to get the month from MySQL $thisyear = ''.intval(substr($m, 0, 4)); $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); } elseif ( !empty($m) ) { $thisyear = ''.intval(substr($m, 0, 4)); if ( strlen($m) < 6 ) $thismonth = '01'; else $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2); } else { $thisyear = gmdate('Y', current_time('timestamp')); $thismonth = gmdate('m', current_time('timestamp')); } $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); // Get the next and previous month and year with at least one post $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date < '$thisyear-$thismonth-01' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date > '$thisyear-$thismonth-01' AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date ASC LIMIT 1"); echo ''; $myweek = array(); for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); } foreach ( $myweek as $wd ) { for($week_num=0;$week_num<=6;$week_num++){ $week_name = $wp_locale->get_weekday($week_num); if ($week_name === $wd) break; } $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); if ($week_num ==0) $day_name = '' . $day_name . ''; if ($week_num ==6) $day_name = '' . $day_name . ''; echo "\n\t\t"; } echo ' '; if ( $previous ) { echo "\n\t\t".''; } else { echo "\n\t\t".''; } echo "\n\t\t".''; if ( $next ) { echo "\n\t\t".''; } else { echo "\n\t\t".''; } echo ' '; // Get days with posts $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' AND YEAR(post_date) = '$thisyear' AND post_type = 'post' AND post_status = 'publish' AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); if ( $dayswithposts ) { foreach ( (array) $dayswithposts as $daywith ) { $daywithpost[] = $daywith[0]; } } else { $daywithpost = array(); } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false) $ak_title_separator = "\n"; else $ak_title_separator = ', '; $ak_titles_for_day = array(); $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " ."FROM $wpdb->posts " ."WHERE YEAR(post_date) = '$thisyear' " ."AND MONTH(post_date) = '$thismonth' " ."AND post_date < '".current_time('mysql')."' " ."AND post_type = 'post' AND post_status = 'publish'" ); if ( $ak_post_titles ) { foreach ( (array) $ak_post_titles as $ak_post_title ) { $post_title = apply_filters( "the_title", $ak_post_title->post_title ); $post_title = str_replace('"', '"', wptexturize( $post_title )); if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one $ak_titles_for_day["$ak_post_title->dom"] = $post_title; else $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title; } } // See how much we should pad in the beginning $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); if ( 0 != $pad ) echo "\n\t\t".''; $daysinmonth = intval(date('t', $unixmonth)); for ( $day = 1; $day <= $daysinmonth; ++$day ) { if ( isset($newrow) && $newrow ) echo "\n\t\n\t\n\t\t"; $newrow = false; if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) ) echo ''; if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) $newrow = true; } $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); if ( $pad != 0 && $pad != 7 ) echo "\n\t\t".''; echo "\n\t\n\t\n\t
    ' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '
    $day_name
    « ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '  ' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' » 
     
    '; else echo ''; if ( in_array($day, $daywithpost) ) // any posts today? echo '$day"; else echo $day; echo ' 
    "; $output = ob_get_contents(); ob_end_clean(); // echo $output; // $cache[ $key ] = $output; // wp_cache_set( 'get_calendar', $cache, 'calendar' ); return $output; } ?>