General inline documentation improvements in wp-includes/functions.php.

Second run. See #26185.


git-svn-id: https://develop.svn.wordpress.org/trunk@28936 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Drew Jaynes (DrewAPicture) 2014-07-01 01:43:48 +00:00
parent 8b0ef058f3
commit ecb39eaccb

View File

@ -641,7 +641,7 @@ function wp_get_http_headers( $url, $deprecated = false ) {
* @global string $currentday The day of the current post in the loop. * @global string $currentday The day of the current post in the loop.
* @global string $previousday The day of the previous post in the loop. * @global string $previousday The day of the previous post in the loop.
* *
* @return int 1 when new day, 0 if not a new day. * @return int|bool 1|true when new day, 0|false if not a new day.
*/ */
function is_new_day() { function is_new_day() {
global $currentday, $previousday; global $currentday, $previousday;
@ -657,14 +657,14 @@ function is_new_day() {
* This is a convenient function for easily building url queries. It sets the * This is a convenient function for easily building url queries. It sets the
* separator to '&' and uses _http_build_query() function. * separator to '&' and uses _http_build_query() function.
* *
* @see _http_build_query() Used to build the query
* @link http://us2.php.net/manual/en/function.http-build-query.php more on what
* http_build_query() does.
*
* @since 2.3.0 * @since 2.3.0
* *
* @see _http_build_query() Used to build the query
* @see http://us2.php.net/manual/en/function.http-build-query.php for more on what
* http_build_query() does.
*
* @param array $data URL-encode key/value pairs. * @param array $data URL-encode key/value pairs.
* @return string URL encoded string * @return string URL-encoded string.
*/ */
function build_query( $data ) { function build_query( $data ) {
return _http_build_query( $data, null, '&', '', false ); return _http_build_query( $data, null, '&', '', false );
@ -729,9 +729,9 @@ function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urle
* *
* @since 1.5.0 * @since 1.5.0
* *
* @param mixed $param1 Either newkey or an associative_array * @param string|array $param1 Either newkey or an associative_array.
* @param mixed $param2 Either newvalue or oldquery or uri * @param string $param2 Either newvalue or oldquery or URI.
* @param mixed $param3 Optional. Old query or uri * @param string $param3 Optional. Old query or URI.
* @return string New URL query string. * @return string New URL query string.
*/ */
function add_query_arg() { function add_query_arg() {
@ -802,10 +802,10 @@ function add_query_arg() {
* @since 1.5.0 * @since 1.5.0
* *
* @param string|array $key Query key or keys to remove. * @param string|array $key Query key or keys to remove.
* @param bool $query When false uses the $_SERVER value. * @param bool $query Optional. When false uses the $_SERVER value. Default false.
* @return string New URL query string. * @return string New URL query string.
*/ */
function remove_query_arg( $key, $query=false ) { function remove_query_arg( $key, $query = false ) {
if ( is_array( $key ) ) { // removing multiple keys if ( is_array( $key ) ) { // removing multiple keys
foreach ( $key as $k ) foreach ( $key as $k )
$query = add_query_arg( $k, false, $query ); $query = add_query_arg( $k, false, $query );
@ -837,7 +837,8 @@ function add_magic_quotes( $array ) {
* HTTP request for URI to retrieve content. * HTTP request for URI to retrieve content.
* *
* @since 1.5.1 * @since 1.5.1
* @uses wp_remote_get() *
* @see wp_safe_remote_get()
* *
* @param string $uri URI/URL of web page to retrieve. * @param string $uri URI/URL of web page to retrieve.
* @return bool|string HTTP content. False on failure. * @return bool|string HTTP content. False on failure.
@ -962,6 +963,7 @@ function get_status_header_desc( $code ) {
* Set HTTP status header. * Set HTTP status header.
* *
* @since 2.0.0 * @since 2.0.0
*
* @see get_status_header_desc() * @see get_status_header_desc()
* *
* @param int $code HTTP status code. * @param int $code HTTP status code.
@ -994,10 +996,10 @@ function status_header( $code ) {
} }
/** /**
* Gets the header information to prevent caching. * Get the header information to prevent caching.
* *
* The several different headers cover the different ways cache prevention is handled * The several different headers cover the different ways cache prevention
* by different browsers * is handled by different browsers
* *
* @since 2.8.0 * @since 2.8.0
* *
@ -1016,6 +1018,8 @@ function wp_get_nocache_headers() {
* *
* @since 2.8.0 * @since 2.8.0
* *
* @see wp_get_nocache_headers()
*
* @param array $headers { * @param array $headers {
* Header names and field values. * Header names and field values.
* *
@ -1031,12 +1035,14 @@ function wp_get_nocache_headers() {
} }
/** /**
* Sets the headers to prevent caching for the different browsers. * Set the headers to prevent caching for the different browsers.
* *
* Different browsers support different nocache headers, so several headers must * Different browsers support different nocache headers, so several
* be sent so that all of them get the point that no caching should occur. * headers must be sent so that all of them get the point that no
* caching should occur.
* *
* @since 2.0.0 * @since 2.0.0
*
* @see wp_get_nocache_headers() * @see wp_get_nocache_headers()
*/ */
function nocache_headers() { function nocache_headers() {
@ -1069,6 +1075,7 @@ function nocache_headers() {
*/ */
function cache_javascript_headers() { function cache_javascript_headers() {
$expiresOffset = 10 * DAY_IN_SECONDS; $expiresOffset = 10 * DAY_IN_SECONDS;
header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) ); header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) );
header( "Vary: Accept-Encoding" ); // Handle proxies header( "Vary: Accept-Encoding" ); // Handle proxies
header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" ); header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" );
@ -1079,7 +1086,9 @@ function cache_javascript_headers() {
* *
* @since 2.0.0 * @since 2.0.0
* *
* @return int Number of database queries * @global wpdb $wpdb WordPress database access abstraction object.
*
* @return int Number of database queries.
*/ */
function get_num_queries() { function get_num_queries() {
global $wpdb; global $wpdb;
@ -1087,19 +1096,21 @@ function get_num_queries() {
} }
/** /**
* Whether input is yes or no. Must be 'y' to be true. * Whether input is yes or no.
*
* Must be 'y' to be true.
* *
* @since 1.0.0 * @since 1.0.0
* *
* @param string $yn Character string containing either 'y' or 'n' * @param string $yn Character string containing either 'y' (yes) or 'n' (no).
* @return bool True if yes, false on anything else * @return bool True if yes, false on anything else.
*/ */
function bool_from_yn( $yn ) { function bool_from_yn( $yn ) {
return ( strtolower( $yn ) == 'y' ); return ( strtolower( $yn ) == 'y' );
} }
/** /**
* Loads the feed template from the use of an action hook. * Load the feed template from the use of an action hook.
* *
* If the feed action does not have a hook, then the function will die with a * If the feed action does not have a hook, then the function will die with a
* message telling the visitor that the feed is not valid. * message telling the visitor that the feed is not valid.
@ -1141,6 +1152,8 @@ function do_feed() {
* Load the RDF RSS 0.91 Feed template. * Load the RDF RSS 0.91 Feed template.
* *
* @since 2.1.0 * @since 2.1.0
*
* @see load_template()
*/ */
function do_feed_rdf() { function do_feed_rdf() {
load_template( ABSPATH . WPINC . '/feed-rdf.php' ); load_template( ABSPATH . WPINC . '/feed-rdf.php' );
@ -1150,6 +1163,8 @@ function do_feed_rdf() {
* Load the RSS 1.0 Feed Template. * Load the RSS 1.0 Feed Template.
* *
* @since 2.1.0 * @since 2.1.0
*
* @see load_template()
*/ */
function do_feed_rss() { function do_feed_rss() {
load_template( ABSPATH . WPINC . '/feed-rss.php' ); load_template( ABSPATH . WPINC . '/feed-rss.php' );
@ -1160,6 +1175,8 @@ function do_feed_rss() {
* *
* @since 2.1.0 * @since 2.1.0
* *
* @see load_template()
*
* @param bool $for_comments True for the comment feed, false for normal feed. * @param bool $for_comments True for the comment feed, false for normal feed.
*/ */
function do_feed_rss2( $for_comments ) { function do_feed_rss2( $for_comments ) {
@ -1174,6 +1191,8 @@ function do_feed_rss2( $for_comments ) {
* *
* @since 2.1.0 * @since 2.1.0
* *
* @see load_template()
*
* @param bool $for_comments True for the comment feed, false for normal feed. * @param bool $for_comments True for the comment feed, false for normal feed.
*/ */
function do_feed_atom( $for_comments ) { function do_feed_atom( $for_comments ) {
@ -1225,21 +1244,25 @@ function do_robots() {
/** /**
* Test whether blog is already installed. * Test whether blog is already installed.
* *
* The cache will be checked first. If you have a cache plugin, which saves the * The cache will be checked first. If you have a cache plugin, which saves
* cache values, then this will work. If you use the default WordPress cache, * the cache values, then this will work. If you use the default WordPress
* and the database goes away, then you might have problems. * cache, and the database goes away, then you might have problems.
* *
* Checks for the option siteurl for whether WordPress is installed. * Checks for the 'siteurl' option for whether WordPress is installed.
* *
* @since 2.1.0 * @since 2.1.0
* @uses $wpdb
* *
* @return bool Whether blog is already installed. * @global wpdb $wpdb WordPress database access abstraction object.
*
* @return bool Whether the blog is already installed.
*/ */
function is_blog_installed() { function is_blog_installed() {
global $wpdb; global $wpdb;
// Check cache first. If options table goes away and we have true cached, oh well. /*
* Check cache first. If options table goes away and we have true
* cached, oh well.
*/
if ( wp_cache_get( 'is_blog_installed' ) ) if ( wp_cache_get( 'is_blog_installed' ) )
return true; return true;
@ -1266,9 +1289,11 @@ function is_blog_installed() {
$suppress = $wpdb->suppress_errors(); $suppress = $wpdb->suppress_errors();
// Loop over the WP tables. If none exist, then scratch install is allowed. /*
// If one or more exist, suggest table repair since we got here because the options * Loop over the WP tables. If none exist, then scratch install is allowed.
// table could not be accessed. * If one or more exist, suggest table repair since we got here because the
* options table could not be accessed.
*/
$wp_tables = $wpdb->tables(); $wp_tables = $wpdb->tables();
foreach ( $wp_tables as $table ) { foreach ( $wp_tables as $table ) {
// The existence of custom user tables shouldn't suggest an insane state or prevent a clean install. // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
@ -1302,8 +1327,8 @@ function is_blog_installed() {
* @since 2.0.4 * @since 2.0.4
* *
* @param string $actionurl URL to add nonce action. * @param string $actionurl URL to add nonce action.
* @param string $action Optional. Nonce action name. * @param string $action Optional. Nonce action name. Default -1.
* @param string $name Optional. Nonce name. * @param string $name Optional. Nonce name. Default '_wpnonce'.
* @return string Escaped URL with nonce action added. * @return string Escaped URL with nonce action added.
*/ */
function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) { function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) {
@ -1331,11 +1356,11 @@ function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) {
* *
* @since 2.0.4 * @since 2.0.4
* *
* @param string $action Optional. Action name. * @param string $action Optional. Action name. Default -1.
* @param string $name Optional. Nonce name. * @param string $name Optional. Nonce name. Default '_wpnonce'.
* @param bool $referer Optional, default true. Whether to set the referer field for validation. * @param bool $referer Optional. Whether to set the referer field for validation. Default true.
* @param bool $echo Optional, default true. Whether to display or return hidden form field. * @param bool $echo Optional. Whether to display or return hidden form field. Default true.
* @return string Nonce field. * @return string Nonce field HTML markup.
*/ */
function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) { function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
$name = esc_attr( $name ); $name = esc_attr( $name );
@ -1358,8 +1383,8 @@ function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $ec
* *
* @since 2.0.4 * @since 2.0.4
* *
* @param bool $echo Whether to echo or return the referer field. * @param bool $echo Optional. Whether to echo or return the referer field. Default true.
* @return string Referer field. * @return string Referer field HTML markup.
*/ */
function wp_referer_field( $echo = true ) { function wp_referer_field( $echo = true ) {
$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />'; $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
@ -1373,13 +1398,14 @@ function wp_referer_field( $echo = true ) {
* Retrieve or display original referer hidden field for forms. * Retrieve or display original referer hidden field for forms.
* *
* The input name is '_wp_original_http_referer' and will be either the same * The input name is '_wp_original_http_referer' and will be either the same
* value of {@link wp_referer_field()}, if that was posted already or it will * value of wp_referer_field(), if that was posted already or it will be the
* be the current page, if it doesn't exist. * current page, if it doesn't exist.
* *
* @since 2.0.4 * @since 2.0.4
* *
* @param bool $echo Whether to echo the original http referer * @param bool $echo Optional. Whether to echo the original http referer. Default true.
* @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to. * @param string $jump_back_to Optional. Can be 'previous' or page you want to jump back to.
* Default 'current'.
* @return string Original referer field. * @return string Original referer field.
*/ */
function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) { function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
@ -1393,8 +1419,9 @@ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
} }
/** /**
* Retrieve referer from '_wp_http_referer' or HTTP referer. If it's the same * Retrieve referer from '_wp_http_referer' or HTTP referer.
* as the current request URL, will return false. *
* If it's the same as the current request URL, will return false.
* *
* @since 2.0.4 * @since 2.0.4
* *
@ -1440,21 +1467,24 @@ function wp_get_original_referer() {
function wp_mkdir_p( $target ) { function wp_mkdir_p( $target ) {
$wrapper = null; $wrapper = null;
// strip the protocol // Strip the protocol.
if( wp_is_stream( $target ) ) { if( wp_is_stream( $target ) ) {
list( $wrapper, $target ) = explode( '://', $target, 2 ); list( $wrapper, $target ) = explode( '://', $target, 2 );
} }
// from php.net/mkdir user contributed notes // From php.net/mkdir user contributed notes.
$target = str_replace( '//', '/', $target ); $target = str_replace( '//', '/', $target );
// put the wrapper back on the target // Put the wrapper back on the target.
if( $wrapper !== null ) { if( $wrapper !== null ) {
$target = $wrapper . '://' . $target; $target = $wrapper . '://' . $target;
} }
// safe mode fails with a trailing slash under certain PHP versions. /*
$target = rtrim($target, '/'); // Use rtrim() instead of untrailingslashit to avoid formatting.php dependency. * Safe mode fails with a trailing slash under certain PHP versions.
* Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
*/
$target = rtrim($target, '/');
if ( empty($target) ) if ( empty($target) )
$target = '/'; $target = '/';
@ -1476,7 +1506,10 @@ function wp_mkdir_p( $target ) {
if ( @mkdir( $target, $dir_perms, true ) ) { if ( @mkdir( $target, $dir_perms, true ) ) {
// If a umask is set that modifies $dir_perms, we'll have to re-set the $dir_perms correctly with chmod() /*
* If a umask is set that modifies $dir_perms, we'll have to re-set
* the $dir_perms correctly with chmod()
*/
if ( $dir_perms != ( $dir_perms & ~umask() ) ) { if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
$folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) ); $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
for ( $i = 1; $i <= count( $folder_parts ); $i++ ) { for ( $i = 1; $i <= count( $folder_parts ); $i++ ) {
@ -1491,38 +1524,44 @@ function wp_mkdir_p( $target ) {
} }
/** /**
* Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows'). * Test if a give filesystem path is absolute.
*
* For example, '/foo/bar', or 'c:\windows'.
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param string $path File path * @param string $path File path.
* @return bool True if path is absolute, false is not absolute. * @return bool True if path is absolute, false is not absolute.
*/ */
function path_is_absolute( $path ) { function path_is_absolute( $path ) {
// this is definitive if true but fails if $path does not exist or contains a symbolic link /*
* This is definitive if true but fails if $path does not exist or contains
* a symbolic link.
*/
if ( realpath($path) == $path ) if ( realpath($path) == $path )
return true; return true;
if ( strlen($path) == 0 || $path[0] == '.' ) if ( strlen($path) == 0 || $path[0] == '.' )
return false; return false;
// windows allows absolute paths like this // Windows allows absolute paths like this.
if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
return true; return true;
// a path starting with / or \ is absolute; anything else is relative // A path starting with / or \ is absolute; anything else is relative.
return ( $path[0] == '/' || $path[0] == '\\' ); return ( $path[0] == '/' || $path[0] == '\\' );
} }
/** /**
* Join two filesystem paths together (e.g. 'give me $path relative to $base'). * Join two filesystem paths together.
* *
* If the $path is absolute, then it the full path is returned. * For example, 'give me $path relative to $base'. If the $path is absolute,
* then it the full path is returned.
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param string $base * @param string $base Base path.
* @param string $path * @param string $path Path relative to $base.
* @return string The path with the base or absolute path. * @return string The path with the base or absolute path.
*/ */
function path_join( $base, $path ) { function path_join( $base, $path ) {
@ -1535,8 +1574,8 @@ function path_join( $base, $path ) {
/** /**
* Normalize a filesystem path. * Normalize a filesystem path.
* *
* Replaces backslashes with forward slashes for Windows systems, * Replaces backslashes with forward slashes for Windows systems, and ensures
* and ensures no duplicate slashes exist. * no duplicate slashes exist.
* *
* @since 3.9.0 * @since 3.9.0
* *
@ -1550,18 +1589,18 @@ function wp_normalize_path( $path ) {
} }
/** /**
* Determines a writable directory for temporary files. * Determine a writable directory for temporary files.
* Function's preference is the return value of <code>sys_get_temp_dir()</code>, *
* Function's preference is the return value of sys_get_temp_dir(),
* followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR, * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR,
* before finally defaulting to /tmp/ * before finally defaulting to /tmp/
* *
* In the event that this function does not find a writable location, * In the event that this function does not find a writable location,
* It may be overridden by the <code>WP_TEMP_DIR</code> constant in * It may be overridden by the WP_TEMP_DIR constant in your wp-config.php file.
* your <code>wp-config.php</code> file.
* *
* @since 2.5.0 * @since 2.5.0
* *
* @return string Writable temporary directory * @return string Writable temporary directory.
*/ */
function get_temp_dir() { function get_temp_dir() {
static $temp; static $temp;
@ -1592,15 +1631,15 @@ function get_temp_dir() {
/** /**
* Determine if a directory is writable. * Determine if a directory is writable.
* *
* This function is used to work around certain ACL issues * This function is used to work around certain ACL issues in PHP primarily
* in PHP primarily affecting Windows Servers. * affecting Windows Servers.
*
* @see win_is_writable()
* *
* @since 3.6.0 * @since 3.6.0
* *
* @param string $path * @see win_is_writable()
* @return bool *
* @param string $path Path to check for write-ability.
* @return bool Whether the path is writable.
*/ */
function wp_is_writable( $path ) { function wp_is_writable( $path ) {
if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
@ -1617,13 +1656,13 @@ function wp_is_writable( $path ) {
* checking the ability to open files rather than relying * checking the ability to open files rather than relying
* upon PHP to interprate the OS ACL. * upon PHP to interprate the OS ACL.
* *
* @link http://bugs.php.net/bug.php?id=27609
* @link http://bugs.php.net/bug.php?id=30931
*
* @since 2.8.0 * @since 2.8.0
* *
* @param string $path * @see http://bugs.php.net/bug.php?id=27609
* @return bool * @see http://bugs.php.net/bug.php?id=30931
*
* @param string $path Windows path to check for write-ability.
* @return bool Whether the path is writable.
*/ */
function win_is_writable( $path ) { function win_is_writable( $path ) {
@ -1672,7 +1711,7 @@ function win_is_writable( $path ) {
* *
* @since 2.0.0 * @since 2.0.0
* *
* @param string $time Optional. Time formatted in 'yyyy/mm'. * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
* @return array See above for description. * @return array See above for description.
*/ */
function wp_upload_dir( $time = null ) { function wp_upload_dir( $time = null ) {
@ -1695,8 +1734,10 @@ function wp_upload_dir( $time = null ) {
$url = trailingslashit( $siteurl ) . $upload_path; $url = trailingslashit( $siteurl ) . $upload_path;
} }
// Obey the value of UPLOADS. This happens as long as ms-files rewriting is disabled. /*
// We also sometimes obey UPLOADS when rewriting is enabled -- see the next block. * Honor the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
* We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
*/
if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) { if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) {
$dir = ABSPATH . UPLOADS; $dir = ABSPATH . UPLOADS;
$url = trailingslashit( $siteurl ) . UPLOADS; $url = trailingslashit( $siteurl ) . UPLOADS;
@ -1706,11 +1747,14 @@ function wp_upload_dir( $time = null ) {
if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) {
if ( ! get_site_option( 'ms_files_rewriting' ) ) { if ( ! get_site_option( 'ms_files_rewriting' ) ) {
// If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward: /*
// Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory * If ms-files rewriting is disabled (networks created post-3.5), it is fairly
// prevents a four-digit ID from conflicting with a year-based directory for the main site. * straightforward: Append sites/%d if we're not on the main site (for post-MU
// But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra * networks). (The extra directory prevents a four-digit ID from conflicting with
// directory, as they never had wp-content/uploads for the main site.) * a year-based directory for the main site. But if a MU-era network has disabled
* ms-files rewriting manually, they don't need the extra directory, as they never
* had wp-content/uploads for the main site.)
*/
if ( defined( 'MULTISITE' ) ) if ( defined( 'MULTISITE' ) )
$ms_dir = '/sites/' . get_current_blog_id(); $ms_dir = '/sites/' . get_current_blog_id();
@ -1721,17 +1765,19 @@ function wp_upload_dir( $time = null ) {
$url .= $ms_dir; $url .= $ms_dir;
} elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) {
// Handle the old-form ms-files.php rewriting if the network still has that enabled. /*
// When ms-files rewriting is enabled, then we only listen to UPLOADS when: * Handle the old-form ms-files.php rewriting if the network still has that enabled.
// 1) we are not on the main site in a post-MU network, * When ms-files rewriting is enabled, then we only listen to UPLOADS when:
// as wp-content/uploads is used there, and * 1) We are not on the main site in a post-MU network, as wp-content/uploads is used
// 2) we are not switched, as ms_upload_constants() hardcodes * there, and
// these constants to reflect the original blog ID. * 2) We are not switched, as ms_upload_constants() hardcodes these constants to reflect
// * the original blog ID.
// Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute. *
// (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as * Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute.
// as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files * (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as
// rewriting in multisite, the resulting URL is /files. (#WP22702 for background.) * as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
* rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
*/
if ( defined( 'BLOGUPLOADDIR' ) ) if ( defined( 'BLOGUPLOADDIR' ) )
$dir = untrailingslashit( BLOGUPLOADDIR ); $dir = untrailingslashit( BLOGUPLOADDIR );
@ -1775,7 +1821,7 @@ function wp_upload_dir( $time = null ) {
'error' => false, 'error' => false,
) ); ) );
// Make sure we have an uploads dir // Make sure we have an uploads directory.
if ( ! wp_mkdir_p( $uploads['path'] ) ) { if ( ! wp_mkdir_p( $uploads['path'] ) ) {
if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) if ( 0 === strpos( $uploads['basedir'], ABSPATH ) )
$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
@ -1801,36 +1847,39 @@ function wp_upload_dir( $time = null ) {
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param string $dir * @param string $dir Directory.
* @param string $filename * @param string $filename File name.
* @param mixed $unique_filename_callback Callback. * @param callback $unique_filename_callback Callback. Default null.
* @return string New filename, if given wasn't unique. * @return string New filename, if given wasn't unique.
*/ */
function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) { function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) {
// sanitize the file name before we begin processing // Sanitize the file name before we begin processing.
$filename = sanitize_file_name($filename); $filename = sanitize_file_name($filename);
// separate the filename into a name and extension // Separate the filename into a name and extension.
$info = pathinfo($filename); $info = pathinfo($filename);
$ext = !empty($info['extension']) ? '.' . $info['extension'] : ''; $ext = !empty($info['extension']) ? '.' . $info['extension'] : '';
$name = basename($filename, $ext); $name = basename($filename, $ext);
// edge case: if file is named '.ext', treat as an empty name // Edge case: if file is named '.ext', treat as an empty name.
if ( $name === $ext ) if ( $name === $ext )
$name = ''; $name = '';
// Increment the file number until we have a unique file to save in $dir. Use callback if supplied. /*
* Increment the file number until we have a unique file to save in $dir.
* Use callback if supplied.
*/
if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) { if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) {
$filename = call_user_func( $unique_filename_callback, $dir, $name, $ext ); $filename = call_user_func( $unique_filename_callback, $dir, $name, $ext );
} else { } else {
$number = ''; $number = '';
// change '.ext' to lower case // Change '.ext' to lower case.
if ( $ext && strtolower($ext) != $ext ) { if ( $ext && strtolower($ext) != $ext ) {
$ext2 = strtolower($ext); $ext2 = strtolower($ext);
$filename2 = preg_replace( '|' . preg_quote($ext) . '$|', $ext2, $filename ); $filename2 = preg_replace( '|' . preg_quote($ext) . '$|', $ext2, $filename );
// check for both lower and upper case extension or image sub-sizes may be overwritten // Check for both lower and upper case extension or image sub-sizes may be overwritten.
while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) { while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) {
$new_number = $number + 1; $new_number = $number + 1;
$filename = str_replace( "$number$ext", "$new_number$ext", $filename ); $filename = str_replace( "$number$ext", "$new_number$ext", $filename );
@ -1868,10 +1917,10 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
* *
* @since 2.0.0 * @since 2.0.0
* *
* @param string $name * @param string $name Filename.
* @param null $deprecated Never used. Set to null. * @param null $deprecated Never used. Set to null.
* @param mixed $bits File content * @param mixed $bits File content
* @param string $time Optional. Time formatted in 'yyyy/mm'. * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
* @return array * @return array
*/ */
function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
@ -2012,6 +2061,7 @@ function wp_check_filetype( $filename, $mimes = null ) {
/** /**
* Attempt to determine the real file type of a file. * Attempt to determine the real file type of a file.
*
* If unable to, the file name extension will be used to determine type. * If unable to, the file name extension will be used to determine type.
* *
* If it's determined that the extension does not match the file's real type, * If it's determined that the extension does not match the file's real type,
@ -2022,9 +2072,11 @@ function wp_check_filetype( $filename, $mimes = null ) {
* @since 3.0.0 * @since 3.0.0
* *
* @param string $file Full path to the file. * @param string $file Full path to the file.
* @param string $filename The name of the file (may differ from $file due to $file being in a tmp directory) * @param string $filename The name of the file (may differ from $file due to $file being
* in a tmp directory).
* @param array $mimes Optional. Key is the file extension with value as the mime type. * @param array $mimes Optional. Key is the file extension with value as the mime type.
* @return array Values for the extension, MIME, and either a corrected filename or false if original $filename is valid * @return array Values for the extension, MIME, and either a corrected filename or false
* if original $filename is valid.
*/ */
function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
@ -2116,14 +2168,14 @@ function wp_get_mime_types() {
* corresponding to those types. * corresponding to those types.
*/ */
return apply_filters( 'mime_types', array( return apply_filters( 'mime_types', array(
// Image formats // Image formats.
'jpg|jpeg|jpe' => 'image/jpeg', 'jpg|jpeg|jpe' => 'image/jpeg',
'gif' => 'image/gif', 'gif' => 'image/gif',
'png' => 'image/png', 'png' => 'image/png',
'bmp' => 'image/bmp', 'bmp' => 'image/bmp',
'tif|tiff' => 'image/tiff', 'tif|tiff' => 'image/tiff',
'ico' => 'image/x-icon', 'ico' => 'image/x-icon',
// Video formats // Video formats.
'asf|asx' => 'video/x-ms-asf', 'asf|asx' => 'video/x-ms-asf',
'wmv' => 'video/x-ms-wmv', 'wmv' => 'video/x-ms-wmv',
'wmx' => 'video/x-ms-wmx', 'wmx' => 'video/x-ms-wmx',
@ -2139,7 +2191,7 @@ function wp_get_mime_types() {
'mkv' => 'video/x-matroska', 'mkv' => 'video/x-matroska',
'3gp|3gpp' => 'video/3gpp', // Can also be audio '3gp|3gpp' => 'video/3gpp', // Can also be audio
'3g2|3gp2' => 'video/3gpp2', // Can also be audio '3g2|3gp2' => 'video/3gpp2', // Can also be audio
// Text formats // Text formats.
'txt|asc|c|cc|h|srt' => 'text/plain', 'txt|asc|c|cc|h|srt' => 'text/plain',
'csv' => 'text/csv', 'csv' => 'text/csv',
'tsv' => 'text/tab-separated-values', 'tsv' => 'text/tab-separated-values',
@ -2149,7 +2201,7 @@ function wp_get_mime_types() {
'htm|html' => 'text/html', 'htm|html' => 'text/html',
'vtt' => 'text/vtt', 'vtt' => 'text/vtt',
'dfxp' => 'application/ttaf+xml', 'dfxp' => 'application/ttaf+xml',
// Audio formats // Audio formats.
'mp3|m4a|m4b' => 'audio/mpeg', 'mp3|m4a|m4b' => 'audio/mpeg',
'ra|ram' => 'audio/x-realaudio', 'ra|ram' => 'audio/x-realaudio',
'wav' => 'audio/wav', 'wav' => 'audio/wav',
@ -2158,7 +2210,7 @@ function wp_get_mime_types() {
'wma' => 'audio/x-ms-wma', 'wma' => 'audio/x-ms-wma',
'wax' => 'audio/x-ms-wax', 'wax' => 'audio/x-ms-wax',
'mka' => 'audio/x-matroska', 'mka' => 'audio/x-matroska',
// Misc application formats // Misc application formats.
'rtf' => 'application/rtf', 'rtf' => 'application/rtf',
'js' => 'application/javascript', 'js' => 'application/javascript',
'pdf' => 'application/pdf', 'pdf' => 'application/pdf',
@ -2170,7 +2222,7 @@ function wp_get_mime_types() {
'rar' => 'application/rar', 'rar' => 'application/rar',
'7z' => 'application/x-7z-compressed', '7z' => 'application/x-7z-compressed',
'exe' => 'application/x-msdownload', 'exe' => 'application/x-msdownload',
// MS Office formats // MS Office formats.
'doc' => 'application/msword', 'doc' => 'application/msword',
'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
'wri' => 'application/vnd.ms-write', 'wri' => 'application/vnd.ms-write',
@ -2199,7 +2251,7 @@ function wp_get_mime_types() {
'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote', 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote',
'oxps' => 'application/oxps', 'oxps' => 'application/oxps',
'xps' => 'application/vnd.ms-xpsdocument', 'xps' => 'application/vnd.ms-xpsdocument',
// OpenOffice formats // OpenOffice formats.
'odt' => 'application/vnd.oasis.opendocument.text', 'odt' => 'application/vnd.oasis.opendocument.text',
'odp' => 'application/vnd.oasis.opendocument.presentation', 'odp' => 'application/vnd.oasis.opendocument.presentation',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
@ -2207,9 +2259,9 @@ function wp_get_mime_types() {
'odc' => 'application/vnd.oasis.opendocument.chart', 'odc' => 'application/vnd.oasis.opendocument.chart',
'odb' => 'application/vnd.oasis.opendocument.database', 'odb' => 'application/vnd.oasis.opendocument.database',
'odf' => 'application/vnd.oasis.opendocument.formula', 'odf' => 'application/vnd.oasis.opendocument.formula',
// WordPerfect formats // WordPerfect formats.
'wp|wpd' => 'application/wordperfect', 'wp|wpd' => 'application/wordperfect',
// iWork formats // iWork formats.
'key' => 'application/vnd.apple.keynote', 'key' => 'application/vnd.apple.keynote',
'numbers' => 'application/vnd.apple.numbers', 'numbers' => 'application/vnd.apple.numbers',
'pages' => 'application/vnd.apple.pages', 'pages' => 'application/vnd.apple.pages',
@ -2223,7 +2275,8 @@ function wp_get_mime_types() {
* @uses wp_get_upload_mime_types() to fetch the list of mime types * @uses wp_get_upload_mime_types() to fetch the list of mime types
* *
* @param int|WP_User $user Optional. User to check. Defaults to current user. * @param int|WP_User $user Optional. User to check. Defaults to current user.
* @return array Array of mime types keyed by the file extension regex corresponding to those types. * @return array Array of mime types keyed by the file extension regex corresponding
* to those types.
*/ */
function get_allowed_mime_types( $user = null ) { function get_allowed_mime_types( $user = null ) {
$t = wp_get_mime_types(); $t = wp_get_mime_types();
@ -2251,8 +2304,8 @@ function get_allowed_mime_types( $user = null ) {
/** /**
* Display "Are You Sure" message to confirm the action being taken. * Display "Are You Sure" message to confirm the action being taken.
* *
* If the action has the nonce explain message, then it will be displayed along * If the action has the nonce explain message, then it will be displayed
* with the "Are you sure?" message. * along with the "Are you sure?" message.
* *
* @since 2.0.4 * @since 2.0.4
* *
@ -2284,9 +2337,9 @@ function wp_nonce_ays( $action ) {
* *
* @since 2.0.4 * @since 2.0.4
* *
* @param string $message Error message. * @param string $message Optional. Error message. Default empty.
* @param string $title Error title. * @param string $title Optional. Error title. Default empty.
* @param string|array $args Optional arguments to control behavior. * @param string|array $args Optional. Arguments to control behavior. Default empty array.
*/ */
function wp_die( $message = '', $title = '', $args = array() ) { function wp_die( $message = '', $title = '', $args = array() ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
@ -2331,8 +2384,8 @@ function wp_die( $message = '', $title = '', $args = array() ) {
* @access private * @access private
* *
* @param string $message Error message. * @param string $message Error message.
* @param string $title Error title. * @param string $title Optional. Error title. Default empty.
* @param string|array $args Optional arguments to control behavior. * @param string|array $args Optional. Arguments to control behavior. Default empty array.
*/ */
function _default_wp_die_handler( $message, $title = '', $args = array() ) { function _default_wp_die_handler( $message, $title = '', $args = array() ) {
$defaults = array( 'response' => 500 ); $defaults = array( 'response' => 500 );
@ -2509,8 +2562,8 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
* @access private * @access private
* *
* @param string $message Error message. * @param string $message Error message.
* @param string $title Error title. * @param string $title Optional. Error title. Default empty.
* @param string|array $args Optional arguments to control behavior. * @param string|array $args Optional. Arguments to control behavior. Default empty array.
*/ */
function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) { function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
global $wp_xmlrpc_server; global $wp_xmlrpc_server;
@ -2533,7 +2586,7 @@ function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
* @since 3.4.0 * @since 3.4.0
* @access private * @access private
* *
* @param string $message Optional. Response to print. * @param string $message Optional. Response to print. Default empty.
*/ */
function _ajax_wp_die_handler( $message = '' ) { function _ajax_wp_die_handler( $message = '' ) {
if ( is_scalar( $message ) ) if ( is_scalar( $message ) )
@ -2549,7 +2602,7 @@ function _ajax_wp_die_handler( $message = '' ) {
* @since 3.4.0 * @since 3.4.0
* @access private * @access private
* *
* @param string $message Optional. Response to print. * @param string $message Optional. Response to print. Default empty.
*/ */
function _scalar_wp_die_handler( $message = '' ) { function _scalar_wp_die_handler( $message = '' ) {
if ( is_scalar( $message ) ) if ( is_scalar( $message ) )
@ -2562,7 +2615,8 @@ function _scalar_wp_die_handler( $message = '' ) {
* *
* @since 3.5.0 * @since 3.5.0
* *
* @param mixed $response Variable (usually an array or object) to encode as JSON, then print and die. * @param mixed $response Variable (usually an array or object) to encode as JSON,
* then print and die.
*/ */
function wp_send_json( $response ) { function wp_send_json( $response ) {
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
@ -2608,14 +2662,16 @@ function wp_send_json_error( $data = null ) {
/** /**
* Retrieve the WordPress home page URL. * Retrieve the WordPress home page URL.
* *
* If the constant named 'WP_HOME' exists, then it will be used and returned by * If the constant named 'WP_HOME' exists, then it will be used and returned
* the function. This can be used to counter the redirection on your local * by the function. This can be used to counter the redirection on your local
* development environment. * development environment.
* *
* @access private
* @since 2.2.0 * @since 2.2.0
* @access private
* *
* @param string $url URL for the home location * @see WP_HOME
*
* @param string $url URL for the home location.
* @return string Homepage location. * @return string Homepage location.
*/ */
function _config_wp_home( $url = '' ) { function _config_wp_home( $url = '' ) {
@ -2628,14 +2684,16 @@ function _config_wp_home( $url = '' ) {
* Retrieve the WordPress site URL. * Retrieve the WordPress site URL.
* *
* If the constant named 'WP_SITEURL' is defined, then the value in that * If the constant named 'WP_SITEURL' is defined, then the value in that
* constant will always be returned. This can be used for debugging a site on * constant will always be returned. This can be used for debugging a site
* your localhost while not having to change the database to your URL. * on your localhost while not having to change the database to your URL.
* *
* @access private
* @since 2.2.0 * @since 2.2.0
* @access private
*
* @see WP_SITEURL
* *
* @param string $url URL to set the WordPress site location. * @param string $url URL to set the WordPress site location.
* @return string The WordPress Site URL * @return string The WordPress Site URL.
*/ */
function _config_wp_siteurl( $url = '' ) { function _config_wp_siteurl( $url = '' ) {
if ( defined( 'WP_SITEURL' ) ) if ( defined( 'WP_SITEURL' ) )
@ -2646,15 +2704,16 @@ function _config_wp_siteurl( $url = '' ) {
/** /**
* Set the localized direction for MCE plugin. * Set the localized direction for MCE plugin.
* *
* Will only set the direction to 'rtl', if the WordPress locale has the text * Will only set the direction to 'rtl', if the WordPress locale has
* direction set to 'rtl'. * the text direction set to 'rtl'.
* *
* Fills in the 'directionality' setting, enables the 'directionality' plugin, * Fills in the 'directionality' setting, enables the 'directionality'
* and adds the 'ltr' button to 'toolbar1', formerly 'theme_advanced_buttons1' array * plugin, and adds the 'ltr' button to 'toolbar1', formerly
* keys. These keys are then returned in the $input (TinyMCE settings) array. * 'theme_advanced_buttons1' array keys. These keys are then returned
* in the $input (TinyMCE settings) array.
* *
* @access private
* @since 2.1.0 * @since 2.1.0
* @access private
* *
* @param array $input MCE settings array. * @param array $input MCE settings array.
* @return array Direction set for 'rtl', if needed by locale. * @return array Direction set for 'rtl', if needed by locale.
@ -2689,6 +2748,7 @@ function _mce_set_direction( $input ) {
* *
* @global array $wpsmiliestrans * @global array $wpsmiliestrans
* @global array $wp_smiliessearch * @global array $wp_smiliessearch
*
* @since 2.2.0 * @since 2.2.0
*/ */
function smilies_init() { function smilies_init() {
@ -2796,7 +2856,7 @@ function smilies_init() {
* @since 2.2.0 * @since 2.2.0
* *
* @param string|array $args Value to merge with $defaults * @param string|array $args Value to merge with $defaults
* @param array $defaults Array that serves as the defaults. * @param array $defaults Optional. Array that serves as the defaults. Default empty.
* @return array Merged user defined values with defaults. * @return array Merged user defined values with defaults.
*/ */
function wp_parse_args( $args, $defaults = '' ) { function wp_parse_args( $args, $defaults = '' ) {
@ -2817,8 +2877,8 @@ function wp_parse_args( $args, $defaults = '' ) {
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param array|string $list * @param array|string $list List of ids.
* @return array Sanitized array of IDs * @return array Sanitized array of IDs.
*/ */
function wp_parse_id_list( $list ) { function wp_parse_id_list( $list ) {
if ( !is_array($list) ) if ( !is_array($list) )
@ -2832,9 +2892,9 @@ function wp_parse_id_list( $list ) {
* *
* @since 3.1.0 * @since 3.1.0
* *
* @param array $array The original array * @param array $array The original array.
* @param array $keys The list of keys * @param array $keys The list of keys.
* @return array The array slice * @return array The array slice.
*/ */
function wp_array_slice_assoc( $array, $keys ) { function wp_array_slice_assoc( $array, $keys ) {
$slice = array(); $slice = array();
@ -2851,11 +2911,14 @@ function wp_array_slice_assoc( $array, $keys ) {
* @since 3.0.0 * @since 3.0.0
* *
* @param array $list An array of objects to filter * @param array $list An array of objects to filter
* @param array $args An array of key => value arguments to match against each object * @param array $args Optional. An array of key => value arguments to match
* @param string $operator The logical operation to perform. 'or' means only one element * against each object. Default empty array.
* from the array needs to match; 'and' means all elements must match. The default is 'and'. * @param string $operator Optional. The logical operation to perform. 'or' means
* @param bool|string $field A field from the object to place instead of the entire object * only one element from the array needs to match; 'and'
* @return array A list of objects or object fields * means all elements must match. Default 'and'.
* @param bool|string $field A field from the object to place instead of the entire object.
* Default false.
* @return array A list of objects or object fields.
*/ */
function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) { function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) {
if ( ! is_array( $list ) ) if ( ! is_array( $list ) )
@ -2874,14 +2937,14 @@ function wp_filter_object_list( $list, $args = array(), $operator = 'and', $fiel
* *
* @since 3.1.0 * @since 3.1.0
* *
* @param array $list An array of objects to filter * @param array $list An array of objects to filter.
* @param array $args An array of key => value arguments to match against each object * @param array $args Optional. An array of key => value arguments to match
* @param string $operator The logical operation to perform: * against each object. Default empty array.
* 'AND' means all elements from the array must match; * @param string $operator Optional. The logical operation to perform. 'AND' means
* 'OR' means only one element needs to match; * all elements from the array must match. 'OR' means only
* 'NOT' means no elements may match. * one element needs to match. 'NOT' means no elements may
* The default is 'AND'. * match. Default 'AND'.
* @return array * @return array Array of found values.
*/ */
function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
if ( ! is_array( $list ) ) if ( ! is_array( $list ) )
@ -2920,16 +2983,21 @@ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
* array_column() (PHP 5.5) but also supports objects. * array_column() (PHP 5.5) but also supports objects.
* *
* @since 3.1.0 * @since 3.1.0
* @since 4.0.0 $index_key parameter added.
* *
* @param array $list A list of objects or arrays * @param array $list List of objects or arrays
* @param int|string $field A field from the object to place instead of the entire object * @param int|string $field Field from the object to place instead of the entire object
* @param int|string $index_key A field from the object to use as keys for the new array * @param int|string $index_key Optional. Field from the object to use as keys for the new array.
* @return array * Default null.
* @return array Array of found values. If $index_key is set, an array of found values with keys
* corresponding to $index_key.
*/ */
function wp_list_pluck( $list, $field, $index_key = null ) { function wp_list_pluck( $list, $field, $index_key = null ) {
if ( ! $index_key ) { if ( ! $index_key ) {
// This is simple. Could at some point wrap array_column() /*
// if we knew we had an array of arrays. * This is simple. Could at some point wrap array_column()
* if we knew we had an array of arrays.
*/
foreach ( $list as $key => $value ) { foreach ( $list as $key => $value ) {
if ( is_object( $value ) ) { if ( is_object( $value ) ) {
$list[ $key ] = $value->$field; $list[ $key ] = $value->$field;
@ -2940,9 +3008,10 @@ function wp_list_pluck( $list, $field, $index_key = null ) {
return $list; return $list;
} }
// When index_key is not set for a particular item, /*
// push the value to the end of the stack. * When index_key is not set for a particular item, push the value
// This is how array_column() behaves. * to the end of the stack. This is how array_column() behaves.
*/
$newlist = array(); $newlist = array();
foreach ( $list as $value ) { foreach ( $list as $value ) {
if ( is_object( $value ) ) { if ( is_object( $value ) ) {
@ -2966,16 +3035,18 @@ function wp_list_pluck( $list, $field, $index_key = null ) {
/** /**
* Determines if Widgets library should be loaded. * Determines if Widgets library should be loaded.
* *
* Checks to make sure that the widgets library hasn't already been loaded. If * Checks to make sure that the widgets library hasn't already been loaded.
* it hasn't, then it will load the widgets library and run an action hook. * If it hasn't, then it will load the widgets library and run an action hook.
* *
* @since 2.2.0 * @since 2.2.0
* @uses add_action() Calls '_admin_menu' hook with 'wp_widgets_add_menu' value.
*/ */
function wp_maybe_load_widgets() { function wp_maybe_load_widgets() {
/** /**
* Filter whether to load the Widgets library. * Filter whether to load the Widgets library.
* *
* Passing a falsey value to the filter will effectively short-circuit
* the Widgets library from loading.
*
* @since 2.8.0 * @since 2.8.0
* *
* @param bool $wp_maybe_load_widgets Whether to load the Widgets library. * @param bool $wp_maybe_load_widgets Whether to load the Widgets library.
@ -2984,7 +3055,9 @@ function wp_maybe_load_widgets() {
if ( ! apply_filters( 'load_default_widgets', true ) ) { if ( ! apply_filters( 'load_default_widgets', true ) ) {
return; return;
} }
require_once( ABSPATH . WPINC . '/default-widgets.php' ); require_once( ABSPATH . WPINC . '/default-widgets.php' );
add_action( '_admin_menu', 'wp_widgets_add_menu' ); add_action( '_admin_menu', 'wp_widgets_add_menu' );
} }
@ -2992,6 +3065,7 @@ function wp_maybe_load_widgets() {
* Append the Widgets menu to the themes main menu. * Append the Widgets menu to the themes main menu.
* *
* @since 2.2.0 * @since 2.2.0
*
* @uses $submenu The administration submenu list. * @uses $submenu The administration submenu list.
*/ */
function wp_widgets_add_menu() { function wp_widgets_add_menu() {
@ -3007,7 +3081,7 @@ function wp_widgets_add_menu() {
/** /**
* Flush all output buffers for PHP 5.2. * Flush all output buffers for PHP 5.2.
* *
* Make sure all output buffers are flushed before our singletons our destroyed. * Make sure all output buffers are flushed before our singletons are destroyed.
* *
* @since 2.2.0 * @since 2.2.0
*/ */
@ -3032,7 +3106,8 @@ function wp_ob_end_flush_all() {
* in WordPress 2.5.0. * in WordPress 2.5.0.
* *
* @since 2.3.2 * @since 2.3.2
* @uses $wpdb *
* @global wpdb $wpdb WordPress database access abstraction object.
*/ */
function dead_db() { function dead_db() {
global $wpdb; global $wpdb;