Changeset 28936 for trunk/src/wp-includes/functions.php
- Timestamp:
- 07/01/2014 01:43:48 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r28933 r28936 639 639 * @since 0.71 640 640 * 641 * @global string $currentday The day of the current post in the loop.641 * @global string $currentday The day of the current post in the loop. 642 642 * @global string $previousday The day of the previous post in the loop. 643 643 * 644 * @return int 1 when new day, 0if not a new day.644 * @return int|bool 1|true when new day, 0|false if not a new day. 645 645 */ 646 646 function is_new_day() { … … 658 658 * separator to '&' and uses _http_build_query() function. 659 659 * 660 * @since 2.3.0 661 * 660 662 * @see _http_build_query() Used to build the query 661 * @ link http://us2.php.net/manual/en/function.http-build-query.phpmore on what663 * @see http://us2.php.net/manual/en/function.http-build-query.php for more on what 662 664 * http_build_query() does. 663 665 * 664 * @since 2.3.0665 *666 666 * @param array $data URL-encode key/value pairs. 667 * @return string URL encoded string667 * @return string URL-encoded string. 668 668 */ 669 669 function build_query( $data ) { … … 730 730 * @since 1.5.0 731 731 * 732 * @param mixed $param1 Either newkey or an associative_array733 * @param mixed $param2 Either newvalue or oldquery or uri734 * @param mixed $param3 Optional. Old query or uri732 * @param string|array $param1 Either newkey or an associative_array. 733 * @param string $param2 Either newvalue or oldquery or URI. 734 * @param string $param3 Optional. Old query or URI. 735 735 * @return string New URL query string. 736 736 */ … … 802 802 * @since 1.5.0 803 803 * 804 * @param string|array $key Query key or keys to remove.805 * @param bool $query When false uses the $_SERVER value.804 * @param string|array $key Query key or keys to remove. 805 * @param bool $query Optional. When false uses the $_SERVER value. Default false. 806 806 * @return string New URL query string. 807 807 */ 808 function remove_query_arg( $key, $query =false ) {808 function remove_query_arg( $key, $query = false ) { 809 809 if ( is_array( $key ) ) { // removing multiple keys 810 810 foreach ( $key as $k ) … … 838 838 * 839 839 * @since 1.5.1 840 * @uses wp_remote_get() 840 * 841 * @see wp_safe_remote_get() 841 842 * 842 843 * @param string $uri URI/URL of web page to retrieve. … … 963 964 * 964 965 * @since 2.0.0 966 * 965 967 * @see get_status_header_desc() 966 968 * … … 995 997 996 998 /** 997 * Get sthe header information to prevent caching.998 * 999 * The several different headers cover the different ways cache prevention is handled1000 * by different browsers999 * Get the header information to prevent caching. 1000 * 1001 * The several different headers cover the different ways cache prevention 1002 * is handled by different browsers 1001 1003 * 1002 1004 * @since 2.8.0 … … 1016 1018 * 1017 1019 * @since 2.8.0 1020 * 1021 * @see wp_get_nocache_headers() 1018 1022 * 1019 1023 * @param array $headers { … … 1032 1036 1033 1037 /** 1034 * Sets the headers to prevent caching for the different browsers. 1035 * 1036 * Different browsers support different nocache headers, so several headers must 1037 * be sent so that all of them get the point that no caching should occur. 1038 * Set the headers to prevent caching for the different browsers. 1039 * 1040 * Different browsers support different nocache headers, so several 1041 * headers must be sent so that all of them get the point that no 1042 * caching should occur. 1038 1043 * 1039 1044 * @since 2.0.0 1045 * 1040 1046 * @see wp_get_nocache_headers() 1041 1047 */ … … 1070 1076 function cache_javascript_headers() { 1071 1077 $expiresOffset = 10 * DAY_IN_SECONDS; 1078 1072 1079 header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) ); 1073 1080 header( "Vary: Accept-Encoding" ); // Handle proxies … … 1080 1087 * @since 2.0.0 1081 1088 * 1082 * @return int Number of database queries 1089 * @global wpdb $wpdb WordPress database access abstraction object. 1090 * 1091 * @return int Number of database queries. 1083 1092 */ 1084 1093 function get_num_queries() { … … 1088 1097 1089 1098 /** 1090 * Whether input is yes or no. Must be 'y' to be true. 1099 * Whether input is yes or no. 1100 * 1101 * Must be 'y' to be true. 1091 1102 * 1092 1103 * @since 1.0.0 1093 1104 * 1094 * @param string $yn Character string containing either 'y' or 'n'1095 * @return bool True if yes, false on anything else 1105 * @param string $yn Character string containing either 'y' (yes) or 'n' (no). 1106 * @return bool True if yes, false on anything else. 1096 1107 */ 1097 1108 function bool_from_yn( $yn ) { … … 1100 1111 1101 1112 /** 1102 * Load sthe feed template from the use of an action hook.1113 * Load the feed template from the use of an action hook. 1103 1114 * 1104 1115 * If the feed action does not have a hook, then the function will die with a … … 1142 1153 * 1143 1154 * @since 2.1.0 1155 * 1156 * @see load_template() 1144 1157 */ 1145 1158 function do_feed_rdf() { … … 1151 1164 * 1152 1165 * @since 2.1.0 1166 * 1167 * @see load_template() 1153 1168 */ 1154 1169 function do_feed_rss() { … … 1160 1175 * 1161 1176 * @since 2.1.0 1177 * 1178 * @see load_template() 1162 1179 * 1163 1180 * @param bool $for_comments True for the comment feed, false for normal feed. … … 1174 1191 * 1175 1192 * @since 2.1.0 1193 * 1194 * @see load_template() 1176 1195 * 1177 1196 * @param bool $for_comments True for the comment feed, false for normal feed. … … 1226 1245 * Test whether blog is already installed. 1227 1246 * 1228 * The cache will be checked first. If you have a cache plugin, which saves the1229 * cache values, then this will work. If you use the default WordPress cache,1230 * and the database goes away, then you might have problems.1231 * 1232 * Checks for the option siteurlfor whether WordPress is installed.1247 * The cache will be checked first. If you have a cache plugin, which saves 1248 * the cache values, then this will work. If you use the default WordPress 1249 * cache, and the database goes away, then you might have problems. 1250 * 1251 * Checks for the 'siteurl' option for whether WordPress is installed. 1233 1252 * 1234 1253 * @since 2.1.0 1235 * @uses $wpdb 1236 * 1237 * @return bool Whether blog is already installed. 1254 * 1255 * @global wpdb $wpdb WordPress database access abstraction object. 1256 * 1257 * @return bool Whether the blog is already installed. 1238 1258 */ 1239 1259 function is_blog_installed() { 1240 1260 global $wpdb; 1241 1261 1242 // Check cache first. If options table goes away and we have true cached, oh well. 1262 /* 1263 * Check cache first. If options table goes away and we have true 1264 * cached, oh well. 1265 */ 1243 1266 if ( wp_cache_get( 'is_blog_installed' ) ) 1244 1267 return true; … … 1267 1290 $suppress = $wpdb->suppress_errors(); 1268 1291 1269 // Loop over the WP tables. If none exist, then scratch install is allowed. 1270 // If one or more exist, suggest table repair since we got here because the options 1271 // table could not be accessed. 1292 /* 1293 * Loop over the WP tables. If none exist, then scratch install is allowed. 1294 * If one or more exist, suggest table repair since we got here because the 1295 * options table could not be accessed. 1296 */ 1272 1297 $wp_tables = $wpdb->tables(); 1273 1298 foreach ( $wp_tables as $table ) { … … 1303 1328 * 1304 1329 * @param string $actionurl URL to add nonce action. 1305 * @param string $action Optional. Nonce action name.1306 * @param string $name Optional. Nonce name.1330 * @param string $action Optional. Nonce action name. Default -1. 1331 * @param string $name Optional. Nonce name. Default '_wpnonce'. 1307 1332 * @return string Escaped URL with nonce action added. 1308 1333 */ … … 1332 1357 * @since 2.0.4 1333 1358 * 1334 * @param string $action Optional. Action name.1335 * @param string $name Optional. Nonce name.1336 * @param bool $referer Optional, default true. Whether to set the referer field for validation.1337 * @param bool $echo Optional, default true. Whether to display or return hidden form field.1338 * @return string Nonce field .1359 * @param string $action Optional. Action name. Default -1. 1360 * @param string $name Optional. Nonce name. Default '_wpnonce'. 1361 * @param bool $referer Optional. Whether to set the referer field for validation. Default true. 1362 * @param bool $echo Optional. Whether to display or return hidden form field. Default true. 1363 * @return string Nonce field HTML markup. 1339 1364 */ 1340 1365 function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) { … … 1359 1384 * @since 2.0.4 1360 1385 * 1361 * @param bool $echo Whether to echo or return the referer field.1362 * @return string Referer field .1386 * @param bool $echo Optional. Whether to echo or return the referer field. Default true. 1387 * @return string Referer field HTML markup. 1363 1388 */ 1364 1389 function wp_referer_field( $echo = true ) { … … 1374 1399 * 1375 1400 * The input name is '_wp_original_http_referer' and will be either the same 1376 * value of {@link wp_referer_field()}, if that was posted already or it will1377 * be thecurrent page, if it doesn't exist.1401 * value of wp_referer_field(), if that was posted already or it will be the 1402 * current page, if it doesn't exist. 1378 1403 * 1379 1404 * @since 2.0.4 1380 1405 * 1381 * @param bool $echo Whether to echo the original http referer 1382 * @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to. 1406 * @param bool $echo Optional. Whether to echo the original http referer. Default true. 1407 * @param string $jump_back_to Optional. Can be 'previous' or page you want to jump back to. 1408 * Default 'current'. 1383 1409 * @return string Original referer field. 1384 1410 */ … … 1394 1420 1395 1421 /** 1396 * Retrieve referer from '_wp_http_referer' or HTTP referer. If it's the same 1397 * as the current request URL, will return false. 1422 * Retrieve referer from '_wp_http_referer' or HTTP referer. 1423 * 1424 * If it's the same as the current request URL, will return false. 1398 1425 * 1399 1426 * @since 2.0.4 … … 1441 1468 $wrapper = null; 1442 1469 1443 // strip the protocol1470 // Strip the protocol. 1444 1471 if( wp_is_stream( $target ) ) { 1445 1472 list( $wrapper, $target ) = explode( '://', $target, 2 ); 1446 1473 } 1447 1474 1448 // from php.net/mkdir user contributed notes1475 // From php.net/mkdir user contributed notes. 1449 1476 $target = str_replace( '//', '/', $target ); 1450 1477 1451 // put the wrapper back on the target1478 // Put the wrapper back on the target. 1452 1479 if( $wrapper !== null ) { 1453 1480 $target = $wrapper . '://' . $target; 1454 1481 } 1455 1482 1456 // safe mode fails with a trailing slash under certain PHP versions. 1457 $target = rtrim($target, '/'); // Use rtrim() instead of untrailingslashit to avoid formatting.php dependency. 1483 /* 1484 * Safe mode fails with a trailing slash under certain PHP versions. 1485 * Use rtrim() instead of untrailingslashit to avoid formatting.php dependency. 1486 */ 1487 $target = rtrim($target, '/'); 1458 1488 if ( empty($target) ) 1459 1489 $target = '/'; … … 1477 1507 if ( @mkdir( $target, $dir_perms, true ) ) { 1478 1508 1479 // If a umask is set that modifies $dir_perms, we'll have to re-set the $dir_perms correctly with chmod() 1509 /* 1510 * If a umask is set that modifies $dir_perms, we'll have to re-set 1511 * the $dir_perms correctly with chmod() 1512 */ 1480 1513 if ( $dir_perms != ( $dir_perms & ~umask() ) ) { 1481 1514 $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) ); … … 1492 1525 1493 1526 /** 1494 * Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows'). 1527 * Test if a give filesystem path is absolute. 1528 * 1529 * For example, '/foo/bar', or 'c:\windows'. 1495 1530 * 1496 1531 * @since 2.5.0 1497 1532 * 1498 * @param string $path File path 1533 * @param string $path File path. 1499 1534 * @return bool True if path is absolute, false is not absolute. 1500 1535 */ 1501 1536 function path_is_absolute( $path ) { 1502 // this is definitive if true but fails if $path does not exist or contains a symbolic link 1537 /* 1538 * This is definitive if true but fails if $path does not exist or contains 1539 * a symbolic link. 1540 */ 1503 1541 if ( realpath($path) == $path ) 1504 1542 return true; … … 1507 1545 return false; 1508 1546 1509 // windows allows absolute paths like this1547 // Windows allows absolute paths like this. 1510 1548 if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) 1511 1549 return true; 1512 1550 1513 // a path starting with / or \ is absolute; anything else is relative1551 // A path starting with / or \ is absolute; anything else is relative. 1514 1552 return ( $path[0] == '/' || $path[0] == '\\' ); 1515 1553 } 1516 1554 1517 1555 /** 1518 * Join two filesystem paths together (e.g. 'give me $path relative to $base'). 1519 * 1520 * If the $path is absolute, then it the full path is returned. 1556 * Join two filesystem paths together. 1557 * 1558 * For example, 'give me $path relative to $base'. If the $path is absolute, 1559 * then it the full path is returned. 1521 1560 * 1522 1561 * @since 2.5.0 1523 1562 * 1524 * @param string $base 1525 * @param string $path 1563 * @param string $base Base path. 1564 * @param string $path Path relative to $base. 1526 1565 * @return string The path with the base or absolute path. 1527 1566 */ … … 1536 1575 * Normalize a filesystem path. 1537 1576 * 1538 * Replaces backslashes with forward slashes for Windows systems, 1539 * and ensuresno duplicate slashes exist.1577 * Replaces backslashes with forward slashes for Windows systems, and ensures 1578 * no duplicate slashes exist. 1540 1579 * 1541 1580 * @since 3.9.0 … … 1551 1590 1552 1591 /** 1553 * Determines a writable directory for temporary files. 1554 * Function's preference is the return value of <code>sys_get_temp_dir()</code>, 1592 * Determine a writable directory for temporary files. 1593 * 1594 * Function's preference is the return value of sys_get_temp_dir(), 1555 1595 * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR, 1556 1596 * before finally defaulting to /tmp/ 1557 1597 * 1558 1598 * In the event that this function does not find a writable location, 1559 * It may be overridden by the <code>WP_TEMP_DIR</code> constant in 1560 * your <code>wp-config.php</code> file. 1599 * It may be overridden by the WP_TEMP_DIR constant in your wp-config.php file. 1561 1600 * 1562 1601 * @since 2.5.0 1563 1602 * 1564 * @return string Writable temporary directory 1603 * @return string Writable temporary directory. 1565 1604 */ 1566 1605 function get_temp_dir() { … … 1593 1632 * Determine if a directory is writable. 1594 1633 * 1595 * This function is used to work around certain ACL issues 1596 * in PHP primarily affecting Windows Servers. 1634 * This function is used to work around certain ACL issues in PHP primarily 1635 * affecting Windows Servers. 1636 * 1637 * @since 3.6.0 1597 1638 * 1598 1639 * @see win_is_writable() 1599 1640 * 1600 * @since 3.6.0 1601 * 1602 * @param string $path 1603 * @return bool 1641 * @param string $path Path to check for write-ability. 1642 * @return bool Whether the path is writable. 1604 1643 */ 1605 1644 function wp_is_writable( $path ) { … … 1618 1657 * upon PHP to interprate the OS ACL. 1619 1658 * 1620 * @link http://bugs.php.net/bug.php?id=276091621 * @link http://bugs.php.net/bug.php?id=309311622 *1623 1659 * @since 2.8.0 1624 1660 * 1625 * @param string $path 1626 * @return bool 1661 * @see http://bugs.php.net/bug.php?id=27609 1662 * @see http://bugs.php.net/bug.php?id=30931 1663 * 1664 * @param string $path Windows path to check for write-ability. 1665 * @return bool Whether the path is writable. 1627 1666 */ 1628 1667 function win_is_writable( $path ) { … … 1673 1712 * @since 2.0.0 1674 1713 * 1675 * @param string $time Optional. Time formatted in 'yyyy/mm'. 1714 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. 1676 1715 * @return array See above for description. 1677 1716 */ … … 1696 1735 } 1697 1736 1698 // Obey the value of UPLOADS. This happens as long as ms-files rewriting is disabled. 1699 // We also sometimes obey UPLOADS when rewriting is enabled -- see the next block. 1737 /* 1738 * Honor the value of UPLOADS. This happens as long as ms-files rewriting is disabled. 1739 * We also sometimes obey UPLOADS when rewriting is enabled -- see the next block. 1740 */ 1700 1741 if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) { 1701 1742 $dir = ABSPATH . UPLOADS; … … 1707 1748 1708 1749 if ( ! get_site_option( 'ms_files_rewriting' ) ) { 1709 // If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward: 1710 // Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory 1711 // prevents a four-digit ID from conflicting with a year-based directory for the main site. 1712 // But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra 1713 // directory, as they never had wp-content/uploads for the main site.) 1750 /* 1751 * If ms-files rewriting is disabled (networks created post-3.5), it is fairly 1752 * straightforward: Append sites/%d if we're not on the main site (for post-MU 1753 * networks). (The extra directory prevents a four-digit ID from conflicting with 1754 * a year-based directory for the main site. But if a MU-era network has disabled 1755 * ms-files rewriting manually, they don't need the extra directory, as they never 1756 * had wp-content/uploads for the main site.) 1757 */ 1714 1758 1715 1759 if ( defined( 'MULTISITE' ) ) … … 1722 1766 1723 1767 } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { 1724 // Handle the old-form ms-files.php rewriting if the network still has that enabled. 1725 // When ms-files rewriting is enabled, then we only listen to UPLOADS when: 1726 // 1) we are not on the main site in a post-MU network, 1727 // as wp-content/uploads is used there, and 1728 // 2) we are not switched, as ms_upload_constants() hardcodes 1729 // these constants to reflect the original blog ID. 1730 // 1731 // Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute. 1732 // (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as 1733 // as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files 1734 // rewriting in multisite, the resulting URL is /files. (#WP22702 for background.) 1768 /* 1769 * Handle the old-form ms-files.php rewriting if the network still has that enabled. 1770 * When ms-files rewriting is enabled, then we only listen to UPLOADS when: 1771 * 1) We are not on the main site in a post-MU network, as wp-content/uploads is used 1772 * there, and 1773 * 2) We are not switched, as ms_upload_constants() hardcodes these constants to reflect 1774 * the original blog ID. 1775 * 1776 * Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute. 1777 * (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as 1778 * as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files 1779 * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.) 1780 */ 1735 1781 1736 1782 if ( defined( 'BLOGUPLOADDIR' ) ) … … 1776 1822 ) ); 1777 1823 1778 // Make sure we have an uploads dir 1824 // Make sure we have an uploads directory. 1779 1825 if ( ! wp_mkdir_p( $uploads['path'] ) ) { 1780 1826 if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) … … 1802 1848 * @since 2.5.0 1803 1849 * 1804 * @param string $dir1805 * @param string $filename1806 * @param mixed $unique_filename_callback Callback.1850 * @param string $dir Directory. 1851 * @param string $filename File name. 1852 * @param callback $unique_filename_callback Callback. Default null. 1807 1853 * @return string New filename, if given wasn't unique. 1808 1854 */ 1809 1855 function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) { 1810 // sanitize the file name before we begin processing1856 // Sanitize the file name before we begin processing. 1811 1857 $filename = sanitize_file_name($filename); 1812 1858 1813 // separate the filename into a name and extension1859 // Separate the filename into a name and extension. 1814 1860 $info = pathinfo($filename); 1815 1861 $ext = !empty($info['extension']) ? '.' . $info['extension'] : ''; 1816 1862 $name = basename($filename, $ext); 1817 1863 1818 // edge case: if file is named '.ext', treat as an empty name1864 // Edge case: if file is named '.ext', treat as an empty name. 1819 1865 if ( $name === $ext ) 1820 1866 $name = ''; 1821 1867 1822 // Increment the file number until we have a unique file to save in $dir. Use callback if supplied. 1868 /* 1869 * Increment the file number until we have a unique file to save in $dir. 1870 * Use callback if supplied. 1871 */ 1823 1872 if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) { 1824 1873 $filename = call_user_func( $unique_filename_callback, $dir, $name, $ext ); … … 1826 1875 $number = ''; 1827 1876 1828 // change '.ext' to lower case1877 // Change '.ext' to lower case. 1829 1878 if ( $ext && strtolower($ext) != $ext ) { 1830 1879 $ext2 = strtolower($ext); 1831 1880 $filename2 = preg_replace( '|' . preg_quote($ext) . '$|', $ext2, $filename ); 1832 1881 1833 // check for both lower and upper case extension or image sub-sizes may be overwritten1882 // Check for both lower and upper case extension or image sub-sizes may be overwritten. 1834 1883 while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) { 1835 1884 $new_number = $number + 1; … … 1869 1918 * @since 2.0.0 1870 1919 * 1871 * @param string $name 1872 * @param null $deprecated Never used. Set to null.1873 * @param mixed $bitsFile content1874 * @param string $time Optional. Time formatted in 'yyyy/mm'.1920 * @param string $name Filename. 1921 * @param null $deprecated Never used. Set to null. 1922 * @param mixed $bits File content 1923 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. 1875 1924 * @return array 1876 1925 */ … … 1990 2039 * 1991 2040 * @param string $filename File name or path. 1992 * @param array $mimesOptional. Key is the file extension with value as the mime type.2041 * @param array $mimes Optional. Key is the file extension with value as the mime type. 1993 2042 * @return array Values with extension first and mime type. 1994 2043 */ … … 2013 2062 /** 2014 2063 * Attempt to determine the real file type of a file. 2064 * 2015 2065 * If unable to, the file name extension will be used to determine type. 2016 2066 * … … 2022 2072 * @since 3.0.0 2023 2073 * 2024 * @param string $file Full path to the file. 2025 * @param string $filename The name of the file (may differ from $file due to $file being in a tmp directory) 2026 * @param array $mimes Optional. Key is the file extension with value as the mime type. 2027 * @return array Values for the extension, MIME, and either a corrected filename or false if original $filename is valid 2074 * @param string $file Full path to the file. 2075 * @param string $filename The name of the file (may differ from $file due to $file being 2076 * in a tmp directory). 2077 * @param array $mimes Optional. Key is the file extension with value as the mime type. 2078 * @return array Values for the extension, MIME, and either a corrected filename or false 2079 * if original $filename is valid. 2028 2080 */ 2029 2081 function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { … … 2117 2169 */ 2118 2170 return apply_filters( 'mime_types', array( 2119 // Image formats 2171 // Image formats. 2120 2172 'jpg|jpeg|jpe' => 'image/jpeg', 2121 2173 'gif' => 'image/gif', … … 2124 2176 'tif|tiff' => 'image/tiff', 2125 2177 'ico' => 'image/x-icon', 2126 // Video formats 2178 // Video formats. 2127 2179 'asf|asx' => 'video/x-ms-asf', 2128 2180 'wmv' => 'video/x-ms-wmv', … … 2140 2192 '3gp|3gpp' => 'video/3gpp', // Can also be audio 2141 2193 '3g2|3gp2' => 'video/3gpp2', // Can also be audio 2142 // Text formats 2194 // Text formats. 2143 2195 'txt|asc|c|cc|h|srt' => 'text/plain', 2144 2196 'csv' => 'text/csv', … … 2150 2202 'vtt' => 'text/vtt', 2151 2203 'dfxp' => 'application/ttaf+xml', 2152 // Audio formats 2204 // Audio formats. 2153 2205 'mp3|m4a|m4b' => 'audio/mpeg', 2154 2206 'ra|ram' => 'audio/x-realaudio', … … 2159 2211 'wax' => 'audio/x-ms-wax', 2160 2212 'mka' => 'audio/x-matroska', 2161 // Misc application formats 2213 // Misc application formats. 2162 2214 'rtf' => 'application/rtf', 2163 2215 'js' => 'application/javascript', … … 2171 2223 '7z' => 'application/x-7z-compressed', 2172 2224 'exe' => 'application/x-msdownload', 2173 // MS Office formats 2225 // MS Office formats. 2174 2226 'doc' => 'application/msword', 2175 2227 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', … … 2200 2252 'oxps' => 'application/oxps', 2201 2253 'xps' => 'application/vnd.ms-xpsdocument', 2202 // OpenOffice formats 2254 // OpenOffice formats. 2203 2255 'odt' => 'application/vnd.oasis.opendocument.text', 2204 2256 'odp' => 'application/vnd.oasis.opendocument.presentation', … … 2208 2260 'odb' => 'application/vnd.oasis.opendocument.database', 2209 2261 'odf' => 'application/vnd.oasis.opendocument.formula', 2210 // WordPerfect formats 2262 // WordPerfect formats. 2211 2263 'wp|wpd' => 'application/wordperfect', 2212 // iWork formats 2264 // iWork formats. 2213 2265 'key' => 'application/vnd.apple.keynote', 2214 2266 'numbers' => 'application/vnd.apple.numbers', … … 2224 2276 * 2225 2277 * @param int|WP_User $user Optional. User to check. Defaults to current user. 2226 * @return array Array of mime types keyed by the file extension regex corresponding to those types. 2278 * @return array Array of mime types keyed by the file extension regex corresponding 2279 * to those types. 2227 2280 */ 2228 2281 function get_allowed_mime_types( $user = null ) { … … 2252 2305 * Display "Are You Sure" message to confirm the action being taken. 2253 2306 * 2254 * If the action has the nonce explain message, then it will be displayed along2255 * with the "Are you sure?" message.2307 * If the action has the nonce explain message, then it will be displayed 2308 * along with the "Are you sure?" message. 2256 2309 * 2257 2310 * @since 2.0.4 … … 2285 2338 * @since 2.0.4 2286 2339 * 2287 * @param string $message Error message.2288 * @param string $title Error title.2289 * @param string|array $args Optional arguments to control behavior.2340 * @param string $message Optional. Error message. Default empty. 2341 * @param string $title Optional. Error title. Default empty. 2342 * @param string|array $args Optional. Arguments to control behavior. Default empty array. 2290 2343 */ 2291 2344 function wp_die( $message = '', $title = '', $args = array() ) { … … 2331 2384 * @access private 2332 2385 * 2333 * @param string $message Error message.2334 * @param string $title Error title.2335 * @param string|array $args Optional arguments to control behavior.2386 * @param string $message Error message. 2387 * @param string $title Optional. Error title. Default empty. 2388 * @param string|array $args Optional. Arguments to control behavior. Default empty array. 2336 2389 */ 2337 2390 function _default_wp_die_handler( $message, $title = '', $args = array() ) { … … 2509 2562 * @access private 2510 2563 * 2511 * @param string $message Error message.2512 * @param string $title Error title.2513 * @param string|array $args Optional arguments to control behavior.2564 * @param string $message Error message. 2565 * @param string $title Optional. Error title. Default empty. 2566 * @param string|array $args Optional. Arguments to control behavior. Default empty array. 2514 2567 */ 2515 2568 function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) { … … 2534 2587 * @access private 2535 2588 * 2536 * @param string $message Optional. Response to print. 2589 * @param string $message Optional. Response to print. Default empty. 2537 2590 */ 2538 2591 function _ajax_wp_die_handler( $message = '' ) { … … 2550 2603 * @access private 2551 2604 * 2552 * @param string $message Optional. Response to print. 2605 * @param string $message Optional. Response to print. Default empty. 2553 2606 */ 2554 2607 function _scalar_wp_die_handler( $message = '' ) { … … 2563 2616 * @since 3.5.0 2564 2617 * 2565 * @param mixed $response Variable (usually an array or object) to encode as JSON, then print and die. 2618 * @param mixed $response Variable (usually an array or object) to encode as JSON, 2619 * then print and die. 2566 2620 */ 2567 2621 function wp_send_json( $response ) { … … 2609 2663 * Retrieve the WordPress home page URL. 2610 2664 * 2611 * If the constant named 'WP_HOME' exists, then it will be used and returned by2612 * the function. This can be used to counter the redirection on your local2665 * If the constant named 'WP_HOME' exists, then it will be used and returned 2666 * by the function. This can be used to counter the redirection on your local 2613 2667 * development environment. 2614 2668 * 2669 * @since 2.2.0 2615 2670 * @access private 2616 * @since 2.2.0 2617 * 2618 * @param string $url URL for the home location 2671 * 2672 * @see WP_HOME 2673 * 2674 * @param string $url URL for the home location. 2619 2675 * @return string Homepage location. 2620 2676 */ … … 2629 2685 * 2630 2686 * If the constant named 'WP_SITEURL' is defined, then the value in that 2631 * constant will always be returned. This can be used for debugging a site on 2632 * your localhost while not having to change the database to your URL. 2633 * 2687 * constant will always be returned. This can be used for debugging a site 2688 * on your localhost while not having to change the database to your URL. 2689 * 2690 * @since 2.2.0 2634 2691 * @access private 2635 * @since 2.2.0 2692 * 2693 * @see WP_SITEURL 2636 2694 * 2637 2695 * @param string $url URL to set the WordPress site location. 2638 * @return string The WordPress Site URL 2696 * @return string The WordPress Site URL. 2639 2697 */ 2640 2698 function _config_wp_siteurl( $url = '' ) { … … 2647 2705 * Set the localized direction for MCE plugin. 2648 2706 * 2649 * Will only set the direction to 'rtl', if the WordPress locale has the text 2650 * direction set to 'rtl'. 2651 * 2652 * Fills in the 'directionality' setting, enables the 'directionality' plugin, 2653 * and adds the 'ltr' button to 'toolbar1', formerly 'theme_advanced_buttons1' array 2654 * keys. These keys are then returned in the $input (TinyMCE settings) array. 2655 * 2707 * Will only set the direction to 'rtl', if the WordPress locale has 2708 * the text direction set to 'rtl'. 2709 * 2710 * Fills in the 'directionality' setting, enables the 'directionality' 2711 * plugin, and adds the 'ltr' button to 'toolbar1', formerly 2712 * 'theme_advanced_buttons1' array keys. These keys are then returned 2713 * in the $input (TinyMCE settings) array. 2714 * 2715 * @since 2.1.0 2656 2716 * @access private 2657 * @since 2.1.02658 2717 * 2659 2718 * @param array $input MCE settings array. … … 2690 2749 * @global array $wpsmiliestrans 2691 2750 * @global array $wp_smiliessearch 2751 * 2692 2752 * @since 2.2.0 2693 2753 */ … … 2796 2856 * @since 2.2.0 2797 2857 * 2798 * @param string|array $args Value to merge with $defaults2799 * @param array $defaults Array that serves as the defaults.2858 * @param string|array $args Value to merge with $defaults 2859 * @param array $defaults Optional. Array that serves as the defaults. Default empty. 2800 2860 * @return array Merged user defined values with defaults. 2801 2861 */ … … 2818 2878 * @since 3.0.0 2819 2879 * 2820 * @param array|string $list 2821 * @return array Sanitized array of IDs 2880 * @param array|string $list List of ids. 2881 * @return array Sanitized array of IDs. 2822 2882 */ 2823 2883 function wp_parse_id_list( $list ) { … … 2833 2893 * @since 3.1.0 2834 2894 * 2835 * @param array $array The original array 2836 * @param array $keys The list of keys2837 * @return array The array slice 2895 * @param array $array The original array. 2896 * @param array $keys The list of keys. 2897 * @return array The array slice. 2838 2898 */ 2839 2899 function wp_array_slice_assoc( $array, $keys ) { … … 2851 2911 * @since 3.0.0 2852 2912 * 2853 * @param array $list An array of objects to filter 2854 * @param array $args An array of key => value arguments to match against each object 2855 * @param string $operator The logical operation to perform. 'or' means only one element 2856 * from the array needs to match; 'and' means all elements must match. The default is 'and'. 2857 * @param bool|string $field A field from the object to place instead of the entire object 2858 * @return array A list of objects or object fields 2913 * @param array $list An array of objects to filter 2914 * @param array $args Optional. An array of key => value arguments to match 2915 * against each object. Default empty array. 2916 * @param string $operator Optional. The logical operation to perform. 'or' means 2917 * only one element from the array needs to match; 'and' 2918 * means all elements must match. Default 'and'. 2919 * @param bool|string $field A field from the object to place instead of the entire object. 2920 * Default false. 2921 * @return array A list of objects or object fields. 2859 2922 */ 2860 2923 function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) { … … 2875 2938 * @since 3.1.0 2876 2939 * 2877 * @param array $list An array of objects to filter2878 * @param array $args An array of key => value arguments to match against each object2879 * @param string $operator The logical operation to perform:2880 * 'AND' means all elements from the array must match;2881 * 'OR' means only one element needs to match;2882 * 'NOT' means no elements may match.2883 * The default is'AND'.2884 * @return array 2940 * @param array $list An array of objects to filter. 2941 * @param array $args Optional. An array of key => value arguments to match 2942 * against each object. Default empty array. 2943 * @param string $operator Optional. The logical operation to perform. 'AND' means 2944 * all elements from the array must match. 'OR' means only 2945 * one element needs to match. 'NOT' means no elements may 2946 * match. Default 'AND'. 2947 * @return array Array of found values. 2885 2948 */ 2886 2949 function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { … … 2921 2984 * 2922 2985 * @since 3.1.0 2923 * 2924 * @param array $list A list of objects or arrays 2925 * @param int|string $field A field from the object to place instead of the entire object 2926 * @param int|string $index_key A field from the object to use as keys for the new array 2927 * @return array 2986 * @since 4.0.0 $index_key parameter added. 2987 * 2988 * @param array $list List of objects or arrays 2989 * @param int|string $field Field from the object to place instead of the entire object 2990 * @param int|string $index_key Optional. Field from the object to use as keys for the new array. 2991 * Default null. 2992 * @return array Array of found values. If $index_key is set, an array of found values with keys 2993 * corresponding to $index_key. 2928 2994 */ 2929 2995 function wp_list_pluck( $list, $field, $index_key = null ) { 2930 2996 if ( ! $index_key ) { 2931 // This is simple. Could at some point wrap array_column() 2932 // if we knew we had an array of arrays. 2997 /* 2998 * This is simple. Could at some point wrap array_column() 2999 * if we knew we had an array of arrays. 3000 */ 2933 3001 foreach ( $list as $key => $value ) { 2934 3002 if ( is_object( $value ) ) { … … 2941 3009 } 2942 3010 2943 // When index_key is not set for a particular item, 2944 // push the value to the end of the stack. 2945 // This is how array_column() behaves. 3011 /* 3012 * When index_key is not set for a particular item, push the value 3013 * to the end of the stack. This is how array_column() behaves. 3014 */ 2946 3015 $newlist = array(); 2947 3016 foreach ( $list as $value ) { … … 2967 3036 * Determines if Widgets library should be loaded. 2968 3037 * 2969 * Checks to make sure that the widgets library hasn't already been loaded. If2970 * it hasn't, then it will load the widgets library and run an action hook.3038 * Checks to make sure that the widgets library hasn't already been loaded. 3039 * If it hasn't, then it will load the widgets library and run an action hook. 2971 3040 * 2972 3041 * @since 2.2.0 2973 * @uses add_action() Calls '_admin_menu' hook with 'wp_widgets_add_menu' value.2974 3042 */ 2975 3043 function wp_maybe_load_widgets() { 2976 3044 /** 2977 3045 * Filter whether to load the Widgets library. 3046 * 3047 * Passing a falsey value to the filter will effectively short-circuit 3048 * the Widgets library from loading. 2978 3049 * 2979 3050 * @since 2.8.0 … … 2985 3056 return; 2986 3057 } 3058 2987 3059 require_once( ABSPATH . WPINC . '/default-widgets.php' ); 3060 2988 3061 add_action( '_admin_menu', 'wp_widgets_add_menu' ); 2989 3062 } … … 2993 3066 * 2994 3067 * @since 2.2.0 3068 * 2995 3069 * @uses $submenu The administration submenu list. 2996 3070 */ … … 3008 3082 * Flush all output buffers for PHP 5.2. 3009 3083 * 3010 * Make sure all output buffers are flushed before our singletons ourdestroyed.3084 * Make sure all output buffers are flushed before our singletons are destroyed. 3011 3085 * 3012 3086 * @since 2.2.0 … … 3033 3107 * 3034 3108 * @since 2.3.2 3035 * @uses $wpdb 3109 * 3110 * @global wpdb $wpdb WordPress database access abstraction object. 3036 3111 */ 3037 3112 function dead_db() {
Note: See TracChangeset
for help on using the changeset viewer.