]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/functions.php
Wordpress 3.3
[autoinstalls/wordpress.git] / wp-includes / functions.php
index 7a682ef364400926727f39267aa2fe4b825f8f11..6b5aa505ca7570ff2c327e9aec7b96e4b6bdb403 100644 (file)
@@ -20,7 +20,7 @@
  * @param string $dateformatstring Either 'G', 'U', or php date format.
  * @param string $mysqlstring Time from mysql DATETIME field.
  * @param bool $translate Optional. Default is true. Will switch format to locale.
- * @return string Date formated by $dateformatstring or locale (if available).
+ * @return string Date formatted by $dateformatstring or locale (if available).
  */
 function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
        $m = $mysqlstring;
@@ -324,6 +324,7 @@ function is_serialized_string( $data ) {
  *     the option value.
  *
  * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
+ * @param mixed $default Optional. Default value to return if the option does not exist.
  * @return mixed Value set for the option.
  */
 function get_option( $option, $default = false ) {
@@ -454,7 +455,7 @@ function wp_load_alloptions() {
 }
 
 /**
- * Loads and caches certain often requested site options if is_multisite() and a peristent cache is not being used.
+ * Loads and caches certain often requested site options if is_multisite() and a persistent cache is not being used.
  *
  * @since 3.0.0
  * @package WordPress
@@ -569,11 +570,10 @@ function update_option( $option, $newvalue ) {
  * it will be serialized before it is inserted into the database. Remember,
  * resources can not be serialized or added as an option.
  *
- * You can create options without values and then add values later. Does not
- * check whether the option has already been added, but does check that you
+ * You can create options without values and then update the values later.
+ * Existing options will not be updated and checks are performed to ensure that you
  * aren't adding a protected WordPress option. Care should be taken to not name
- * options the same as the ones which are protected and to not add options
- * that were already added.
+ * options the same as the ones which are protected.
  *
  * @package WordPress
  * @subpackage Option
@@ -586,7 +586,7 @@ function update_option( $option, $newvalue ) {
  * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped.
  * @param mixed $deprecated Optional. Description. Not used anymore.
  * @param bool $autoload Optional. Default is enabled. Whether to load the option when WordPress starts up.
- * @return null returns when finished.
+ * @return bool False if option was not added and true if option was added.
  */
 function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
        global $wpdb;
@@ -609,7 +609,7 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
        $notoptions = wp_cache_get( 'notoptions', 'options' );
        if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
                if ( false !== get_option( $option ) )
-                       return;
+                       return false;
 
        $_value = $value;
        $value = maybe_serialize( $value );
@@ -686,7 +686,7 @@ function delete_option( $option ) {
 }
 
 /**
- * Delete a transient
+ * Delete a transient.
  *
  * @since 2.8.0
  * @package WordPress
@@ -719,7 +719,7 @@ function delete_transient( $transient ) {
 }
 
 /**
- * Get the value of a transient
+ * Get the value of a transient.
  *
  * If the transient does not exist or does not have a value, then the return value
  * will be false.
@@ -768,7 +768,7 @@ function get_transient( $transient ) {
 }
 
 /**
- * Set/update the value of a transient
+ * Set/update the value of a transient.
  *
  * You do not need to serialize values. If the value needs to be serialized, then
  * it will be serialized before it is set.
@@ -1037,6 +1037,8 @@ function maybe_serialize( $data ) {
        if ( is_array( $data ) || is_object( $data ) )
                return serialize( $data );
 
+       // Double serialization is required for backward compatibility.
+       // See http://core.trac.wordpress.org/ticket/12930
        if ( is_serialized( $data ) )
                return serialize( $data );
 
@@ -1417,8 +1419,9 @@ function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=t
  * using this function. You can also retrieve the full URL with query data.
  *
  * Adding a single key & value or an associative array. Setting a key value to
- * emptystring removes the key. Omitting oldquery_or_uri uses the $_SERVER
- * value.
+ * an empty string removes the key. Omitting oldquery_or_uri uses the $_SERVER
+ * value. Additional values provided are expected to be encoded appropriately
+ * with urlencode() or rawurlencode().
  *
  * @since 1.5.0
  *
@@ -1794,7 +1797,7 @@ function do_feed_rdf() {
 }
 
 /**
- * Load the RSS 1.0 Feed Template
+ * Load the RSS 1.0 Feed Template.
  *
  * @since 2.1.0
  */
@@ -1831,27 +1834,28 @@ function do_feed_atom( $for_comments ) {
 }
 
 /**
- * Display the robot.txt file content.
+ * Display the robots.txt file content.
  *
  * The echo content should be with usage of the permalinks or for creating the
- * robot.txt file.
+ * robots.txt file.
  *
  * @since 2.1.0
- * @uses do_action() Calls 'do_robotstxt' hook for displaying robot.txt rules.
+ * @uses do_action() Calls 'do_robotstxt' hook for displaying robots.txt rules.
  */
 function do_robots() {
        header( 'Content-Type: text/plain; charset=utf-8' );
 
        do_action( 'do_robotstxt' );
 
-       $output = '';
+       $output = "User-agent: *\n";
        $public = get_option( 'blog_public' );
-       if ( '0' ==  $public ) {
-               $output .= "User-agent: *\n";
+       if ( '0' == $public ) {
                $output .= "Disallow: /\n";
        } else {
-               $output .= "User-agent: *\n";
-               $output .= "Disallow:\n";
+               $site_url = parse_url( site_url() );
+               $path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';
+               $output .= "Disallow: $path/wp-admin/\n";
+               $output .= "Disallow: $path/wp-includes/\n";
        }
 
        echo apply_filters('robots_txt', $output, $public);
@@ -1895,32 +1899,35 @@ function is_blog_installed() {
        if ( $installed )
                return true;
 
+       // If visiting repair.php, return true and let it take over.
+       if ( defined( 'WP_REPAIRING' ) )
+               return true;
+
        $suppress = $wpdb->suppress_errors();
-       $tables = $wpdb->get_col('SHOW TABLES');
-       $wpdb->suppress_errors( $suppress );
 
-       $wp_tables = $wpdb->tables();
        // 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
        // table could not be accessed.
+       $wp_tables = $wpdb->tables();
        foreach ( $wp_tables as $table ) {
-               // If one of the WP tables exist, then we are in an insane state.
-               if ( in_array( $table, $tables ) ) {
-                       // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
-                       if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
-                               continue;
-                       if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
-                               continue;
+               // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
+               if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
+                       continue;
+               if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
+                       continue;
 
-                       // If visiting repair.php, return true and let it take over.
-                       if ( defined('WP_REPAIRING') )
-                               return true;
-                       // Die with a DB error.
-                       $wpdb->error = sprintf( /*WP_I18N_NO_TABLES*/'One or more database tables are unavailable.  The database may need to be <a href="%s">repaired</a>.'/*/WP_I18N_NO_TABLES*/, 'maint/repair.php?referrer=is_blog_installed' );
-                       dead_db();
-               }
+               if ( ! $wpdb->get_results( "DESCRIBE $table;" ) )
+                       continue;
+
+               // One or more tables exist. We are insane.
+
+               // Die with a DB error.
+               $wpdb->error = sprintf( /*WP_I18N_NO_TABLES*/'One or more database tables are unavailable.  The database may need to be <a href="%s">repaired</a>.'/*/WP_I18N_NO_TABLES*/, 'maint/repair.php?referrer=is_blog_installed' );
+               dead_db();
        }
 
+       $wpdb->suppress_errors( $suppress );
+
        wp_cache_set( 'is_blog_installed', false );
 
        return false;
@@ -2030,7 +2037,8 @@ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
 }
 
 /**
- * Retrieve referer from '_wp_http_referer', HTTP referer, or current page respectively.
+ * Retrieve referer from '_wp_http_referer' or HTTP referer. If it's the same
+ * as the current request URL, will return false.
  *
  * @package WordPress
  * @subpackage Security
@@ -2039,13 +2047,13 @@ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
  * @return string|bool False on failure. Referer URL on success.
  */
 function wp_get_referer() {
-       $ref = '';
+       $ref = false;
        if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
                $ref = $_REQUEST['_wp_http_referer'];
        else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
                $ref = $_SERVER['HTTP_REFERER'];
 
-       if ( $ref !== $_SERVER['REQUEST_URI'] )
+       if ( $ref && $ref !== $_SERVER['REQUEST_URI'] )
                return $ref;
        return false;
 }
@@ -2125,7 +2133,7 @@ function path_is_absolute( $path ) {
                return true;
 
        // a path starting with / or \ is absolute; anything else is relative
-       return (bool) preg_match('#^[/\\\\]#', $path);
+       return ( $path[0] == '/' || $path[0] == '\\' );
 }
 
 /**
@@ -2432,7 +2440,7 @@ function wp_ext2type( $ext ) {
                'spreadsheet' => array( 'numbers',     'ods',  'xls',  'xlsx', 'xlsb',  'xlsm' ),
                'interactive' => array( 'key', 'ppt',  'pptx', 'pptm', 'odp',  'swf' ),
                'text'        => array( 'asc', 'csv',  'tsv',  'txt' ),
-               'archive'     => array( 'bz2', 'cab',  'dmg',  'gz',   'rar',  'sea',   'sit', 'sqx', 'tar', 'tgz',  'zip' ),
+               'archive'     => array( 'bz2', 'cab',  'dmg',  'gz',   'rar',  'sea',   'sit', 'sqx', 'tar', 'tgz',  'zip', '7z' ),
                'code'        => array( 'css', 'htm',  'html', 'php',  'js' ),
        ));
        foreach ( $ext2type as $type => $exts )
@@ -2598,6 +2606,8 @@ function get_allowed_mime_types() {
                'tar' => 'application/x-tar',
                'zip' => 'application/zip',
                'gz|gzip' => 'application/x-gzip',
+               'rar' => 'application/rar',
+               '7z' => 'application/x-7z-compressed',
                'exe' => 'application/x-msdownload',
                // openoffice formats
                'odt' => 'application/vnd.oasis.opendocument.text',
@@ -2744,13 +2754,13 @@ function wp_nonce_ays( $action ) {
  * HTML will be displayed to the user. It is recommended to use this function
  * only, when the execution should not continue any further. It is not
  * recommended to call this function very often and try to handle as many errors
- * as possible siliently.
+ * as possible silently.
  *
  * @since 2.0.4
  *
  * @param string $message Error message.
  * @param string $title Error title.
- * @param string|array $args Optional arguements to control behaviour.
+ * @param string|array $args Optional arguments to control behavior.
  */
 function wp_die( $message, $title = '', $args = array() ) {
        if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
@@ -2776,7 +2786,7 @@ function wp_die( $message, $title = '', $args = array() ) {
  *
  * @param string $message Error message.
  * @param string $title Error title.
- * @param string|array $args Optional arguements to control behaviour.
+ * @param string|array $args Optional arguments to control behavior.
  */
 function _default_wp_die_handler( $message, $title = '', $args = array() ) {
        $defaults = array( 'response' => 500 );
@@ -2808,48 +2818,105 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
 
        if ( isset( $r['back_link'] ) && $r['back_link'] ) {
                $back_text = $have_gettext? __('&laquo; Back') : '&laquo; Back';
-               $message .= "\n<p><a href='javascript:history.back()'>$back_text</p>";
+               $message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
        }
 
-       if ( defined( 'WP_SITEURL' ) && '' != WP_SITEURL )
-               $admin_dir = WP_SITEURL . '/wp-admin/';
-       elseif ( function_exists( 'get_bloginfo' ) && '' != get_bloginfo( 'wpurl' ) )
-               $admin_dir = get_bloginfo( 'wpurl' ) . '/wp-admin/';
-       elseif ( strpos( $_SERVER['PHP_SELF'], 'wp-admin' ) !== false )
-               $admin_dir = '';
-       else
-               $admin_dir = 'wp-admin/';
-
        if ( !function_exists( 'did_action' ) || !did_action( 'admin_head' ) ) :
-       if ( !headers_sent() ) {
-               status_header( $r['response'] );
-               nocache_headers();
-               header( 'Content-Type: text/html; charset=utf-8' );
-       }
+               if ( !headers_sent() ) {
+                       status_header( $r['response'] );
+                       nocache_headers();
+                       header( 'Content-Type: text/html; charset=utf-8' );
+               }
 
-       if ( empty($title) )
-               $title = $have_gettext ? __('WordPress &rsaquo; Error') : 'WordPress &rsaquo; Error';
+               if ( empty($title) )
+                       $title = $have_gettext ? __('WordPress &rsaquo; Error') : 'WordPress &rsaquo; Error';
 
-       $text_direction = 'ltr';
-       if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
-               $text_direction = 'rtl';
-       elseif ( function_exists( 'is_rtl' ) && is_rtl() )
-               $text_direction = 'rtl';
+               $text_direction = 'ltr';
+               if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
+                       $text_direction = 'rtl';
+               elseif ( function_exists( 'is_rtl' ) && is_rtl() )
+                       $text_direction = 'rtl';
 ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono -->
+<!DOCTYPE html>
+<!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono
+-->
 <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) language_attributes(); else echo "dir='$text_direction'"; ?>>
 <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><?php echo $title ?></title>
-       <link rel="stylesheet" href="<?php echo $admin_dir; ?>css/install.css" type="text/css" />
-<?php
-if ( 'rtl' == $text_direction ) : ?>
-       <link rel="stylesheet" href="<?php echo $admin_dir; ?>css/install-rtl.css" type="text/css" />
-<?php endif; ?>
+       <style type="text/css">
+               html {
+                       background: #f9f9f9;
+               }
+               body {
+                       background: #fff;
+                       color: #333;
+                       font-family: sans-serif;
+                       margin: 2em auto;
+                       padding: 1em 2em;
+                       -webkit-border-radius: 3px;
+                       border-radius: 3px;
+                       border: 1px solid #dfdfdf;
+                       max-width: 700px;
+               }
+               #error-page {
+                       margin-top: 50px;
+               }
+               #error-page p {
+                       font-size: 14px;
+                       line-height: 1.5;
+                       margin: 25px 0 20px;
+               }
+               #error-page code {
+                       font-family: Consolas, Monaco, monospace;
+               }
+               ul li {
+                       margin-bottom: 10px;
+                       font-size: 14px ;
+               }
+               a {
+                       color: #21759B;
+                       text-decoration: none;
+               }
+               a:hover {
+                       color: #D54E21;
+               }
+
+               .button {
+                       font-family: sans-serif;
+                       text-decoration: none;
+                       font-size: 14px !important;
+                       line-height: 16px;
+                       padding: 6px 12px;
+                       cursor: pointer;
+                       border: 1px solid #bbb;
+                       color: #464646;
+                       -webkit-border-radius: 15px;
+                       border-radius: 15px;
+                       -moz-box-sizing: content-box;
+                       -webkit-box-sizing: content-box;
+                       box-sizing: content-box;
+               }
+
+               .button:hover {
+                       color: #000;
+                       border-color: #666;
+               }
+
+               .button {
+                       background: #f2f2f2 url(<?php echo wp_guess_url(); ?>/wp-admin/images/white-grad.png) repeat-x scroll left top;
+               }
+
+               .button:active {
+                       background: #eee url(<?php echo wp_guess_url(); ?>/wp-admin/images/white-grad-active.png) repeat-x scroll left top;
+               }
+               <?php if ( 'rtl' == $text_direction ) : ?>
+               body { font-family: Tahoma, Arial; }
+               <?php endif; ?>
+       </style>
 </head>
 <body id="error-page">
-<?php endif; ?>
+<?php endif; // !function_exists( 'did_action' ) || !did_action( 'admin_head' ) ?>
        <?php echo $message; ?>
 </body>
 </html>
@@ -2867,7 +2934,7 @@ if ( 'rtl' == $text_direction ) : ?>
  *
  * @param string $message Error message.
  * @param string $title Error title.
- * @param string|array $args Optional arguements to control behaviour.
+ * @param string|array $args Optional arguments to control behavior.
  */
 function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
        global $wp_xmlrpc_server;
@@ -2896,7 +2963,7 @@ function _xmlrpc_wp_die_filter() {
 /**
  * Retrieve the WordPress home page URL.
  *
- * If the constant named 'WP_HOME' exists, then it willl be used and returned by
+ * If the constant named 'WP_HOME' exists, then it will be used and returned by
  * the function. This can be used to counter the redirection on your local
  * development environment.
  *
@@ -2909,7 +2976,7 @@ function _xmlrpc_wp_die_filter() {
  */
 function _config_wp_home( $url = '' ) {
        if ( defined( 'WP_HOME' ) )
-               return WP_HOME;
+               return untrailingslashit( WP_HOME );
        return $url;
 }
 
@@ -2929,7 +2996,7 @@ function _config_wp_home( $url = '' ) {
  */
 function _config_wp_siteurl( $url = '' ) {
        if ( defined( 'WP_SITEURL' ) )
-               return WP_SITEURL;
+               return untrailingslashit( WP_SITEURL );
        return $url;
 }
 
@@ -3098,7 +3165,7 @@ function wp_parse_args( $args, $defaults = '' ) {
 }
 
 /**
- * Clean up an array, comma- or space-separated list of IDs
+ * Clean up an array, comma- or space-separated list of IDs.
  *
  * @since 3.0.0
  *
@@ -3113,7 +3180,7 @@ function wp_parse_id_list( $list ) {
 }
 
 /**
- * Extract a slice of an array, given a list of keys
+ * Extract a slice of an array, given a list of keys.
  *
  * @since 3.1.0
  *
@@ -3131,7 +3198,7 @@ function wp_array_slice_assoc( $array, $keys ) {
 }
 
 /**
- * Filters a list of objects, based on a set of key => value arguments
+ * Filters a list of objects, based on a set of key => value arguments.
  *
  * @since 3.0.0
  *
@@ -3155,7 +3222,7 @@ function wp_filter_object_list( $list, $args = array(), $operator = 'and', $fiel
 }
 
 /**
- * Filters a list of objects, based on a set of key => value arguments
+ * Filters a list of objects, based on a set of key => value arguments.
  *
  * @since 3.1.0
  *
@@ -3180,9 +3247,16 @@ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
        $filtered = array();
 
        foreach ( $list as $key => $obj ) {
-               $matched = count( array_intersect_assoc( (array) $obj, $args ) );
+               $to_match = (array) $obj;
+
+               $matched = 0;
+               foreach ( $args as $m_key => $m_value ) {
+                       if ( $m_value == $to_match[ $m_key ] )
+                               $matched++;
+               }
+
                if ( ( 'AND' == $operator && $matched == $count )
-                 || ( 'OR' == $operator && $matched <= $count )
+                 || ( 'OR' == $operator && $matched > 0 )
                  || ( 'NOT' == $operator && 0 == $matched ) ) {
                        $filtered[$key] = $obj;
                }
@@ -3192,7 +3266,7 @@ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
 }
 
 /**
- * Pluck a certain field out of each object in a list
+ * Pluck a certain field out of each object in a list.
  *
  * @since 3.1.0
  *
@@ -3202,8 +3276,10 @@ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
  */
 function wp_list_pluck( $list, $field ) {
        foreach ( $list as $key => $value ) {
-               $value = (array) $value;
-               $list[ $key ] = $value[ $field ];
+               if ( is_object( $value ) )
+                       $list[ $key ] = $value->$field;
+               else
+                       $list[ $key ] = $value[ $field ];
        }
 
        return $list;
@@ -3285,15 +3361,15 @@ function dead_db() {
        nocache_headers();
        header( 'Content-Type: text/html; charset=utf-8' );
 ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-       <title>Database Error</title>
+       <title><?php echo /*WP_I18N_DB_ERROR*/'Database Error'/*/WP_I18N_DB_ERROR*/; ?></title>
 
 </head>
 <body>
-       <h1>Error establishing a database connection</h1>
+       <h1><?php echo /*WP_I18N_DB_CONNECTION_ERROR*/'Error establishing a database connection'/*/WP_I18N_DB_CONNECTION_ERROR*/; ?></h1>
 </body>
 </html>
 <?php
@@ -3305,7 +3381,7 @@ function dead_db() {
  *
  * @since 2.5.0
  *
- * @param mixed $maybeint Data you wish to have convered to an nonnegative integer
+ * @param mixed $maybeint Data you wish to have converted to a nonnegative integer
  * @return int An nonnegative integer
  */
 function absint( $maybeint ) {
@@ -3372,7 +3448,7 @@ function url_is_accessable_via_ssl($url)
  * @param string $version The version of WordPress that deprecated the function
  * @param string $replacement Optional. The function that should have been called
  */
-function _deprecated_function( $function, $version, $replacement=null ) {
+function _deprecated_function( $function, $version, $replacement = null ) {
 
        do_action( 'deprecated_function_run', $function, $replacement, $version );
 
@@ -3498,12 +3574,13 @@ function _doing_it_wrong( $function, $message, $version ) {
        // Allow plugin to filter the output error trigger
        if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
                $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version );
+               $message .= ' ' . __( 'Please see <a href="http://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.' );
                trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
        }
 }
 
 /**
- * Is the server running earlier than 1.5.0 version of lighttpd
+ * Is the server running earlier than 1.5.0 version of lighttpd?
  *
  * @since 2.5.0
  *
@@ -3516,7 +3593,7 @@ function is_lighttpd_before_150() {
 }
 
 /**
- * Does the specified module exist in the apache config?
+ * Does the specified module exist in the Apache config?
  *
  * @since 2.5.0
  *
@@ -3545,7 +3622,7 @@ function apache_mod_loaded($mod, $default = false) {
 }
 
 /**
- * Check if IIS 7 supports pretty permalinks
+ * Check if IIS 7 supports pretty permalinks.
  *
  * @since 2.8.0
  *
@@ -3559,7 +3636,7 @@ function iis7_supports_permalinks() {
                /* First we check if the DOMDocument class exists. If it does not exist,
                 * which is the case for PHP 4.X, then we cannot easily update the xml configuration file,
                 * hence we just bail out and tell user that pretty permalinks cannot be used.
-                * This is not a big issue because PHP 4.X is going to be depricated and for IIS it
+                * This is not a big issue because PHP 4.X is going to be deprecated and for IIS it
                 * is recommended to use PHP 5.X NTS.
                 * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When
                 * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'.
@@ -3587,16 +3664,16 @@ function iis7_supports_permalinks() {
  * @return int 0 means nothing is wrong, greater than 0 means something was wrong.
  */
 function validate_file( $file, $allowed_files = '' ) {
-       if ( false !== strpos( $file, '..' ))
+       if ( false !== strpos( $file, '..' ) )
                return 1;
 
-       if ( false !== strpos( $file, './' ))
+       if ( false !== strpos( $file, './' ) )
                return 1;
 
-       if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
+       if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) )
                return 3;
 
-       if (':' == substr( $file, 1, 1 ))
+       if (':' == substr( $file, 1, 1 ) )
                return 2;
 
        return 0;
@@ -3681,6 +3758,30 @@ function wp_guess_url() {
        return rtrim($url, '/');
 }
 
+/**
+ * Temporarily suspend cache additions.
+ *
+ * Stops more data being added to the cache, but still allows cache retrieval.
+ * This is useful for actions, such as imports, when a lot of data would otherwise
+ * be almost uselessly added to the cache.
+ *
+ * Suspension lasts for a single page load at most. Remember to call this
+ * function again if you wish to re-enable cache adds earlier.
+ *
+ * @since 3.3.0
+ *
+ * @param bool $suspend Optional. Suspends additions if true, re-enables them if false.
+ * @return bool The current suspend setting
+ */
+function wp_suspend_cache_addition( $suspend = null ) {
+       static $_suspend = false;
+
+       if ( is_bool( $suspend ) )
+               $_suspend = $suspend;
+
+       return $_suspend;
+}
+
 /**
  * Suspend cache invalidation.
  *
@@ -3739,14 +3840,13 @@ function get_site_option( $option, $default = false, $use_cache = true ) {
                        $row = $wpdb->get_row( $wpdb->prepare("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) );
 
                        // Has to be get_row instead of get_var because of funkiness with 0, false, null values
-                       if ( is_object( $row ) )
+                       if ( is_object( $row ) ) {
                                $value = $row->meta_value;
-                       else
+                               $value = maybe_unserialize( $value );
+                               wp_cache_set( $cache_key, $value, 'site-options' );
+                       } else {
                                $value = $default;
-
-                       $value = maybe_unserialize( $value );
-
-                       wp_cache_set( $cache_key, $value, 'site-options' );
+                       }
                }
        }
 
@@ -3756,6 +3856,8 @@ function get_site_option( $option, $default = false, $use_cache = true ) {
 /**
  * Add a new site option.
  *
+ * Existing options will not be updated. Note that prior to 3.3 this wasn't the case.
+ *
  * @see add_option()
  * @package WordPress
  * @subpackage Option
@@ -3779,22 +3881,24 @@ function add_site_option( $option, $value ) {
        } else {
                $cache_key = "{$wpdb->siteid}:$option";
 
-               if ( $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
-                       return update_site_option( $option, $value );
+               if ( false !== get_site_option( $option ) )
+                       return false;
 
                $value = sanitize_option( $option, $value );
                wp_cache_set( $cache_key, $value, 'site-options' );
 
                $_value = $value;
-               $value = maybe_serialize($value);
+               $value = maybe_serialize( $value );
                $result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) );
                $value = $_value;
        }
 
-       do_action( "add_site_option_{$option}", $option, $value );
-       do_action( "add_site_option", $option, $value );
-
-       return $result;
+       if ( $result ) {
+               do_action( "add_site_option_{$option}", $option, $value );
+               do_action( "add_site_option", $option, $value );
+               return true;
+       }
+       return false;
 }
 
 /**
@@ -3864,14 +3968,14 @@ function update_site_option( $option, $value ) {
        if ( $value === $oldvalue )
                return false;
 
+       if ( false === $oldvalue )
+               return add_site_option( $option, $value );
+
        if ( !is_multisite() ) {
                $result = update_option( $option, $value );
        } else {
-               $cache_key = "{$wpdb->siteid}:$option";
-
-               if ( $value && !$wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
-                       return add_site_option( $option, $value );
                $value = sanitize_option( $option, $value );
+               $cache_key = "{$wpdb->siteid}:$option";
                wp_cache_set( $cache_key, $value, 'site-options' );
 
                $_value = $value;
@@ -3881,15 +3985,15 @@ function update_site_option( $option, $value ) {
        }
 
        if ( $result ) {
-               do_action( "update_site_option_{$option}", $option, $value );
-               do_action( "update_site_option", $option, $value );
+               do_action( "update_site_option_{$option}", $option, $value, $oldvalue );
+               do_action( "update_site_option", $option, $value, $oldvalue );
                return true;
        }
        return false;
 }
 
 /**
- * Delete a site transient
+ * Delete a site transient.
  *
  * @since 2.9.0
  * @package WordPress
@@ -3920,7 +4024,7 @@ function delete_site_transient( $transient ) {
 }
 
 /**
- * Get the value of a site transient
+ * Get the value of a site transient.
  *
  * If the transient does not exist or does not have a value, then the return value
  * will be false.
@@ -3969,7 +4073,7 @@ function get_site_transient( $transient ) {
 }
 
 /**
- * Set/update the value of a site transient
+ * Set/update the value of a site transient.
  *
  * You do not need to serialize values, if the value needs to be serialize, then
  * it will be serialized before it is set.
@@ -4016,7 +4120,7 @@ function set_site_transient( $transient, $value, $expiration = 0 ) {
 }
 
 /**
- * is main site
+ * Is main site?
  *
  *
  * @since 3.0.0
@@ -4062,9 +4166,9 @@ function global_terms_enabled() {
 }
 
 /**
- * gmt_offset modification for smart timezone handling
+ * gmt_offset modification for smart timezone handling.
  *
- * Overrides the gmt_offset option if we have a timezone_string available
+ * Overrides the gmt_offset option if we have a timezone_string available.
  *
  * @since 2.8.0
  *
@@ -4131,7 +4235,7 @@ function _wp_timezone_choice_usort_callback( $a, $b ) {
 }
 
 /**
- * Gives a nicely formatted list of timezone strings // temporary! Not in final
+ * Gives a nicely formatted list of timezone strings. // temporary! Not in final
  *
  * @since 2.9.0
  *
@@ -4260,7 +4364,7 @@ function wp_timezone_choice( $selected_zone ) {
 }
 
 /**
- * Strip close comment and close php tags from file headers used by WP
+ * Strip close comment and close php tags from file headers used by WP.
  * See http://core.trac.wordpress.org/ticket/8497
  *
  * @since 2.8.0
@@ -4321,7 +4425,7 @@ function wp_scheduled_delete() {
  * Retrieve metadata from a file.
  *
  * Searches for metadata in the first 8kiB of a file, such as a plugin or theme.
- * Each piece of metadata must be on its own line. Fields can not span multple
+ * Each piece of metadata must be on its own line. Fields can not span multiple
  * lines, the value will get cut at the end of the first line.
  *
  * If the file data is not within that first 8kiB, then the author should correct
@@ -4370,7 +4474,7 @@ function get_file_data( $file, $default_headers, $context = '' ) {
 }
 
 /**
- * Used internally to tidy up the search terms
+ * Used internally to tidy up the search terms.
  *
  * @access private
  * @since 2.9.0
@@ -4383,9 +4487,9 @@ function _search_terms_tidy($t) {
 }
 
 /**
- * Returns true
+ * Returns true.
  *
- * Useful for returning true to filters easily
+ * Useful for returning true to filters easily.
  *
  * @since 3.0.0
  * @see __return_false()
@@ -4396,9 +4500,9 @@ function __return_true() {
 }
 
 /**
- * Returns false
+ * Returns false.
  *
- * Useful for returning false to filters easily
+ * Useful for returning false to filters easily.
  *
  * @since 3.0.0
  * @see __return_true()
@@ -4409,9 +4513,9 @@ function __return_false() {
 }
 
 /**
- * Returns 0
+ * Returns 0.
  *
- * Useful for returning 0 to filters easily
+ * Useful for returning 0 to filters easily.
  *
  * @since 3.0.0
  * @see __return_zero()
@@ -4422,9 +4526,9 @@ function __return_zero() {
 }
 
 /**
- * Returns an empty array
+ * Returns an empty array.
  *
- * Useful for returning an empty array to filters easily
+ * Useful for returning an empty array to filters easily.
  *
  * @since 3.0.0
  * @see __return_zero()
@@ -4501,7 +4605,7 @@ function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_arg
  * @since 3.1.0
  * @access private
  *
- * @param callback $callback function that accupts ( ID, callback_arg, ... ) and outputs parent_ID
+ * @param callback $callback function that accepts ( ID, callback_arg, ... ) and outputs parent_ID
  * @param int $start The ID to start the loop check at
  * @param array $override an array of ( ID => parent_ID, ... ) to use instead of $callback
  * @param array $callback_args optional additional arguments to send to $callback
@@ -4549,4 +4653,24 @@ function send_frame_options_header() {
        @header( 'X-Frame-Options: SAMEORIGIN' );
 }
 
+/**
+ * Retrieve a list of protocols to allow in HTML attributes.
+ *
+ * @since 3.3.0
+ * @see wp_kses()
+ * @see esc_url()
+ *
+ * @return array Array of allowed protocols
+ */
+function wp_allowed_protocols() {
+       static $protocols;
+
+       if ( empty( $protocols ) ) {
+               $protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' );
+               $protocols = apply_filters( 'kses_allowed_protocols', $protocols );
+       }
+
+       return $protocols;
+}
+
 ?>