<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13139] trunk/wp-includes/functions.php: Whitespace, phpdoc,
  standard variable names,
  better return values for options and transients APIs.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13139">13139</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-02-14 06:17:42 +0000 (Sun, 14 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Whitespace, phpdoc, standard variable names, better return values for options and transients APIs. See <a href="http://trac.wordpress.org/ticket/10788">#10788</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (13138 => 13139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2010-02-14 06:12:12 UTC (rev 13138)
+++ trunk/wp-includes/functions.php        2010-02-14 06:17:42 UTC (rev 13139)
</span><span class="lines">@@ -311,18 +311,18 @@
</span><span class="cx">  * @since 1.5.0
</span><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Option
</span><del>- * @uses apply_filters() Calls 'pre_option_$optionname' false to allow
</del><ins>+ * @uses apply_filters() Calls 'pre_option_$option' false to allow
</ins><span class="cx">  *                overwriting the option value in a plugin.
</span><del>- * @uses apply_filters() Calls 'option_$optionname' with the option name value.
</del><ins>+ * @uses apply_filters() Calls 'option_$option' with the option value.
</ins><span class="cx">  *
</span><del>- * @param string $setting Name of option to retrieve. Should already be SQL-escaped
</del><ins>+ * @param string $option Name of option to retrieve. Should already be SQL-escaped
</ins><span class="cx">  * @return mixed Value set for the option.
</span><span class="cx">  */
</span><del>-function get_option( $setting, $default = false ) {
</del><ins>+function get_option( $option, $default = false ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         // Allow plugins to short-circuit options.
</span><del>-        $pre = apply_filters( 'pre_option_' . $setting, false );
</del><ins>+        $pre = apply_filters( 'pre_option_' . $option, false );
</ins><span class="cx">         if ( false !== $pre )
</span><span class="cx">                 return $pre;
</span><span class="cx"> 
</span><span class="lines">@@ -331,7 +331,7 @@
</span><span class="cx">                 $notoptions = array();
</span><span class="cx">         } else {
</span><span class="cx">                 $notoptions = wp_cache_get( 'notoptions', 'options' );
</span><del>-                if ( isset( $notoptions[$setting] ) )
</del><ins>+                if ( isset( $notoptions[$option] ) )
</ins><span class="cx">                         return $default;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -339,24 +339,24 @@
</span><span class="cx">                 $alloptions = wp_load_alloptions();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( isset( $alloptions[$setting] ) ) {
-                $value = $alloptions[$setting];
</del><ins>+        if ( isset( $alloptions[$option] ) ) {
+                $value = $alloptions[$option];
</ins><span class="cx">         } else {
</span><del>-                $value = wp_cache_get( $setting, 'options' );
</del><ins>+                $value = wp_cache_get( $option, 'options' );
</ins><span class="cx"> 
</span><span class="cx">                 if ( false === $value ) {
</span><span class="cx">                         if ( defined( 'WP_INSTALLING' ) )
</span><span class="cx">                                 $suppress = $wpdb-&gt;suppress_errors();
</span><del>-                        // expected_slashed ($setting)
-                        $row = $wpdb-&gt;get_row( &quot;SELECT option_value FROM $wpdb-&gt;options WHERE option_name = '$setting' LIMIT 1&quot; );
</del><ins>+                        // expected_slashed ($option)
+                        $row = $wpdb-&gt;get_row( &quot;SELECT option_value FROM $wpdb-&gt;options WHERE option_name = '$option' LIMIT 1&quot; );
</ins><span class="cx">                         if ( defined( 'WP_INSTALLING' ) )
</span><del>-                                $wpdb-&gt;suppress_errors($suppress);
</del><ins>+                                $wpdb-&gt;suppress_errors( $suppress );
</ins><span class="cx"> 
</span><span class="cx">                         if ( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
</span><span class="cx">                                 $value = $row-&gt;option_value;
</span><del>-                                wp_cache_add( $setting, $value, 'options' );
</del><ins>+                                wp_cache_add( $option, $value, 'options' );
</ins><span class="cx">                         } else { // option does not exist, so we must cache its non-existence
</span><del>-                                $notoptions[$setting] = true;
</del><ins>+                                $notoptions[$option] = true;
</ins><span class="cx">                                 wp_cache_set( 'notoptions', $notoptions, 'options' );
</span><span class="cx">                                 return $default;
</span><span class="cx">                         }
</span><span class="lines">@@ -364,13 +364,13 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // If home is not set use siteurl.
</span><del>-        if ( 'home' == $setting &amp;&amp; '' == $value )
</del><ins>+        if ( 'home' == $option &amp;&amp; '' == $value )
</ins><span class="cx">                 return get_option( 'siteurl' );
</span><span class="cx"> 
</span><del>-        if ( in_array( $setting, array('siteurl', 'home', 'category_base', 'tag_base') ) )
</del><ins>+        if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
</ins><span class="cx">                 $value = untrailingslashit( $value );
</span><span class="cx"> 
</span><del>-        return apply_filters( 'option_' . $setting, maybe_unserialize( $value ) );
</del><ins>+        return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -481,12 +481,12 @@
</span><span class="cx">  * to set whether an option autoloaded, then you need to use the add_option().
</span><span class="cx">  *
</span><span class="cx">  * Before the option is updated, then the filter named
</span><del>- * 'pre_update_option_$option_name', with the $option_name as the $option_name
</del><ins>+ * 'pre_update_option_$option', with the $option as the $option
</ins><span class="cx">  * parameter value, will be called. The hook should accept two parameters, the
</span><span class="cx">  * first is the new value and the second is the old value.  Whatever is
</span><span class="cx">  * returned will be used as the new value.
</span><span class="cx">  *
</span><del>- * After the value has been updated the action named 'update_option_$option_name'
</del><ins>+ * After the value has been updated the action named 'update_option_$option'
</ins><span class="cx">  * will be called.  This action receives two parameters the first being the old
</span><span class="cx">  * value and the second the new value.
</span><span class="cx">  *
</span><span class="lines">@@ -494,56 +494,54 @@
</span><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Option
</span><span class="cx">  *
</span><del>- * @param string $option_name Option name. Expected to not be SQL-escaped
</del><ins>+ * @param string $option Option name. Expected to not be SQL-escaped
</ins><span class="cx">  * @param mixed $newvalue Option value.
</span><span class="cx">  * @return bool False if value was not updated and true if value was updated.
</span><span class="cx">  */
</span><del>-function update_option( $option_name, $newvalue ) {
</del><ins>+function update_option( $option, $newvalue ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><del>-        wp_protect_special_option( $option_name );
</del><ins>+        wp_protect_special_option( $option );
</ins><span class="cx"> 
</span><del>-        $safe_option_name = esc_sql( $option_name );
-        $newvalue = sanitize_option( $option_name, $newvalue );
</del><ins>+        $safe_option_name = esc_sql( $option );
+        $newvalue = sanitize_option( $option, $newvalue );
</ins><span class="cx"> 
</span><span class="cx">         $oldvalue = get_option( $safe_option_name );
</span><span class="cx"> 
</span><del>-        $newvalue = apply_filters( 'pre_update_option_' . $option_name, $newvalue, $oldvalue );
</del><ins>+        $newvalue = apply_filters( 'pre_update_option_' . $option, $newvalue, $oldvalue );
</ins><span class="cx"> 
</span><span class="cx">         // If the new and old values are the same, no need to update.
</span><span class="cx">         if ( $newvalue === $oldvalue )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        if ( false === $oldvalue ) {
-                add_option( $option_name, $newvalue );
-                return true;
-        }
</del><ins>+        if ( false === $oldvalue )
+                return add_option( $option, $newvalue );
</ins><span class="cx"> 
</span><span class="cx">         $notoptions = wp_cache_get( 'notoptions', 'options' );
</span><del>-        if ( is_array( $notoptions ) &amp;&amp; isset( $notoptions[$option_name] ) ) {
-                unset( $notoptions[$option_name] );
</del><ins>+        if ( is_array( $notoptions ) &amp;&amp; isset( $notoptions[$option] ) ) {
+                unset( $notoptions[$option] );
</ins><span class="cx">                 wp_cache_set( 'notoptions', $notoptions, 'options' );
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $_newvalue = $newvalue;
</span><span class="cx">         $newvalue = maybe_serialize( $newvalue );
</span><span class="cx"> 
</span><del>-        do_action( 'update_option', $option_name, $oldvalue, $newvalue );
</del><ins>+        do_action( 'update_option', $option, $oldvalue, $newvalue );
</ins><span class="cx">         if ( ! defined( 'WP_INSTALLING' ) ) {
</span><span class="cx">                 $alloptions = wp_load_alloptions();
</span><del>-                if ( isset( $alloptions[$option_name] ) ) {
-                        $alloptions[$option_name] = $newvalue;
</del><ins>+                if ( isset( $alloptions[$option] ) ) {
+                        $alloptions[$option] = $newvalue;
</ins><span class="cx">                         wp_cache_set( 'alloptions', $alloptions, 'options' );
</span><span class="cx">                 } else {
</span><del>-                        wp_cache_set( $option_name, $newvalue, 'options' );
</del><ins>+                        wp_cache_set( $option, $newvalue, 'options' );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        $wpdb-&gt;update($wpdb-&gt;options, array('option_value' =&gt; $newvalue), array('option_name' =&gt; $option_name) );
</del><ins>+        $result = $wpdb-&gt;update( $wpdb-&gt;options, array( 'option_value' =&gt; $newvalue ), array( 'option_name' =&gt; $option ) );
</ins><span class="cx"> 
</span><del>-        if ( $wpdb-&gt;rows_affected == 1 ) {
-                do_action( &quot;update_option_{$option_name}&quot;, $oldvalue, $_newvalue );
-                do_action( 'updated_option', $option_name, $oldvalue, $_newvalue );
</del><ins>+        if ( $result ) {
+                do_action( &quot;update_option_{$option}&quot;, $oldvalue, $_newvalue );
+                do_action( 'updated_option', $option, $oldvalue, $_newvalue );
</ins><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="cx">         return false;
</span><span class="lines">@@ -562,7 +560,7 @@
</span><span class="cx">  * options, the same as the ones which are protected and to not add options
</span><span class="cx">  * that were already added.
</span><span class="cx">  *
</span><del>- * The filter named 'add_option_$optionname', with the $optionname being
</del><ins>+ * The filter named 'add_option_$option', with the $optionname being
</ins><span class="cx">  * replaced with the option's name, will be called. The hook should accept two
</span><span class="cx">  * parameters, the first is the option name, and the second is the value.
</span><span class="cx">  *
</span><span class="lines">@@ -571,91 +569,91 @@
</span><span class="cx">  * @since 1.0.0
</span><span class="cx">  * @link http://alex.vort-x.net/blog/ Thanks Alex Stapleton
</span><span class="cx">  *
</span><del>- * @param string $name Option name to add. Expects to NOT be SQL escaped.
</del><ins>+ * @param string $option Name of option to add. Expects to NOT be SQL escaped.
</ins><span class="cx">  * @param mixed $value Optional. Option value, can be anything.
</span><span class="cx">  * @param mixed $deprecated Optional. Description. Not used anymore.
</span><span class="cx">  * @param bool $autoload Optional. Default is enabled. Whether to load the option when WordPress starts up.
</span><span class="cx">  * @return null returns when finished.
</span><span class="cx">  */
</span><del>-function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) {
</del><ins>+function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
</ins><span class="cx">         if ( !empty( $deprecated ) )
</span><span class="cx">                 _deprecated_argument( __FUNCTION__, '2.3' );
</span><span class="cx"> 
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><del>-        wp_protect_special_option( $name );
-        $safe_name = esc_sql( $name );
-        $value = sanitize_option( $name, $value );
</del><ins>+        wp_protect_special_option( $option );
+        $safe_name = esc_sql( $option );
+        $value = sanitize_option( $option, $value );
</ins><span class="cx"> 
</span><span class="cx">         // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
</span><span class="cx">         $notoptions = wp_cache_get( 'notoptions', 'options' );
</span><del>-        if ( !is_array( $notoptions ) || !isset( $notoptions[$name] ) )
</del><ins>+        if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
</ins><span class="cx">                 if ( false !== get_option( $safe_name ) )
</span><span class="cx">                         return;
</span><span class="cx"> 
</span><span class="cx">         $value = maybe_serialize( $value );
</span><span class="cx">         $autoload = ( 'no' === $autoload ) ? 'no' : 'yes';
</span><del>-        do_action( 'add_option', $name, $value );
</del><ins>+        do_action( 'add_option', $option, $value );
</ins><span class="cx">         if ( ! defined( 'WP_INSTALLING' ) ) {
</span><span class="cx">                 if ( 'yes' == $autoload ) {
</span><span class="cx">                         $alloptions = wp_load_alloptions();
</span><del>-                        $alloptions[$name] = $value;
</del><ins>+                        $alloptions[$option] = $value;
</ins><span class="cx">                         wp_cache_set( 'alloptions', $alloptions, 'options' );
</span><span class="cx">                 } else {
</span><del>-                        wp_cache_set( $name, $value, 'options' );
</del><ins>+                        wp_cache_set( $option, $value, 'options' );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // This option exists now
</span><span class="cx">         $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh
</span><del>-        if ( is_array( $notoptions ) &amp;&amp; isset( $notoptions[$name] ) ) {
-                unset( $notoptions[$name] );
</del><ins>+        if ( is_array( $notoptions ) &amp;&amp; isset( $notoptions[$option] ) ) {
+                unset( $notoptions[$option] );
</ins><span class="cx">                 wp_cache_set( 'notoptions', $notoptions, 'options' );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;INSERT INTO `$wpdb-&gt;options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)&quot;, $name, $value, $autoload ) );
</del><ins>+        $result = $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;INSERT INTO `$wpdb-&gt;options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)&quot;, $option, $value, $autoload ) );
</ins><span class="cx"> 
</span><del>-        do_action( &quot;add_option_{$name}&quot;, $name, $value );
-        do_action( 'added_option', $name, $value );
</del><ins>+        do_action( &quot;add_option_{$option}&quot;, $option, $value );
+        do_action( 'added_option', $option, $value );
</ins><span class="cx"> 
</span><del>-        return;
</del><ins>+        return $result;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Removes option by name and prevents removal of protected WordPress options.
</del><ins>+ * Removes option by name. Prevents removal of protected WordPress options.
</ins><span class="cx">  *
</span><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Option
</span><span class="cx">  * @since 1.2.0
</span><span class="cx">  *
</span><del>- * @param string $name Option name to remove.
</del><ins>+ * @param string $option Name of option to remove.
</ins><span class="cx">  * @return bool True, if succeed. False, if failure.
</span><span class="cx">  */
</span><del>-function delete_option( $name ) {
</del><ins>+function delete_option( $option ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><del>-        wp_protect_special_option( $name );
</del><ins>+        wp_protect_special_option( $option );
</ins><span class="cx"> 
</span><span class="cx">         // Get the ID, if no ID then return
</span><del>-        // expected_slashed ($name)
-        $option = $wpdb-&gt;get_row( &quot;SELECT autoload FROM $wpdb-&gt;options WHERE option_name = '$name'&quot; );
-        if ( is_null($option) )
</del><ins>+        // expected_slashed ($option)
+        $row = $wpdb-&gt;get_row( &quot;SELECT autoload FROM $wpdb-&gt;options WHERE option_name = '$option'&quot; );
+        if ( is_null( $row ) )
</ins><span class="cx">                 return false;
</span><del>-        do_action( 'delete_option', $name );
-        // expected_slashed ($name)
-        $wpdb-&gt;query( &quot;DELETE FROM $wpdb-&gt;options WHERE option_name = '$name'&quot; );
</del><ins>+        do_action( 'delete_option', $option );
+        // expected_slashed ($option)
+        $result = $wpdb-&gt;query( &quot;DELETE FROM $wpdb-&gt;options WHERE option_name = '$option'&quot; );
</ins><span class="cx">         if ( ! defined( 'WP_INSTALLING' ) ) {
</span><del>-                if ( 'yes' == $option-&gt;autoload ) {
</del><ins>+                if ( 'yes' == $row-&gt;autoload ) {
</ins><span class="cx">                         $alloptions = wp_load_alloptions();
</span><del>-                        if ( isset( $alloptions[$name] ) ) {
-                                unset( $alloptions[$name] );
</del><ins>+                        if ( isset( $alloptions[$option] ) ) {
+                                unset( $alloptions[$option] );
</ins><span class="cx">                                 wp_cache_set( 'alloptions', $alloptions, 'options' );
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        wp_cache_delete( $name, 'options' );
</del><ins>+                        wp_cache_delete( $option, 'options' );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        do_action( 'deleted_option', $name );
</del><ins>+        do_action( 'deleted_option', $option );
</ins><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -669,16 +667,16 @@
</span><span class="cx">  * @param string $transient Transient name. Expected to not be SQL-escaped
</span><span class="cx">  * @return bool true if successful, false otherwise
</span><span class="cx">  */
</span><del>-function delete_transient($transient) {
-        global $_wp_using_ext_object_cache, $wpdb;
</del><ins>+function delete_transient( $transient ) {
+        global $_wp_using_ext_object_cache;
</ins><span class="cx"> 
</span><span class="cx">     do_action( 'delete_transient_' . $transient );
</span><span class="cx"> 
</span><span class="cx">         if ( $_wp_using_ext_object_cache ) {
</span><del>-                return wp_cache_delete($transient, 'transient');
</del><ins>+                return wp_cache_delete( $transient, 'transient' );
</ins><span class="cx">         } else {
</span><del>-                $transient = '_transient_' . esc_sql($transient);
-                return delete_option($transient);
</del><ins>+                $transient = '_transient_' . esc_sql( $transient );
+                return delete_option( $transient );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -695,40 +693,41 @@
</span><span class="cx">  * @param string $transient Transient name. Expected to not be SQL-escaped
</span><span class="cx">  * @return mixed Value of transient
</span><span class="cx">  */
</span><del>-function get_transient($transient) {
-        global $_wp_using_ext_object_cache, $wpdb;
</del><ins>+function get_transient( $transient ) {
+        global $_wp_using_ext_object_cache;
</ins><span class="cx"> 
</span><span class="cx">         $pre = apply_filters( 'pre_transient_' . $transient, false );
</span><span class="cx">         if ( false !== $pre )
</span><span class="cx">                 return $pre;
</span><span class="cx"> 
</span><span class="cx">         if ( $_wp_using_ext_object_cache ) {
</span><del>-                $value = wp_cache_get($transient, 'transient');
</del><ins>+                $value = wp_cache_get( $transient, 'transient' );
</ins><span class="cx">         } else {
</span><del>-                $transient_option = '_transient_' . esc_sql($transient);
</del><ins>+                $safe_transient   = esc_sql( $transient );
+                $transient_option = '_transient_' . $safe_transient;
</ins><span class="cx">                 if ( ! defined( 'WP_INSTALLING' ) ) {
</span><span class="cx">                         // If option is not in alloptions, it is not autoloaded and thus has a timeout
</span><span class="cx">                         $alloptions = wp_load_alloptions();
</span><span class="cx">                         if ( !isset( $alloptions[$transient_option] ) ) {
</span><del>-                                $transient_timeout = '_transient_timeout_' . esc_sql($transient);
-                                if ( get_option($transient_timeout) &lt; time() ) {
-                                        delete_option($transient_option);
-                                        delete_option($transient_timeout);
</del><ins>+                                $transient_timeout = '_transient_timeout_' . $safe_transient;
+                                if ( get_option( $transient_timeout ) &lt; time() ) {
+                                        delete_option( $transient_option  );
+                                        delete_option( $transient_timeout );
</ins><span class="cx">                                         return false;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                $value = get_option($transient_option);
</del><ins>+                $value = get_option( $transient_option );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return apply_filters('transient_' . $transient, $value);
</del><ins>+        return apply_filters( 'transient_' . $transient, $value );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Set/update the value of a transient
</span><span class="cx">  *
</span><del>- * You do not need to serialize values, if the value needs to be serialize, then
</del><ins>+ * You do not need to serialize values. If the value needs to be serialized, then
</ins><span class="cx">  * it will be serialized before it is set.
</span><span class="cx">  *
</span><span class="cx">  * @since 2.8.0
</span><span class="lines">@@ -740,27 +739,27 @@
</span><span class="cx">  * @param int $expiration Time until expiration in seconds, default 0
</span><span class="cx">  * @return bool False if value was not set and true if value was set.
</span><span class="cx">  */
</span><del>-function set_transient($transient, $value, $expiration = 0) {
-        global $_wp_using_ext_object_cache, $wpdb;
</del><ins>+function set_transient( $transient, $value, $expiration = 0 ) {
+        global $_wp_using_ext_object_cache;
</ins><span class="cx"> 
</span><span class="cx">     $value = apply_filters( 'pre_set_transient_' . $transient, $value );
</span><span class="cx"> 
</span><span class="cx">         if ( $_wp_using_ext_object_cache ) {
</span><del>-                return wp_cache_set($transient, $value, 'transient', $expiration);
</del><ins>+                return wp_cache_set( $transient, $value, 'transient', $expiration );
</ins><span class="cx">         } else {
</span><span class="cx">                 $transient_timeout = '_transient_timeout_' . $transient;
</span><span class="cx">                 $transient = '_transient_' . $transient;
</span><del>-                $safe_transient = esc_sql($transient);
</del><ins>+                $safe_transient = esc_sql( $transient );
</ins><span class="cx">                 if ( false === get_option( $safe_transient ) ) {
</span><span class="cx">                         $autoload = 'yes';
</span><del>-                        if ( 0 != $expiration ) {
</del><ins>+                        if ( $expiration ) {
</ins><span class="cx">                                 $autoload = 'no';
</span><span class="cx">                                 add_option($transient_timeout, time() + $expiration, '', 'no');
</span><span class="cx">                         }
</span><span class="cx">                         return add_option($transient, $value, '', $autoload);
</span><span class="cx">                 } else {
</span><del>-                        if ( 0 != $expiration )
-                                update_option($transient_timeout, time() + $expiration);
</del><ins>+                        if ( $expiration )
+                                update_option( $transient_timeout, time() + $expiration );
</ins><span class="cx">                         return update_option($transient, $value);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -3342,32 +3341,35 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * {@internal Missing Short Description}}
</del><ins>+ * Retrieve site option value based on name of option.
</ins><span class="cx">  *
</span><del>- * @since 2.8
</del><ins>+ * @see get_option()
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.8.0
</ins><span class="cx">  *
</span><del>- * @param unknown_type $key
- * @param unknown_type $default
- * @param unknown_type $use_cache
- * @return unknown
</del><ins>+ * @param string $option Name of option to retrieve. Should already be SQL-escaped
+ * @param mixed $default Optional value to return if option doesn't exist. Default false.
+ * @param bool $use_cache Whether to use cache. Multisite only. Default true.
+ * @return mixed Value set for the option.
</ins><span class="cx">  */
</span><del>-function get_site_option( $key, $default = false, $use_cache = true ) {
</del><ins>+function get_site_option( $option, $default = false, $use_cache = true ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         // Allow plugins to short-circuit site options.
</span><del>-         $pre = apply_filters( 'pre_site_option_' . $key, false );
</del><ins>+         $pre = apply_filters( 'pre_site_option_' . $option, false );
</ins><span class="cx">          if ( false !== $pre )
</span><span class="cx">                  return $pre;
</span><span class="cx"> 
</span><span class="cx">         if ( !is_multisite() ) {
</span><del>-                $value = get_option($key, $default);
</del><ins>+                $value = get_option($option, $default);
</ins><span class="cx">         } else {
</span><del>-                $cache_key = &quot;$wpdb-&gt;siteid:$key&quot;;
</del><ins>+                $cache_key = &quot;{$wpdb-&gt;siteid}:$option&quot;;
</ins><span class="cx">                 if ( $use_cache )
</span><span class="cx">                         $value = wp_cache_get($cache_key, 'site-options');
</span><span class="cx"> 
</span><span class="cx">                 if ( false === $value ) {
</span><del>-                        $value = $wpdb-&gt;get_var( $wpdb-&gt;prepare(&quot;SELECT meta_value FROM $wpdb-&gt;sitemeta WHERE meta_key = %s AND site_id = %d&quot;, $key, $wpdb-&gt;siteid) );
</del><ins>+                        $value = $wpdb-&gt;get_var( $wpdb-&gt;prepare(&quot;SELECT meta_value FROM $wpdb-&gt;sitemeta WHERE meta_key = %s AND site_id = %d&quot;, $option, $wpdb-&gt;siteid ) );
</ins><span class="cx"> 
</span><span class="cx">                         if ( is_null($value) )
</span><span class="cx">                                 $value = $default;
</span><span class="lines">@@ -3378,111 +3380,120 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-         return apply_filters( 'site_option_' . $key, $value );
</del><ins>+         return apply_filters( 'site_option_' . $option, $value );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * {@internal Missing Short Description}}
</del><ins>+ * Add a new site option.
</ins><span class="cx">  *
</span><del>- * @since 2.8
</del><ins>+ * @see add_option()
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.8.0
</ins><span class="cx">  *
</span><del>- * @param unknown_type $key not to be SQL escaped
- * @param unknown_type $value not to be SQL escaped
- * @return unknown
</del><ins>+ * @param string $option Name of option to add. Expects to not be SQL escaped.
+ * @param mixed $value Optional. Option value, can be anything.
+ * @return bool False if option was not added and true if option was added.
</ins><span class="cx">  */
</span><del>-function add_site_option( $key, $value ) {
</del><ins>+function add_site_option( $option, $value ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><del>-        $value = apply_filters( 'pre_add_site_option_' . $key, $value );
</del><ins>+        $value = apply_filters( 'pre_add_site_option_' . $option, $value );
</ins><span class="cx"> 
</span><span class="cx">         if ( !is_multisite() ) {
</span><del>-                $result =  add_option($key, $value);
</del><ins>+                $result = add_option( $option, $value );
</ins><span class="cx">         } else {
</span><del>-                $cache_key = &quot;{$wpdb-&gt;siteid}:$key&quot;;
</del><ins>+                $cache_key = &quot;{$wpdb-&gt;siteid}:$option&quot;;
</ins><span class="cx"> 
</span><del>-                if ( $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT meta_value FROM $wpdb-&gt;sitemeta WHERE meta_key = %s AND site_id = %d&quot;, $key, $wpdb-&gt;siteid ) ) )
-                        return update_site_option( $key, $value );
</del><ins>+                if ( $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT meta_value FROM $wpdb-&gt;sitemeta WHERE meta_key = %s AND site_id = %d&quot;, $option, $wpdb-&gt;siteid ) ) )
+                        return update_site_option( $option, $value );
</ins><span class="cx"> 
</span><del>-                $value = sanitize_option( $key, $value );
-                wp_cache_set( $cache_key, $value, 'site-options');
</del><ins>+                $value = sanitize_option( $option, $value );
+                wp_cache_set( $cache_key, $value, 'site-options' );
</ins><span class="cx"> 
</span><span class="cx">                 $value = maybe_serialize($value);
</span><span class="cx"> 
</span><del>-                $result = $wpdb-&gt;insert( $wpdb-&gt;sitemeta, array('site_id' =&gt; $wpdb-&gt;siteid, 'meta_key' =&gt; $key, 'meta_value' =&gt; $value) );
</del><ins>+                $result = $wpdb-&gt;insert( $wpdb-&gt;sitemeta, array('site_id' =&gt; $wpdb-&gt;siteid, 'meta_key' =&gt; $option, 'meta_value' =&gt; $value ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        do_action( &quot;add_site_option_{$key}&quot;, $key, $value );
-        do_action( &quot;add_site_option&quot;, $key, $value );
</del><ins>+        do_action( &quot;add_site_option_{$option}&quot;, $option, $value );
+        do_action( &quot;add_site_option&quot;, $option, $value );
</ins><span class="cx"> 
</span><span class="cx">         return $result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * {@internal Missing Short Description}}
</del><ins>+ * Removes site option by name.
</ins><span class="cx">  *
</span><del>- * @since 2.9
</del><ins>+ * @see delete_option()
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.8.0
</ins><span class="cx">  *
</span><del>- * @param unknown_type $key
- * @return unknown
</del><ins>+ * @param string $option Name of option to remove. Expected to be SQL-escaped.
+ * @return bool True, if succeed. False, if failure.
</ins><span class="cx">  */
</span><del>-function delete_site_option( $key ) {
</del><ins>+function delete_site_option( $option ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><del>-        //wpmu_protect_special_option( $key ); @todo
</del><ins>+        // ms_protect_special_option( $option ); @todo
</ins><span class="cx"> 
</span><del>-        do_action( 'pre_delete_site_option_' . $key );
</del><ins>+        do_action( 'pre_delete_site_option_' . $option );
</ins><span class="cx"> 
</span><span class="cx">         if ( !is_multisite() ) {
</span><del>-                $result = delete_option($key);
</del><ins>+                $result = delete_option( $option );
</ins><span class="cx">         } else {
</span><del>-                $option = $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT meta_id FROM {$wpdb-&gt;sitemeta} WHERE meta_key = %s AND site_id = %d&quot;, $key, $wpdb-&gt;siteid ) );
</del><ins>+                $option = $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT meta_id FROM {$wpdb-&gt;sitemeta} WHERE meta_key = %s AND site_id = %d&quot;, $option, $wpdb-&gt;siteid ) );
</ins><span class="cx">                 if ( is_null( $option ) || !$option-&gt;meta_id )
</span><span class="cx">                         return false;
</span><del>-                $cache_key = &quot;{$wpdb-&gt;siteid}:$key&quot;;
</del><ins>+                $cache_key = &quot;{$wpdb-&gt;siteid}:$option&quot;;
</ins><span class="cx">                 wp_cache_delete( $cache_key, 'site-options' );
</span><span class="cx"> 
</span><del>-                $result = $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$wpdb-&gt;sitemeta} WHERE meta_key = %s AND site_id = %d&quot;, $key, $wpdb-&gt;siteid ) );
</del><ins>+                $result = $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$wpdb-&gt;sitemeta} WHERE meta_key = %s AND site_id = %d&quot;, $option, $wpdb-&gt;siteid ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        do_action( &quot;delete_site_option_{$key}&quot;, $key );
-        do_action( &quot;delete_site_option&quot;, $key );
</del><ins>+        do_action( &quot;delete_site_option_{$option}&quot;, $option );
+        do_action( &quot;delete_site_option&quot;, $option );
</ins><span class="cx">         return $result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * {@internal Missing Short Description}}
</del><ins>+ * Update the value of a site option that was already added.
</ins><span class="cx">  *
</span><ins>+ * @see update_option()
</ins><span class="cx">  * @since 2.8.0
</span><ins>+ * @package WordPress
+ * @subpackage Option
</ins><span class="cx">  *
</span><del>- * @param unknown_type $key not to be SQL escaped
- * @param unknown_type $value not to be SQL escaped
- * @return unknown
</del><ins>+ * @param string $option Name of option. Expected to not be SQL-escaped
+ * @param mixed $value Option value.
+ * @return bool False if value was not updated and true if value was updated.
</ins><span class="cx">  */
</span><del>-function update_site_option( $key, $value ) {
</del><ins>+function update_site_option( $option, $value ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><del>-        $oldvalue = get_site_option( $key );
-        $value = apply_filters( 'pre_update_site_option_' . $key, $value, $oldvalue );
</del><ins>+        $oldvalue = get_site_option( $option );
+        $value = apply_filters( 'pre_update_site_option_' . $option, $value, $oldvalue );
</ins><span class="cx"> 
</span><del>-        if ( $value == $oldvalue )
</del><ins>+        if ( $value === $oldvalue )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         if ( !is_multisite() ) {
</span><del>-                $result = update_option($key, $value);
</del><ins>+                $result = update_option( $option, $value );
</ins><span class="cx">         } else {
</span><del>-                $cache_key = &quot;{$wpdb-&gt;siteid}:$key&quot;;
</del><ins>+                $cache_key = &quot;{$wpdb-&gt;siteid}:$option&quot;;
</ins><span class="cx"> 
</span><del>-                if ( $value &amp;&amp; !$wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT meta_value FROM $wpdb-&gt;sitemeta WHERE meta_key = %s AND site_id = %d&quot;, $key, $wpdb-&gt;siteid) ) )
-                        return add_site_option( $key, $value );
-                $value = sanitize_option( $key, $value );
</del><ins>+                if ( $value &amp;&amp; !$wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT meta_value FROM $wpdb-&gt;sitemeta WHERE meta_key = %s AND site_id = %d&quot;, $option, $wpdb-&gt;siteid ) ) )
+                        return add_site_option( $option, $value );
+                $value = sanitize_option( $option, $value );
</ins><span class="cx">                 wp_cache_set( $cache_key, $value, 'site-options' );
</span><span class="cx"> 
</span><del>-                $value = maybe_serialize($value);
-                $result = $wpdb-&gt;update( $wpdb-&gt;sitemeta, array('meta_value' =&gt; $value), array('site_id' =&gt; $wpdb-&gt;siteid, 'meta_key' =&gt; $key) );
</del><ins>+                $value = maybe_serialize( $value );
+                $result = $wpdb-&gt;update( $wpdb-&gt;sitemeta, array( 'meta_value' =&gt; $value ), array( 'site_id' =&gt; $wpdb-&gt;siteid, 'meta_key' =&gt; $option ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        do_action( &quot;update_site_option_{$key}&quot;, $key, $value );
-        do_action( &quot;update_site_option&quot;, $key, $value );
</del><ins>+        do_action( &quot;update_site_option_{$option}&quot;, $option, $value );
+        do_action( &quot;update_site_option&quot;, $option, $value );
</ins><span class="cx">         return $result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3494,17 +3505,18 @@
</span><span class="cx">  * @subpackage Transient
</span><span class="cx">  *
</span><span class="cx">  * @param string $transient Transient name. Expected to not be SQL-escaped
</span><del>- * @return bool true if successful, false otherwise
</del><ins>+ * @return bool True if successful, false otherwise
</ins><span class="cx">  */
</span><del>-function delete_site_transient($transient) {
-        global $_wp_using_ext_object_cache, $wpdb;
</del><ins>+function delete_site_transient( $transient ) {
+        global $_wp_using_ext_object_cache;
</ins><span class="cx"> 
</span><span class="cx">         if ( $_wp_using_ext_object_cache ) {
</span><del>-                return wp_cache_delete($transient, 'site-transient');
</del><ins>+                $result = wp_cache_delete( $transient, 'site-transient' );
</ins><span class="cx">         } else {
</span><del>-                $transient = '_site_transient_' . esc_sql($transient);
-                return delete_site_option($transient);
</del><ins>+                $transient = '_site_transient_' . esc_sql( $transient );
+                $result = delete_site_option( $transient );
</ins><span class="cx">         }
</span><ins>+        return $result;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -3513,6 +3525,7 @@
</span><span class="cx">  * If the transient does not exist or does not have a value, then the return value
</span><span class="cx">  * will be false.
</span><span class="cx">  *
</span><ins>+ * @see get_transient()
</ins><span class="cx">  * @since 2.9.0
</span><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Transient
</span><span class="lines">@@ -3520,33 +3533,33 @@
</span><span class="cx">  * @param string $transient Transient name. Expected to not be SQL-escaped
</span><span class="cx">  * @return mixed Value of transient
</span><span class="cx">  */
</span><del>-function get_site_transient($transient) {
-        global $_wp_using_ext_object_cache, $wpdb;
</del><ins>+function get_site_transient( $transient ) {
+        global $_wp_using_ext_object_cache;
</ins><span class="cx"> 
</span><span class="cx">         $pre = apply_filters( 'pre_site_transient_' . $transient, false );
</span><span class="cx">         if ( false !== $pre )
</span><span class="cx">                 return $pre;
</span><span class="cx"> 
</span><span class="cx">         if ( $_wp_using_ext_object_cache ) {
</span><del>-                $value = wp_cache_get($transient, 'site-transient');
</del><ins>+                $value = wp_cache_get( $transient, 'site-transient' );
</ins><span class="cx">         } else {
</span><span class="cx">                 // Core transients that do not have a timeout. Listed here so querying timeouts can be avoided.
</span><span class="cx">                 $no_timeout = array('update_core', 'update_plugins', 'update_themes');
</span><del>-                $transient_option = '_site_transient_' . esc_sql($transient);
-                if ( !in_array($transient, $no_timeout) ) {
-                        $transient_timeout = '_site_transient_timeout_' . esc_sql($transient);
-                        $timeout = get_site_option($transient_timeout);
</del><ins>+                $transient_option = '_site_transient_' . esc_sql( $transient );
+                if ( ! in_array( $transient, $no_timeout ) ) {
+                        $transient_timeout = '_site_transient_timeout_' . esc_sql( $transient );
+                        $timeout = get_site_option( $transient_timeout );
</ins><span class="cx">                         if ( false !== $timeout &amp;&amp; $timeout &lt; time() ) {
</span><del>-                                delete_site_option($transient_option);
-                                delete_site_option($transient_timeout);
</del><ins>+                                delete_site_option( $transient_option  );
+                                delete_site_option( $transient_timeout );
</ins><span class="cx">                                 return false;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                $value = get_site_option($transient_option);
</del><ins>+                $value = get_site_option( $transient_option );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return apply_filters('site_transient_' . $transient, $value);
</del><ins>+        return apply_filters( 'site_transient_' . $transient, $value );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -3555,6 +3568,7 @@
</span><span class="cx">  * You do not need to serialize values, if the value needs to be serialize, then
</span><span class="cx">  * it will be serialized before it is set.
</span><span class="cx">  *
</span><ins>+ * @see set_transient()
</ins><span class="cx">  * @since 2.9.0
</span><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Transient
</span><span class="lines">@@ -3564,25 +3578,26 @@
</span><span class="cx">  * @param int $expiration Time until expiration in seconds, default 0
</span><span class="cx">  * @return bool False if value was not set and true if value was set.
</span><span class="cx">  */
</span><del>-function set_site_transient($transient, $value, $expiration = 0) {
-        global $_wp_using_ext_object_cache, $wpdb;
</del><ins>+function set_site_transient( $transient, $value, $expiration = 0 ) {
+        global $_wp_using_ext_object_cache;
</ins><span class="cx"> 
</span><span class="cx">         if ( $_wp_using_ext_object_cache ) {
</span><del>-                return wp_cache_set($transient, $value, 'site-transient', $expiration);
</del><ins>+                $result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
</ins><span class="cx">         } else {
</span><span class="cx">                 $transient_timeout = '_site_transient_timeout_' . $transient;
</span><span class="cx">                 $transient = '_site_transient_' . $transient;
</span><del>-                $safe_transient = esc_sql($transient);
</del><ins>+                $safe_transient = esc_sql( $transient );
</ins><span class="cx">                 if ( false === get_site_option( $safe_transient ) ) {
</span><del>-                        if ( 0 != $expiration )
-                                add_site_option($transient_timeout, time() + $expiration);
-                        return add_site_option($transient, $value);
</del><ins>+                        if ( $expiration )
+                                add_site_option( $transient_timeout, time() + $expiration );
+                        $result = add_site_option( $transient, $value );
</ins><span class="cx">                 } else {
</span><del>-                        if ( 0 != $expiration )
-                                update_site_option($transient_timeout, time() + $expiration);
-                        return update_site_option($transient, $value);
</del><ins>+                        if ( $expiration )
+                                update_site_option( $transient_timeout, time() + $expiration );
+                        $result = update_site_option( $transient, $value );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><ins>+        return $result;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>

</body>
</html>