Function Reference 函数参考
函数参考目录:
- Post, Page, Attachment and Bookmarks Functions 文章,页面,附件和链接的函数 – Posts, Post insertion/removal
- Post, Page, Attachment and Bookmarks Functions 文章,页面,附件和链接的函数 – Pages, Custom field (postmeta)
- Post, Page, Attachment and Bookmarks Functions 文章,页面,附件和链接的函数 – Attachments, Bookmarks, Terms, Others
- Category, Tag and Taxonomy Functions 分类、标签和分类法函数 – Categories, Category Creation, Tags, Taxonomy
- User and Author Functions 用户和作者的函数 – Users and Authors, User meta, User insertion/removal, Login / Logout
- Feed Functions 订阅函数 – Feed
- Comment, Ping, and Trackback Functions 评论,广播和引用通告函数
- Action, Filter and Plugin Functions 动作,过滤器和插件函数 – Filter, Action, Plugin, Shortcode
- Theme-Related Functions 主题相关函数 – Include functions, Other functions
- Fommatting Functions 格式化函数
- Miscellaneous Functions 其他函数 – Time/Date Functions, Serialization, Options, XMLRPC
- Miscellaneous Functions 其他函数 – Localization, Cron (Scheduling), Miscellaneous
- Geo tags 地理标签
Functions by category 分类函数
1、Post, Page, Attachment and Bookmarks Functions 文章,页面,附件和链接的函数
-
get_adjacent_post <?php get_adjacent_post( $in_same_cat, $excluded_categories, $previous ) ?>
- 返回邻近的文章的信息数组,详情见: http://codex.wordpress.org/Function_Reference/get_adjacent_post. get_children <?php get_children( mixed $args = “”, constant $output = OBJECT); ?>
- 检索附件、版本、子页面等信息,一般情况下由父文章执行,详情见: http://codex.wordpress.org/Function_Reference/get_children. get_extended <?php get_extended( $post ) ?>
- 获取文章more标签分割的数组.$post是文章的内容 get_next_post <?php get_next_post( $in_same_cat, $excluded_categories ) ?>
- 获取下一篇邻近的文章信息. get_post <?php get_post( $id, $output ); ?>
- 返回单篇文章的信息数组或对象,$id是文章id,注意这里只能用变量,详情见: http://codex.wordpress.org/Function_Reference/get_post. get_post_ancestors <?php get_post_ancestors( $post ) ?>
- 返回基于文章ID的父文章的信息数组. get_post_mime_type <?php get_post_mime_type( $ID ) ?>
- 返回基于附件ID的方式类型信息. get_post_status <?php get_post_status( $ID ) ?>
- 返回基于文章ID的文章状态. get_post_type <?php get_post_type( $post ) ?>
- 返回基于文章ID的文章类型. get_previous_post <?php get_previous_post( $in_same_cat, $excluded_categories ) ?>
- 返回上一篇邻近的文章信息. get_posts <?php get_posts(‘arguments’); ?>
- 获取一系列文章的集合,详情见: http://codex.wordpress.org/Template_Tags/get_posts. is_post <?php is_post(); ?>
- 已弃用. is_single <?php is_single($post); ?>
- 判断是否规定的单篇日志. is_sticky <?php is_sticky($post_ID); ?>
- 判断文章是否置顶. register_post_type <?php register_post_type( $post_type, $args ) ?>
- 注册发布类型,详情见: http://codex.wordpress.org/Function_Reference/register_post_type. wp_get_recent_posts <?php wp_get_recent_posts( $num ) ?>
- 返回最近发布的文章数组. wp_get_single_post <?php wp_get_single_post( $postid, $mode ) ?>
- 返回单篇文章的的数组或对象,同get_post().
-
wp_delete_post <?php wp_delete_post( $postid, $force_delete = false ) ?>
- 删除文章、页面或附件,$force_delete为true时不经过回收站. wp_insert_post <?php wp_insert_post( $post ); ?>
- 发表一片文章或页面,详情见: http://codex.wordpress.org/Function_Reference/wp_insert_post. wp_publish_post <?php wp_publish_post( $post_id ) ?>
- 通过更改文章状态来发表文章 wp_update_post <?php wp_update_post( $post ); ?>
- 更新一篇文章,详情见: http://codex.wordpress.org/Function_Reference/wp_update_post.
-
get_all_page_ids <?php print_r( get_all_page_ids() ) ?>
- 返回所有页面的数组. get_page <?php get_page( $page_id ) ?>
- 返回一个页面的对象或数组,详情见: http://codex.wordpress.org/Function_Reference/get_page. get_page_link <?php get_page_link($id, $leavename, $sample); ?>
- 获取页面的链接,$id是页面ID,$leavename 判断是否允许使用页面名, $sample 判断是否示例链接 get_page_by_path <?php get_page_by_path( $page_path, $output ) ?>
- 获取一篇基于地址的页面对象或数组,$page_path是页面地址,$output指定输出类型是否对象或数组,默认是对象. get_page_by_title <?php get_page_by_title( $page_title, $output, $post_type ) ?>
- 获取一篇基于标题的页面对象或数组,$page_title是页面标题, $output 是输出类型,默认对象, $post_type 是文章类型,默认page. get_page_children <?php get_page_children( $page_id, $pages ) ?>
- 在编号相匹配的页面列表中检索子页面,$page_id是父页面的ID,$pages是被检索的页面数组. get_page_hierarchy <?php get_page_hierarchy( $posts, $parent ) ?>
- 返回一个数组,该数组按页面排序次序进行排序,$posts是页面的集合,$parent 是父ID. get_page_uri <?php get_page_uri( $page_id ) ?>
- 获取指定Id的页面uri. get_pages <?php get_pages(‘arguments’); ?>
- 获取页面的集合,详情见: http://codex.wordpress.org/Function_Reference/get_pages. is_page <?php is_page($page); ?>
- 判断是否当前或指定的页面. page_uri_index <?php page_uri_index() ?>
- 为页面URI检索所有页面与附件。检索以页面为父级的文章的附件。 wp_list_pages <?php wp_list_pages( $args ); ?>
- 输出页面的列表,$args 详情见: http://codex.wordpress.org/Template_Tags/wp_list_pages.
-
add_post_meta <?php add_post_meta($post_id, $meta_key, $meta_value, $unique); ?>
- 为指定文章添加自定义(meta)字段, 详情见: http://codex.wordpress.org/Function_Reference/add_post_meta. delete_post_meta <?php delete_post_meta($post_id, $key, $value); ?>
- 从指定文章中删除含有指定关键字的所有自定义字段,详情见: http://codex.wordpress.org/Function_Reference/delete_post_meta. get_post_custom <?php get_post_custom($post_id); ?>
- 返回指定文章的自定义字段. get_post_custom_keys <?php get_post_custom_keys($post_id); ?>
- 获取指定文章的自定义字段名. get_post_custom_values <?php get_post_custom_values($key, $post_id); ?>
- 获取指定文章的自定义字段名的值. get_post_meta <?php $meta_values = get_post_meta($post_id, $key, $single); ?>
- 返回指定文章中含有指定关键字自定义字段的值,详情见: http://codex.wordpress.org/Function_Reference/get_post_meta. update_post_meta <?php update_post_meta($post_id, $meta_key, $meta_value, $prev_value); ?>
- 为指定文章更新自定义(meta)字段.
-
get_attached_file <?php get_attached_file( $attachment_id, $unfiltered ); ?>
- 获取一个附件的地址.$attachment_id 是附件的ID, $unfiltered 判断是否使用过滤器. is_attachment <?php is_attachment(); ?>
- 判断附件是否被显示. is_local_attachment <?php is_local_attachment( $url ) ?>
- 判断url地址是否为本地的附件. update_attached_file <?php update_attached_file( $attachment_id, $file ) ?>
- 更新一个附件. $file是附件地址 wp_attachment_is_image <?php wp_attachment_is_image( $post_id ); ?>
- 判断指定的附件是否为图片. wp_insert_attachment <?php wp_insert_attachment( $attachment, $filename, $parent_post_id ); ?>
- 为指定的页面插入一个附件,详情见: http://codex.wordpress.org/Function_Reference/wp_insert_attachment. wp_delete_attachment <?php wp_delete_attachment( $postid, $force_delete = false ); ?>
- 删除指定的附件,$postid是附件ID,$force_delete为true时不经过回收站. wp_get_attachment_image <?php (string) $img = wp_get_attachment_image($attachment_id, $size=’thumbnail’, $icon = false); ?>
- 返回一个附件的html,$attachment_id是附件ID,$size是(thumbnail, medium, large or full),$icon是替代的图标地址. wp_get_attachment_image_src <?php $image = wp_get_attachment_image_src( $attachment_id, $size=’thumbnail’, $icon = false ); ?>
- 返回一个附件的src,$attachment_id是附件ID,$size是(thumbnail, medium, large or full),$icon 是替代的图标地址. wp_get_attachment_metadata <?php wp_get_attachment_metadata( $post_id, $unfiltered ) ?>
- 返回一个附件的元数据,$post_id是附件ID,$unfiltered判断是否使用过滤器. wp_get_attachment_thumb_file <?php wp_get_attachment_thumb_file( $post_id ) ?>
- 获取附件的缩略图地址. wp_get_attachment_thumb_url <?php wp_get_attachment_thumb_url( $post_id ) ?>
- 获取附件缩略图地址. wp_get_attachment_url <?php echo wp_get_attachment_url($post_id); ?>
- 获取附件的url. wp_check_for_changed_slugs <?php wp_check_for_changed_slugs( $post_id ) ?>
- 检查已发表文章中经改动的缩略名并保存原有缩略名. wp_count_posts <?php wp_count_posts(‘type’, ‘readable’); ?>
- 输出文章的统计数组,type为文章类型,’readable’是可读性. wp_mime_type_icon <?php wp_mime_type_icon( $mime ) ?>
- 检索MIME类型的图标. wp_update_attachment_metadata <?php wp_update_attachment_metadata( $post_id, $data ) ?>
- 更新指定附件的MIME类型.
-
get_bookmark <?php get_bookmark( $bookmark, $output=’OBJECT‘, $filter ) ?>
- 获取一个链接的数组. $bookmark是书签ID, $output是输出方式(OBJECT, ARRAY_N, or ARRAY_A). get_bookmarks <?php get_bookmarks( $args ); ?>
- 返回书签的数组. $args详情见: http://codex.wordpress.org/Function_Reference/get_bookmarks. wp_list_bookmarks <?php wp_list_bookmarks( $args ); ?>
- 输出书签的数组. $args详情见: http://codex.wordpress.org/Template_Tags/wp_list_bookmarks.
- 相关废弃标签: get_links_list() 和 get_links().
-
wp_get_post_categories <?php wp_get_post_categories( $post_id, $args ) ?>
- 返回文章的类型ID数组. wp_set_post_categories <?php wp_set_post_categories( $post_ID, $post_categories ) ?>
- 设置文章分类ID. wp_get_post_tags <?php wp_get_post_tags( $post_id, $args ) ?>
- 获取文章的标签ID. wp_set_post_tags <?php wp_set_post_tags( $post_ID, $tags, $append ) ?>
- 设置文章的标签,$tags是要添加的标签字符串数组,$append默认为 false覆盖已有标签,true为添加. wp_get_post_terms <?php wp_get_post_terms( $post_id = 0, $taxonomy = ‘post_tag’, $args = array() ) ?>
- 获取文章的分类法数组, 默认是’post_tag’. wp_set_post_terms <?php wp_set_post_terms( $post_ID, $tags, $taxonomy, $append ) ?>
- 设置文章的分类法,$tags是要添加的标签字符串数组,$taxonomy是分类方法,默认’post_tag’,$append默认为 false覆盖已有标签,true为添加.
-
add_meta_box <?php add_meta_box( $id, $title, $callback, $page, $context, $priority ); ?>
- 插件开发者可通过该函数在Write Post,Write Page和Write Link编辑页面内添加版块.详情见: http://codex.wordpress.org/Function_Reference/add_meta_box. get_the_ID <?php echo get_the_ID(); ?>
- 返回当前文章的ID. get_the_author <?php $author = get_the_author(); ?>
- 获取文章的标签ID. get_the_content <?php get_the_content( $more_link_text, $stripteaser, $more_file ) ?>
- 获取文章的内容,$more_link_text 是更多的链接文字, $stripteaser 在更多内容前显示内容摘要, $more_file 可选,不使用. wp_trim_excerpt <?php wp_trim_excerpt( $text ) ?>
- 必要时为文章生成内容摘要. 摘要应在55字以内,如果总字数多于该数目,摘要结尾应添加字符串’[...]‘。如果少于55个字符,显示摘要全文。
2、Category, Tag and Taxonomy Functions 分类、标签和分类法函数
-
cat_is_ancestor_of <?php cat_is_ancestor_of( $cat1, $cat2 ); ?>
- 判断$cat1是否为$cat2的祖先分类. get_all_category_ids <?php get_all_category_ids() ?>
- 返回所有分类的数组. get_cat_ID <?php get_cat_ID( $cat_name ) ?>
- 根据分类名获取其ID. get_cat_name <?php get_cat_name( $cat_id ) ?>
- 分居分类ID获取其名称. get_categories <?php $categories = get_categories( $args ); ?>
- 返回多个分类的数组. $args详情见: http://codex.wordpress.org/Function_Reference/get_categories. get_category <?php get_category( $category, $output, $filter ) ?>
- 返回单个分类的详细信息对象或数组。 get_category_by_path <?php get_category_by_path( $category_path, $full_match, $output ) ?>
- 根据地址获取分类的详细信息对象或数组。 get_category_by_slug <?php get_category_by_slug( $slug ) ?>
- 根据别名获取分类的详细信息对象或数组。 get_category_link <?php get_category_link( $category_id ); ?>
- 根据分类ID获取分类的链接。 get_category_parents <?php echo get_category_parents(category, display link, separator, nice name); ?>
- 根据分类的ID获取父分类。 get_the_category <?php get_the_category(); ?>
- 返回所有分类的详细信息数组。 in_category <?php in_category( $category, $_post ) ?>
- 判断文章是否属于某分类. is_category <?php is_category($category); ?>
- 判断当前页是否指定的分类 wp_list_categories <?php wp_list_categories( $args ); ?>
- 输出分类的列表,详情见模板标签: http://codex.wordpress.org/Template_Tags/wp_list_categories.
-
wp_create_category <?php wp_create_category( $cat_name, $parent ); ?>
- 创建分类. wp_delete_category <?php wp_delete_category( $cat_ID ) ?>
- 删除分类. wp_insert_category <?php wp_insert_category( $catarr, $wp_error ); ?>
- 插入一个新分类到分类系统.
-
get_tag <?php get_tag( $tag, $output, $filter ) ?>
- 获取标签的对象或数组. get_tag_link <?php echo get_tag_link($tag_id); ?>
- 获取标签的链接. get_tags <?php $tag_list = get_tags($args); ?>
- 获取标签的数组.$args详情见: http://codex.wordpress.org/Function_Reference/get_tags. get_the_tag_list <?php $tag_list = get_the_tag_list( $before = ‘before’, $sep = ‘seperator’, $after = ‘after’ ) ?>
- 获取分类的列表. get_the_tags <?php $tag_list = get_the_tags(); ?>
- 获取所有标签的数组. is_tag <?php is_tag($slug); ?>
- 判断是否标签.
-
wp_create_category <?php wp_create_category( $cat_name, $parent ); ?>
- 创建分类. wp_delete_category <?php wp_delete_category( $cat_ID ) ?>
- 删除分类. wp_insert_category <?php wp_insert_category( $catarr, $wp_error ); ?>
- 插入一个新分类到分类系统.
-
get_term <?php get_term( $term, $taxonomy, $output, $filter ) ?>
- 获取分类法 , $term是分类法ID, $taxonomy是分类方法,默认’post_tag’, $output 是输出类型(OBJECT, ARRAY_A, or ARRAY_N), $filter是过滤器, 默认’raw’. get_the_term_list <?php get_the_term_list( $id = 0, $taxonomy, $before = , $sep = , $after = ) ?>
- 返回分类法的列表.$id是文章ID, $taxonomy是分类方法, $before是前缀 , $sep是分隔符 , $after是后缀. get_term_by <?php get_term_by( $field, $value, $taxonomy, $output, $filter ) ?>
- 分居别名,名称或ID来获取分类,详情见: http://codex.wordpress.org/Function_Reference/get_term_by. get_term_children <?php get_term_children( $term, $taxonomy ) ?>
- 获取子分类法. get_terms <?php get_terms( $taxonomies, $args ) ?>
- 获取所有分类法的数组.详情见: http://codex.wordpress.org/Function_Reference/get_terms. is_taxonomy <?php is_taxonomy($taxonomy); ?>
- 判断是否分类法. is_taxonomy_hierarchical <?php is_taxonomy_hierarchical( $taxonomy ) ?>
- 判断是否分级的分类法. is_term <?php is_term( $term, $taxonomy ) ?>
- 检查term是否存在. register_taxonomy <?php register_taxonomy($taxonomy, $object_type, $args); ?>
- 注册分类法. 详情见: http://codex.wordpress.org/Function_Reference/register_taxonomy. register_taxonomy_for_object_type <?php register_taxonomy_for_object_type($taxonomy, $object_type); ?>
- 为对象类型注册分类法,详情见: http://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type. (3.0函数) wp_get_object_terms <?php wp_get_object_terms( $object_ids, $taxonomies, $args ) ?>
- 获取对象的分类法. wp_insert_term <?php wp_insert_term( $term, $taxonomy, $args = array() ); ?>
- 插入分类法,详情见: http://codex.wordpress.org/Function_Reference/wp_insert_term. wp_update_term <?php wp_update_term( $term_id, $taxonomy, $args ) ?>
- 更新分类法,详情见: http://codex.wordpress.org/Function_Reference/wp_update_term. wp_delete_term <?php wp_delete_term( $term_id, $taxonomy, $args ) ?>
- 删除分类法,详情见: http://codex.wordpress.org/Function_Reference/wp_delete_term.
3、User and Author Functions 用户和作者的函数
-
auth_redirect <?php auth_redirect() ?>
- 是一个简单函数,要求用户访问页面前登录. count_users <?php count_users( $strategy ); ?>
- 返回用户的角色总数. (3.0 函数) count_user_posts <?php count_user_posts( $userid ); ?>
- 返回指定用户的文章数. (3.0 函数) count_many_users_posts <?php count_many_users_posts( $users ); ?>
- 返回多个用户的文章总数. (3.0 函数) get_currentuserinfo <?php get_currentuserinfo(); ?>
- 获取当前用户信息.详情见: http://codex.wordpress.org/Function_Reference/get_currentuserinfo. get_profile <?php get_profile( $field, $user ); ?>
- 获取个人信息, $field是字段名,$user是登录名. get_userdata <?php get_userdata(userid); ?>
- 获取指定ID的用户对象。 get_userdatabylogin <?php get_userdatabylogin( $user_login ) ?
- 获取指定登录名的用户对象. get_usernumposts <?php get_usernumposts(userid); ?>
- 获取指定用户发飙的文章数. set_current_user <?php set_current_user( $id, $name ) ?>
- 改变目前用户的编号或名称。在用户编号未知的情况下可以将$id设为0并指定一个名称。 user_pass_ok <?php user_pass_ok( $user_login, $user_pass ) ?>
- 判断用户名密码是否正确 username_exists <?php username_exists($username); ?>
- 判断用户名是否存在. (3.0 函数) validate_username <?php validate_username( $username ) ?>
- 判断用户名是否有效. (3.0 函数?) wp_get_current_user <?php wp_get_current_user(); ?>
- 获取当前用户的详细资料方法2. 可以对非登录用户进行编辑或执行动作, 详情见: http://codex.wordpress.org/Function_Reference/wp_get_current_user. wp_set_current_user <?php wp_set_current_user( $id, $name ) ?>
- 改变目前用户的编号或名称。在用户编号未知的情况下可以将$id设为0并指定一个名称. 可以对非登录用户进行编辑或执行动作.
-
delete_user_meta <?php delete_user_meta( $user_id, $meta_key, $meta_value ) ?>
- 删除用户元数据. (3.0 函数) get_user_meta <?php get_user_meta($user_id, $key, $single) ?>
- 返回用户的元数据. (3.0 函数) update_user_meta <?php update_user_meta( $user_id, $meta_key, $meta_value, $prev_value ) ?>
- 更新用户原数据. (3.0 函数)
-
wp_create_user <?php wp_create_user( $username, $password, $email ); ?>
- 创建新用户. wp_delete_user <?php wp_delete_user( $id, $reassign ) ?>
- 删除用户. wp_insert_user <?php wp_insert_user( $userdata ) ?>
- 插入用户. wp_update_user <?php wp_update_user( $userdata ) ?>
- 更新用户资料.
-
delete_user_meta <?php delete_user_meta( $user_id, $meta_key, $meta_value ) ?>
- 删除用户元数据. (3.0 函数) get_user_meta <?php get_user_meta($user_id, $key, $single) ?>
- 返回用户的元数据. (3.0 函数) update_user_meta <?php update_user_meta( $user_id, $meta_key, $meta_value, $prev_value ) ?>
- 更新用户原数据. (3.0 函数)
-
is_user_logged_in <?php if ( is_user_logged_in() ) { … } ?>
- 判断用户是否登录. wp_signon <?php wp_signon( $credentials, $secure_cookie ) ?>
- 用户登录, 详情见: http://codex.wordpress.org/Function_Reference/wp_signon. wp_logout <?php wp_logout(); ?>
- 用户登出.
4、Feed Functions 订阅函数
-
bloginfo_rss <?php bloginfo_rss( $show ) ?>
- 输出bloginfo函数的RSS容器。$show的有效值见: http://codex.wordpress.org/Function_Reference/get_bloginfo. comment_author_rss <?php comment_author_rss() ?>
- 在订阅中显示当前评论的作者. comment_link <?php comment_link() ?>
- 显示评论的链接. comment_text_rss <?php comment_text_rss() ?>
- 在订阅中显示评论的内容. do_feed <?php do_feed() ?>
- 使用action钩子(hook)装载feed模板。如果feed action没有钩子,函数会发布信息通知访问者feed不可用,之后函数消失。 do_feed_atom <?php do_feed_atom( $for_comments ) ?>
- 装载 Atom通用feed或 Atom文章feed。$for_comments(布尔值)(必需)使用通用feed时为true,标准feed时为false。 do_feed_rdf <?php do_feed_rdf() ?>
- 装载RDF RSS 0.91版本feed模板。 do_feed_rss <?php do_feed_rss() ?>
- 装载RDF RSS 1.0版本feed模板. do_feed_rss2 <?php do_feed_rss2( $for_comments ) ?>
- 装载RSS2通用feed或RSS2文章feed。$for_comments(布尔值)(必需)使用通用feed时为true,标准feed时为false。 fetch_rss <?php fetch_rss($uri); ?>
- 检索某个RSS订阅并进行解析。用 MagpieRSS and RSSCache进行解析并自动缓存,用 Snoopy HTTP 客户端进行实际检索. 已弃用. get_author_feed_link <?php get_author_feed_link( $author_id, $feed ) ?>
- 检索所给定作者的feed链接。$author_id(整数)(必需)作者编号, $feed是Feed类型. get_bloginfo_rss <?php get_bloginfo_rss( $show ) ?>
- bloginfo函数的RSS集装箱。可以用 get_bloginfo()函数检索任何想要检索的信息。当函数值在 feed中被检索以供使用时,所有值的标签都将被除去,字符也将被转换。$show 详情见: http://codex.wordpress.org/Function_Reference/get_bloginfo_rss。 get_category_feed_link <?php get_category_feed_link( $cat_id, $feed ); ?>
- 返回指定类别中所有文章的feed链接。可请求特别feed,但为空时,函数返回’rss2′feed链接。该函数取代了已经弃用的 get_category_rss_link函数。$feed 是’rss2′或’atom’ get_comment_link <?php get_comment_link( $comment, $args ) ?>
- 获取评论的链接. get_comment_author_rss <?php get_comment_author_rss() ?>
- 输出当前评论的作者. get_post_comments_feed_link <?php get_post_comments_feed_link( $post_id, $feed ) ?>
- 输出文章的评论feed链接。链接内容放置在锚(anchor)中。未指定链接文本时使用默认内容。未指定文章编号时使用当前文章。. get_rss <?php get_rss($uri, $num = 5) ?>
- 检索一个RSS feed并进行解析,并将其作为链接列表显示。 已弃用. get_search_comments_feed_link <?php get_search_comments_feed_link( $search_query, $feed ) ?>
- 在搜索结果中检索评论feed的永久链接.$searcu_query是URL搜索查询. get_search_feed_link <?php get_search_feed_link( $search_query, $feed ) ?>
- 在搜索结果中检索feed的永久链接.$searcu_query是URL搜索查询. get_the_category_rss <?php get_the_category_rss( $type ) ?>
- 检索所有文章类别,并格式化以便在feed中使用。$type默认值为’rss’。也可以是 ‘atom’ 或 ‘rdf’。 get_the_title_rss <?php get_the_title_rss() ?>
- 为feed检索当前文章的标题. permalink_single_rss <?php permalink_single_rss( $file ); ?>
- 按 RSS 或Atom 聚合feed形式显示当前文章的永久链接。该标签须在 The Loop 内使用。$file是链接所指向的页面。默认为当前页面。 post_comments_feed_link <?php post_comments_feed_link( $link_text = ‘link_text’, $post_id = ‘post_id’, $feed = ‘feed_type’ ) ?>
- 输出文章的评论feed链接。链接内容放置在锚(anchor)中。未指定链接文本时使用默认内容。未指定文章编号时使用当前文章.$link_text 是描述性内容,$post_id是文章编号,$feed是feed类别。有效值包括:atom,rdf,rss,rss2(默认值)。 rss_enclosure <?php rss_enclosure() ?>
- 显示当前文章的rss enclosure。 the_title_rss <?php the_title_rss() ?>
- 在feed中显示文章标题. the_category_rss <?php the_category_rss( $type ) ?>
- 在feed中显示文章类别.$type默认值为’rss’。也可以是’rss’, ‘atom’, 或 ‘rdf’。 the_content_rss <?php the_content_rss( $more_link_text, $stripteaser, $more_file, $cut, $encode_html ) ?>
- 为feed显示文章内容。$more_link_text是当有更多内容但无法显示时,该参数显示剩余内容,$stripteaser默认为0,$more_file,$cut 是可显示的内容总字数,$encode_html是如何对内容进行编码,默认值:0。 the_excerpt_rss <?php the_excerpt_rss() ?>
- 为feed显示文章摘要. wp_rss <?php wp_rss($uri, $num); ?>
- 检索一个RSS feed并进行解析,并将其作为无秩序的链接列表显示。 已弃用.
5、Comment, Ping, and Trackback Functions 评论,广播和引用通告函数
-
add_ping <?php add_ping( $post_id, $uri ) ?>
- 为已有ping添加URL.$post_id是文章编号,$uri是Ping URI. check_comment <?php check_comment( $author, $email, $url, $comment, $user_ip, $user_agent, $comment_type ) ?>
- 判断评论是否传递WordPress Comment_Moderation 的内部检验。详情见: http://codex.wordpress.org/Function_Reference/check_comment. discover_pingback_server_uri <?php discover_pingback_server_uri( $url, $deprecated ) ?>
- 根据已给URL查找pingback的服务器URI.详情见: http://codex.wordpress.org/Function_Reference/discover_pingback_server_uri. do_all_pings <?php do_all_pings() ?>
- 该函数执行所有pingback、enclosure、trackback,并将其发送到pingback服务中。 do_enclose <?php do_enclose( $content, $post_ID ) ?>
- 检查视频音频链接的内容,将内容作为 enclosures加入。已经添加的enclosure将不再重新加入。 do_trackbacks <?php do_trackbacks( $post_id ) ?>
- 执行引用通告。 generic_ping <?php generic_ping( $post_id ) ?>
- 将 pings 发送给所有ping网站服务。 get_approved_comments <?php $comment_array = get_approved_comments($post_id); ?>
- 获取文章编号并返回一个对象数组,表示已经被提交并批准的评论。 get_avatar <?php echo get_avatar( $id_or_email, $size, $default, $alt ); ?>
- 获取头像。 get_comment <?php get_comment($id, $output); ?>
- 获取单个评论的对象或数组。 get_comments <?php get_comments( $args ); ?>
- 获取评论的对象或数组,$args详情见: http://codex.wordpress.org/Function_Reference/get_comments. get_enclosed <?php get_enclosed( $post_id ) ?>
- 获取文章中已有的附件。 get_lastcommentmodified <?php get_lastcommentmodified( $timezone ) ?>
- 获取最近一次评论修改日期。 get_pung <?php get_pung( $post_id ) ?>
- 检索文章中被引用的URL. get_to_ping <?php get_to_ping( $post_id ) ?>
- 检索需要被引用的URL. next_comments_link <?php next_comments_link( $label, $max_page ) ?>
- 输出下一页评论的链接. paginate_comments_links <?php paginate_comments_links( $args ); ?>
- 该标签使评论模板中的分页评论有新的排列方法。相较于使用“上一页”和“下一页”评论链接,该标签可利用数值型索引显示完整的评论页.详情见: http://codex.wordpress.org/Function_Reference/paginate_comments_links。 pingback <?php pingback( $content, $post_ID ) ?>
- 广播文章中的链接. previous_comments_link <?php previous_comments_link( $label ) ?>
- 输出上一页评论的链接. privacy_ping_filter <?php privacy_ping_filter( $sites ) ?>
- 检查博客在返回到站点前是否为公开状态。 sanitize_comment_cookies <?php sanitize_comment_cookies() ?>
- 审查发送给用户的cookies,若已经为用户生成cookies,可以进行其他操作。cookies被发送到其他地方之后,可以使用该函数。. is_trackback <?php is_trackback(); ?>
- 判断是否为引用通告。 trackback <?php trackback( $trackback_url, $title, $excerpt, $ID ) ?>
- 发送一个trackback。该函数在发送trackback以避免复制时更新数据库。 trackback_url <?php trackback_url(); ?>
- 显示引用通告的链接。 trackback_url_list <?php trackback_url_list( $tb_list, $post_id ) ?>
- 为URL列表操作 trackbacks. weblog_ping <?php weblog_ping( $server, $path ) ?>
- 为URL列表操作 trackbacks。 wp_allow_comment <?php wp_allow_comment( $commentdata ) ?>
- 验证是否可以发布当前评论。 wp_delete_comment <?php wp_delete_comment( $comment_id ) ?>
- 删除评论编号,之后可能更新文章评论总数。 wp_filter_comment <?php wp_filter_comment( $commentdata ) ?>
- 过滤审查评论资料。完成后将评论资料’filtered’字段设为true。这一动作可判断评论是否应被过滤,以及是否应该阻止同一评论被多次过滤。 wp_get_comment_status <?php wp_get_comment_status( $comment_id ) ?>
- 获取一个评论的状态。 wp_get_current_commenter <?php wp_get_current_commenter() ?>
- 获取当前评论者的姓名、电子邮件和URL。希望cookies内容已经被过滤。该函数的使用者可能希望重新检查返回的数组。 wp_insert_comment <?php wp_insert_comment($data); ?>
- 插入评论,详情见: http://codex.wordpress.org/Function_Reference/wp_insert_comment . wp_new_comment <?php wp_new_comment( $commentdata ) ?>
- 在数据库中添加新评论。 wp_set_comment_status <?php wp_set_comment_status( $comment_id, $comment_status ) ?>
- 设置评论的状态。 wp_throttle_comment_flood <?php wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) ?>
- 评论数量异常增多时,该函数决定是否禁止评论.详情见: http://codex.wordpress.org/Function_Reference/wp_throttle_comment_flood。 wp_update_comment <?php wp_update_comment( $commentarr ) ?>
- 更新一个评论。 wp_update_comment_count <?php wp_update_comment_count( $post_id, $do_deferred ) ?>
- 更新文章的评论计数。
6、Action, Filter and Plugin Functions 动作,过滤器和插件函数
-
has_filters <?php has_filters( $tag, $function_to_check ); ?>
- 检测如果某些过滤器已经为一个钩子注册.$tag 是过滤器钩子的名称. $function_to_check 是指定的程序. add_filter <?php add_filter( $tag, $function_to_add, $priority, $accepted_args ); ?>
- 为一个指定的过滤器动作挂钩一个程序.$tag 是过滤器名称, $function_to_add 是希望调用的函数名称,$priority是函数的重要程度。改变此参数以决定函数与其他函数的调用顺序。默认值:10,$accepted_args是 函数所接受参数的数量。默认值:1。 apply_filters <?php apply_filters( $tag, $value ); ?>
- 呼叫一个函数添加到过滤器钩子,参见插件接口的过滤器 钩子列表.$tag是过滤器钩子的名称,$value 是过滤器可能修改的值。 current_filter <?php current_filter() ?>
- 获取当前的过滤器或动作。 merge_filters <?php merge_filters($tag); ?>
- 融合一个特殊的过滤器钩子程序到一个普通过滤器函数。$tag是要融合的过滤器函数名称。 remove_filter <?php remove_filter( $tag, $function_to_remove, $priority, $accepted_args ); ?>
- 移除过滤器函数。$tag是将要被删除的函数所连接到的动作hook,$function_to_remove 是将要被删除函数的名称,$priority是函数优先级(在函数最初连接时定义)默认值:10,$accepted_args是函数所接受参数的数量。 默认值:1。 remove_all_filters <?php remove_all_filters( $tag, $priority ) ?>
- 移除所有指定钩子的过滤器。$tag是钩子的名称,$priority是优先级。
-
has_action <?php has_action( $tag, $function_to_check ) ?>
- 检测如果某些动作已经为一个钩子注册.$tag 是动作的名称. $function_to_check 是指定的程序. add_action <?php add_action( $tag, $function_to_add, $priority, $accepted_args ); ?>
- 为一个指定的动作挂钩一个程序.$tag 是动作名称, $function_to_add 是希望调用的函数名称,$priority函数的重要程度。改变此参数以决定函数与其他函数的调用顺序。默认值:10,$accepted_args是函 数所接受参数的数量。默认值:1。 do_action <?php do_action( $tag, $arg ); ?>
- 呼叫一个函数添加到过滤器钩子,参见插件接口的过滤器 钩子列表.$tag是希望创建的钩子名称,$arg是该钩子允许的参数列表。 do_action_ref_array <?php do_action_ref_array( $tag, $arg ); ?>
- 执行指定钩子上的函数,在数组中指定参数。$tag是希望钩子名称,$arg是该钩子允许的参数列表数组。 did_action <?php did_action( $tag ); ?>
- 返回动作钩子所执行的次数。$tag是钩子名称。 remove_action <?php remove_action( $tag, $function_to_remove, $priority, $accepted_args ); ?>
- 移除动作。$tag是将要被删除的函数所连接到的动作hook,$function_to_remove 是将要被删除函数的名称,$priority是函数优先级(在函数最初连接时定义)默认值:10,$accepted_args是函数所接受参数的数量。 默认值:1。 remove_all_actions <?php remove_all_actions( $tag, $priority ) ?>
- 移除所有指定钩子的动作。$tag是钩子的名称,$priority是优先级。
-
plugin_basename <?php plugin_basename($file); ?>
- 从文件名中获取插件的基名. register_activation_hook <?php register_activation_hook($file, $function); ?>
- 寄存一个插件函数,该插件函数在插件被激活时运行。该函数比activate_pluginname动作使用更加方便。 register_deactivation_hook <?php register_deactivation_hook($file, $function); ?>
- 寄存一个插件函数,该插件函数在插件被禁用时运行。 register_setting <?php register_setting( $option_group, $option_name, $sanitize_callback ); ?>
- 注册设置。详情见: http://codex.wordpress.org/Function_Reference/register_setting. settings_fields <?php settings_fields( $option_group ) ?>
- 设置字段。 unregister_setting <?php unregister_setting( $option_group, $option_name, $sanitize_callback ); ?>
- 注销设置。详情见: http://codex.wordpress.org/Function_Reference/unregister_setting.
虽然WordPress 2.5已引进了功能强大的简码,但目前仍只有很少人了解它。试想一下:只要输入“adsense”系统就会显示AdSense广告;键入 “post_count”就能立即了解博客上的日志数目会是怎样的体验。
而WordPress简码完全可以完成以上功能,而且还拥有更多神奇功能,它将使您的博客体验更加轻松容易。本文将向大家介绍如何创建并使用简码,并提供了杀手级的可直接使用的WordPress简码,这无疑会增强您的博客体验经历。
-
add_shortcode <?php add_shortcode( $tag , $func ); ?>
- 为简码shortcode添加一个钩子. do_shortcode <?php do_shortcode( $content ) ?>
- 在钩子中搜索和过滤简码shortcode。 do_shortcode_tag <?php do_shortcode_tag( $m ) ?>
- 用户do_shortcode()的正则表达式… get_shortcode_regex <?php get_shortcode_regex(); ?>
- 在文章中用正则表达式搜寻简码shortcode. remove_shortcode <?php remove_shortcode( $tag ); ?>
- 已初简码shortcode 。 remove_all_shortcodes <?php remove_all_shortcodes(); ?>
- 移除所有简码shortcode。 shortcode_atts <?php shortcode_atts( $pairs , $atts ); ?>
- 简码shortcode_atts的属性。 shortcode_parse_atts <?php shortcode_parse_atts( $text ); ?>
- 简码shortcode的愈发属性。 strip_shortcodes <?php strip_shortcodes( $content ); ?>
- 在所给的内容上剥去所有的简码shortcode.
7、Theme-Related Functions 主题相关函数
-
comments_template <?php comments_template( $file, $separate_comments ); ?>
- 包含评论模板.$file 默认值:’/comments.php’, $separate_comments 是否按评论类型分隔评论 get_footer <?php get_footer( $name ); ?>
- 包含页脚模版。$name 调用 ‘/footer-name.php’. get_header <?php get_header( $name ); ?>
- 包含页头模版。$name 调用 ‘/header-name.php’. get_sidebar <?php get_sidebar( $name ); ?>
- 包含边栏模版。$name 调用 ‘/sidebar-name.php’. get_search_form <?php get_search_form(); ?>
- 包含搜索表单 ‘/searchform.php’.
-
add_custom_background <?php add_custom_background( $header_callback, $admin_header_callback, $admin_image_div_callback ) ?>
- 自定义背景,详情见: http://codex.wordpress.org/Function_Reference/add_custom_background. (3.0函数) add_custom_image_header <?php add_custom_image_header( $header_callback, $admin_header_callback ) ?>
- 自定义图片页头.详情见: http://codex.wordpress.org/Function_Reference/add_custom_image_header。 add_theme_support <?php add_theme_support(‘post-thumbnails’); ?>
- 添加主题支持.用来激活文章缩略图(2.9)、导航菜单(3.0)或自动订阅链接(3.0),详情见: http://codex.wordpress.org/Function_Reference/add_theme_support. current_theme_supports <?php current_theme_supports( $feature ) ?>
- 通过特征判断当前的主题支持. dynamic_sidebar <?php dynamic_sidebar( $index ); ?>
- 判断是否设置了边栏项目. get_404_template <?php get_404_template() ?>
- 获得当前模版或父模版的404模版的路径. get_archive_template <?php get_archive_template() ?>
- 获得当前模版或父模版的归档模版的路径. get_attachment_template <?php get_attachment_template() ?>
- 获得当前模版或父模版的附件模版的路径. get_author_template <?php get_author_template() ?>
- 获得当前模版或父模版的作者模版的路径. get_category_template <?php get_category_template() ?>
- 获得当前模版或父模版的分类模版的路径. get_comments_popup_template <?php get_comments_popup_template() ?>
- 获得当前模版或父模版的弹出窗口评论模版的路径. get_current_theme <?php get_current_theme() ?>
- 获得当前模板的名称 get_date_template <?php get_date_template() ?>
- 获得当前模版或父模版的日期模版的路径. get_header_image <?php get_header_image() ?>
- 从自定义页头中获取页头图片. get_header_textcolor <?php get_header_textcolor() ?>
- 从自定义页头中获取文字颜色. get_home_template <?php get_home_template() ?>
- 获得当前模版或父模版的首页模版的路径. get_locale_stylesheet_uri <?php get_locale_stylesheet_uri() ?>
- 获得style.css的路径. get_page_template <?php get_page_template() ?>
- 获得当前模版或父模版的页面模版的路径. get_paged_template <?php get_paged_template() ?>
- 获得当前模版或父模版的分页模版的路径. get_query_template <?php if ( ” != get_query_template( ’404′ ) ) include( get_query_template( ’404′ ) ); ?>
- 查询模板的路径. get_search_template <?php get_search_template() ?>
- 获得当前模版或父模版的搜索模版的路径. get_single_template <?php get_single_template() ?>
- 获得当前模版或父模版的单文章模版的路径. get_stylesheet <?php get_stylesheet() ?>
- 获得当前样式表的名字? get_stylesheet_directory <?php get_stylesheet_directory() ?>
- 获得当前样式表的目录的本地路径. get_stylesheet_directory_uri <?php get_stylesheet_directory_uri(); ?>
- 获得当前样式表的目录的http路径. get_stylesheet_uri <?php get_stylesheet_uri() ?>
- 获取当前样式表的http路径. get_tag_template <?php get_tag_template() ?>
- 获得当前模版或父模版的标签模版的路径. get_taxonomy_template <?php get_taxonomy_template() ?>
- 获得当前模版或父模版的分类法模版的路径. get_template <?php get_template() ?>
- 获得当前模版的名称. get_template_directory<?php get_template_directory() ?>
- 获得当前模版的目录的本地路径. get_template_directory_uri <?php get_template_directory_uri() ?>
- 获得当前模版的目录的http地址. get_theme <?php get_theme( $theme ) ?>
- 判断主题是否存在,如果存在,则返回主题的资料数组. get_theme_data <?php get_theme_data( $theme_filename ); ?>
- 获得主题的资料数组,$theme_filename是style.css的路径. get_theme_mod <?php get_theme_mod( $name, $default ) ?>
- 为当前主题检索主题修改值。 get_theme_root <?php get_theme_root() ?>
- 返回themes的根目录本地路径. get_theme_root_uri <?php get_theme_root_uri() ?>
- 返回themes的根目录的http地址. get_themes <?php get_themes() ?>
- 获得所有主题的数组. header_image <?php header_image() ?>
- 输出页头图片的地址. header_textcolor <?php header_textcolor() ?>
- 输出页头的文字颜色. load_template <?php load_template( $_template_file ) ?>
- 读取模版.$_template_file是模版的路径. locale_stylesheet <?php locale_stylesheet() ?>
- 输出style.css的路径. locate_template <?php locate_template( $template_names, $load ) ?>
- 判断模板文件是否存在,并且$load为true时读取它. preview_theme <?php preview_theme() ?>
- 预览模板. preview_theme_ob_filter <?php preview_theme_ob_filter( $content ) ?>
- 为ob_start()回调函数以获取主题中所有链接. preview_theme_ob_filter_callback <?php preview_theme_ob_filter_callback( $matches ) ?>
- 处理预览主题链接,以控制并保持定位。为preg_replace_callback()回调函数以匹配过滤器. register_theme_directory <?php register_theme_directory( $directory ) ?>
- 插件可以添加其他主题目录以便于被搜索到。这意味着一个插件基本上可以捆绑自己的主题. remove_theme_mod <?php remove_theme_mod( $name ) ?>
- 从当前主题列表中移除主题修改值. remove_theme_mods <?php remove_theme_mods() ?>
- 从当前主题列表中移除主题修改值选项. require_if_theme_supports <?php require_if_theme_supports( $feature, $include ) ?>
- 在读取functions前执行检查主题对一个给定的功能支持. search_theme_directories <?php search_theme_directories() ?>
- 在所有已注册的主题目录中搜寻已完成的且有效的主题. set_theme_mod <?php set_theme_mod( $name, $value ) ?>
- 更新当前主题的主题修改值. switch_theme <?php switch_theme( $template, $stylesheet ) ?>
- 将当前主题转换为新模板和新的样式表单名称. validate_current_theme <?php validate_current_theme() ?>
- 检查当前主题文件 ‘index.php’ 与’style.css’是否存在. wp_nav_menu <?php wp_nav_menu($args); ?>
- 显示导航菜单.详情见: http://codex.wordpress.org/Function_Reference/wp_nav_menu. (3.0函数)
8、Fomatting Functions 格式化函数
-
add_magic_quotes <?php add_magic_quotes( $array ) ?>
- 过滤内容时访问数组中的每一个元素。 addslashes_gpc <?php addslashes_gpc( $gpc ) ?>
- 添加斜线以避免使用字符串。 antispambot <?php antispambot( $emailaddy, $mailto ) ?>
- 将电子邮件地址的字符转换为HTML实体以阻止广告机器人. attribute_escape <?php echo attribute_escape($text); ?>
- 在HTML属性中,该函数对特定HTML字符(包括单引号和双引号)进行字符转义或将这些字符译为计算机语言。该函数工作方式类似于标准的PHP函数 htmlspecialchars,唯一不同在于该函数不会对HTML实体进行双重编码(例如,该函数用 &&代替&&)。 (已弃用) backslashit <?php backslashit( $string ) ?>
- 在字母和字符串首的数字前添加反斜线符号。 balanceTags <?php balanceTags( $text, $force ) ?>
- 函数仅在被要求以及选项被设为校正标签时会对标签进行自动校正。 clean_pre <?php clean_pre( $matches ) ?>
- 该函数接收来自wpautop()中 preg_replace_callback 的匹配数组或字符串。确保 <pre>…</pre> HTML块中的内容没有转换成段落或分行符。 clean_url <?php clean_url( $url, $protocols, $context ) ?>
- 查看并过滤URL。URL中若干字符被删除。如果URL用于在文本中显示链接地址,URL中的&号也会被替换。clean_url对返回的已过滤URL进行再次过滤。 (已弃用) convert_chars <?php convert_chars( $content, $deprecated ) ?>
- 将字符串转换为一系列字符。该函数移除Metadata标签<title> 和<category>,将 <br> 和<hr>转换为相应的XHTML,将统一码字符转换为可用值。 convert_smilies <?php convert_smilies( $text ) ?>
- 将文本中的表情符号转换为表情图像。只在选项’use_smilies’为true,且函数中的全局变量不为空时转换表情符号。 ent2ncr <?php ent2ncr( $text ) ?>
- 将名称实体转换为数值型实体. esc_attr <?php esc_attr( $text ) ?>
- 编码< > & ” ‘为实体。 force_balance_tags <?php force_balance_tags( $text ) ?>
- 用改进的堆栈自动校正字符串标签。忽略’use_balanceTags’选项。 format_to_edit <?php format_to_edit( $content, $richedit ) ?>
- 处理将要被编辑的文本。$richedit未赋值时只是一个存储“format_to_edit”过滤器的文件夹。如果$richedit被设为true,那么 htmlspecialchars会在文本上运行并将特定字符转换为 HTML实体。 format_to_post <?php format_to_post( $content ) ?>
- 保存’format_to_post’ 过滤器。 funky_javascript_fix <?php funky_javascript_fix( $text ) ?
- 修正浏览器中的JavaScript错误。将统一码字符转换为 HTML数值实体。 htmlentities2 <?php htmlentities2( $myHTML ) ?>
- 转换字符实体,保留已经被编码的字符实体。 is_email <?php is_email( $email, $check_dns ) ?>
- 合适email是否有效。 js_escape <?php js_escape( $text ) ?>
- 转义单引号,转换双引号,改正行结束符号。也可使用过滤器’js_escape’ 。 make_clickable <?php make_clickable( $ret ) ?>
- 将普通文本URL转换成HTML链接。可以转换URL,www,ftp和电子邮件地址等。 popuplinks <?php popuplinks( $text ) ?>
- 为所有HTML的anchor标签添加 target=’_blank’ and rel=’external’代码,以在新窗口中打开链接。该函数可过滤弹出窗口中的注释文本。目前该函数没有多大用途,但在理想情况下它可以判断目标或 rel属性是否存在并相应调整操作。 remove_accents <?php remove_accents( $string ) ?>
- 将所有重音字符转换为ASCII字符。如果没有重音字符,返回所给字符串。 sanitize_email <?php sanitize_email( $email ) ?>
- 过滤邮件中不允许出现的字符。 sanitize_file_name <?php sanitize_file_name( $name ) ?>
- 过滤文件名中的特定字符串。删除所有字符串,只保留以空格、破折号以及时间隔开的字母数字式字符串,将所有字符串转换为小写状态。所有空格和下划线都被转换为破折号。将多个破折号转换为单一破折号。删除名称以破折号结尾的文件。 sanitize_user <?php sanitize_user( $username, $strict ) ?>
- 消除用户名中的不安全字符。若$strict参数为true,则返回添加了_, space, ., -, *, 以及 @的字母数字式字符。该函数删除所有标签,XX以及实体,如果$strict参数被激活,该函数删除所有非ASCII字符。清理用户名后,该函数将用户 名、原始用户名(参数中的用户名)以及$strict参数作为过滤器参数。 sanitize_title <?php sanitize_title( $title, $fallback_title ) ?>
- 检查标题或使用备用标题。特别要说明的是, HTML 和PHP标签都会被忽略。可以通过插件API来添加下一步动作。若$title为空且已设置$fallback_title,函数会使用后者。 sanitize_title_with_dashes <?php sanitize_title_with_dashes( $title ) ?>
- 检查标题,用破折号代替空格。输出结果仅限于字母数字字符、下划线(_)和破折号(-)。空格将被替换为破折号。 seems_utf8 <?php seems_utf8( $Str ) ?>
- 检查是否有urf8编码格式的字符串。 stripslashes_deep <?php stripslashes_deep( $value ) ?>
- 该函数通过数组进行导航,删除函数值中的斜线。数组被传递后,array_map()函数引发回调,将值回传给stripslashes_deep()函数。stripslashes()函数删除值中的斜线。 trailingslashit <?php trailingslashit( $string ) ?>
- 添加结尾斜线。添加前删除已有的结尾斜线,防止字符串或路径出现双斜线。该函数主要用于路径,也只应该用于路径。函数对路径没有特别限制,也不为路径提供特别支持。 untrailingslashit <?php untrailingslashit( $string ) ?>
-
删除已有的结尾斜线。
该函数主要用于路径,也只应该用于路径。函数对路径没有特别限制,也不为路径提供特别支持。
utf8_uri_encode <?php utf8_uri_encode( $utf8_string, $length ) ?>
- 为URI中使用的统一码值进行编码。 wpautop <?php wpautop( $pee, $br = 1 ); ?>
- 将文本中的成对换行符换成HTML段落符号(<p>…</p>),WordPress使用该函数来过滤文章内容和摘要。 wptexturize <?php wptexturize(); ?>
- 返回一些转换的字符串。 wp_filter_kses <?php wp_filter_kses( $data ) ?>
- 过滤带有合法 HTMLKses规则的文本。 wp_filter_post_kses <?php wp_filter_post_kses( $data ) ?>
- 在日志正文中检查含有合法HTML标签的文本。日志正文指类型为“日志(post)”的页面内容,而非表格中的 $_POST数据。 wp_filter_nohtml_kses <?php wp_filter_nohtml_kses( $data ) ?>
- 删除文本中的所有 HTML。 wp_iso_descrambler <?php wp_iso_descrambler( $string ) ?>
- 将电子邮件主题转换为 ASCII码。 wp_kses <?php wp_kses($string, $allowed_html, $allowed_protocols); ?>
- 该函数确保在$string中只出现经许可的HTML元素名称、属性名称和属性值以及有意义的HTML实体。调用该函数前需要删除PHP魔术引号中的斜线。 wp_kses_array_lc <?php wp_kses_array_lc( $inarray ) ?>
- 该函数遍历某数组并将其中的密码改为小写状态。 wp_kses_attr <?php wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) ?>
- 该函数删除元素不允许的所有属性。若某些属性得到许可,函数调用 wp_kses_hair()进一步分裂这些属性,并利用 wp_kses_hair()返回的信息创建新的HTML代码。该函数删除剩余的’<’ and ‘>’字符。此外该函数还负责检查标签是否具有XHTML结尾斜线,如果有,函数会在返回的代码中也添加结尾斜线。 wp_kses_bad_protocol <?php wp_kses_bad_protocol( $string, $allowed_protocols ) ?>
- 过滤bad protocol中的字符串。该函数在$string开始时,删除所有不被允许的protocol。函数可以忽略空格和字母大小写的差异,同时可以识别 HTML实体。函数在while循环中工作,因此不会被类似’javascript:javascript:alert(57)’的字符串欺骗。 wp_kses_bad_protocol_once <?php wp_kses_bad_protocol_once( $string, $allowed_protocols ) ?>
- 过滤文本中的bad protocol和其它字符。该函数在处理空格符和HTML实体时,在$string的开始部分查找URL protocol(协议)。 wp_kses_bad_protocol_once2 <?php wp_kses_bad_protocol_once2( $matches ) ?>
- 该函数接收来自wpautop()中 preg_replace_callback 的匹配数组或字符串。确保 <pre>…</pre> HTML块中的内容没有转换成段落或分行符。 wp_kses_check_attr_val <?php wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) ?>
- 该函数为属性值执行不同查询。目前可执行的查询包括’maxlen’, ‘minlen’, ‘maxval’, ‘minval’ 以及 ‘valueless’,将来可能会支持更多可执行查询。 wp_kses_decode_entities <?php wp_kses_decode_entities( $string ) ?>
- 该函数将所有实体转换为与之相对应的字符。该函数为数值型HTML实体(如A 与 A)解码。函数不处理ä等其它实体,但我们在URL protocol白名单中也不需要这类实体。 wp_kses_hair <?php wp_kses_hair( $attr, $allowed_protocols ) ?>
- 该函数从含有属性的字符串中建立一个属性列表。该函数可有多种用途。首先该函数将属性列表解析为一个带有属性信息的数组,之后即使接收到怪异的输入内容也 会尽量保持正确操作。其次该函数会为没有引号或撇号的属性值添加引号,以便更轻松地生成符合W3C HTML标准的HTML代码。此外该函数还可以删除属性值中的坏链协议,利用之前定义的属性((foo=’bar’ foo=’baz’ will result in foo=’bar’))减少重复属性。 wp_kses_hook <?php wp_kses_hook( $string, $allowed_html, $allowed_protocols ) ?>
- 可在此处添加任何kses(用PHP编写的HTML过滤器)钩子。目前WordPress中只有一个kses 钩子,于是系统会在wp_kses_hook中调用这个钩子。所有参数都被传递到kses钩子,期望返回字符串。 wp_kses_html_error <?php wp_kses_html_error( $string ) ?>
- 该函数处理wp_kses_hair中的错误解析。通常该函数会删除所有内容,只保留一些空格,函数也可以处理引号和撇号。 wp_kses_js_entities <?php wp_kses_js_entities( $string ) ?>
- 该函数删除Netscape 4早期版本中的HTMLJavaScript实体。 wp_kses_no_null <?php wp_kses_no_null( $string ) ?>
- 删除$string中的NULL字符。 wp_kses_normalize_entities <?php wp_kses_normalize_entities( $string ) ?>
- 转换并修正HTML实体。该函数统一HTML字符,使之正规化。函数将”AT&T”转换为”AT&T”,将 “:”转换为 “:”,将”&#XYZZY;” 转换为 “&#XYZZY;”等等。 wp_kses_normalize_entities2 <?php wp_kses_normalize_entities2( $matches ) ?>
- 为正则表达式 wp_kses_normalize_entities()进行回调。该函数使wp_kses_normalize_entities()只支持16位值以及 &#number; 实体。 wp_kses_split <?php wp_kses_split( $string, $allowed_html, $allowed_protocols ) ?>
- 查找HTML标签,无论格式是否被破坏。该函数还可以为单个“>”字符配对。 wp_kses_split2 <?php wp_kses_split2( $string, $allowed_html, $allowed_protocols ) ?>
- 回调 wp_kses_split(),修复损坏的HTML标签。该函数进行大量工作。wp_kses_split2()拒绝<:::>等不完整字 符。如果某个元素不允许出现,wp_kses_split2()返回空字符。否则wp_kses_split2()会将标签拆分为一个元素和一个属性列 表。标签被拆分后会运行另一个过滤器函数,这个过滤器函数能够删除所有非法属性。 wp_ks