' . $prefix.strip_tags($my_cat_name) . ''; else return strip_tags($my_cat_name); } } } endif; if ( !function_exists('_single_tag_title') ) : function _single_tag_title($prefix = '', $display = true ) { if ( !is_tag() ) return; $tag_id = intval( get_query_var('tag_id') ); if ( !empty($tag_id) ) { $my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display'); if ( is_wp_error( $my_tag ) ) return false; $my_tag_name = apply_filters('single_tag_title', $my_tag->name); if ( !empty($my_tag_name) ) { if ( $display ) echo '

' . $prefix . $my_tag_name . '

'; else return $my_tag_name; } } } endif; if ( !function_exists('_get_tag_link') ) : function _get_tag_link( $tag_id ) { $tag = &get_term($tag_id, 'post_tag'); if ( is_wp_error( $tag ) ) return $tag; $slug = $tag->slug; $taglink = '?tag=' . $slug; return apply_filters('tag_link', $taglink, $tag_id); } endif; if ( !function_exists('_get_the_tag_list') ) : function _get_the_tag_list(){ $posttags = get_the_tags(); $content = ""; if ($posttags) { $tag_i = 0; foreach($posttags as $tag) { if($tag_i > 0) { $content .= ', '; } $content .= '' .$tag->name . ''; $tag_i++; } } else { $content .= '无'; } return $content; } endif; if ( !function_exists('_get_the_category_list') ) : function _get_the_category_list($separator = '', $parents='') { $categories = get_the_category(); $thelist = ''; if (empty($categories)) return apply_filters('the_category', __('Uncategorized'), $separator, $parents); $i = 0; foreach ( $categories as $category ) { if ( 0 < $i ) $thelist .= $separator . ' '; $thelist .= 'name) . '" ' . $rel . '>' . $category->name.''; ++$i; } return $thelist; } endif; if ( !function_exists('_wp_list_categories') ) : function _wp_list_categories($args = '') { $defaults = array( 'show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '', 'hierarchical' => true, 'title_li' => __('Categories','wap'), 'echo' => 1 ); $r = wp_parse_args( $args, $defaults ); if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { $r['pad_counts'] = true; } if ( isset( $r['show_date'] ) ) { $r['include_last_update_time'] = $r['show_date']; } extract( $r ); $categories = get_categories($r); $output = ''; if ( $title_li && 'list' == $style ) $output = '
  • ' . $r['title_li'] . '
  • '; if ( $echo ) echo $output; else return $output; } endif; if ( !function_exists('_wp') ) : function _wp($query_vars = '') { global $wp, $wp_query, $wp_the_query; $wp->init(); $wp->parse_request($query_vars); _send_headers(); $wp->query_posts(); $wp->handle_404(); $wp->register_globals(); do_action_ref_array('wp', array(&$wp)); if( !isset($wp_the_query) ) $wp_the_query = $wp_query; } endif; if ( !function_exists('_send_headers') ) : function _send_headers() { @header('X-Pingback: '. get_bloginfo('pingback_url')); if ( is_user_logged_in() ) nocache_headers(); @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); } endif; /* 截取UTF-8字符串 */ if ( !function_exists('ustrcut') ) : function ustrcut($string,$sublen) { if($sublen>=strlen($string)) { return $string; } $s=""; for( $i=0; $i< $sublen; $i++ ) { $code = ord($string[$i]); if( $code >= 224 ) { $s.=$string[$i] . $string[++$i] . $string[++$i]; } elseif( $code >= 127 ) { $s.=$string[$i] . $string[++$i]; } else{ $s.=$string[$i]; } } return $s; }// End Function cnSubStr($string,$sublen) endif; function _wp23_get_related_posts() { global $wpdb, $post; if(!$post->ID){return;} $now = current_time('mysql', 1); $tags = wp_get_post_tags($post->ID); //print_r($tags); $taglist = "'" . str_replace("'",'',str_replace('"','',urldecode($tags[0]->term_id))). "'"; $tagcount = count($tags); if ($tagcount > 1) { for ($i = 1; $i <= $tagcount; $i++) { $taglist = $taglist . ", '" . str_replace("'",'',str_replace('"','',urldecode($tags[$i]->term_id))) . "'"; } } $limit = get_option("wp23_RP_limit"); if ($limit) $limitclause = "LIMIT $limit"; $exclude = get_option("wp23_RP_exclude"); if ( $exclude != '' ) { $excludeclause = "AND p.ID NOT IN (SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id REGEXP '[$exclude]')"; } $q = "SELECT DISTINCT p.ID, p.post_title, p.post_date, p.comment_count, count(t_r.object_id) as cnt FROM $wpdb->term_taxonomy t_t, $wpdb->term_relationships t_r, $wpdb->posts p WHERE t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id AND t_r.object_id = p.ID AND (t_t.term_id IN ($taglist)) AND p.ID != $post->ID AND p.post_status = 'publish' AND p.post_date_gmt < '$now' $excludeclause GROUP BY t_r.object_id ORDER BY cnt DESC, p.post_date_gmt DESC $limitclause;"; //echo $q; $related_posts = $wpdb->get_results($q); $output = ""; $wp23_RP_title = get_option("wp23_RP_title"); if(!$wp23_RP_title) $wp23_RP_title= __("Related Post",'wp23_related_posts'); if (!$related_posts){ $wp23_no_RP = get_option("wp23_no_RP"); if(!$wp23_no_RP || ($wp23_no_RP == "popularity" && !function_exists('akpc_most_popular'))) $wp23_no_RP = "text"; $wp23_no_RP_text = get_option("wp23_no_RP_text"); if($wp23_no_RP == "text"){ if(!$wp23_no_RP_text) $wp23_no_RP_text= __("No Related Post",'wp23_related_posts'); $output .= '
  • '.$wp23_no_RP_text .'
  • '; } else{ if( function_exists('wp23_random_posts') && $wp23_no_RP == "random"){ if(!$wp23_no_RP_text) $wp23_no_RP_text= __("Random Posts",'wp23_related_posts'); $related_posts = wp23_random_posts($limitclause); } elseif( function_exists('wp23_most_commented_posts') && $wp23_no_RP == "commented"){ if(!$wp23_no_RP_text) $wp23_no_RP_text= __("Most Commented Posts",'wp23_related_posts'); $related_posts = wp23_most_commented_posts($limitclause); } elseif( function_exists('wp23_most_popular_posts') && $wp23_no_RP == "popularity"){ if(!$wp23_no_RP_text) $wp23_no_RP_text= __("Most Popular Posts",'wp23_related_posts'); $related_posts = wp23_most_popular_posts($limitclause); }else{ return __("Something wrong",'wp23_related_posts');; } $wp23_RP_title = $wp23_no_RP_text; } } foreach ($related_posts as $related_post ){ $output .= '
  • '; $show_date = get_option("wp23_RP_Date"); if ($show_date){ $dateformat = get_option('date_format'); $output .= mysql2date($dateformat, $related_post->post_date) . " -- "; } $output .= ''.wptexturize($related_post->post_title).''; $show_comments_count = get_option("wp23_RP_Comments"); if ($show_comments_count){ $output .= " (" . $related_post->comment_count . ")"; } $output .= '
  • '; } $output = '

    '.$wp23_RP_title .'

    '.''; return $output; } function _wp23_related_posts(){ $output = _wp23_get_related_posts() ; echo $output; } function _get_next_posts_page_link($max_page = 0) { global $paged, $pagenow; if ( !is_single() ) { if ( !$paged ) $paged = 1; $nextpage = intval($paged) + 1; if ( !$max_page || $max_page >= $nextpage ) return _get_pagenum_link($nextpage); } } function _next_posts($max_page = 0) { echo clean_url(_get_next_posts_page_link($max_page)); } function _next_posts_link($label='Next Page »', $max_page=0) { global $paged, $wpdb, $wp_query; if ( !$max_page ) { $max_page = $wp_query->max_num_pages; } if ( !$paged ) $paged = 1; $nextpage = intval($paged) + 1; if ( (! is_single()) && (empty($paged) || $nextpage <= $max_page) ) { echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; } } function _get_pagenum_link($pagenum = 1, $using_permalinks = false) { global $wp_rewrite; $pagenum = (int) $pagenum; $request = remove_query_arg( 'paged' ); $home_root = parse_url(_get_wap_home()); $home_root = $home_root['path']; $home_root = preg_quote( trailingslashit( $home_root ), '|' ); $request = preg_replace('|^'. $home_root . '|', '', $request); $request = preg_replace('|^/+|', '', $request); if ( !$using_permalinks ) { $base = trailingslashit( _get_wap_home() ); if ( $pagenum > 1 ) { $result = add_query_arg( 'paged', $pagenum, $base . $request ); } else { $result = $base . $request; } } else { $qs_regex = '|\?.*?$|'; preg_match( $qs_regex, $request, $qs_match ); if ( $qs_match[0] ) { $query_string = $qs_match[0]; $request = preg_replace( $qs_regex, '', $request ); } else { $query_string = ''; } $request = preg_replace( '|page/(.+)/?$|', '', $request); $request = preg_replace( '|^index\.php|', '', $request); $request = ltrim($request, '/'); $base = trailingslashit( get_bloginfo( 'url' ) ); if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) $base .= 'index.php/'; if ( $pagenum > 1 ) { $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' ); } $result = $base . $request . $query_string; } return $result; } function _get_previous_posts_page_link() { global $paged, $pagenow; if ( !is_single() ) { $nextpage = intval($paged) - 1; if ( $nextpage < 1 ) $nextpage = 1; return _get_pagenum_link($nextpage); } } function _previous_posts() { echo _get_previous_posts_page_link(); } function _previous_posts_link($label='« Previous Page') { global $paged; if ( (!is_single()) && ($paged > 1) ) { echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .' '; } } // Navigation links function _get_previous_post($in_same_cat = false, $excluded_categories = '') { global $post, $wpdb; if( empty($post) || !is_single() || is_attachment() ) return null; $current_post_date = $post->post_date; $join = ''; if ( $in_same_cat ) { $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id "; $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=tt_ids'); $join .= ' AND (tr.term_taxonomy_id = ' . intval($cat_array[0]); for ( $i = 1; $i < (count($cat_array)); $i++ ) { $join .= ' OR tr.term_taxonomy_id = ' . intval($cat_array[$i]); } $join .= ')'; } $sql_exclude_cats = ''; if ( !empty($excluded_categories) ) { $blah = explode(' and ', $excluded_categories); $posts_in_ex_cats = get_objects_in_term($blah, 'category'); $posts_in_ex_cats_sql = 'AND p.ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; } $join = apply_filters( 'get_previous_post_join', $join, $in_same_cat, $excluded_categories ); $where = apply_filters( 'get_previous_post_where', "WHERE p.post_date < '$current_post_date' AND p.post_type = 'post' AND p.post_status = 'publish' $posts_in_ex_cats_sql", $in_same_cat, $excluded_categories ); $sort = apply_filters( 'get_previous_post_sort', 'ORDER BY p.post_date DESC LIMIT 1' ); return @$wpdb->get_row("SELECT p.ID, p.post_title FROM $wpdb->posts AS p $join $where $sort"); } function _get_next_post($in_same_cat = false, $excluded_categories = '') { global $post, $wpdb; if( empty($post) || !is_single() || is_attachment() ) return null; $current_post_date = $post->post_date; $join = ''; if ( $in_same_cat ) { $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id "; $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=tt_ids'); $join .= ' AND (tr.term_taxonomy_id = ' . intval($cat_array[0]); for ( $i = 1; $i < (count($cat_array)); $i++ ) { $join .= ' OR tr.term_taxonomy_id = ' . intval($cat_array[$i]); } $join .= ')'; } $sql_exclude_cats = ''; if ( !empty($excluded_categories) ) { $blah = explode(' and ', $excluded_categories); $posts_in_ex_cats = get_objects_in_term($blah, 'category'); $posts_in_ex_cats_sql = 'AND p.ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; } $join = apply_filters( 'get_next_post_join', $join, $in_same_cat, $excluded_categories ); $where = apply_filters( 'get_next_post_where', "WHERE p.post_date > '$current_post_date' AND p.post_type = 'post' AND p.post_status = 'publish' $posts_in_ex_cats_sql AND p.ID != $post->ID", $in_same_cat, $excluded_categories ); $sort = apply_filters( 'get_next_post_sort', 'ORDER BY p.post_date ASC LIMIT 1' ); return @$wpdb->get_row("SELECT p.ID, p.post_title FROM $wpdb->posts AS p $join $where $sort"); } function _previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { if ( is_attachment() ) $post = & get_post($GLOBALS['post']->post_parent); else $post = _get_previous_post($in_same_cat, $excluded_categories); if ( !$post ) return; $title = $post->post_title; if ( empty($post->post_title) ) $title = __('Previous Post'); $title = apply_filters('the_title', $title, $post); $string = ''; $link = str_replace('%title', $title, $link); $link = $pre . $string . $link . ''; $format = str_replace('%link', $link, $format); echo $format; } function _get_permalink($id = 0) { $post = &get_post($id); if ( empty($post->ID) ) return FALSE; return _get_wap_home() . "/index.php?p=" . $post->ID; } function _next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { $post = _get_next_post($in_same_cat, $excluded_categories); if ( !$post ) return; $title = $post->post_title; if ( empty($post->post_title) ) $title = __('Next Post'); $title = apply_filters('the_title', $title, $post); $string = ''; $link = str_replace('%title', $title, $link); $link = $string . $link . ''; $format = str_replace('%link', $link, $format); echo $format; } if(!function_exists('_get_most_viewed')) { function _get_most_viewed($mode = '', $limit = 10, $chars = 0, $display = true) { global $wpdb, $post; $where = ''; $temp = ''; if(!empty($mode) && $mode != 'both') { $where = "post_type = '$mode'"; } else { $where = '1=1'; } $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit"); if($most_viewed) { if($chars > 0) { foreach ($most_viewed as $post) { $post_title = get_the_title(); $post_views = intval($post->views); $post_views = number_format($post_views); $temp .= "
  • ".snippet_chars($post_title, $chars)." - $post_views ".__('views', 'wp-postviews')."
  • \n"; } } else { foreach ($most_viewed as $post) { $post_title = get_the_title(); $post_views = intval($post->views); $post_views = number_format($post_views); $temp .= "
  • $post_title
  • \n"; //$temp .= "
  • $post_title - $post_views ".__('views', 'wp-postviews')."
  • \n"; //$temp .= "
  • $post_title ($post_views 次)
  • \n"; } } } else { $temp = '
  • '.__('No Posts', 'wap').'
  • '."\n"; } if($display) { echo $temp; } else { return $temp; } } } if ( !function_exists('_get_wap_home') ): function _get_wap_home() { $wap_home = $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"]; $wap_home = str_replace("\\", "/", $wap_home); $pos = strrpos ( $wap_home, "/" ); $wap_home = substr ( $wap_home, 0, $pos ); $wap_home = "http://" . $wap_home; return $wap_home; } endif; if ( !function_exists('_wap_header') ) : function _wap_header($title = '', $name = ''){ $stitle = get_option("wap_sitetitle"); if( $stitle == '' ) { $stitle = get_bloginfo('name'); } $sname = $stitle; if ( isset( $title ) && $title != '' ) $stitle = $title; if ( isset( $name ) && $name != '' ) $sname = $name; echo ''; ?> <?php echo $stitle; ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?>



    \n"; foreach ( (array) $q as $a ) { $v = substr(strstr($a, '='), 1); $k = substr($a, 0, -(strlen($v)+1)); $html .= "\t\t\n"; } $html .= "\t\t\n"; $html .= "\t\t
    \n\t\t

    " . wp_specialchars(wp_explain_nonce($action)) . "

    \n\t\t

    " . __('No') . "

    \n\t\t
    \n\t\n"; } else { $html .= "\t
    \n\t

    " . wp_specialchars(wp_explain_nonce($action)) . "

    \n\t

    " . __('No') . " " . __('Yes') . "

    \n\t
    \n"; } _wap_die($html, $title); } endif; if ( !function_exists('_wap_die') ) : function _wap_die( $message, $title = '' ) { global $wp_locale; if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { if ( empty($title) ) { $error_data = $message->get_error_data(); if ( is_array($error_data) && isset($error_data['title']) ) $title = $error_data['title']; } $errors = $message->get_error_messages(); switch ( count($errors) ) : case 0 : $message = ''; break; case 1 : $message = "

    {$errors[0]}

    "; break; default : $message = ""; break; endswitch; } elseif ( is_string($message) ) { $message = "

    $message

    "; } $admin_dir = _get_wap_home() . '/writer.php'; if ( !function_exists('did_action') || !did_action('admin_head') ) : if( !headers_sent() ){ status_header(500); nocache_headers(); header('Content-Type: text/html; charset=utf-8'); } if ( empty($title) ){ if( function_exists('__') ) $title = __('WordPress › Error'); else $title = 'WordPress › Error'; } _wap_header(); ?> get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" ); } else{ $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' ORDER BY comment_date DESC LIMIT $start, $num" ); } update_comment_cache($comments); $total = $wpdb->get_var( "SELECT FOUND_ROWS()" ); return array($comments, $total); } endif; if ( !function_exists('_wap_comment_list_item') ) : function _wap_comment_list_item( $id, $view_all = false ) { global $authordata, $comment, $wpdb; $id = (int) $id; $comment =& get_comment( $id ); $class = ''; $post = get_post($comment->comment_post_ID); $authordata = get_userdata($post->post_author); $comment_status = wp_get_comment_status($comment->comment_ID); if ( 'unapproved' == $comment_status ){ $class .= ' unapproved'; } else{ if ( !$view_all ) return; } echo "
  • "; $post = get_post($comment->comment_post_ID, OBJECT, 'display'); $post_title = wp_specialchars( $post->post_title, 'double' ); $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; ?>


    :

    : comment_author_email != '' && current_user_can('edit_post', $comment->comment_post_ID) ) { ?>
    : comment_author_email ?> comment_author_url && 'http://' != $comment->comment_author_url) { ?>
    :


    comment_post_ID) ) { echo '[comment_author)) . "', theCommentList );\">" . __('Delete','wap') . ' '; if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { if ( 'unapproved' != $comment_status ) echo ' | ' . __('Pending','wap') . ' '; else echo ' | ' . __('Approved','wap') . ' '; } echo " | comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)). "', theCommentList );\">" . __('Spam','wap') . " ]"; } ?>

  • '

    ' . __('Pages:'), 'after' => '

    ', 'next_or_number' => 'number', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'more_file' => '', 'echo' => 1 ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); global $post, $id, $page, $numpages, $multipage, $more, $pagenow; if ( $more_file != '' ) $file = $more_file; else $file = $pagenow; $output = ''; if ( $multipage ) { if ( 'number' == $next_or_number ) { $output .= $before; for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) { $j = str_replace('%',"$i",$pagelink); $output .= ' '; if ( ($i != $page) || ((!$more) && ($page==1)) ) { if ( 1 == $i ) { $output .= ''; } else { //if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) $output .= ''; //else //$output .= ''; } } $output .= $j; if ( ($i != $page) || ((!$more) && ($page==1)) ) $output .= ''; } $output .= $after; } else { if ( $more ) { $output .= $before; $i = $page - 1; if ( $i && $more ) { if ( 1 == $i ) { $output .= '' . $previouspagelink . ''; } else { //if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) $output .= '' . $previouspagelink . ''; //else // $output .= '' . $previouspagelink . ''; } } $i = $page + 1; if ( $i <= $numpages && $more ) { if ( 1 == $i ) { $output .= '' . $nextpagelink . ''; } else { //if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) $output .= '' . $nextpagelink . ''; //else // $output .= '' . $nextpagelink . ''; } } $output .= $after; } } } if ( $echo ) echo $output; return $output; } endif; ?>