Ticket #5639: functions.phpdoc.r8259.diff
| File functions.phpdoc.r8259.diff, 20.0 KB (added by jacobsantos, 4 years ago) |
|---|
-
functions.php
118 118 // Sanity check for PHP 5.1.0- 119 119 if ( -1 == $i ) 120 120 $i = false; 121 121 122 122 if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { 123 123 $datemonth = $wp_locale->get_month( date( 'm', $i ) ); 124 124 $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); … … 195 195 return false; 196 196 } 197 197 198 198 /** 199 * Get the week start and end from the datetime or date string from mysql. 200 * 201 * @since 0.71 202 * 203 * @param string $mysqlstring Date or datetime field type from mysql. 204 * @param int $start_of_week Optional. Start of the week as an integer. 205 * @return array Keys are 'start' and 'end'. 206 */ 199 207 function get_weekstartend( $mysqlstring, $start_of_week = '' ) { 200 $my = substr( $mysqlstring, 0, 4 ); 201 $mm = substr( $mysqlstring, 8, 2 ); 202 $md = substr( $mysqlstring, 5, 2 ); 203 $day = mktime( 0, 0, 0, $md, $mm, $my ); 204 $weekday = date( 'w', $day ); 205 $i = 86400; 208 $my = substr( $mysqlstring, 0, 4 ); // Mysql string Year 209 $mm = substr( $mysqlstring, 8, 2 ); // Mysql string Month 210 $md = substr( $mysqlstring, 5, 2 ); // Mysql string day 211 $day = mktime( 0, 0, 0, $md, $mm, $my ); // The timestamp for mysqlstring day. 212 $weekday = date( 'w', $day ); // The day of the week from the timestamp 213 $i = 86400; // One day 206 214 if( !is_numeric($start_of_week) ) 207 215 $start_of_week = get_option( 'start_of_week' ); 208 216 … … 415 423 * @return array List of all options. 416 424 */ 417 425 function get_alloptions() { 418 global $wpdb , $wp_queries;426 global $wpdb; 419 427 $show = $wpdb->hide_errors(); 420 428 if ( !$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) 421 429 $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); … … 639 647 return $data; 640 648 } 641 649 642 650 /** 651 * Strip HTML and put links at the bottom of stripped content. 652 * 653 * Searches for all of the links, strips them out of the content, and places 654 * them at the bottom of the content with numbers. 655 * 656 * @since unknown 657 * 658 * @param string $content Content to get links 659 * @return string HTML stripped out of content with links at the bottom. 660 */ 643 661 function make_url_footnote( $content ) { 644 662 preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches ); 645 663 $j = 0; … … 659 677 return $content; 660 678 } 661 679 662 680 /** 681 * Retrieve post title from XMLRPC XML. 682 * 683 * If the title element is not part of the XML, then the default post title from 684 * the $post_default_title will be used instead. 685 * 686 * @package WordPress 687 * @subpackage XMLRPC 688 * @since unknown 689 * 690 * @global string $post_default_title Default XMLRPC post title. 691 * 692 * @param string $content XMLRPC XML Request content 693 * @return string Post title 694 */ 663 695 function xmlrpc_getposttitle( $content ) { 664 696 global $post_default_title; 665 697 if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) { … … 672 704 return $post_title; 673 705 } 674 706 675 707 /** 708 * Retrieve the post category or categories from XMLRPC XML. 709 * 710 * If the category element is not found, then the default post category will be 711 * used. The return type then would be what $post_default_category. If the 712 * category is found, then it will always be an array. 713 * 714 * @package WordPress 715 * @subpackage XMLRPC 716 * @since unknown 717 * 718 * @global string $post_default_category Default XMLRPC post category. 719 * 720 * @param string $content XMLRPC XML Request content 721 * @return string|array List of categories or category name. 722 */ 676 723 function xmlrpc_getpostcategory( $content ) { 677 724 global $post_default_category; 678 725 if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) { … … 684 731 return $post_category; 685 732 } 686 733 687 734 /** 735 * XMLRPC XML content without title and category elements. 736 * 737 * @package WordPress 738 * @subpackage XMLRPC 739 * @since unknown 740 * 741 * @param string $content XMLRPC XML Request content 742 * @return string XMLRPC XML Request content without title and category elements. 743 */ 688 744 function xmlrpc_removepostdata( $content ) { 689 745 $content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content ); 690 746 $content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content ); … … 903 959 /** 904 960 * Whether today is a new day. 905 961 * 906 * {@internal Need to find out how this function is used.}}907 *908 962 * @since 0.71 909 963 * @uses $day Today 910 964 * @uses $previousday Previous day … … 935 989 * @return string URL encoded string 936 990 */ 937 991 function build_query( $data ) { 938 return _http_build_query( $data, NULL, '&', '', false );992 return _http_build_query( $data, null, '&', '', false ); 939 993 } 940 994 941 995 /** … … 953 1007 * @param mixed $param1 Either newkey or an associative_array 954 1008 * @param mixed $param2 Either newvalue or oldquery or uri 955 1009 * @param mixed $param3 Optional. Old query or uri 956 * @return unknown1010 * @return string New URL query string. 957 1011 */ 958 1012 function add_query_arg() { 959 1013 $ret = ''; … … 1027 1081 * 1028 1082 * @param string|array $key Query key or keys to remove. 1029 1083 * @param bool $query When false uses the $_SERVER value. 1030 * @return unknown1084 * @return string New URL query string. 1031 1085 */ 1032 1086 function remove_query_arg( $key, $query=false ) { 1033 1087 if ( is_array( $key ) ) { // removing multiple keys … … 1105 1159 } 1106 1160 } 1107 1161 1108 1162 /** 1163 * Setup the WordPress query. 1164 * 1165 * @since 2.0.0 1166 * 1167 * @param string $query_vars Default WP_Query arguments. 1168 */ 1109 1169 function wp( $query_vars = '' ) { 1110 1170 global $wp, $wp_query, $wp_the_query; 1111 1171 $wp->main( $query_vars ); … … 1263 1323 return ( strtolower( $yn ) == 'y' ); 1264 1324 } 1265 1325 1266 1326 /** 1327 * Loads the feed template from the use of an action hook. 1328 * 1329 * If the feed action does not have a hook, then the function will die with a 1330 * message telling the visitor that the feed is not valid. 1331 * 1332 * It is better to only have one hook for each feed. 1333 * 1334 * @since 2.1.0 1335 * @uses $wp_query Used to tell if the use a comment feed. 1336 * @uses do_action() Calls 'do_feed_$feed' hook, if a hook exists for the feed. 1337 */ 1267 1338 function do_feed() { 1268 1339 global $wp_query; 1269 1340 … … 1353 1424 } 1354 1425 } 1355 1426 1356 1427 /** 1428 * Test whether blog is already installed. 1429 * 1430 * The cache will be checked first. If you have a cache plugin, which saves the 1431 * cache values, then this will work. If you use the default WordPress cache, 1432 * and the database goes away, then you might have problems. 1433 * 1434 * Checks for the option siteurl for whether WordPress is installed. 1435 * 1436 * @since 2.1.0 1437 * @uses $wpdb 1438 * 1439 * @return bool Whether blog is already installed. 1440 */ 1357 1441 function is_blog_installed() { 1358 1442 global $wpdb; 1359 1443 1360 // Check cache first. If options table goes away and we have true cached, oh well.1444 // Check cache first. If options table goes away and we have true cached, oh well. 1361 1445 if ( wp_cache_get('is_blog_installed') ) 1362 1446 return true; 1363 1447 … … 1371 1455 return $installed; 1372 1456 } 1373 1457 1374 1458 /** 1459 * Retrieve URL with nonce added to URL query. 1460 * 1461 * @since 2.0.4 1462 * 1463 * @param string $actionurl URL to add nonce action 1464 * @param string $action Optional. Nonce action name 1465 * @return string URL with nonce action added. 1466 */ 1375 1467 function wp_nonce_url( $actionurl, $action = -1 ) { 1376 1468 $actionurl = str_replace( '&', '&', $actionurl ); 1377 1469 return wp_specialchars( add_query_arg( '_wpnonce', wp_create_nonce( $action ), $actionurl ) ); 1378 1470 } 1379 1471 1380 1381 1472 function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) { 1382 1473 $name = attribute_escape( $name ); 1383 1474 $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; … … 1390 1481 return $nonce_field; 1391 1482 } 1392 1483 1393 1394 1484 function wp_referer_field( $echo = true) { 1395 1485 $ref = attribute_escape( $_SERVER['REQUEST_URI'] ); 1396 1486 $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />'; … … 1409 1499 return $orig_referer_field; 1410 1500 } 1411 1501 1412 1413 1502 function wp_get_referer() { 1414 1503 if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) 1415 1504 $ref = $_REQUEST['_wp_http_referer']; … … 1428 1517 return false; 1429 1518 } 1430 1519 1431 1432 1520 function wp_mkdir_p( $target ) { 1433 1521 // from php.net/mkdir user contributed notes 1434 1522 $target = str_replace( '//', '/', $target ); … … 1452 1540 return false; 1453 1541 } 1454 1542 1455 // Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows') 1543 /** 1544 * Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows'). 1545 * 1546 * @since unknown 1547 * 1548 * @param string $path File path 1549 * @return bool True if path is absolute, false is not absolute. 1550 */ 1456 1551 function path_is_absolute( $path ) { 1457 1552 // this is definitive if true but fails if $path does not exist or contains a symbolic link 1458 1553 if ( realpath($path) == $path ) … … 1469 1564 return (bool) preg_match('#^[/\\\\]#', $path); 1470 1565 } 1471 1566 1472 // Join two filesystem paths together (e.g. 'give me $path relative to $base') 1567 /** 1568 * Join two filesystem paths together (e.g. 'give me $path relative to $base'). 1569 * 1570 * If the $path is absolute, then it the full path is returned. 1571 * 1572 * @since unknown 1573 * 1574 * @param string $base 1575 * @param string $path 1576 * @return string The path with the base or absolute path. 1577 */ 1473 1578 function path_join( $base, $path ) { 1474 1579 if ( path_is_absolute($path) ) 1475 1580 return $path; … … 1477 1582 return rtrim($base, '/') . '/' . ltrim($path, '/'); 1478 1583 } 1479 1584 1480 // Returns an array containing the current upload directory's path and url, or an error message. 1481 function wp_upload_dir( $time = NULL ) { 1585 /** 1586 * Get an array containing the current upload directory's path and url, or an error message. 1587 * 1588 * {@internal Missing Long Description}} 1589 * 1590 * @since 2.0.0 1591 * 1592 * @param unknown_type $time 1593 * @return unknown 1594 */ 1595 function wp_upload_dir( $time = null ) { 1482 1596 $siteurl = get_option( 'siteurl' ); 1483 1597 $upload_path = get_option( 'upload_path' ); 1484 1598 if ( trim($upload_path) === '' ) … … 1519 1633 return apply_filters( 'upload_dir', $uploads ); 1520 1634 } 1521 1635 1522 // return a filename that is sanitized and unique for the given directory 1523 function wp_unique_filename( $dir, $filename, $unique_filename_callback = NULL ) { 1636 /** 1637 * Get a filename that is sanitized and unique for the given directory. 1638 * 1639 * {@internal Missing Long Description}} 1640 * 1641 * @since 2.5 1642 * 1643 * @param string $dir 1644 * @param string $filename 1645 * @param string $unique_filename_callback Function name 1646 * @return unknown 1647 */ 1648 function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) { 1524 1649 $filename = strtolower( $filename ); 1525 1650 // separate the filename into a name and extension 1526 1651 $info = pathinfo($filename); 1527 1652 $ext = $info['extension']; 1528 1653 $name = basename($filename, ".{$ext}"); 1529 1654 1530 1655 // edge case: if file is named '.ext', treat as an empty name 1531 1656 if( $name === ".$ext" ) 1532 1657 $name = ''; … … 1557 1682 return $filename; 1558 1683 } 1559 1684 1560 function wp_upload_bits( $name, $deprecated, $bits, $time = NULL) {1685 function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { 1561 1686 if ( empty( $name ) ) 1562 1687 return array( 'error' => __( "Empty filename" ) ); 1563 1688 … … 1596 1721 return array( 'file' => $new_file, 'url' => $url, 'error' => false ); 1597 1722 } 1598 1723 1724 /** 1725 * Retrieve the file type based on the extension name. 1726 * 1727 * @package WordPress 1728 * @since unknown 1729 * @uses apply_filters() Calls 'ext2type' hook on default supported types. 1730 * 1731 * @param string $ext The extension to search. 1732 * @return string|null The file type, example: audio, video, document, spreadsheet, etc. Null if not found. 1733 */ 1599 1734 function wp_ext2type( $ext ) { 1600 1735 $ext2type = apply_filters('ext2type', array( 1601 1736 'audio' => array('aac','ac3','aif','aiff','mp1','mp2','mp3','m3a','m4a','m4b','ogg','ram','wav','wma'), … … 1612 1747 return $type; 1613 1748 } 1614 1749 1750 /** 1751 * Retrieve the file type from the file name. 1752 * 1753 * You can optionally define the mime array, if needed. 1754 * 1755 * @since 2.0.4 1756 * 1757 * @param string $filename File name or path. 1758 * @param array $mimes Optional. Key is the file extension with value as the mime type. 1759 * @return array Values with extension first and mime type. 1760 */ 1615 1761 function wp_check_filetype( $filename, $mimes = null ) { 1616 1762 // Accepted MIME types are set here as PCRE unless provided. 1617 1763 $mimes = ( is_array( $mimes ) ) ? $mimes : apply_filters( 'upload_mimes', array( … … 1676 1822 return compact( 'ext', 'type' ); 1677 1823 } 1678 1824 1825 /** 1826 * Retrieve nonce action "Are you sure" message. 1827 * 1828 * The action is split by verb and noun. The action format is as follows: 1829 * verb-action_extra. The verb is before the first dash and has the format of 1830 * letters and no spaces and numbers. The noun is after the dash and before the 1831 * underscore, if an underscore exists. The noun is also only letters. 1832 * 1833 * The filter will be called for any action, which is not defined by WordPress. 1834 * You may use the filter for your plugin to explain nonce actions to the user, 1835 * when they get the "Are you sure?" message. The filter is in the format of 1836 * 'explain_nonce_$verb-$noun' with the $verb replaced by the found verb and the 1837 * $noun replaced by the found noun. The two parameters that are given to the 1838 * hook are the localized "Are you sure you want to do this?" message with the 1839 * extra text (the text after the underscore). 1840 * 1841 * @since 2.0.4 1842 * 1843 * @param string $action Nonce action. 1844 * @return string Are you sure message. 1845 */ 1679 1846 function wp_explain_nonce( $action ) { 1680 1847 if ( $action !== -1 && preg_match( '/([a-z]+)-([a-z]+)(_(.+))?/', $action, $matches ) ) { 1681 1848 $verb = $matches[1]; … … 1741 1908 return apply_filters( 'explain_nonce_' . $verb . '-' . $noun, __( 'Are you sure you want to do this?' ), $matches[4] ); 1742 1909 } 1743 1910 1744 1911 /** 1912 * Display "Are You Sure" message to confirm the action being taken. 1913 * 1914 * If the action has the nonce explain message, then it will be displayed along 1915 * with the "Are you sure?" message. 1916 * 1917 * @since 2.0.4 1918 * 1919 * @param string $action The nonce action. 1920 */ 1745 1921 function wp_nonce_ays( $action ) { 1746 1922 $title = __( 'WordPress Failure Notice' ); 1747 1923 $html = wp_specialchars( wp_explain_nonce( $action ) ) . '</p>'; … … 1750 1926 wp_die( $html, $title); 1751 1927 } 1752 1928 1753 1929 /** 1930 * Kill WordPress execution and display HTML message with error message. 1931 * 1932 * Call this function complements the die() PHP function. The difference is that 1933 * HTML will be displayed to the user. It is recommended to use this function 1934 * only, when the execution should not continue any further. It is not 1935 * recommended to call this function very often and try to handle as many errors 1936 * as possible siliently. 1937 * 1938 * @since 2.0.4 1939 * 1940 * @param string $message Error message. 1941 * @param string $title Error title. 1942 */ 1754 1943 function wp_die( $message, $title = '' ) { 1755 1944 global $wp_locale; 1756 1945 … … 1820 2009 die(); 1821 2010 } 1822 2011 1823 2012 /** 2013 * Retrieve the WordPress home page URL. 2014 * 2015 * If the constant named 'WP_HOME' exists, then it willl be used and returned by 2016 * the function. This can be used to counter the redirection on your local 2017 * development environment. 2018 * 2019 * @access private 2020 * @package WordPress 2021 * @since 2.2.0 2022 * 2023 * @param string $url URL for the home location 2024 * @return string Homepage location. 2025 */ 1824 2026 function _config_wp_home( $url = '' ) { 1825 2027 if ( defined( 'WP_HOME' ) ) 1826 2028 return WP_HOME; 1827 2029 return $url; 1828 2030 } 1829 2031 1830 2032 /** 2033 * Retrieve the WordPress site URL. 2034 * 2035 * If the constant named 'WP_SITEURL' is defined, then the value in that 2036 * constant will always be returned. This can be used for debugging a site on 2037 * your localhost while not having to change the database to your URL. 2038 * 2039 * @access private 2040 * @package WordPress 2041 * @since 2.2.0 2042 * 2043 * @param string $url URL to set the WordPress site location. 2044 * @return string The WordPress Site URL 2045 */ 1831 2046 function _config_wp_siteurl( $url = '' ) { 1832 2047 if ( defined( 'WP_SITEURL' ) ) 1833 2048 return WP_SITEURL; 1834 2049 return $url; 1835 2050 } 1836 2051 1837 2052 /** 2053 * Set the localized direction for MCE plugin. 2054 * 2055 * Will only set the direction to 'rtl', if the WordPress locale has the text 2056 * direction set to 'rtl'. 2057 * 2058 * Fills in the 'directionality', 'plugins', and 'theme_advanced_button1' array 2059 * keys. These keys are then returned in the $input array. 2060 * 2061 * @access private 2062 * @package WordPress 2063 * @subpackage MCE 2064 * @since 2.1.0 2065 * 2066 * @param array $input MCE plugin array. 2067 * @return array Direction set for 'rtl', if needed by locale. 2068 */ 1838 2069 function _mce_set_direction( $input ) { 1839 2070 global $wp_locale; 1840 2071 … … 1847 2078 return $input; 1848 2079 } 1849 2080 1850 2081 /** 2082 * Convert smiley code to the icon graphic file equivalent. 2083 * 2084 * You can turn off smilies, by going to the write setting screen and unchecking 2085 * the box, or by setting 'use_smilies' option to false or removing the option. 2086 * 2087 * Plugins may override the default smiley list by setting the $wpsmiliestrans 2088 * to an array, with the key the code the blogger types in and the value the 2089 * image file. 2090 * 2091 * The $wp_smiliessearch global is for the regular expression array and is 2092 * set each time the function is called. The $wp_smiliesreplace is the full 2093 * replacement. Supposely, the $wp_smiliessearch array is looped over using 2094 * preg_replace() or just setting the array of $wp_smiliessearch along with the 2095 * array of $wp_smiliesreplace in the search and replace parameters of 2096 * preg_replace(), which would be faster and less overhead. Either way, both are 2097 * used with preg_replace() and can be defined after the function is called. 2098 * 2099 * The full list of smilies can be found in the function and won't be listed in 2100 * the description. Probably should create a Codex page for it, so that it is 2101 * available. 2102 * 2103 * @global array $wpsmiliestrans 2104 * @global array $wp_smiliesreplace 2105 * @global array $wp_smiliessearch 2106 * @since 2.2.0 2107 */ 1851 2108 function smilies_init() { 1852 2109 global $wpsmiliestrans, $wp_smiliessearch, $wp_smiliesreplace; 1853 2110 … … 2045 2302 * Converts value to positive integer. 2046 2303 * 2047 2304 * @since 2.5 2048 * 2049 * @param mixed $maybeint data you wish to have convered to an absolute integer2050 * @return int an absolute integer2305 * 2306 * @param mixed $maybeint Data you wish to have convered to an absolute integer 2307 * @return int An absolute integer 2051 2308 */ 2052 2309 function absint( $maybeint ) { 2053 2310 return abs( intval( $maybeint ) ); … … 2066 2323 function url_is_accessable_via_ssl($url) 2067 2324 { 2068 2325 if (in_array('curl', get_loaded_extensions())) { 2069 $ssl = preg_replace( '/^http:\/\//', 'https://', $url );2326 $ssl = preg_replace( '/^http:\/\//', 'https://', $url ); 2070 2327 2071 $ch = curl_init();2072 curl_setopt($ch, CURLOPT_URL, $ssl);2073 curl_setopt($ch, CURLOPT_FAILONERROR, true);2074 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);2075 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);2328 $ch = curl_init(); 2329 curl_setopt($ch, CURLOPT_URL, $ssl); 2330 curl_setopt($ch, CURLOPT_FAILONERROR, true); 2331 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 2332 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 2076 2333 2077 curl_exec($ch);2334 curl_exec($ch); 2078 2335 2079 $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);2080 curl_close ($ch);2336 $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); 2337 curl_close ($ch); 2081 2338 2082 if ($status == 200 || $status == 401) {2083 return true;2084 }2339 if ($status == 200 || $status == 401) { 2340 return true; 2341 } 2085 2342 } 2086 2343 return false; 2087 2344 } … … 2123 2380 * @uses apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do trigger or false to not trigger error. 2124 2381 * 2125 2382 * @param string $function The function that was called 2126 * @param string $version The version of WordPress that deprec eated the function2383 * @param string $version The version of WordPress that deprecated the function 2127 2384 * @param string $replacement Optional. The function that should have been called 2128 2385 */ 2129 2386 function _deprecated_function($function, $version, $replacement=null) { … … 2160 2417 * @uses apply_filters() Calls 'deprecated_file_trigger_error' and expects boolean value of true to do trigger or false to not trigger error. 2161 2418 * 2162 2419 * @param string $file The file that was included 2163 * @param string $version The version of WordPress that deprec eated the function2420 * @param string $version The version of WordPress that deprecated the function 2164 2421 * @param string $replacement Optional. The function that should have been called 2165 2422 */ 2166 2423 function _deprecated_file($file, $version, $replacement=null) {
