芝麻web文件管理V1.00
编辑当前文件:/www/wwwroot/shphe-en.com/wp-content/themes/global/functions.php
query_vars['prisna_translate_seo_request'])?urldecode($wp_query->query_vars['prisna_translate_seo_request']):''; if ($get_lang!='') $result = str_replace(".com/",".com/".$get_lang."/",$result); else return $result; return $result; } add_filter('redirect_canonical', 'cancel_redirect_canonical'); function cancel_redirect_canonical($redirect_url) { if( is_page()) return false; return $redirect_url; } function add_query_vars($aVars) { $aVars[] = 'prisna_translate_seo_request'; return $aVars; } add_filter('query_vars', 'add_query_vars'); function submitTrRequest($url, $regularParams) { $ch = curl_init (); // print_r($ch); curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_POST, 1 ); curl_setopt ( $ch, CURLOPT_HEADER, 0 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $regularParams ); $response = curl_exec ( $ch ); curl_close ( $ch ); return json_decode($response,true); } add_theme_support('post-thumbnails'); show_admin_bar(false); function tj_custom_post_type() { register_post_type( 'admin', tj_custom_post_type_args("admin")); register_post_type( 'ad_img', tj_custom_post_type_args("ad_img")); register_post_type( 'home', tj_custom_post_type_args("home")); register_post_type( 'transall', tj_custom_post_type_args("transall")); register_post_type( 'skype', tj_custom_post_type_args("skype")); register_post_type( 'qq', tj_custom_post_type_args("qq")); register_post_type( 'ww', tj_custom_post_type_args("ww")); register_post_type( 'pro_detail', tj_custom_post_type_args("pro_detail")); register_post_type( 'pro_shuxing', tj_custom_post_type_args("pro_shuxing")); register_post_type( 'xunpan', tj_custom_post_type_args("xunpan")); register_post_type( 'sitemap', tj_custom_post_type_args("sitemap")); } function tj_cutom_post_type_label_args($typeName){ return $labels = array( 'name' => $typeName, 'singular_name' => $typeName, 'add_new' => 'Add New', 'add_new_item' => 'Add New '.$typeName, 'edit_item' => 'Edit '.$typeName, 'new_item' => 'New '.$typeName, 'all_items' => 'All '.$typeName, 'view_item' => 'View '.$typeName, 'search_items' => 'Search '.$typeName, 'not_found' => 'No '.$typeName.' found', 'not_found_in_trash' => 'No '.$typeName.' found in Trash', 'parent_item_colon' => '', 'menu_name' => $typeName ); } function tj_custom_post_type_args($typeName,$postType="post",$public=true,$queryable=true,$show_ui=true,$show_menu=true,$query_var=true,$has_archive = true, $hierarchical = false,$menu_position = null){ return $args = array( 'labels' => tj_cutom_post_type_label_args($typeName), 'public' => $public, 'publicly_queryable' => $queryable, 'show_ui' => $show_ui, 'show_in_menu' => $show_menu, 'query_var' => $query_var, 'rewrite' => array( 'slug' => strtolower($typeName)), 'capability_type' => $postType, 'has_archive' => $has_archive, 'hierarchical' => $hierarchical, 'menu_position' => $menu_position, 'supports' => array( 'title', 'thumbnail') ); } /*************************************************------------------------------Article function custom_post_article() { $labels = array( 'name' => _x( 'Article', 'post type general name' ), 'singular_name' => _x( 'Article', 'post type singular name' ), 'add_new' => _x( 'Add New', 'book' ), 'add_new_item' => __( 'Add New article' ), 'edit_item' => __( 'Edit article' ), 'new_item' => __( 'New article' ), 'all_items' => __( 'All article' ), 'view_item' => __( 'View article' ), 'search_items' => __( 'Search article' ), 'not_found' => __( 'No article found' ), 'not_found_in_trash' => __( 'No article found in the Trash' ), 'parent_item_colon' => '', 'menu_name' => 'article' ); $args = array( 'labels' => $labels, 'description' => 'Holds our product and product specific data', 'public' => true, 'menu_position' => 10, 'supports' => array( 'title', 'editor', 'thumbnail'), 'has_archive' => true, ); register_post_type( 'article', $args ); } add_action( 'init', 'custom_post_article' ); */ /*************************************************------------------------------Product */ function custom_post_guide() { $labels = array( 'name' => _x( 'Product Guide', 'post type general name' ), 'singular_name' => _x( 'Product Guide', 'post type singular name' ), 'add_new' => _x( 'Add New', 'book' ), 'add_new_item' => __( 'Add New Product Guide' ), 'edit_item' => __( 'Edit Product Guide' ), 'new_item' => __( 'New Product Guide' ), 'all_items' => __( 'All Product Guide' ), 'view_item' => __( 'View Product Guide' ), 'search_items' => __( 'Search Product Guide' ), 'not_found' => __( 'No Product Guide found' ), 'not_found_in_trash' => __( 'No Product Guide found in the Trash' ), 'parent_item_colon' => '', 'menu_name' => 'Product Guide' ); $args = array( 'labels' => $labels, 'description' => 'Holds our product and product specific data', 'public' => true, 'menu_position' => 10, 'supports' => array( 'title', 'editor', 'thumbnail'), 'has_archive' => true, ); register_post_type( 'guide', $args ); } add_action( 'init', 'custom_post_guide' ); /*************************************************------------------------------VideoShow */ function custom_post_vs() { $labels = array( 'name' => _x( 'Video Show', 'post type general name' ), 'singular_name' => _x( 'Video Show', 'post type singular name' ), 'add_new' => _x( 'Add New', 'book' ), 'add_new_item' => __( 'Add New vs' ), 'edit_item' => __( 'Edit vs' ), 'new_item' => __( 'New vs' ), 'all_items' => __( 'All vs' ), 'view_item' => __( 'View vs' ), 'search_items' => __( 'Search vs' ), 'not_found' => __( 'No vs found' ), 'not_found_in_trash' => __( 'No vs found in the Trash' ), 'parent_item_colon' => '', 'menu_name' => 'vs' ); $args = array( 'labels' => $labels, 'description' => 'Holds our product and product specific data', 'public' => true, 'menu_position' => 10, 'supports' => array( 'title', 'editor', 'thumbnail'), 'has_archive' => true, ); register_post_type( 'vs', $args ); } add_action( 'init', 'custom_post_vs' ); /*************************************************------------------------------help */ function custom_post_help() { $labels = array( 'name' => _x( '相关页面', 'post type general name' ), 'singular_name' => _x( 'Help', 'post type singular name' ), 'add_new' => _x( '新建', 'book' ), 'add_new_item' => __( '新建 相关页面' ), 'edit_item' => __( '修改 相关页面' ), 'new_item' => __( '新建 相关页面' ), 'all_items' => __( '所有 相关页面' ), 'view_item' => __( '查看 相关页面' ), 'search_items' => __( '搜索 相关页面' ), 'not_found' => __( '无 相关页面 内容' ), 'not_found_in_trash' => __( '无 相关页面 内容' ), 'parent_item_colon' => '', 'menu_name' => '相关页面' ); $args = array( 'labels' => $labels, 'description' => 'Holds our product and product specific data', 'public' => true, 'menu_position' => 10, 'supports' => array( 'title', 'editor', 'thumbnail'), 'has_archive' => true, ); register_post_type( 'help', $args ); } add_action( 'init', 'custom_post_help' ); /*************************************************------------------------------news */ function custom_post_news() { $labels = array( 'name' => _x( 'News', 'post type general name' ), 'singular_name' => _x( 'News', 'post type singular name' ), 'add_new' => _x( 'Add New', 'book' ), 'add_new_item' => __( 'Add New news' ), 'edit_item' => __( 'Edit news' ), 'new_item' => __( 'New news' ), 'all_items' => __( 'All news' ), 'view_item' => __( 'View news' ), 'search_items' => __( 'Search news' ), 'not_found' => __( 'No news found' ), 'not_found_in_trash' => __( 'No news found in the Trash' ), 'parent_item_colon' => '', 'menu_name' => 'News' ); $args = array( 'labels' => $labels, 'description' => 'Holds our product and product specific data', 'public' => true, 'menu_position' => 10, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), 'has_archive' => true, ); register_post_type( 'news', $args ); } add_action( 'init', 'custom_post_news' ); //Custom Taxonomies (news Categories) function taxonomies_news() { $labels = array( 'name' => _x( '新闻分类', 'taxonomy general name' ), 'singular_name' => _x( 'News Categories', 'taxonomy singular name' ), 'search_items' => __( '搜索新闻分类' ), 'all_items' => __( '新闻分类' ), 'parent_item' => __( '新闻分类' ), 'parent_item_colon' => __( '新闻分类:' ), 'edit_item' => __( '新闻分类修改' ), 'update_item' => __( '新闻分类更新' ), 'add_new_item' => __( '新增新闻分类' ), 'new_item_name' => __( '新新闻分类' ), 'menu_name' => __( '新闻分类' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, ); register_taxonomy( 'news_catalog', 'news', $args ); } add_action( 'init', 'taxonomies_news', 0 ); /*************************************************------------------------------blog function custom_post_blog() { $labels = array( 'name' => _x( 'Blog', 'post type general name' ), 'singular_name' => _x( 'Blog', 'post type singular name' ), 'add_new' => _x( '新建', 'book' ), 'add_new_item' => __( '新建 Blog' ), 'edit_item' => __( '修改 Blog' ), 'new_item' => __( '新建 Blog' ), 'all_items' => __( '所有 Blog' ), 'view_item' => __( '查看 Blog' ), 'search_items' => __( '搜索 Blog' ), 'not_found' => __( '无 Blog 内容' ), 'not_found_in_trash' => __( '无 Blog 内容' ), 'parent_item_colon' => '', 'menu_name' => 'Blog' ); $args = array( 'labels' => $labels, 'description' => 'Holds our product and product specific data', 'public' => true, 'menu_position' => 10, 'supports' => array( 'title', 'editor', 'thumbnail'), 'has_archive' => true, ); register_post_type( 'blog', $args ); } add_action( 'init', 'custom_post_blog' ); function taxonomies_blog() { $labels = array( 'name' => _x( 'Blog分类', 'taxonomy general name' ), 'singular_name' => _x( 'Blog分类', 'taxonomy singular name' ), 'search_items' => __( '搜索Blog分类' ), 'all_items' => __( 'Blog分类' ), 'parent_item' => __( 'Blog分类' ), 'parent_item_colon' => __( 'Blog分类:' ), 'edit_item' => __( 'Blog分类修改' ), 'update_item' => __( 'Blog分类更新' ), 'add_new_item' => __( '新增Blog分类' ), 'new_item_name' => __( '新Blog分类' ), 'menu_name' => __( 'Blog分类' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, ); register_taxonomy( 'blog_catalog', 'blog', $args ); } add_action( 'init', 'taxonomies_blog', 0 ); /*************************************************------------------------------video function custom_post_video() { $labels = array( 'name' => _x( 'Video', 'post type general name' ), 'singular_name' => _x( 'Video', 'post type singular name' ), 'add_new' => _x( 'Add New', 'book' ), 'add_new_item' => __( 'Add New video' ), 'edit_item' => __( 'Edit video' ), 'new_item' => __( 'New video' ), 'all_items' => __( 'All video' ), 'view_item' => __( 'View video' ), 'search_items' => __( 'Search video' ), 'not_found' => __( 'No video found' ), 'not_found_in_trash' => __( 'No video found in the Trash' ), 'parent_item_colon' => '', 'menu_name' => 'Video' ); $args = array( 'labels' => $labels, 'description' => 'Holds our product and product specific data', 'public' => true, 'menu_position' => 10, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), 'has_archive' => true, ); register_post_type( 'video', $args ); } add_action( 'init', 'custom_post_video' ); //Custom Taxonomies (video Categories) function taxonomies_video() { $labels = array( 'name' => _x( 'Video分类', 'taxonomy general name' ), 'singular_name' => _x( 'Video Categories', 'taxonomy singular name' ), 'search_items' => __( '搜索Video分类' ), 'all_items' => __( 'Video分类' ), 'parent_item' => __( 'Video分类' ), 'parent_item_colon' => __( 'Video分类:' ), 'edit_item' => __( 'Video分类修改' ), 'update_item' => __( 'Video分类更新' ), 'add_new_item' => __( '新增Video分类' ), 'new_item_name' => __( '新Video分类' ), 'menu_name' => __( 'Video分类' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, ); register_taxonomy( 'video_catalog', 'video', $args ); } add_action( 'init', 'taxonomies_video', 0 ); */ /*************************************************------------------------------project function custom_post_project() { $labels = array( 'name' => _x( 'Project', 'post type general name' ), 'singular_name' => _x( 'Project', 'post type singular name' ), 'add_new' => _x( 'Add New', 'book' ), 'add_new_item' => __( 'Add New project' ), 'edit_item' => __( 'Edit project' ), 'new_item' => __( 'New project' ), 'all_items' => __( 'All project' ), 'view_item' => __( 'View project' ), 'search_items' => __( 'Search project' ), 'not_found' => __( 'No project found' ), 'not_found_in_trash' => __( 'No project found in the Trash' ), 'parent_item_colon' => '', 'menu_name' => 'Project' ); $args = array( 'labels' => $labels, 'description' => 'Holds our product and product specific data', 'public' => true, 'menu_position' => 10, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), 'has_archive' => true, ); register_post_type( 'project', $args ); } add_action( 'init', 'custom_post_project' ); //Custom Taxonomies (project Categories) function taxonomies_project() { $labels = array( 'name' => _x( 'Project分类', 'taxonomy general name' ), 'singular_name' => _x( 'Project Categories', 'taxonomy singular name' ), 'search_items' => __( '搜索Project分类' ), 'all_items' => __( 'Project分类' ), 'parent_item' => __( 'Project分类' ), 'parent_item_colon' => __( 'Project分类:' ), 'edit_item' => __( 'Project分类修改' ), 'update_item' => __( 'Project分类更新' ), 'add_new_item' => __( '新增Project分类' ), 'new_item_name' => __( '新Project分类' ), 'menu_name' => __( 'Project分类' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, ); register_taxonomy( 'project_catalog', 'project', $args ); } add_action( 'init', 'taxonomies_project', 0 ); /************************************************* 自定义字段结束 *************************************************/ //判断是否为机器人、爬虫 function checkrobot($useragent = ''){ static $kw_spiders = 'Bot|Crawl|Spider|slurp|sohu-search|lycos|robozilla'; static $kw_browsers = 'MSIE|Netscape|Opera|Konqueror|Mozilla'; $useragent = empty($useragent) ? $_SERVER['HTTP_USER_AGENT'] : $useragent; if(!strexists($useragent, 'http://') && preg_match("/($kw_browsers)/i", $useragent)) { return false; } elseif(preg_match("/($kw_spiders)/i", $useragent)) { return true; } else { return false; } } function strexists($haystack, $needle) { return !(strpos($haystack, $needle) === FALSE); } function email_address_login($username) { $user = get_user_by_email($username); if(!empty($user->user_login)) $username = $user->user_login; return $username; } function no_self_ping( &$links ) { $home = get_option( 'home' ); foreach ( $links as $l => $link ) if ( 0 === strpos( $link, $home ) ) unset($links[$l]); } add_action( 'pre_ping', 'no_self_ping' ); /************************************************* 菜单名称输出 *************************************************/ function get_menu_name_by_id($id){ global $wpdb; $res = $wpdb->get_row("SELECT * FROM $wpdb->terms WHERE term_id = '{$id}'"); if($res) return $res->name; return false; } /** 只搜索文章的标题 */ function __search_by_title_only( $search, &$wp_query ) { global $wpdb; if ( empty( $search ) ) return $search; // skip processing - no search term in query $q = $wp_query->query_vars; $n = ! empty( $q['exact'] ) ? '' : '%'; $search = $searchand = ''; foreach ( (array) $q['search_terms'] as $term ) { $term = esc_sql( like_escape( $term ) ); $search .= "{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')"; $searchand = ' AND '; } if ( ! empty( $search ) ) { $search = " AND ({$search}) "; if ( ! is_user_logged_in() ) $search .= " AND ($wpdb->posts.post_password = '') "; } return $search; } add_filter( 'posts_search', '__search_by_title_only', 500, 2 ); function get_referrer_category() { global $posts; if ( ! $referrer_url = get_referrer_url( false ) ) return false; foreach ( get_the_category( $posts[0]->ID ) as $cat ) { $cat_link = get_category_link( $cat->term_id ); if ( false !== strpos( $referrer_url, $cat_link ) ) return $cat; } foreach ( get_the_tags( $posts[0]->ID ) as $tag ) { $tag_link = get_tag_link( $tag->term_id ); if ( false !== strpos( $referrer_url, $tag_link ) ) return $tag; } foreach ( get_the_terms( $posts[0]->ID, 'color' ) as $term ) { $term_link = get_term_link( $term->term_id ); if ( false !== strpos( $referrer_url, $term_link ) ) return $term; } return false; } add_filter( 'post_thumbnail_html', 'remove_wps_width', 10 ); add_filter( 'image_send_to_editor', 'remove_wps_width', 10 ); function remove_wps_width( $html ) { $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html ); return $html; } add_action( 'init', 'tj_custom_post_type' ); function get_category_root_id($cat) { $this_category = get_category($cat); // 取得当前分类 while($this_category->category_parent) // 若当前分类有上级分类时,循环 { $this_category = get_category($this_category->category_parent); // 将当前分类设为上级分类(往上爬) } return $this_category->term_id; // 返回根分类的id号 } add_filter( 'gettext_with_context', 'wpdx_disable_open_sans', 888, 4 ); function wpdx_disable_open_sans( $translations, $text, $context, $domain ) { if ( 'Open Sans font: on or off' == $context && 'on' == $text ) { $translations = 'off'; } return $translations; } remove_action('pre_post_update','wp_save_post_revision' ); add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1); add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1); add_filter('page_css_class', 'my_css_attributes_filter', 100, 1); function my_css_attributes_filter($var) { return is_array($var) ? array_intersect($var, array('nav-current','current-post-ancestor','current-menu-ancestor','current-menu-parent')) : ''; } add_action('login_head', 'my_custom_login_logo'); function my_custom_login_logo() { echo ''; } remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'rsd_link' ); remove_action( 'wp_head', 'wlwmanifest_link' ); remove_action( 'wp_head', 'index_rel_link' ); remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); remove_action( 'wp_head', 'locale_stylesheet' ); remove_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); remove_action( 'wp_head', 'noindex', 1 ); remove_action( 'wp_head', 'wp_print_styles', 8 ); remove_action( 'wp_head', 'wp_print_head_scripts', 9 ); remove_action( 'wp_head', 'wp_generator' ); remove_action( 'wp_head', 'rel_canonical' ); remove_action( 'wp_footer', 'wp_print_footer_scripts' ); remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); remove_action( 'template_redirect', 'wp_shortlink_header', 11, 0 ); remove_action( 'wp_head', 'index_rel_link' ); // Removes the index link remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // Removes the prev link remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // Removes the start link remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); // Removes the relational links for the posts adjacent to the current post. add_action('widgets_init', 'my_remove_recent_comments_style'); function wpdx_change_role_name() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $wp_roles->roles['administrator']['name'] = '超级管理员'; $wp_roles->role_names['administrator'] = '超级管理员'; $wp_roles->roles['editor']['name'] = '网站编辑'; $wp_roles->role_names['editor'] = '网站编辑'; } add_action('init', 'wpdx_change_role_name'); remove_role( 'author' ); remove_role( 'sc_chat_op' ); remove_role( 'pending' ); remove_role( 'subscriber' ); remove_role( 'contributor' ); remove_role( 'kefu' ); remove_role( 'yewu' ); function my_remove_recent_comments_style() { global $wp_widget_factory; remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style')); } if ( function_exists('register_sidebar') ) { register_sidebar( array( 'name' => 'inquiry', 'id' => 'inquiry', ) ); } if ( function_exists('register_sidebar') ) { register_sidebar( array( 'name' => 'newsletter', 'id' => 'newsletter', ) ); } function cut_str($sourcestr,$cutlength) { $returnstr=''; $i=0; $n=0; $str_length=strlen($sourcestr); while (($n<$cutlength) and ($i<=$str_length)) { $temp_str=substr($sourcestr,$i,1); $ascnum=Ord($temp_str); if ($ascnum>=224) { $returnstr=$returnstr.substr($sourcestr,$i,3); $i=$i+3; $n++; } elseif ($ascnum>=192) { $returnstr=$returnstr.substr($sourcestr,$i,2); $i=$i+2; $n++; } elseif ($ascnum>=65 && $ascnum<=90) { $returnstr=$returnstr.substr($sourcestr,$i,1); $i=$i+1; $n++; } else { $returnstr=$returnstr.substr($sourcestr,$i,1); $i=$i+1; $n=$n+0.5; } } if (mb_strlen($sourcestr)>$cutlength){ $returnstr = $returnstr . "…"; } return $returnstr; } function get_the_thumb($id) { $post=get_post($id); $first_img = ''; $first_img = get_post_meta($post->ID, "zuluo_thumbnail", true); if ($first_img != '') return $first_img; if ( has_post_thumbnail($id) ) { $imgstr = explode('src="', get_the_post_thumbnail($id,'thumbnail')); $img = explode('"', $imgstr[1]); $first_img = $img[0]; return $first_img; } else { $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $id, 'orderby' => 'post_date', 'order' => 'DESC' ); $attachments = get_posts( $args ); if ( $attachments ) { foreach ( $attachments as $attachment ) { $imgstr = explode('src="', wp_get_attachment_image( $attachment->ID, 'thumbnail' )); $img = explode('"', $imgstr[1]); $first_img = $img[0]; return $first_img; } } else { $output = preg_match_all('/
/i', $post->post_content, $matches); if ( $matches[1] ) $first_img = $matches[1][0]; if ($first_img=='') { $first_img = get_template_directory_uri() . "/images/thumb/". rand(1,3) .".jpg"; } return $first_img; } } } function my_profile( $contactmethods ) { unset($contactmethods['aim']); unset($contactmethods['yim']); unset($contactmethods['jabber']); return $contactmethods; } add_filter('user_contactmethods','my_profile'); function zuluo_pagination($range = 11){ global $paged, $wp_query; if ( !$max_page ) { $max_page = $wp_query->max_num_pages; } if($max_page > 1){ if(!$paged){ $paged = 1; } if($paged != 1){ echo "
First
"; } previous_posts_link('Previous'); if($max_page > $range){ if($paged < $range){ for($i = 1; $i <= $range; $i++){ echo "
$i
"; } } elseif($paged >= ($max_page - ceil(($range/2)))){ for($i = $max_page - $range + 1; $i <= $max_page; $i++){ echo "
$i
"; } } elseif($paged >= $range && $paged < ($max_page - ceil(($range/2)))){ for($i = ($paged - ceil($range/2)) + 1; $i < ($paged + ceil(($range/2))); $i++){ echo "
$i
"; } } } else{ for($i = 1; $i <= $max_page; $i++){ echo "
$i
"; } } next_posts_link('Next'); if($paged != $max_page){ echo "
Last
"; } } } function mypo_parse_query_useronly( $wp_query ) { if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) { if ( !current_user_can( 'manage_options' ) ) { global $current_user; $wp_query->set( 'author', $current_user->id ); } } } add_filter('parse_query', 'mypo_parse_query_useronly' ); // ad_img调用方案 function get_the_field($field_name,$post_id=-1){ if($post_id < 0){ //not id input global $eric_g_id; if($eric_g_id){ $post_id = $eric_g_id; }else{ global $wpdb; $res = $wpdb->get_row("SELECT ID FROM $wpdb->posts WHERE post_status='publish' and post_type='ad_img' ORDER BY post_date DESC LIMIT 0,1"); if(!$res) return false; $post_id = $res->ID; $eric_g_id = $post_id; } } the_field($field_name, $post_id); } function get_get_field($field_name,$post_id=-1){ if($post_id < 0){ //not id input global $eric_g_id; if($eric_g_id){ $post_id = $eric_g_id; }else{ global $wpdb; $res = $wpdb->get_row("SELECT ID FROM $wpdb->posts WHERE post_status='publish' and post_type='ad_img' ORDER BY post_date DESC LIMIT 0,1"); if(!$res) return false; $post_id = $res->ID; $eric_g_id = $post_id; } } return get_field($field_name, $post_id); } function id_reset(){ global $eric_g_id; $eric_g_id = null; } function keep_id_continuous(){ global $wpdb; // 删掉自动草稿和修订版 $wpdb->query("DELETE FROM `$wpdb->posts` WHERE `post_status` = 'auto-draft' OR `post_type` = 'revision'"); // 自增值小于现有最大ID,MySQL会自动设置正确的自增值 $wpdb->query("ALTER TABLE `$wpdb->posts` AUTO_INCREMENT = 1"); } add_filter( 'load-post-new.php', 'keep_id_continuous' ); add_filter( 'load-media-new.php', 'keep_id_continuous' ); add_filter( 'load-nav-menus.php', 'keep_id_continuous' ); function custom_excerpt_more($more) { return '...'; } add_filter('excerpt_more', 'custom_excerpt_more'); function custom_excerpt_length($length) { return 70; } add_filter('excerpt_length', 'custom_excerpt_length'); class zuluo_Catpost_Widget extends WP_Widget { function zuluo_Catpost_Widget() { $widget_ops = array('description' => '分类文章列表', 'description' => '分类文章列表'); $control_ops = array('width' => 200, 'height' => 300); parent::WP_Widget(false,$name='分类文章列表(zuluo)',$widget_ops,$control_ops); } function form($instance) { $catposts = isset($instance['catposts']) ? esc_attr($instance['catposts']) : '1'; $number = isset($instance['number']) ? absint($instance['number']) : 8; ?>
分类ID:
文章列表数目:
'; echo '
'. $title. '
'.'
'; ?>
$catid1, 'showposts' => $number, 'orderby' => 'date', 'order' => 'ASC', ) ); while ($popular->have_posts()) : $popular->the_post(); ?>
'; ?>
'; // 分隔符 $before = '
'; // 在当前链接前插入 $after = '
'; // 在当前链接后插入 if ( !is_home() && !is_front_page() || is_paged() ) { echo ''.__( '' , 'cmp' ); global $post; $homeLink = home_url(); echo '
' . __( 'Home' , 'cmp' ) . '
' . $delimiter . ' '; if ( is_category() ) { // 分类 存档 global $wp_query; $cat_obj = $wp_query->get_queried_object(); $thisCat = $cat_obj->term_id; $thisCat = get_category($thisCat); $parentCat = get_category($thisCat->parent); if ($thisCat->parent != 0){ $cat_code = get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '); echo $cat_code = str_replace ('
' . get_the_time('Y') . '
' . $delimiter . ' '; echo '
' . get_the_time('F') . '
' . $delimiter . ' '; echo $before . get_the_time('d') . $after; } elseif ( is_month() ) { // 月 存档 echo '
' . get_the_time('Y') . '
' . $delimiter . ' '; echo $before . get_the_time('F') . $after; } elseif ( is_year() ) { // 年 存档 echo $before . get_the_time('Y') . $after; } elseif ( is_single() && !is_attachment() ) { // 文章 if ( get_post_type() != 'post' ) { // 自定义文章类型 $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; echo '
' . $post_type->labels->singular_name . '
' . $delimiter . ' '; echo $before . get_the_title() . $after; } else { // 文章 post $cat = get_the_category(); $flg = 0; foreach($cat as $kk=>$vv){ $rrrr = get_category_children($vv->term_id); if(!$rrrr){ $cat_t = $cat[$kk]; $flg=1; } } if($flg == 0){ $cat = $cat[0]; }else{ $cat = $cat_t; } $cat_code = get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); $cat_code = substr($cat_code,0,strlen($cat_code)-5); echo $cat_code = str_replace ('
labels->singular_name . $after; } elseif ( is_attachment() ) { // 附件 $parent = get_post($post->post_parent); $cat = get_the_category($parent->ID); $cat = $cat[0]; echo '
' . $parent->post_title . '
' . $delimiter . ' '; echo $before . get_the_title() . $after; } elseif ( is_page() && !$post->post_parent ) { // 页面 echo $before . get_the_title() . $after; } elseif ( is_page() && $post->post_parent ) { // 父级页面 $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '
' . get_the_title($page->ID) . '
'; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } elseif ( is_search() ) { // 搜索结果 echo $before ; printf( __( 'Search Results for: %s', 'cmp' ), get_search_query() ); echo $after; } elseif ( is_tag() ) { //标签 存档 echo $before ; printf( __( 'Tag Archives: %s', 'cmp' ), single_tag_title( '', false ) ); echo $after; } elseif ( is_author() ) { // 作者存档 global $author; $userdata = get_userdata($author); echo $before ; printf( __( 'Author Archives: %s', 'cmp' ), $userdata->display_name ); echo $after; } elseif ( is_404() ) { // 404 页面 echo $before; _e( 'Not Found', 'cmp' ); echo $after; } echo ''; } } function af_titledespacer($title) { return trim($title); } add_filter('wp_title', 'af_titledespacer'); $keywords = substr($keywords,0,-2); class RRHE { // Register the column - Registered public static function registerdate($columns) { $columns['registerdate'] = __('注册时间', 'registerdate'); return $columns; } // Display the column content public static function registerdate_columns( $value, $column_name, $user_id ) { if ( 'registerdate' != $column_name ) return $value; $user = get_userdata( $user_id ); $registerdate = get_date_from_gmt($user->user_registered); return $registerdate; } public static function registerdate_column_sortable($columns) { $custom = array( // meta column id => sortby value used in query 'registerdate' => 'registered', ); return wp_parse_args($custom, $columns); } public static function registerdate_column_orderby( $vars ) { if ( isset( $vars['orderby'] ) && 'registerdate' == $vars['orderby'] ) { $vars = array_merge( $vars, array( 'meta_key' => 'registerdate', 'orderby' => 'meta_value' ) ); } return $vars; } } // Actions add_filter( 'manage_users_columns', array('RRHE','registerdate')); add_action( 'manage_users_custom_column', array('RRHE','registerdate_columns'), 15, 3); add_filter( 'manage_users_sortable_columns', array('RRHE','registerdate_column_sortable') ); add_filter( 'request', array('RRHE','registerdate_column_orderby') ); class zuluo_Catlist_Widget extends WP_Widget { function zuluo_Catlist_Widget() { $widget_ops = array('description' => '分类标题列表', 'description' => '分类标题列表'); $control_ops = array('width' => 200, 'height' => 300); parent::WP_Widget(false,$name='分类标题列表(zuluo)',$widget_ops,$control_ops); } function form($instance) { $catparent = isset($instance['catparent']) ? esc_attr($instance['catparent']) : '1'; ?>
父分类ID:
'; $titlestr .= '
'. $title; $titlestr .= '
'.'
'; $titlestr .= '
'; echo $titlestr; //$variable = wp_list_categories( array( wp_list_categories( array( 'child_of' => $catparent, 'orderby' => 'slug', 'order' => 'ASC', 'title_li' => '', 'hide_empty' => 0, 'depth' => 4, 'hierarchical' => true, 'current_category' => 0, 'show_option_none' =>'' //'echo' => 0 ) ); //echo preg_replace('/title=\"(.*?)\"/','',$variable); echo '
'; echo '
'; } } register_widget('zuluo_Catlist_Widget'); class zuluo_Cattree_Widget extends WP_Widget { function zuluo_Cattree_Widget() { $widget_ops = array('description' => '分类目录树', 'description' => '分类目录树'); $control_ops = array('width' => 200, 'height' => 300); parent::WP_Widget(false,$name='分类目录树(zuluo)',$widget_ops,$control_ops); } function form($instance) { $catparent = isset($instance['catparent']) ? esc_attr($instance['catparent']) : '1'; ?>
父分类ID:
'; $titlestr .= '
'. $title; $titlestr .= '
'.'
'; $titlestr .= '
'; echo $titlestr; //$variable = wp_list_categories( array( wp_list_categories( array( 'child_of' => $catparent, 'orderby' => 'slug', 'order' => 'ASC', 'title_li' => '', 'hide_empty' => 0, 'depth' => 4, 'hierarchical' => true, 'current_category' => 0, 'show_option_none' =>'' //'echo' => 0 ) ); //echo preg_replace('/title=\"(.*?)\"/','',$variable); echo '
'; echo ''; } } register_widget('zuluo_Cattree_Widget'); add_filter( 'manage_media_columns', 'wpdaxue_media_column' ); function wpdaxue_media_column( $columns ) { $columns["media_url"] = "URL"; return $columns; } add_action( 'manage_media_custom_column', 'wpdaxue_media_value', 10, 2 ); function wpdaxue_media_value( $column_name, $id ) { if ( $column_name == "media_url" ) echo '
'; } function wt_get_category_count($input = '') { global $wpdb; if($input == '') { $category = get_the_category(); return $category[0]->category_count; } elseif(is_numeric($input)) { $SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->term_taxonomy.term_id=$input"; return $wpdb->get_var($SQL); } else { $SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->terms.slug='$input'"; return $wpdb->get_var($SQL); } } function wt_get_category_count_g($input = '') { global $wpdb; if($input == '') { $category = get_the_category(); return $category[2]->category_count; } elseif(is_numeric($input)) { $SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->term_taxonomy.term_id=$input"; return $wpdb->get_var($SQL); } else { $SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->terms.slug='$input'"; return $wpdb->get_var($SQL); } } /** * 自动为文章标签添加该标签的链接 */ $match_num_from = 1; // 一个标签在文章中出现少于多少次不添加链接 $match_num_to = 2; // 一篇文章中同一个标签添加几次链接 add_filter('the_content','tag_link',1); //按长度排序 function tag_sort($a, $b){ if ( $a->name == $b->name ) return 0; return ( strlen($a->name) > strlen($b->name) ) ? -1 : 1; } //为符合条件的标签添加链接 function tag_link($content){ global $match_num_from,$match_num_to; $posttags = get_the_tags(); if ($posttags) { usort($posttags, "tag_sort"); foreach($posttags as $tag) { $link = get_tag_link($tag->term_id); $keyword = $tag->name; //链接的代码 $cleankeyword = stripslashes($keyword); $url = "
"; $limit = rand($match_num_from,$match_num_to); //不链接的代码 $content = preg_replace( '|(
]+>)(.*)('.$ex_word.')(.*)(
]*>)|U'.$case, '$1$2%&&&&&%$4$5', $content); $content = preg_replace( '|(
)|U'.$case, '$1$2%&&&&&%$4$5', $content); $cleankeyword = preg_quote($cleankeyword,'\''); $regEx = '\'(?!((<.*?)|(
]*?)>)|([^>]*?))\'s' . $case; $content = preg_replace($regEx,$url,$content,$limit); $content = str_replace( '%&&&&&%', stripslashes($ex_word), $content); } } return $content; } //-------------------------------------------------------------------------------------------分类/标签等存档页也能置顶文章 function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; $this_page = $_SERVER["REQUEST_URI"]; // 只取 ? 前面的内容 if (strpos($this_page, "?") !== false) $this_page = reset(explode("?", $this_page)); if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $this_page; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $this_page; } return $pageURL; } add_filter('the_posts', 'putStickyOnTop' ); function putStickyOnTop( $posts ) { if(is_home() || !is_main_query() || !is_archive()) return $posts; global $wp_query; $sticky_posts = get_option('sticky_posts'); if ( $wp_query->query_vars['paged'] <= 1 && is_array($sticky_posts) && !empty($sticky_posts) && !get_query_var('ignore_sticky_posts') ) { $stickies1 = get_posts( array( 'post__in' => $sticky_posts ) ); foreach ( $stickies1 as $sticky_post1 ) { if($wp_query->is_category == 1 && !has_category($wp_query->query_vars['cat'], $sticky_post1->ID)) { $offset1 = array_search($sticky_post1->ID, $sticky_posts); unset( $sticky_posts[$offset1] ); } if($wp_query->is_tag == 1 && has_tag($wp_query->query_vars['tag'], $sticky_post1->ID)) { $offset1 = array_search($sticky_post1->ID, $sticky_posts); unset( $sticky_posts[$offset1] ); } if($wp_query->is_year == 1 && date_i18n('Y', strtotime($sticky_post1->post_date))!=$wp_query->query['m']) { $offset1 = array_search($sticky_post1->ID, $sticky_posts); unset( $sticky_posts[$offset1] ); } if($wp_query->is_month == 1 && date_i18n('Ym', strtotime($sticky_post1->post_date))!=$wp_query->query['m']) { $offset1 = array_search($sticky_post1->ID, $sticky_posts); unset( $sticky_posts[$offset1] ); } if($wp_query->is_day == 1 && date_i18n('Ymd', strtotime($sticky_post1->post_date))!=$wp_query->query['m']) { $offset1 = array_search($sticky_post1->ID, $sticky_posts); unset( $sticky_posts[$offset1] ); } if($wp_query->is_author == 1 && $sticky_post1->post_author != $wp_query->query_vars['author']) { $offset1 = array_search($sticky_post1->ID, $sticky_posts); unset( $sticky_posts[$offset1] ); } } $num_posts = count($posts); $sticky_offset = 0; // Loop over posts and relocate stickies to the front. for ( $i = 0; $i < $num_posts; $i++ ) { if ( in_array($posts[$i]->ID, $sticky_posts) ) { $sticky_post = $posts[$i]; // Remove sticky from current position array_splice($posts, $i, 1); // Move to front, after other stickies array_splice($posts, $sticky_offset, 0, array($sticky_post)); // Increment the sticky offset. The next sticky will be placed at this offset. $sticky_offset++; // Remove post from sticky posts array $offset = array_search($sticky_post->ID, $sticky_posts); unset( $sticky_posts[$offset] ); } } // If any posts have been excluded specifically, Ignore those that are sticky. if ( !empty($sticky_posts) && !empty($wp_query->query_vars['post__not_in'] ) ) $sticky_posts = array_diff($sticky_posts, $wp_query->query_vars['post__not_in']); // Fetch sticky posts that weren't in the query results if ( !empty($sticky_posts) ) { $stickies = get_posts( array( 'post__in' => $sticky_posts, 'post_type' => $wp_query->query_vars['post_type'], 'post_status' => 'publish', 'nopaging' => true ) ); foreach ( $stickies as $sticky_post ) { array_splice( $posts, $sticky_offset, 0, array( $sticky_post ) ); $sticky_offset++; } } } return $posts; } add_filter( 'flash_uploader', 'disable_flash_uploader', 7 ); function izt_pagenavi($range = 5){ global $paged, $wp_query; if ( !$max_page ) {$max_page = $wp_query->max_num_pages;} if($max_page > 1){ echo ''; if(!$paged){$paged = 1;} if($paged != 1){echo "
<<
";} previous_posts_link(' < Previous '); if($max_page > $range){ if($paged < $range){for($i = 1; $i <= ($range + 1); $i++){echo "
$i
";}} elseif($paged >= ($max_page - ceil(($range/2)))){ for($i = $max_page - $range; $i <= $max_page; $i++){echo "
$i
";}} elseif($paged >= $range && $paged < ($max_page - ceil(($range/2)))){ for($i = ($paged - ceil($range/2)); $i <= ($paged + ceil(($range/2))); $i++){echo "
$i
";}}} else{for($i = 1; $i <= $max_page; $i++){echo "
$i
";}} next_posts_link(' Next > '); if($paged != $max_page){echo "
>>
Page ".$paged." / ".$max_page."
";}} } if ( !function_exists('fb_AddThumbColumn') && function_exists('add_theme_support') ) { // for post and page add_theme_support('post-thumbnails', array( 'post', 'page' ) ); function fb_AddThumbColumn($cols) { $cols['thumbnail'] = __('Thumbnail'); return $cols; } function fb_AddThumbValue($column_name, $post_id) { $width = (int) 50; if ( 'thumbnail' == $column_name ) { // thumbnail of WP 2.9 $thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true ); // image from gallery $attachments = get_children( array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image') ); if ($thumbnail_id) $thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true ); elseif ($attachments) { foreach ( $attachments as $attachment_id => $attachment ) { $thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true ); } } if ( isset($thumb) && $thumb ) { echo $thumb; } else { echo __('None'); } } } // for posts add_filter( 'manage_posts_columns', 'fb_AddThumbColumn' ); add_action( 'manage_posts_custom_column', 'fb_AddThumbValue', 10, 2 ); // for pages add_filter( 'manage_pages_columns', 'fb_AddThumbColumn' ); add_action( 'manage_pages_custom_column', 'fb_AddThumbValue', 10, 2 ); } // Return the total amount of items in the shopping cart function get_myeshop_cart_itemcount(){ global $blog_id; $total_items_in_cart = 0; if(isset($_SESSION['eshopcart'.$blog_id])) { $item_array = $_SESSION['eshopcart'.$blog_id]; foreach($item_array as $item) { $total_items_in_cart = $total_items_in_cart + $item['qty']; } } return $item_array; } function reset_password_message( $message, $key ) { if ( strpos($_POST['user_login'], '@') ) { $user_data = get_user_by('email', trim($_POST['user_login'])); } else { $login = trim($_POST['user_login']); $user_data = get_user_by('login', $login); } $user_login = $user_data->user_login; $msg = __('密码重设:'). "\r\n\r\n"; $msg .= network_site_url() . "\r\n\r\n"; $msg .= sprintf(__('用户名: %s'), $user_login) . "\r\n\r\n"; $msg .= __('若这不是您本人要求的,或不需要修改密码,请忽略本邮件,密码不变。') . "\r\n\r\n"; $msg .= __('要重置您的密码,请打开下面的链接:'). "\r\n\r\n"; $msg .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') ; return $msg; } add_filter('retrieve_password_message', reset_password_message, null, 2); function display_my_cart_items() { $item = ""; $cart_item_count = get_myeshop_cart_itemcount(); if ($cart_item_count >0){ $total = $sub_total=0; foreach($cart_item_count as $itm){ $item .='
'.$itm["pname"].'
Qty: '.$itm["qty"].'
'.get_currency_symbol().' '.get_currency_price($itm["price"]).'
'; $total = $total+$itm["qty"]; $sub_total = $sub_total+$itm["price"]; $sub_total = get_currency_price($sub_total); } $item .='
Total:
'.$total.'
Sub-Total : '.get_currency_symbol().' '.$sub_total.'
'; }else{ $item ='
You have no items in your Shopping Cart!
'; }; echo $item; } function display_my_cart_items_no() { $item = ""; $cart_item_count = get_myeshop_cart_itemcount(); if ($cart_item_count >0){ $total = $sub_total=0; foreach($cart_item_count as $itm){ $item .=''; $total = $total+$itm["qty"]; $sub_total = $sub_total+$itm["price"]; } $item .=$total; }else{ $item ='0'; }; echo $item; } function display_my_cart_items_price() { $item = ""; $cart_item_count = get_myeshop_cart_itemcount(); if ($cart_item_count >0){ $total = $sub_total=0; foreach($cart_item_count as $itm){ $item .=''; $total = $total+$itm["qty"]; $sub_total = $sub_total+$itm["price"]; } $item .=$sub_total; }else{ $item ='0.00'; }; echo $item; } function Reviews_num(){ global $wpdb; $id = get_post()->ID; //var_dump(the_ID()); echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments where comment_post_ID =".$id); } function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/
/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ $first_img = bloginfo('template_url'). '/images/default-thumb.jpg'; } return $first_img; } //end function make_get($arr){ if(!is_array($arr)){ return ''; } $str = '?'; $s = array(); foreach($arr as $a=>$v){ $s[] = $a.'='.$v; } $str .= implode('&',$s); return $str; } function attr($name,$value=''){ if($value){ update_option($name,$value); }else{ return get_option($name); } } add_action( 'init', 'create_colors_nonhierarchical_taxonomy', 0 ); function create_colors_nonhierarchical_taxonomy() { $str = dopt('d_description'); $arr = explode(',',$str); foreach($arr as $as){ $labels = array( 'name' => _x( $as, 'taxonomy general name' ), 'singular_name' => _x( $as, 'taxonomy singular name' ), 'search_items' => __( 'Search '.$as ), 'popular_items' => __( 'Popular '.$as ), 'all_items' => __( 'All '.$as ), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Edit '.$as ), 'update_item' => __( 'Update '.$as ), 'add_new_item' => __( 'Add New '.$as ), 'new_item_name' => __( 'New '.$as.' Name' ), 'separate_items_with_commas' => __( 'Separate '.$as.' with commas' ), 'add_or_remove_items' => __( 'Add or remove '.$as ), 'choose_from_most_used' => __( 'Choose from the most used '.$as ), 'menu_name' => __( $as ), ); register_taxonomy($as,'post',array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'update_count_callback' => '_update_post_term_count', 'query_var' => true, 'rewrite' => array( 'slug' => $as ), )); } } function ashu_add_cat_field(){ echo '
'; echo '
调用筛选
'; echo '
'; echo '
输入筛选项目名称,逗号分隔
'; echo '
'; } add_action('category_add_form_fields','ashu_add_cat_field', 10, 2); function ashu_edit_cat_field($tag){ echo '
调用筛选
输入筛选项目名称,逗号分隔
'; } add_action('category_edit_form_fields','ashu_edit_cat_field', 10, 2); add_action('created_category', 'ashu_taxonomy_metadata', 10, 1); add_action('edited_category','ashu_taxonomy_metadata', 10, 1); function ashu_taxonomy_metadata($term_id){ if(isset($_POST['xiaoxixi'])){ if(!current_user_can('manage_categories')){ return $term_id ; } $data = $_POST['xiaoxixi']; attr($term_id .'xiaoxixi', $data); } } function dopt($e){ return stripslashes(get_option($e)); } $dname = '过滤'; $themename = $dname.'设置'; $options = array( "d_description" ); function mytheme_add_admin() { global $themename, $options; if ( $_GET['page'] == basename(__FILE__) ) { if ( 'save' == $_REQUEST['action'] ) { foreach ($options as $value) { update_option( $value, $_REQUEST[ $value ] ); } header("Location: admin.php?page=functions.php&saved=true"); die; } } add_theme_page($themename." Options", $themename."设置", 'edit_themes', basename(__FILE__), 'mytheme_admin'); } function mytheme_admin() { global $themename, $options; $i=0; if ( $_REQUEST['saved'] ) echo '
'.$themename.'修改已保存
'; ?>
第一步
:输入筛选项目名称,逗号分隔;注:名称用全小写,空格用减号 - 代替;例如:price,color,size,sleeve-style
第二步
:保存后会显示每个筛选项目,点击下面的项目名称,添加每个筛选项目的具体参数:例如:点击Color,添加Red,Blue,Yellow.......
○ $v
"; }?>
第三步
:在需要显示筛选的
产品分类目录
下添加筛选项目名称;
EUR€"; }else if($currency=='CAD'){ $currency_name="Currency:
CAD$
"; }else if($currency=='GBP'){ $currency_name="Currency:
GBP£
"; }else if($currency=='AUD'){ $currency_name="Currency:
AUD$
"; }else if($currency=='HK'){ $currency_name="Currency:
HK$
"; }else if($currency=='JPY'){ $currency_name="Currency:
JPY円
"; }else if($currency=='RUB'){ $currency_name="Currency:
руб.
"; }else if($currency=='CHF'){ $currency_name="Currency:
CHF
"; }else if($currency=='CHF'){ $currency_name="Currency:
$MXN
"; }else if($currency=='NOK'){ $currency_name="Currency:
Kr
"; }else if($currency=='CZK'){ $currency_name="Currency:
Kč
"; }else if($currency=='BRL'){ $currency_name="Currency:
BRL$
"; }else if($currency=='ARS'){ $currency_name="Currency:
ARS$
"; }else{ $currency_name="Currency:
USD$
"; } return $currency_name; } function get_currency_price($price){ $currency_setting=get_option('currency_setting'); $currency=$_COOKIE['currency']; if($currency=='EUR'){ $currency_symbol_price=$price*$currency_setting['euro']; }else if($currency=='CAD'){ $currency_symbol_price=$price*$currency_setting['canadian']; }else if($currency=='GBP'){ $currency_symbol_price=$price*$currency_setting['british']; }else if($currency=='AUD'){ $currency_symbol_price=$price*$currency_setting['australian']; }else if($currency=='HK'){ $currency_symbol_price=$price*$currency_setting['HK']; }else if($currency=='JPY'){ $currency_symbol_price=$price*$currency_setting['JPY']; }else if($currency=='RUB'){ $currency_symbol_price=$price*$currency_setting['RUB']; }else if($currency=='CHF'){ $currency_symbol_price=$price*$currency_setting['CHF']; }else if($currency=='MXN'){ $currency_symbol_price=$price*$currency_setting['MXN']; }else if($currency=='NOK'){ $currency_symbol_price=$price*$currency_setting['NOK']; }else if($currency=='CZK'){ $currency_symbol_price=$price*$currency_setting['CZK']; }else if($currency=='BRL'){ $currency_symbol_price=$price*$currency_setting['BRL']; }else if($currency=='ARS'){ $currency_symbol_price=$price*$currency_setting['ARS']; }else{ $currency_symbol_price=$price*1; } return round($currency_symbol_price,2); } function custom_posts_per_page($query){ if($query->query['blog_catalog']!=''||$query->query['post_type']=='blog'){ $query->set('posts_per_page',8); } if($query->query['ps_catalog']!=''||$query->query['post_type']=='ps'){ $query->set('posts_per_page',36); } if($query->query['vs_catalog']!=''||$query->query['post_type']=='vs'){ $query->set('posts_per_page',36); } } // 排序 if (!function_exists('eshop_listorderColumn')) { function eshop_listorderColumn($cols) { $cols['listorder'] = __('排序'); return $cols; } function eshop_listorderValue($column_name, $post_id) { if ( 'listorder' == $column_name ) { $listorder = get_post_meta($post_id, '_listorder', true); if(!$listorder){ update_post_meta($post_id, "_listorder", $post_id); $listorder=$post_id; } echo '
'; } } } // for posts add_filter( 'manage_posts_columns', 'eshop_listorderColumn' ); add_action( 'manage_posts_custom_column', 'eshop_listorderValue', 10, 2 ); function edit_listorder() { global $current_user; $post_id = $_POST['post_id']; $listorder = $_POST['listorder']?intval($_POST['listorder']):0; update_post_meta($post_id, "_listorder", $listorder); exit(); } add_action('wp_ajax_edit_listorder', "edit_listorder"); if ( !function_exists( 'listorder_admin_head' ) ) { function listorder_admin_head() { ?> 0 ){ $thum_url = $images[0]['sizes']['thumbnail']; set_post_thumbnail($post_ID,$images[0]['id']); } } add_action( 'save_post', 'eric_updata_thumb', 10, 2 ); ?>