• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

「関数リファレンス」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(en:Function Reference 2007年10月21日 (日) 16:38 NateCook 版)
 
(リンク微調整、原文・言語間リンク追加)
1行目: 1行目:
 
__NOTOC__
 
__NOTOC__
The files of WordPress define many useful PHP functions. Some of the functions, known as [[Template Tags]], are defined especially for use in WordPress themes. There are also some functions related to actions and filters (the [[Plugin API]]), which are therefore used primarily for developing plugins. The rest are used to create the core WordPress functionality.
+
The files of WordPress define many useful PHP functions. Some of the functions, known as [[テンプレートタグ|Template Tags]], are defined especially for use in WordPress themes. There are also some functions related to actions and filters (the [[Plugin API]]), which are therefore used primarily for developing plugins. The rest are used to create the core WordPress functionality.
  
 
Many of the core WordPress functions may also be useful to plugin developers, and to a lesser extent, possibly theme developers as well. So, this article lists most of the core functions, by category; some of the function names are also links to more detailed documentation in separate pages. Each category also lists the files where its functions can be found (the files are in the <tt>wp-includes</tt> directory of WordPress).
 
Many of the core WordPress functions may also be useful to plugin developers, and to a lesser extent, possibly theme developers as well. So, this article lists most of the core functions, by category; some of the function names are also links to more detailed documentation in separate pages. Each category also lists the files where its functions can be found (the files are in the <tt>wp-includes</tt> directory of WordPress).
  
'''Note''': This reference applies to Version 2.1 of WordPress, and does not include functions that have been deprecated as of that version of WordPress. An incomplete page for the 2.0.x versions of WordPress can be found at [[Function Reference 2.0.x]].
+
'''Note''': This reference applies to Version 2.1 of WordPress, and does not include functions that have been deprecated as of that version of WordPress. An incomplete page for the 2.0.x versions of WordPress can be found at [[:en:Function Reference 2.0.x]].
  
'''Note''': Functions specifically for templates, which are listed in the [[Template Tags]] article, and contained in files <tt>wp-includes/*_template.php</tt>, are not listed here.
+
'''Note''': Functions specifically for templates, which are listed in the [[テンプレートタグ|Template Tags]] article, and contained in files <tt>wp-includes/*_template.php</tt>, are not listed here.
  
 
'''Note''': the [http://planetozh.com/projects/wordpress-functions-history/ WordPress Functions History Tool] (unofficial tool) may help in finding when/if a function has been added/dropped.
 
'''Note''': the [http://planetozh.com/projects/wordpress-functions-history/ WordPress Functions History Tool] (unofficial tool) may help in finding when/if a function has been added/dropped.
16行目: 16行目:
 
Here are some things you can do to help:
 
Here are some things you can do to help:
  
* Add documentation to un-documented functions, by creating sub-pages or at least by adding short comments in the lists below. If you create a subpage for a function, please include information and examples of usage of that function, if possible, per the examples found in [[Template Tags]].  
+
* Add documentation to un-documented functions, by creating sub-pages or at least by adding short comments in the lists below. If you create a subpage for a function, please include information and examples of usage of that function, if possible, per the examples found in [[テンプレートタグ|Template Tags]].  
 
* List more functions here, following the category structure.  
 
* List more functions here, following the category structure.  
 
* Remove functions from the list, if you think they could not possibly be useful to plugin developers, or if they have been deprecated.
 
* Remove functions from the list, if you think they could not possibly be useful to plugin developers, or if they have been deprecated.
36行目: 36行目:
 
== Post, Page, and Attachment Functions ==
 
== Post, Page, and Attachment Functions ==
  
These functions are contained in <tt>formatting.php</tt>, <tt>post.php</tt>. See also [[Template Tags]].
+
These functions are contained in <tt>formatting.php</tt>, <tt>post.php</tt>. See also [[テンプレートタグ|Template Tags]].
  
 
* <tt>wp_trim_excerpt</tt>
 
* <tt>wp_trim_excerpt</tt>
43行目: 43行目:
 
* <tt>get_children</tt>
 
* <tt>get_children</tt>
 
* <tt>get_extended</tt>
 
* <tt>get_extended</tt>
* [[Function Reference/get_post|get_post]] - get information on a specific post
+
* [[/get_post|get_post]] - get information on a specific post
* [[Function Reference/get_post_mime_type|get_post_mime_type($ID = "")]] - takes a post ID, returns its MIME type
+
* [[/get_post_mime_type|get_post_mime_type($ID = "")]] - takes a post ID, returns its MIME type
 
* <tt>get_post_status</tt>
 
* <tt>get_post_status</tt>
 
* <tt>get_post_type</tt>
 
* <tt>get_post_type</tt>
* [[Template Tags/get posts|get_posts]]
+
* [[テンプレートタグ/get posts|get_posts]]
 
* <tt>add_post_meta</tt>
 
* <tt>add_post_meta</tt>
 
* <tt>delete_post_meta</tt>
 
* <tt>delete_post_meta</tt>
55行目: 55行目:
 
* <tt>get_post_custom_keys</tt>
 
* <tt>get_post_custom_keys</tt>
 
* <tt>get_post_custom_values</tt>
 
* <tt>get_post_custom_values</tt>
* [[Function Reference/wp_delete_post|wp_delete_post($postid)]] - A generic function to delete a post in the post table
+
* [[/wp_delete_post|wp_delete_post($postid)]] - A generic function to delete a post in the post table
* [[Function Reference/wp_get_post_categories|wp_get_post_categories($postid)]] - Retrieves an array of IDs of categories for a post
+
* [[/wp_get_post_categories|wp_get_post_categories($postid)]] - Retrieves an array of IDs of categories for a post
 
* <tt>get_recent_posts</tt>
 
* <tt>get_recent_posts</tt>
 
* <tt>get_single_post</tt>
 
* <tt>get_single_post</tt>
* [[Function Reference/wp_insert_post|wp_insert_post($postarr=array())]] - A generic function for inserting data into the post table
+
* [[/wp_insert_post|wp_insert_post($postarr=array())]] - A generic function for inserting data into the post table
* [[Function Reference/wp_update_post|wp_update_post($postarr=array())]] - A generic function to update data in the post table
+
* [[/wp_update_post|wp_update_post($postarr=array())]] - A generic function to update data in the post table
* [[Function Reference/wp_publish_post|wp_publish_post($post_id)]] - Set a post's post_status to published. Calls <tt>wp_update_post</tt>.
+
* [[/wp_publish_post|wp_publish_post($post_id)]] - Set a post's post_status to published. Calls <tt>wp_update_post</tt>.
 
* <tt>wp_set_post_categories</tt>
 
* <tt>wp_set_post_categories</tt>
 
* <tt>get_all_page_ids</tt>
 
* <tt>get_all_page_ids</tt>
93行目: 93行目:
  
 
* <tt>get_all_category_ids</tt>
 
* <tt>get_all_category_ids</tt>
* [[Function Reference/get_categories|&get_categories($args=''''''')]]
+
* [[/get_categories|&get_categories($args=''''''')]]
 
* <tt>&get_category</tt>
 
* <tt>&get_category</tt>
 
* <tt>get_category_by_path</tt>
 
* <tt>get_category_by_path</tt>
99行目: 99行目:
 
* <tt>get_cat_ID($cat_name='General')</tt> - Get the ID of a category from its name
 
* <tt>get_cat_ID($cat_name='General')</tt> - Get the ID of a category from its name
 
* <tt>get_cat_name($cat_id)</tt> - get the name of a category from its ID
 
* <tt>get_cat_name($cat_id)</tt> - get the name of a category from its ID
* <tt>[[Function Reference/cat_is_ancestor_of|cat_is_ancestor_of]]</tt>
+
* <tt>[[/cat_is_ancestor_of|cat_is_ancestor_of]]</tt>
  
 
Tag Functions in <tt>category.php</tt>
 
Tag Functions in <tt>category.php</tt>
126行目: 126行目:
  
 
* <tt>get_profile</tt>
 
* <tt>get_profile</tt>
* [[Function_Reference/get_usernumposts|get_usernumposts]] &mdash; get post count for a specific user
+
* [[/get_usernumposts|get_usernumposts]] &mdash; get post count for a specific user
 
* <tt>delete_usermeta</tt>
 
* <tt>delete_usermeta</tt>
* [[Function_Reference/get_usermeta|get_usermeta]] &mdash; get meta data for a specific user
+
* [[/get_usermeta|get_usermeta]] &mdash; get meta data for a specific user
* [[Function_Reference/update_usermeta|update_usermeta]] &mdash; Updates a piece of user meta data.
+
* [[/update_usermeta|update_usermeta]] &mdash; Updates a piece of user meta data.
 
* <tt>set_current_user</tt>
 
* <tt>set_current_user</tt>
 
* <tt>wp_set_current_user</tt>
 
* <tt>wp_set_current_user</tt>
 
* <tt>wp_get_current_user</tt>
 
* <tt>wp_get_current_user</tt>
* [[Function Reference/get_currentuserinfo|get_currentuserinfo]] &mdash; get information on the current user
+
* [[/get_currentuserinfo|get_currentuserinfo]] &mdash; get information on the current user
* [[Function Reference/get_userdata|get_userdata]] &mdash; get information on any user
+
* [[/get_userdata|get_userdata]] &mdash; get information on any user
 
* <tt>get_userdatabylogin</tt>
 
* <tt>get_userdatabylogin</tt>
 
* <tt>wp_login</tt>
 
* <tt>wp_login</tt>
144行目: 144行目:
 
* <tt>wp_insert_user</tt>
 
* <tt>wp_insert_user</tt>
 
* <tt>wp_update_user</tt>
 
* <tt>wp_update_user</tt>
* [[Function_Reference/wp_create_user|wp_create_user]] &mdash; Create a user and add it to the user database.
+
* [[/wp_create_user|wp_create_user]] &mdash; Create a user and add it to the user database.
  
 
|valign="top" bgcolor="#f0f0ff" style="border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;" width="50%"|
 
|valign="top" bgcolor="#f0f0ff" style="border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;" width="50%"|
152行目: 152行目:
 
These functions are in <tt>functions.php</tt>, <tt>feed.php</tt>, <tt>rss.php</tt>
 
These functions are in <tt>functions.php</tt>, <tt>feed.php</tt>, <tt>rss.php</tt>
  
* [[Function_Reference/fetch_rss|fetch_rss]] -- retrieve an RSS feed from a URL with automatic caching (included in rss_functions.php)
+
* [[/fetch_rss|fetch_rss]] -- retrieve an RSS feed from a URL with automatic caching (included in rss_functions.php)
* [[Function_Reference/wp_rss|wp_rss]] -- retrieve and display an RSS feed as an unordered list (included in rss_functions.php)
+
* [[/wp_rss|wp_rss]] -- retrieve and display an RSS feed as an unordered list (included in rss_functions.php)
* [[Function_Reference/get_rss|get_rss]] -- retrieve and display an RSS feed as a list (ordering optional) (included in rss_functions.php)
+
* [[/get_rss|get_rss]] -- retrieve and display an RSS feed as a list (ordering optional) (included in rss_functions.php)
 
* <tt>do_feed</tt>
 
* <tt>do_feed</tt>
 
* <tt>do_feed_rdf</tt>
 
* <tt>do_feed_rdf</tt>
187行目: 187行目:
  
 
* <tt>check_comment</tt>
 
* <tt>check_comment</tt>
* [[Function Reference/get_approved_comments|get_approved_comments]]
+
* [[/get_approved_comments|get_approved_comments]]
 
* <tt>get_comment</tt>
 
* <tt>get_comment</tt>
 
* <tt>get_lastcommentmodified</tt>
 
* <tt>get_lastcommentmodified</tt>
223行目: 223行目:
 
These functions are contained in <tt>plugin.php</tt>. See also [[Plugin API]].
 
These functions are contained in <tt>plugin.php</tt>. See also [[Plugin API]].
  
* [[Function Reference/add_filter|add_filter]]
+
* [[/add_filter|add_filter]]
 
* <tt>apply_filters</tt>
 
* <tt>apply_filters</tt>
 
* <tt>merge_filters</tt>
 
* <tt>merge_filters</tt>
 
* <tt>remove_filter</tt>
 
* <tt>remove_filter</tt>
* [[Function Reference/add_action|add_action]]
+
* [[/add_action|add_action]]
* [[Function Reference/do_action|do_action]]
+
* [[/do_action|do_action]]
 
* <tt>did_action</tt>
 
* <tt>did_action</tt>
 
* <tt>do_action_ref_array</tt>
 
* <tt>do_action_ref_array</tt>
 
* <tt>remove_action</tt>
 
* <tt>remove_action</tt>
 
* <tt>plugin_basename</tt>
 
* <tt>plugin_basename</tt>
* [[Function Reference/register_activation_hook|register_activation_hook]]
+
* [[/register_activation_hook|register_activation_hook]]
* [[Function Reference/register_deactivation_hook|register_deactivation_hook]]
+
* [[/register_deactivation_hook|register_deactivation_hook]]
  
 
|- valign="top"
 
|- valign="top"
251行目: 251行目:
 
* <tt>get_template_directory</tt>
 
* <tt>get_template_directory</tt>
 
* <tt>get_template_directory_uri</tt>
 
* <tt>get_template_directory_uri</tt>
* [[Function Reference/get_theme_data|get_theme_data]]
+
* [[/get_theme_data|get_theme_data]]
 
* <tt>get_themes</tt>
 
* <tt>get_themes</tt>
 
* <tt>get_theme</tt>
 
* <tt>get_theme</tt>
287行目: 287行目:
 
These functions are contained in <tt>formatting.php</tt>, <tt>functions.php</tt>, <tt>kses.php</tt>.
 
These functions are contained in <tt>formatting.php</tt>, <tt>functions.php</tt>, <tt>kses.php</tt>.
  
* [[Function_Reference/wptexturize|wptexturize( $text )]]
+
* [[/wptexturize|wptexturize( $text )]]
* [[Function_Reference/clean_pre|clean_pre( $text )]] - Returns the text without BR tags, and with P tags turned into line-breaks
+
* [[/clean_pre|clean_pre( $text )]] - Returns the text without BR tags, and with P tags turned into line-breaks
* [[Function_Reference/wpautop|wpautop( $pee, $br = 1 )]] - Returns the text with HTML formatting for paragraphs
+
* [[/wpautop|wpautop( $pee, $br = 1 )]] - Returns the text with HTML formatting for paragraphs
* [[Function_Reference/seems_utf8|seems_utf8($Str)]] - Returns true if given string seems like it is UTF8-encoded
+
* [[/seems_utf8|seems_utf8($Str)]] - Returns true if given string seems like it is UTF8-encoded
* [[Function_Reference/wp_specialchars|wp_specialchars( $text, $quotes = 0 )]] - Like the PHP function htmlspecialchars except it doesn't double-encode HTML entities
+
* [[/wp_specialchars|wp_specialchars( $text, $quotes = 0 )]] - Like the PHP function htmlspecialchars except it doesn't double-encode HTML entities
 
* <tt>utf8_uri_encode</tt>
 
* <tt>utf8_uri_encode</tt>
* [[Function_Reference/remove_accents|remove_accents($string)]] - Returns a string with accents or umlauts without these
+
* [[/remove_accents|remove_accents($string)]] - Returns a string with accents or umlauts without these
 
* <tt>sanitize_file_name</tt>
 
* <tt>sanitize_file_name</tt>
* [[Function_Reference/sanitize_user|sanitize_user( $username, $strict = false )]] - Makes the username more machine-readable. Strict option for pure ASCII only.
+
* [[/sanitize_user|sanitize_user( $username, $strict = false )]] - Makes the username more machine-readable. Strict option for pure ASCII only.
* [[Function_Reference/sanitize_title|sanitize_title($title, $fallback_title = '')]]
+
* [[/sanitize_title|sanitize_title($title, $fallback_title = '')]]
* [[Function_Reference/sanitize_title_with_dashes|sanitize_title_with_dashes($title)]]
+
* [[/sanitize_title_with_dashes|sanitize_title_with_dashes($title)]]
* [[Function_Reference/convert_chars|convert_chars($content, $flag = 'obsolete')]] - Translation of invalid Unicode references range to valid range
+
* [[/convert_chars|convert_chars($content, $flag = 'obsolete')]] - Translation of invalid Unicode references range to valid range
 
* <tt>funky_javascript_fix</tt>
 
* <tt>funky_javascript_fix</tt>
* [[Function_Reference/balanceTags|balanceTags($text, $is_comment = 0)]] - Balances Tags of string using a modified stack. Can be disabled by configuration.
+
* [[/balanceTags|balanceTags($text, $is_comment = 0)]] - Balances Tags of string using a modified stack. Can be disabled by configuration.
 
* <tt>force_balance_tags</tt>
 
* <tt>force_balance_tags</tt>
 
* <tt>format_to_edit</tt>
 
* <tt>format_to_edit</tt>
 
* <tt>format_to_post</tt>
 
* <tt>format_to_post</tt>
* [[Function_Reference/zeroise|zeroise($number,$threshold)]] - Adds leading zeros when necessary
+
* [[/zeroise|zeroise($number,$threshold)]] - Adds leading zeros when necessary
 
* <tt>backslashit</tt>
 
* <tt>backslashit</tt>
 
* <tt>trailingslashit</tt>
 
* <tt>trailingslashit</tt>
317行目: 317行目:
 
* <tt>popuplinks</tt> - converts a link into a popup link that will open in a different window
 
* <tt>popuplinks</tt> - converts a link into a popup link that will open in a different window
 
* <tt>sanitize_email</tt>
 
* <tt>sanitize_email</tt>
* [[Function_Reference/ent2ncr|ent2ncr($text)]]  - Returns HTML entity as its number representation.
+
* [[/ent2ncr|ent2ncr($text)]]  - Returns HTML entity as its number representation.
 
* <tt>wp_richedit_pre</tt>
 
* <tt>wp_richedit_pre</tt>
 
* <tt>clean_url</tt>
 
* <tt>clean_url</tt>
363行目: 363行目:
 
* <tt>human_time_diff</tt>
 
* <tt>human_time_diff</tt>
 
* <tt>mysql2date</tt>
 
* <tt>mysql2date</tt>
* [[Function Reference/current time|current_time]]
+
* [[/current time|current_time]]
 
* <tt>date_i18n</tt>
 
* <tt>date_i18n</tt>
 
* <tt>get_weekendstartend</tt>
 
* <tt>get_weekendstartend</tt>
379行目: 379行目:
 
Options
 
Options
  
* [[Function Reference/get option|get_option]]
+
* [[/get option|get_option]]
* [[Function Reference/form option|form_option]]
+
* [[/form option|form_option]]
 
* <tt>get_alloptions</tt>
 
* <tt>get_alloptions</tt>
* [[Function Reference/update option|update_option]]
+
* [[/update option|update_option]]
* [[Function Reference/add option|add_option]]
+
* [[/add option|add_option]]
* [[Function Reference/delete option|delete_option]]
+
* [[/delete option|delete_option]]
 
* <tt>get_user_option</tt>
 
* <tt>get_user_option</tt>
 
* <tt>update_user_option</tt>
 
* <tt>update_user_option</tt>
410行目: 410行目:
 
Cron (Scheduling)
 
Cron (Scheduling)
  
* <tt>[[Function_Reference/wp_schedule_single_event|wp_schedule_single_event]]</tt>
+
* <tt>[[/wp_schedule_single_event|wp_schedule_single_event]]</tt>
* <tt>[[Function_Reference/wp_schedule_event|wp_schedule_event]]</tt>
+
* <tt>[[/wp_schedule_event|wp_schedule_event]]</tt>
 
* <tt>wp_reschedule_event</tt>
 
* <tt>wp_reschedule_event</tt>
* <tt>[[Function_Reference/wp_unschedule_event|wp_unschedule_event]]</tt>
+
* <tt>[[/wp_unschedule_event|wp_unschedule_event]]</tt>
* <tt>[[Function_Reference/wp_clear_scheduled_hook|wp_clear_scheduled_hook]]</tt>
+
* <tt>[[/wp_clear_scheduled_hook|wp_clear_scheduled_hook]]</tt>
* <tt>[[Function_Reference/wp_next_scheduled|wp_next_scheduled]]</tt>
+
* <tt>[[/wp_next_scheduled|wp_next_scheduled]]</tt>
 
* <tt>spawn_cron</tt>
 
* <tt>spawn_cron</tt>
 
* <tt>wp_cron</tt>
 
* <tt>wp_cron</tt>
452行目: 452行目:
 
* <tt>get_bookmark</tt>
 
* <tt>get_bookmark</tt>
 
* <tt>get_bookmarks</tt>
 
* <tt>get_bookmarks</tt>
* [[Function Reference/wp mail|wp_mail]]
+
* [[/wp mail|wp_mail]]
 
* <tt>check_admin_referer</tt>
 
* <tt>check_admin_referer</tt>
 
* <tt>check_ajax_referer</tt>
 
* <tt>check_ajax_referer</tt>
476行目: 476行目:
 
* WP - general request handling
 
* WP - general request handling
 
* WP_Ajax_Response - AJAX handling
 
* WP_Ajax_Response - AJAX handling
* [[Function_Reference/WP_Cache|WP_Object_Cache]] (formerly <tt>WP_Cache</tt>) - Object cache (and functions <tt>wp_cache_add, wp_cache_close, wp_cache_delete, wp_cache_flush, wp_cache_get, wp_cache_init, wp_cache_replace, wp_cache_set</tt>)
+
* [[/WP_Cache|WP_Object_Cache]] (formerly <tt>WP_Cache</tt>) - Object cache (and functions <tt>wp_cache_add, wp_cache_close, wp_cache_delete, wp_cache_flush, wp_cache_get, wp_cache_init, wp_cache_replace, wp_cache_set</tt>)
 
* WP_Error - error handling (and function <tt>is_wp_error</tt>)
 
* WP_Error - error handling (and function <tt>is_wp_error</tt>)
 
* <tt>WP_Locale</tt> - handles date and time locales
 
* <tt>WP_Locale</tt> - handles date and time locales
* [[Function_Reference/WP_Query|WP_Query]] - Request parsing and manipulation, posts fetching (with functions <tt>get_query_var, [[Template Tags/query posts|query_posts]], have_posts, in_the_loop, rewind_posts, the_post, wp_old_slug_redirect, setup_postdata</tt>, as well as the [[Conditional Tags]] <tt>is_*</tt>)
+
* [[/WP_Query|WP_Query]] - Request parsing and manipulation, posts fetching (with functions <tt>get_query_var, [[テンプレートタグ/query posts|query_posts]], have_posts, in_the_loop, rewind_posts, the_post, wp_old_slug_redirect, setup_postdata</tt>, as well as the [[Conditional Tags]] <tt>is_*</tt>)
* [[Function_Reference/WP_Rewrite|WP_Rewrite]] - Rewrite rules (and functions <tt>add_rewrite_rule, add_rewrite_tag, add_feed, add_rewrite_endpoint, url_to_postid</tt>)
+
* [[/WP_Rewrite|WP_Rewrite]] - Rewrite rules (and functions <tt>add_rewrite_rule, add_rewrite_tag, add_feed, add_rewrite_endpoint, url_to_postid</tt>)
 
* WP_Roles, WP_Role, WP_User - Users and capabilities (and functions <tt>map_meta_cap, current_user_can, get_role, add_role, remove_role</tt>)
 
* WP_Roles, WP_Role, WP_User - Users and capabilities (and functions <tt>map_meta_cap, current_user_can, get_role, add_role, remove_role</tt>)
 
* WP_Scripts - JavaScript loading (and functions <tt>wp_print_scripts, wp_register_script, wp_deregister_script, wp_enqueue_script</tt>)
 
* WP_Scripts - JavaScript loading (and functions <tt>wp_print_scripts, wp_register_script, wp_deregister_script, wp_enqueue_script</tt>)
* [[Function Reference/Walker Class|Walker]], Walker_Page, Walker_PageDropdown, Walker_Category, Walker_CategoryDropdown - Display tree-like data
+
* [[/Walker Class|Walker]], Walker_Page, Walker_PageDropdown, Walker_Category, Walker_CategoryDropdown - Display tree-like data
* [[Function_Reference/wpdb Class|wpdb]] - Database interface
+
* [[/wpdb Class|wpdb]] - Database interface
  
 
The following classes were created by outside developers, and are found in files <tt>class-IXR.php</tt>, <tt>class-pop3.php</tt>, <tt>class-snoopy.php</tt>, <tt>gettext.php</tt>, <tt>rss.php</tt>, <tt>streams.php</tt>:
 
The following classes were created by outside developers, and are found in files <tt>class-IXR.php</tt>, <tt>class-pop3.php</tt>, <tt>class-snoopy.php</tt>, <tt>gettext.php</tt>, <tt>rss.php</tt>, <tt>streams.php</tt>:
496行目: 496行目:
 
   
 
   
 
|}
 
|}
 +
 +
{{原文|Function Reference}}
  
 
{{stub}}
 
{{stub}}
  
[[Category:Advanced Topics]]
+
{{DEFAULTSORT:かんすうりふあれんす}}
[[Category:Functions]]
+
[[Category:上級トピック]]
[[Category:WordPress Development]]
+
[[Category:関数]]
 +
[[Category:WordPress の開発]]
 +
 
 +
[[en:Function Reference]]

2007年10月27日 (土) 00:56時点における版

The files of WordPress define many useful PHP functions. Some of the functions, known as Template Tags, are defined especially for use in WordPress themes. There are also some functions related to actions and filters (the Plugin API), which are therefore used primarily for developing plugins. The rest are used to create the core WordPress functionality.

Many of the core WordPress functions may also be useful to plugin developers, and to a lesser extent, possibly theme developers as well. So, this article lists most of the core functions, by category; some of the function names are also links to more detailed documentation in separate pages. Each category also lists the files where its functions can be found (the files are in the wp-includes directory of WordPress).

Note: This reference applies to Version 2.1 of WordPress, and does not include functions that have been deprecated as of that version of WordPress. An incomplete page for the 2.0.x versions of WordPress can be found at en:Function Reference 2.0.x.

Note: Functions specifically for templates, which are listed in the Template Tags article, and contained in files wp-includes/*_template.php, are not listed here.

Note: the WordPress Functions History Tool (unofficial tool) may help in finding when/if a function has been added/dropped.

You can help make this page more complete!

Here are some things you can do to help:

  • Add documentation to un-documented functions, by creating sub-pages or at least by adding short comments in the lists below. If you create a subpage for a function, please include information and examples of usage of that function, if possible, per the examples found in Template Tags.
  • List more functions here, following the category structure.
  • Remove functions from the list, if you think they could not possibly be useful to plugin developers, or if they have been deprecated.
  • Correct errors by moving functions to better categories where appropriate, and of course fixing typos. Note that it is OK for a function to appear in more than one category.

Read Contributing to WordPress to find out more about how you can contribute to the effort!


Functions by category

Post, Page, and Attachment Functions

These functions are contained in formatting.php, post.php. See also Template Tags.

  • wp_trim_excerpt
  • get_attached_file
  • update_attached_file
  • get_children
  • get_extended
  • get_post - get information on a specific post
  • get_post_mime_type($ID = "") - takes a post ID, returns its MIME type
  • get_post_status
  • get_post_type
  • get_posts
  • add_post_meta
  • delete_post_meta
  • get_post_meta
  • update_post_meta
  • get_post_custom
  • get_post_custom_keys
  • get_post_custom_values
  • wp_delete_post($postid) - A generic function to delete a post in the post table
  • wp_get_post_categories($postid) - Retrieves an array of IDs of categories for a post
  • get_recent_posts
  • get_single_post
  • wp_insert_post($postarr=array()) - A generic function for inserting data into the post table
  • wp_update_post($postarr=array()) - A generic function to update data in the post table
  • wp_publish_post($post_id) - Set a post's post_status to published. Calls wp_update_post.
  • wp_set_post_categories
  • get_all_page_ids
  • get_page
  • get_page_by_path
  • get_page_by_title
  • get_page_children
  • get_page_hierarchy
  • get_page_uri
  • get_pages
  • generate_page_uri_index
  • is_local_attachment
  • wp_insert_attachment
  • wp_delete_attachment
  • wp_get_attachment_metadata
  • wp_update_attachment_metadata
  • wp_get_attachment_url
  • wp_get_attachment_thumb_file
  • wp_get_attachment_thumb_url
  • wp_attachment_is_image
  • wp_mime_type_icon
  • wp_check_for_changed_slugs

Category, Tag and Taxonomy Functions

Functions surrounding the WordPress Terms tables, encompassing categories and tags for classifying posts, pages, links, etc.

Category functions in category.php.

  • get_all_category_ids
  • &get_categories($args='')
  • &get_category
  • get_category_by_path
  • get_category_by_slug
  • get_cat_ID($cat_name='General') - Get the ID of a category from its name
  • get_cat_name($cat_id) - get the name of a category from its ID
  • cat_is_ancestor_of

Tag Functions in category.php

  • &get_tags
  • &get_tag

Term Functions in taxonomy.php

  • is_taxonomy - Checks that the taxonomy name exists
  • is_taxonomy_hierarchical - Whether the taxonomy object is hierarchical
  • &get_term
  • get_term_by
  • get_term_children - Merge all term children into a single array.
  • &get_terms
  • is_term - Check if Term exists
  • wp_get_object_terms - Returns the terms associated with the given object(s), in the supplied taxonomies


User and Author Functions

These functions are in user.php, pluggable.php, registration.php. See also Template Functions.

  • get_profile
  • get_usernumposts — get post count for a specific user
  • delete_usermeta
  • get_usermeta — get meta data for a specific user
  • update_usermeta — Updates a piece of user meta data.
  • set_current_user
  • wp_set_current_user
  • wp_get_current_user
  • get_currentuserinfo — get information on the current user
  • get_userdata — get information on any user
  • get_userdatabylogin
  • wp_login
  • is_user_logged_in
  • auth_redirect
  • username_exists
  • email_exists
  • validate_username
  • wp_insert_user
  • wp_update_user
  • wp_create_user — Create a user and add it to the user database.

Feed Functions

These functions are in functions.php, feed.php, rss.php

  • fetch_rss -- retrieve an RSS feed from a URL with automatic caching (included in rss_functions.php)
  • wp_rss -- retrieve and display an RSS feed as an unordered list (included in rss_functions.php)
  • get_rss -- retrieve and display an RSS feed as a list (ordering optional) (included in rss_functions.php)
  • do_feed
  • do_feed_rdf
  • do_feed_rss
  • do_feed_rss2
  • do_feed_atom
  • get_bloginfo_rss
  • bloginfo_rss
  • get_the_title_rss
  • the_title_rss
  • the_content_rss
  • the_excerpt_rss
  • permalink_single_rss
  • comment_link
  • get_comment_author_rss
  • comment_author_rss
  • comment_text_rss
  • comments_rss_link
  • comments_rss
  • get_author_rss_link
  • get_category_rss_link
  • get_the_category_rss
  • the_category_rss
  • rss_enclosure

Comment, Ping, and Trackback Functions

These functions are found in comment.php, functions.php, post.php. See also Template Functions.

  • check_comment
  • get_approved_comments
  • get_comment
  • get_lastcommentmodified
  • sanitize_comment_cookies
  • wp_allow_comment
  • wp_delete_comment
  • wp_get_comment_status
  • wp_get_current_commenter
  • wp_insert_comment
  • wp_filter_comment
  • wp_throttle_comment_flood
  • wp_new_comment
  • wp_set_comment_status
  • wp_update_comment
  • wp_update_comment_count
  • discover_pingback_server_uri
  • do_all_pings
  • do_trackbacks
  • generic_ping
  • pingback
  • privacy_ping_filter
  • trackback
  • weblog_ping
  • do_enclose
  • add_ping
  • get_enclosed
  • get_pung
  • get_to_ping
  • trackback_url_list

Action, Filter, and Plugin Functions

These functions are contained in plugin.php. See also Plugin API.

Theme-Related Functions

These functions are found in theme.php.

  • get_stylesheet
  • get_stylesheet_directory
  • get_stylesheet_directory_uri
  • get_stylesheet_uri
  • get_locale_stylesheet_uri
  • get_template
  • get_template_directory
  • get_template_directory_uri
  • get_theme_data
  • get_themes
  • get_theme
  • get_current_theme
  • get_theme_root
  • get_theme_root_uri
  • get_query_template
  • get_404_template
  • get_archive_template
  • get_author_template
  • get_category_template
  • get_date_template
  • get_home_template
  • get_page_template
  • get_paged_template
  • get_search_template
  • get_single_template
  • get_attachment_template
  • get_comments_popup_template
  • load_template
  • locale_stylesheet
  • validate_current_theme
  • get_theme_mod
  • set_theme_mod
  • get_header_textcolor
  • get_header_image
  • header_image
  • add_custom_image_header


Formatting Functions

These functions are contained in formatting.php, functions.php, kses.php.

  • wptexturize( $text )
  • clean_pre( $text ) - Returns the text without BR tags, and with P tags turned into line-breaks
  • wpautop( $pee, $br = 1 ) - Returns the text with HTML formatting for paragraphs
  • seems_utf8($Str) - Returns true if given string seems like it is UTF8-encoded
  • wp_specialchars( $text, $quotes = 0 ) - Like the PHP function htmlspecialchars except it doesn't double-encode HTML entities
  • utf8_uri_encode
  • remove_accents($string) - Returns a string with accents or umlauts without these
  • sanitize_file_name
  • sanitize_user( $username, $strict = false ) - Makes the username more machine-readable. Strict option for pure ASCII only.
  • sanitize_title($title, $fallback_title = )
  • sanitize_title_with_dashes($title)
  • convert_chars($content, $flag = 'obsolete') - Translation of invalid Unicode references range to valid range
  • funky_javascript_fix
  • balanceTags($text, $is_comment = 0) - Balances Tags of string using a modified stack. Can be disabled by configuration.
  • force_balance_tags
  • format_to_edit
  • format_to_post
  • zeroise($number,$threshold) - Adds leading zeros when necessary
  • backslashit
  • trailingslashit
  • addslashes_gpc
  • stripslashes_deep
  • antispambot - converts email address to anti-spam version
  • make_clickable
  • wp_rel_nofollow
  • convert_smilies
  • is_email
  • wp_iso_descrambler
  • popuplinks - converts a link into a popup link that will open in a different window
  • sanitize_email
  • ent2ncr($text) - Returns HTML entity as its number representation.
  • wp_richedit_pre
  • clean_url
  • htmlentities2
  • js_escape
  • attribute_escape
  • wp_make_link_relative - makes an absolute link into a relative link
  • add_magic_quotes
  • wp_kses
  • wp_kses_hook
  • wp_kses_version
  • wp_kses_split
  • wp_kses_split2
  • wp_kses_attr
  • wp_kses_hair
  • wp_kses_check_attr_val
  • wp_kses_bad_protocol
  • wp_kses_no_null
  • wp_kses_strip_slashes
  • wp_kses_array_lc
  • wp_kses_js_entities
  • wp_kses_html_error
  • wp_kses_bad_protocol_once
  • wp_kses_bad_protocol_once2
  • wp_kses_normalize_entities
  • wp_kses_normalize_entities2
  • wp_kses_decode_entities
  • wp_filter_kses
  • wp_filter_post_kses
  • wp_filter_nohtml_kses

Miscellaneous Functions

These functions are contained in formatting.php, functions.php, bookmarks.php, cron.php, l10n.php, user.php, pluggable.php

Time/Date Functions

  • get_gmt_from_date
  • get_date_from_gmt
  • iso8601_timezone_to_offset
  • iso8601_to_datetime
  • human_time_diff
  • mysql2date
  • current_time
  • date_i18n
  • get_weekendstartend
  • get_lastpostdate
  • get_lastpostmodified
  • is_new_day

Serialization

  • maybe_serialize
  • maybe_unserialize
  • is_serialized
  • is_serialized_string

Options

XMLRPC

  • xmlrpc_getposttitle
  • xmlrpc_getpostcategory
  • xmlrpc_removepostdata
  • user_pass_ok

Localization

See also Translating WordPress.

  • get_locale
  • __
  • _e
  • _ngettext
  • load_textdomain
  • load_default_textdomain
  • load_plugin_textdomain
  • load_theme_textdomain

Cron (Scheduling)

Miscellaneous

  • gzip_compression
  • make_url_footnote
  • wp_get_http_headers
  • add_query_arg
  • remove_query_arg
  • wp_remote_fopen
  • wp
  • status_header
  • nocache_headers
  • cache_javascript_headers
  • get_num_queries
  • bool_from_yn - converts a "Y/N" variable into boolean true/false
  • do_robots
  • is_blog_installed
  • wp_nonce_url
  • wp_nonce_field
  • wp_referer_field
  • wp_original_referer_field
  • wp_get_referer
  • wp_get_original_referer
  • wp_mkdir_p
  • wp_upload_dir
  • wp_upload_bits
  • wp_check_filetype
  • wp_explain_nonce
  • wp_nonce_ays
  • wp_die
  • get_bookmark
  • get_bookmarks
  • wp_mail
  • check_admin_referer
  • check_ajax_referer
  • wp_redirect
  • wp_get_cookie_login
  • wp_setcookie
  • wp_clearcookie
  • wp_notify_postauthor
  • wp_notify_moderator
  • wp_new_user_notification
  • wp_verify_nonce
  • wp_create_nonce
  • wp_salt
  • wp_hash

Classes

The following classes were created by WordPress developers, and are found in files capabilities.php, classes.php, class-snoopy.php, locale.php, query.php, rewrite.php, script-loader.php, wp-db.php:

  • WP - general request handling
  • WP_Ajax_Response - AJAX handling
  • WP_Object_Cache (formerly WP_Cache) - Object cache (and functions wp_cache_add, wp_cache_close, wp_cache_delete, wp_cache_flush, wp_cache_get, wp_cache_init, wp_cache_replace, wp_cache_set)
  • WP_Error - error handling (and function is_wp_error)
  • WP_Locale - handles date and time locales
  • WP_Query - Request parsing and manipulation, posts fetching (with functions get_query_var, query_posts, have_posts, in_the_loop, rewind_posts, the_post, wp_old_slug_redirect, setup_postdata, as well as the Conditional Tags is_*)
  • WP_Rewrite - Rewrite rules (and functions add_rewrite_rule, add_rewrite_tag, add_feed, add_rewrite_endpoint, url_to_postid)
  • WP_Roles, WP_Role, WP_User - Users and capabilities (and functions map_meta_cap, current_user_can, get_role, add_role, remove_role)
  • WP_Scripts - JavaScript loading (and functions wp_print_scripts, wp_register_script, wp_deregister_script, wp_enqueue_script)
  • Walker, Walker_Page, Walker_PageDropdown, Walker_Category, Walker_CategoryDropdown - Display tree-like data
  • wpdb - Database interface

The following classes were created by outside developers, and are found in files class-IXR.php, class-pop3.php, class-snoopy.php, gettext.php, rss.php, streams.php:

  • IXR - XML-RPC Classes, including IXR_Value, IXR_Message, IXR_Server, IXR_IntrospectionServer, IXR_Request, IXR_Client, IXR_ClientMulticall, IXR_Error, IXR_Date, IXR_Base64
  • Snoopy - HTTP client
  • gettext_reader (part of PHP-gettext) - Localization Class
  • RSS Classes (MagpieRSS and RSSCache) (and functions fetch_rss, is_info, is_success, is_redirect, is_error, is_client_error, is_server_error, parse_w3cdtf, wp_rss, get_rss)
  • POP3: SquirrelMail wrapper
  • StreamReader, StringReader, FileReader, CachedFileReader

最新英語版: WordPress Codex » Function Reference

テンプレート:stub