Changeset 8242 for branches/crazyhorse/wp-includes/functions.php
- Timestamp:
- 07/02/2008 11:07:56 PM (18 years ago)
- File:
-
- 1 edited
-
branches/crazyhorse/wp-includes/functions.php (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/crazyhorse/wp-includes/functions.php
r8103 r8242 100 100 } 101 101 102 102 /** 103 * Retrieve the date in localized format, based on timestamp. 104 * 105 * If the locale specifies the locale month and weekday, then the locale will 106 * take over the format for the date. If it isn't, then the date format string 107 * will be used instead. 108 * 109 * @since 0.71 110 * 111 * @param string $dateformatstring Format to display the date 112 * @param int $unixtimestamp Unix timestamp 113 * @return string The date, translated if locale specifies it. 114 */ 103 115 function date_i18n( $dateformatstring, $unixtimestamp ) { 104 116 global $wp_locale; 105 117 $i = $unixtimestamp; 118 // Sanity check for PHP 5.1.0- 119 if ( -1 == $i ) 120 $i = false; 121 106 122 if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { 107 123 $datemonth = $wp_locale->get_month( date( 'm', $i ) ); … … 277 293 } 278 294 279 /* Options functions */280 281 295 /** 282 296 * Retrieve option value based on setting name. 283 297 * 284 * {@internal Missing Long Description}} 298 * If the option does not exist or does not have a value, then the return value 299 * will be false. This is useful to check whether you need to install an option 300 * and is commonly used during installation of plugin options and to test 301 * whether upgrading is required. 302 * 303 * You can "short-circuit" the retrieval of the option from the database for 304 * your plugin or core options that aren't protected. You can do so by hooking 305 * into the 'pre_option_$option' with the $option being replaced by the option 306 * name. You should not try to override special options, but you will not be 307 * prevented from doing so. 308 * 309 * There is a second filter called 'option_$option' with the $option being 310 * replaced with the option name. This gives the value as the only parameter. 285 311 * 286 312 * @since 1.5.0 287 313 * @package WordPress 288 314 * @subpackage Option 315 * @uses apply_filters() Calls 'pre_option_$optionname' false to allow 316 * overwriting the option value in a plugin. 317 * @uses apply_filters() Calls 'option_$optionname' with the option name value. 289 318 * 290 319 * @param string $setting Name of option to retrieve. Should already be SQL-escaped … … 371 400 } 372 401 402 /** 403 * Retrieve all autoload options or all options, if no autoloaded ones exist. 404 * 405 * This is different from wp_load_alloptions(), in this that function does not 406 * cache all options and will retrieve all options from the database every time 407 * it is called. 408 * 409 * @since 1.0.0 410 * @package WordPress 411 * @subpackage Option 412 * @uses apply_filters() Calls 'pre_option_$optionname' hook with option value as parameter. 413 * @uses apply_filters() Calls 'all_options' on options list. 414 * 415 * @return array List of all options. 416 */ 373 417 function get_alloptions() { 374 418 global $wpdb, $wp_queries; … … 381 425 // "When trying to design a foolproof system, 382 426 // never underestimate the ingenuity of the fools :)" -- Dougal 383 if ( in_array( $option->option_name, array( 'siteurl', 'home', 'category_base' ) ) )427 if ( in_array( $option->option_name, array( 'siteurl', 'home', 'category_base', 'tag_base' ) ) ) 384 428 $option->option_value = untrailingslashit( $option->option_value ); 385 429 $value = maybe_unserialize( $option->option_value ); … … 389 433 } 390 434 391 435 /** 436 * Loads and caches all autoloaded options, if available or all options. 437 * 438 * This is different from get_alloptions(), in that this function will cache the 439 * options and will return the cached options when called again. 440 * 441 * @since 2.2.0 442 * @package WordPress 443 * @subpackage Option 444 * 445 * @return array List all options. 446 */ 392 447 function wp_load_alloptions() { 393 448 global $wpdb; … … 408 463 } 409 464 410 411 // expects $option_name to NOT be SQL-escaped 465 /** 466 * Update the value of an option that was already added. 467 * 468 * If the option does not exist, then the option will be added with the option 469 * value, but you will not be able to set whether it is autoloaded. If you want 470 * to set whether an option autoloaded, then you need to use the add_option(). 471 * 472 * When the option is updated, then the filter named 473 * 'update_option_$option_name', with the $option_name as the $option_name 474 * parameter value, will be called. The hook should accept two parameters, the 475 * first is the old parameter and the second is the new parameter. 476 * 477 * @since 1.0.0 478 * @package WordPress 479 * @subpackage Option 480 * 481 * @param string $option_name Option name. Expected to not be SQL-escaped 482 * @param mixed $newvalue Option value. 483 * @return bool False if value was not updated and true if value was updated. 484 */ 412 485 function update_option( $option_name, $newvalue ) { 413 486 global $wpdb; … … 453 526 } 454 527 455 456 // thx Alex Stapleton, http://alex.vort-x.net/blog/ 457 // expects $name to NOT be SQL-escaped 528 /** 529 * Add a new option. 530 * 531 * You can create options without values and then add values later. Does not 532 * check whether the option has already been added, but does check that you 533 * aren't adding a protected WordPress option. Care should be taken to not name 534 * options, the same as the ones which are protected and to not add options 535 * that were already added. 536 * 537 * The filter named 'add_option_$optionname', with the $optionname being 538 * replaced with the option's name, will be called. The hook should accept two 539 * parameters, the first is the option name, and the second is the value. 540 * 541 * @package WordPress 542 * @subpackage Option 543 * @since 1.0.0 544 * @link http://alex.vort-x.net/blog/ Thanks Alex Stapleton 545 * 546 * @param string $name Option name to add. Expects to NOT be SQL escaped. 547 * @param mixed $value Optional. Option value, can be anything. 548 * @param mixed $deprecated Optional. Description. Not used anymore. 549 * @param bool $autoload Optional. Default is enabled. Whether to load the option when WordPress starts up. 550 * @return null returns when finished. 551 */ 458 552 function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) { 459 553 global $wpdb; … … 489 583 $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES (%s, %s, %s)", $name, $value, $autoload ) ); 490 584 491 do_action( "add_option_{$name}", $name, $value ); 585 do_action( "add_option_{$name}", $name, $value ); 492 586 return; 493 587 } 494 588 495 589 /** 590 * Removes option by name and prevents removal of protected WordPress options. 591 * 592 * @package WordPress 593 * @subpackage Option 594 * @since unknown 595 * 596 * @param string $name Option name to remove. 597 * @return bool True, if succeed. False, if failure. 598 */ 496 599 function delete_option( $name ) { 497 600 global $wpdb; … … 518 621 } 519 622 520 623 /** 624 * Serialize data, if needed. 625 * 626 * @param mixed $data Data that might be serialized. 627 * @return mixed A scalar data 628 */ 521 629 function maybe_serialize( $data ) { 522 630 if ( is_string( $data ) ) … … 582 690 } 583 691 584 692 /** 693 * Open the file handle for debugging. 694 * 695 * This function is used for XMLRPC feature, but it is general purpose enough 696 * to be used in anywhere. 697 * 698 * @see fopen() for mode options. 699 * @package WordPress 700 * @subpackage Debug 701 * @since unknown 702 * @uses $debug Used for whether debugging is enabled. 703 * 704 * @param string $filename File path to debug file. 705 * @param string $mode Same as fopen() mode parameter. 706 * @return bool|resource File handle. False on failure. 707 */ 585 708 function debug_fopen( $filename, $mode ) { 586 709 global $debug; … … 593 716 } 594 717 595 718 /** 719 * Write contents to the file used for debugging. 720 * 721 * Technically, this can be used to write to any file handle when the global 722 * $debug is set to 1 or true. 723 * 724 * @package WordPress 725 * @subpackage Debug 726 * @since unknown 727 * @uses $debug Used for whether debugging is enabled. 728 * 729 * @param resource $fp File handle for debugging file. 730 * @param string $string Content to write to debug file. 731 */ 596 732 function debug_fwrite( $fp, $string ) { 597 733 global $debug; … … 600 736 } 601 737 602 738 /** 739 * Close the debugging file handle. 740 * 741 * Technically, this can be used to close any file handle when the global $debug 742 * is set to 1 or true. 743 * 744 * @package WordPress 745 * @subpackage Debug 746 * @since unknown 747 * @uses $debug Used for whether debugging is enabled. 748 * 749 * @param resource $fp Debug File handle. 750 */ 603 751 function debug_fclose( $fp ) { 604 752 global $debug; … … 769 917 } 770 918 771 919 /** 920 * Build URL query based on an associative and, or indexed array. 921 * 922 * This is a convenient function for easily building url queries. It sets the 923 * separator to '&' and uses _http_build_query() function. 924 * 925 * @see _http_build_query() Used to build the query 926 * @link http://us2.php.net/manual/en/function.http-build-query.php more on what 927 * http_build_query() does. 928 * 929 * @since unknown 930 * 931 * @param array $data URL-encode key/value pairs. 932 * @return string URL encoded string 933 */ 772 934 function build_query( $data ) { 773 935 return _http_build_query( $data, NULL, '&', '', false ); … … 775 937 776 938 /** 777 * Retrieve a modified query string. 778 * 779 * {@internal Missing Long Description}} 780 * 781 * Adding a single key & value or an associative array. 782 * Setting a key value to emptystring removes the key. 783 * Omitting oldquery_or_uri uses the $_SERVER value. 939 * Retrieve a modified URL query string. 940 * 941 * You can rebuild the URL and append a new query variable to the URL query by 942 * using this function. You can also retrieve the full URL with query data. 943 * 944 * Adding a single key & value or an associative array. Setting a key value to 945 * emptystring removes the key. Omitting oldquery_or_uri uses the $_SERVER 946 * value. 784 947 * 785 948 * @since 1.5.0 … … 894 1057 } 895 1058 1059 /** 1060 * HTTP request for URI to retrieve content. 1061 * 1062 * Tries to retrieve the HTTP content with fopen first and then using cURL, if 1063 * fopen can't be used. 1064 * 1065 * @since unknown 1066 * 1067 * @param string $uri URI/URL of web page to retrieve. 1068 * @return string HTTP content. 1069 */ 896 1070 function wp_remote_fopen( $uri ) { 897 1071 $timeout = 10; … … 1005 1179 } 1006 1180 1007 1181 /** 1182 * Set HTTP status header. 1183 * 1184 * @since unknown 1185 * @uses apply_filters() Calls 'status_header' on status header string, HTTP 1186 * HTTP code, HTTP code description, and protocol string as separate 1187 * parameters. 1188 * 1189 * @param int $header HTTP status code 1190 * @return null Does not return anything. 1191 */ 1008 1192 function status_header( $header ) { 1009 1193 $text = get_status_header_desc( $header ); … … 1301 1485 // $dir is absolute, $path is (maybe) relative to ABSPATH 1302 1486 $dir = path_join( ABSPATH, $upload_path ); 1303 $path = str_replace( ABSPATH, '', trim( $upload_path ) );1304 1487 1305 1488 if ( !$url = get_option( 'upload_url_path' ) ) 1306 $url = trailingslashit( $siteurl ) . $path;1489 $url = WP_CONTENT_URL . '/uploads'; 1307 1490 1308 1491 if ( defined('UPLOADS') ) { … … 1310 1493 $url = trailingslashit( $siteurl ) . UPLOADS; 1311 1494 } 1312 1495 1313 1496 $subdir = ''; 1314 1497 if ( get_option( 'uploads_use_yearmonth_folders' ) ) { … … 1791 1974 } 1792 1975 1793 1794 1976 /** 1795 1977 * Load the correct database class file. … … 1809 1991 require_once( ABSPATH . WPINC . '/wp-db.php' ); 1810 1992 } 1811 1812 1993 1813 1994 /** … … 1858 2039 } 1859 2040 1860 1861 2041 /** 1862 2042 * Converts value to positive integer. … … 1870 2050 return abs( intval( $maybeint ) ); 1871 2051 } 1872 1873 2052 1874 2053 /** … … 1904 2083 return false; 1905 2084 } 1906 1907 2085 1908 2086 /** … … 1922 2100 } 1923 2101 1924 1925 2102 /** 1926 2103 * Marks a function as deprecated and informs when it has been used. … … 1960 2137 } 1961 2138 1962 1963 2139 /** 1964 2140 * Marks a file as deprecated and informs when it has been used. … … 1998 2174 } 1999 2175 2000 2001 2176 /** 2002 2177 * Is the server running earlier than 1.5.0 version of lighttpd … … 2011 2186 return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ); 2012 2187 } 2013 2014 2188 2015 2189 /** … … 2042 2216 } 2043 2217 2044 2045 2218 /** 2046 2219 * File validates against allowed set of defined rules. … … 2073 2246 } 2074 2247 2075 2076 2248 /** 2077 2249 * Determine if SSL is used. … … 2084 2256 return ( 'on' == strtolower($_SERVER['HTTPS']) ) ? true : false; 2085 2257 } 2086 2087 2258 2088 2259 /** … … 2106 2277 } 2107 2278 2108 2109 2279 /** 2110 2280 * Whether to force SSL used for the Administration Panels. … … 2127 2297 } 2128 2298 2299 /** 2300 * Guess the URL for the site. 2301 * 2302 * Will remove wp-admin links to retrieve only return URLs not in the wp-admin 2303 * directory. 2304 * 2305 * @since 2.6 2306 * 2307 * @return string 2308 */ 2309 function wp_guess_url() { 2310 if ( defined('WP_SITEURL') && '' != WP_SITEURL ) { 2311 $url = WP_SITEURL; 2312 } else { 2313 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; 2314 $url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 2315 } 2316 return $url; 2317 } 2318 2129 2319 ?>
Note: See TracChangeset
for help on using the changeset viewer.