/var/www/wordpress/wp-admin/includes/admin.php
/var/www/wordpress/wp-admin/includes/bookmark.php
/var/www/wordpress/wp-admin/includes/class-ftp-pure.php
/var/www/wordpress/wp-admin/includes/class-ftp-sockets.php
/var/www/wordpress/wp-admin/includes/class-ftp.php
/var/www/wordpress/wp-admin/includes/class-pclzip.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-base.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-direct.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php
/var/www/wordpress/wp-admin/includes/class-wp-importer.php
/var/www/wordpress/wp-admin/includes/class-wp-upgrader.php
/var/www/wordpress/wp-admin/includes/comment.php
/var/www/wordpress/wp-admin/includes/continents-cities.php
/var/www/wordpress/wp-admin/includes/dashboard.php
/var/www/wordpress/wp-admin/includes/deprecated.php
/var/www/wordpress/wp-admin/includes/export.php
/var/www/wordpress/wp-admin/includes/file.php
/var/www/wordpress/wp-admin/includes/image-edit.php
/var/www/wordpress/wp-admin/includes/image.php
/var/www/wordpress/wp-admin/includes/import.php
/var/www/wordpress/wp-admin/includes/manifest.php
/var/www/wordpress/wp-admin/includes/media.php
/var/www/wordpress/wp-admin/includes/meta-boxes.php
/var/www/wordpress/wp-admin/includes/misc.php
/var/www/wordpress/wp-admin/includes/ms-deprecated.php
/var/www/wordpress/wp-admin/includes/ms.php
/var/www/wordpress/wp-admin/includes/nav-menu.php
/var/www/wordpress/wp-admin/includes/plugin-install.php
/var/www/wordpress/wp-admin/includes/plugin.php
/var/www/wordpress/wp-admin/includes/post.php
/var/www/wordpress/wp-admin/includes/schema.php
/var/www/wordpress/wp-admin/includes/taxonomy.php
/var/www/wordpress/wp-admin/includes/template.php
/var/www/wordpress/wp-admin/includes/theme-install.php
/var/www/wordpress/wp-admin/includes/theme.php
/var/www/wordpress/wp-admin/includes/update-core.php
/var/www/wordpress/wp-admin/includes/update.php
/var/www/wordpress/wp-admin/includes/upgrade.php
/var/www/wordpress/wp-admin/includes/user.php
/var/www/wordpress/wp-admin/includes/widgets.php
/var/www/wordpress/wp-admin/js/revisions-js.php
/var/www/wordpress/wp-admin/maint/repair.php
/var/www/wordpress/wp-admin/admin-ajax.php
/var/www/wordpress/wp-admin/admin-footer.php
/var/www/wordpress/wp-admin/admin-functions.php
/var/www/wordpress/wp-admin/admin-header.php
/var/www/wordpress/wp-admin/admin-post.php
/var/www/wordpress/wp-admin/admin.php
/var/www/wordpress/wp-admin/async-upload.php
/var/www/wordpress/wp-admin/comment.php
/var/www/wordpress/wp-admin/custom-background.php
/var/www/wordpress/wp-admin/custom-header.php
/var/www/wordpress/wp-admin/edit-attachment-rows.php
/var/www/wordpress/wp-admin/edit-comments.php
/var/www/wordpress/wp-admin/edit-form-advanced.php
/var/www/wordpress/wp-admin/edit-form-comment.php
/var/www/wordpress/wp-admin/edit-link-categories.php
/var/www/wordpress/wp-admin/edit-link-category-form.php
/var/www/wordpress/wp-admin/edit-link-form.php
/var/www/wordpress/wp-admin/edit-post-rows.php
/var/www/wordpress/wp-admin/edit-tag-form.php
/var/www/wordpress/wp-admin/edit-tags.php
/var/www/wordpress/wp-admin/edit.php
/var/www/wordpress/wp-admin/export.php
/var/www/wordpress/wp-admin/gears-manifest.php
/var/www/wordpress/wp-admin/import.php
/var/www/wordpress/wp-admin/index-extra.php
/var/www/wordpress/wp-admin/index.php
/var/www/wordpress/wp-admin/install-helper.php
/var/www/wordpress/wp-admin/install.php
/var/www/wordpress/wp-admin/link-add.php
/var/www/wordpress/wp-admin/link-category.php
/var/www/wordpress/wp-admin/link-manager.php
/var/www/wordpress/wp-admin/link-parse-opml.php
/var/www/wordpress/wp-admin/link.php
/var/www/wordpress/wp-admin/load-scripts.php
/var/www/wordpress/wp-admin/load-styles.php
/var/www/wordpress/wp-admin/media-new.php
/var/www/wordpress/wp-admin/media-upload.php
/var/www/wordpress/wp-admin/media.php
/var/www/wordpress/wp-admin/menu-header.php
/var/www/wordpress/wp-admin/menu.php
/var/www/wordpress/wp-admin/moderation.php
/var/www/wordpress/wp-admin/ms-admin.php
/var/www/wordpress/wp-admin/ms-delete-site.php
/var/www/wordpress/wp-admin/ms-edit.php
/var/www/wordpress/wp-admin/ms-options.php
/var/www/wordpress/wp-admin/ms-sites.php
/var/www/wordpress/wp-admin/ms-themes.php
/var/www/wordpress/wp-admin/ms-upgrade-network.php
/var/www/wordpress/wp-admin/ms-users.php
/var/www/wordpress/wp-admin/my-sites.php
/var/www/wordpress/wp-admin/nav-menus.php
/var/www/wordpress/wp-admin/network.php
/var/www/wordpress/wp-admin/options-discussion.php
/var/www/wordpress/wp-admin/options-general.php
/var/www/wordpress/wp-admin/options-head.php
/var/www/wordpress/wp-admin/options-media.php
/var/www/wordpress/wp-admin/options-permalink.php
/var/www/wordpress/wp-admin/options-privacy.php
/var/www/wordpress/wp-admin/options-reading.php
/var/www/wordpress/wp-admin/options-writing.php
/var/www/wordpress/wp-admin/options.php
/var/www/wordpress/wp-admin/plugin-editor.php
/var/www/wordpress/wp-admin/plugin-install.php
/var/www/wordpress/wp-admin/plugins.php
/var/www/wordpress/wp-admin/post-new.php
/var/www/wordpress/wp-admin/post.php
/var/www/wordpress/wp-admin/press-this.php
/var/www/wordpress/wp-admin/profile.php
/var/www/wordpress/wp-admin/revision.php
/var/www/wordpress/wp-admin/setup-config.php
/var/www/wordpress/wp-admin/sidebar.php
/var/www/wordpress/wp-admin/theme-editor.php
/var/www/wordpress/wp-admin/theme-install.php
/var/www/wordpress/wp-admin/themes.php
/var/www/wordpress/wp-admin/tools.php
/var/www/wordpress/wp-admin/update-core.php
/var/www/wordpress/wp-admin/update.php
/var/www/wordpress/wp-admin/upgrade-functions.php
/var/www/wordpress/wp-admin/upgrade.php
/var/www/wordpress/wp-admin/upload.php
/var/www/wordpress/wp-admin/user-edit.php
/var/www/wordpress/wp-admin/user-new.php
/var/www/wordpress/wp-admin/users.php
/var/www/wordpress/wp-admin/widgets.php
/var/www/wordpress/wp-content/languages/ru_RU.php
/var/www/wordpress/wp-content/plugins/akismet/akismet.php
/var/www/wordpress/wp-content/plugins/rh/rh.php
/var/www/wordpress/wp-content/plugins/hello.php
/var/www/wordpress/wp-content/plugins/index.php
/var/www/wordpress/wp-content/themes/twentyten/404.php
/var/www/wordpress/wp-content/themes/twentyten/archive.php
/var/www/wordpress/wp-content/themes/twentyten/attachment.php
/var/www/wordpress/wp-content/themes/twentyten/author.php
/var/www/wordpress/wp-content/themes/twentyten/category.php
/var/www/wordpress/wp-content/themes/twentyten/comments.php
/var/www/wordpress/wp-content/themes/twentyten/footer.php
/var/www/wordpress/wp-content/themes/twentyten/functions.php
/var/www/wordpress/wp-content/themes/twentyten/header.php
/var/www/wordpress/wp-content/themes/twentyten/index.php
/var/www/wordpress/wp-content/themes/twentyten/loop.php
/var/www/wordpress/wp-content/themes/twentyten/onecolumn-page.php
/var/www/wordpress/wp-content/themes/twentyten/page.php
/var/www/wordpress/wp-content/themes/twentyten/search.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar-footer.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar.php
/var/www/wordpress/wp-content/themes/twentyten/single.php
/var/www/wordpress/wp-content/themes/twentyten/tag.php
/var/www/wordpress/wp-content/themes/index.php
/var/www/wordpress/wp-content/index.php
/var/www/wordpress/wp-includes/js/tinymce/langs/wp-langs.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/config.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/rpc.php
/var/www/wordpress/wp-includes/js/tinymce/wp-mce-help.php
/var/www/wordpress/wp-includes/js/tinymce/wp-tinymce.php
/var/www/wordpress/wp-includes/pomo/entry.php
/var/www/wordpress/wp-includes/pomo/mo.php
/var/www/wordpress/wp-includes/pomo/po.php
/var/www/wordpress/wp-includes/pomo/streams.php
/var/www/wordpress/wp-includes/pomo/translations.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/native.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/shell.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/string.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/xdiff.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer/inline.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer.php
/var/www/wordpress/wp-includes/Text/Diff.php
/var/www/wordpress/wp-includes/theme-compat/comments-popup.php
/var/www/wordpress/wp-includes/theme-compat/comments.php
/var/www/wordpress/wp-includes/theme-compat/footer.php
/var/www/wordpress/wp-includes/theme-compat/header.php
/var/www/wordpress/wp-includes/theme-compat/sidebar.php
/var/www/wordpress/wp-includes/atomlib.php
/var/www/wordpress/wp-includes/author-template.php
/var/www/wordpress/wp-includes/bookmark-template.php
/var/www/wordpress/wp-includes/bookmark.php
/var/www/wordpress/wp-includes/cache.php
/var/www/wordpress/wp-includes/canonical.php
/var/www/wordpress/wp-includes/capabilities.php
/var/www/wordpress/wp-includes/category-template.php
/var/www/wordpress/wp-includes/category.php
/var/www/wordpress/wp-includes/class-feed.php
/var/www/wordpress/wp-includes/class-http.php
/var/www/wordpress/wp-includes/class-IXR.php
/var/www/wordpress/wp-includes/class-json.php
/var/www/wordpress/wp-includes/class-oembed.php
/var/www/wordpress/wp-includes/class-phpass.php
/var/www/wordpress/wp-includes/class-phpmailer.php
/var/www/wordpress/wp-includes/class-pop3.php
/var/www/wordpress/wp-includes/class-simplepie.php
/var/www/wordpress/wp-includes/class-smtp.php
/var/www/wordpress/wp-includes/class-snoopy.php
/var/www/wordpress/wp-includes/class.wp-dependencies.php
/var/www/wordpress/wp-includes/class.wp-scripts.php
/var/www/wordpress/wp-includes/class.wp-styles.php
/var/www/wordpress/wp-includes/classes.php
/var/www/wordpress/wp-includes/comment-template.php
/var/www/wordpress/wp-includes/comment.php
/var/www/wordpress/wp-includes/compat.php
/var/www/wordpress/wp-includes/cron.php
/var/www/wordpress/wp-includes/default-constants.php
/var/www/wordpress/wp-includes/default-embeds.php
/var/www/wordpress/wp-includes/default-filters.php
/var/www/wordpress/wp-includes/default-widgets.php
/var/www/wordpress/wp-includes/deprecated.php
/var/www/wordpress/wp-includes/feed-atom-comments.php
/var/www/wordpress/wp-includes/feed-atom.php
/var/www/wordpress/wp-includes/feed-rdf.php
/var/www/wordpress/wp-includes/feed-rss.php
/var/www/wordpress/wp-includes/feed-rss2-comments.php
/var/www/wordpress/wp-includes/feed-rss2.php
/var/www/wordpress/wp-includes/feed.php
/var/www/wordpress/wp-includes/formatting.php
/var/www/wordpress/wp-includes/functions.php
#CodeDescriptions
1<?php
2/**
3 * Main WordPress API
4 *
5 * @package WordPress
6 */
7
8/**
9 * Converts MySQL DATETIME field to user specified date format.
10 *
11 * If $dateformatstring has 'G' value, then gmmktime() function will be used to
12 * make the time. If $dateformatstring is set to 'U', then mktime() function
13 * will be used to make the time.
14 *
15 * The $translate will only be used, if it is set to true and it is by default
16 * and if the $wp_locale object has the month and weekday set.
17 *
18 * @since 0.71
19 *
20 * @param string $dateformatstring Either 'G', 'U', or php date format.
21 * @param string $mysqlstring Time from mysql DATETIME field.
22 * @param bool $translate Optional. Default is true. Will switch format to locale.
23 * @return string Date formated by $dateformatstring or locale (if available).
24 */
25function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
26 $m = $mysqlstring;
27 if ( empty( $m ) )
28 return false;
29
30 if ( 'G' == $dateformatstring ) {
31 return strtotime( $m . ' +0000' );
32 }
33
34 $i = strtotime( $m );
35
36 if ( 'U' == $dateformatstring )
37 return $i;
38
39 if ( $translate)
40 return date_i18n( $dateformatstring, $i );
41 else
42 return date( $dateformatstring, $i );
43}
44
45/**
46 * Retrieve the current time based on specified type.
47 *
48 * The 'mysql' type will return the time in the format for MySQL DATETIME field.
49 * The 'timestamp' type will return the current timestamp.
50 *
51 * If $gmt is set to either '1' or 'true', then both types will use GMT time.
52 * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option.
53 *
54 * @since 1.0.0
55 *
56 * @param string $type Either 'mysql' or 'timestamp'.
57 * @param int|bool $gmt Optional. Whether to use GMT timezone. Default is false.
58 * @return int|string String if $type is 'gmt', int if $type is 'timestamp'.
59 */
60function current_time( $type, $gmt = 0 ) {
61 switch ( $type ) {
62 case 'mysql':
63 return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) );
64 break;
65 case 'timestamp':
66 return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * 3600 );
67 break;
68 }
69}
70
71/**
72 * Retrieve the date in localized format, based on timestamp.
73 *
74 * If the locale specifies the locale month and weekday, then the locale will
75 * take over the format for the date. If it isn't, then the date format string
76 * will be used instead.
77 *
78 * @since 0.71
79 *
80 * @param string $dateformatstring Format to display the date.
81 * @param int $unixtimestamp Optional. Unix timestamp.
82 * @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
83 * @return string The date, translated if locale specifies it.
84 */
85function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
86 global $wp_locale;
87 $i = $unixtimestamp;
88 // Sanity check for PHP 5.1.0-
89 if ( false === $i || intval($i) < 0 ) {
90 if ( ! $gmt )
91 $i = current_time( 'timestamp' );
92 else
93 $i = time();
94 // we should not let date() interfere with our
95 // specially computed timestamp
96 $gmt = true;
97 }
98
99 // store original value for language with untypical grammars
100 // see http://core.trac.wordpress.org/ticket/9396
101 $req_format = $dateformatstring;
102
103 $datefunc = $gmt? 'gmdate' : 'date';
104
105 if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
106 $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) );
107 $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
108 $dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) );
109 $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
110 $datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) );
111 $datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) );
112 $dateformatstring = ' '.$dateformatstring;
113 $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
114 $dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring );
115 $dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring );
116 $dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring );
117 $dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring );
118 $dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring );
119
120 $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
121 }
122 $j = @$datefunc( $dateformatstring, $i );
123 // allow plugins to redo this entirely for languages with untypical grammars
124 $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
125 return $j;
126}
127
128/**
129 * Convert integer number to format based on the locale.
130 *
131 * @since 2.3.0
132 *
133 * @param int $number The number to convert based on locale.
134 * @param int $decimals Precision of the number of decimal places.
135 * @return string Converted number in string format.
136 */
137function number_format_i18n( $number, $decimals = 0 ) {
138 global $wp_locale;
139 $formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] );
140 return apply_filters( 'number_format_i18n', $formatted );
141}
142
143/**
144 * Convert number of bytes largest unit bytes will fit into.
145 *
146 * It is easier to read 1kB than 1024 bytes and 1MB than 1048576 bytes. Converts
147 * number of bytes to human readable number by taking the number of that unit
148 * that the bytes will go into it. Supports TB value.
149 *
150 * Please note that integers in PHP are limited to 32 bits, unless they are on
151 * 64 bit architecture, then they have 64 bit size. If you need to place the
152 * larger size then what PHP integer type will hold, then use a string. It will
153 * be converted to a double, which should always have 64 bit length.
154 *
155 * Technically the correct unit names for powers of 1024 are KiB, MiB etc.
156 * @link http://en.wikipedia.org/wiki/Byte
157 *
158 * @since 2.3.0
159 *
160 * @param int|string $bytes Number of bytes. Note max integer size for integers.
161 * @param int $decimals Precision of number of decimal places. Deprecated.
162 * @return bool|string False on failure. Number string on success.
163 */
164function size_format( $bytes, $decimals = 0 ) {
165 $quant = array(
166 // ========================= Origin ====
167 'TB' => 1099511627776, // pow( 1024, 4)
168 'GB' => 1073741824, // pow( 1024, 3)
169 'MB' => 1048576, // pow( 1024, 2)
170 'kB' => 1024, // pow( 1024, 1)
171 'B ' => 1, // pow( 1024, 0)
172 );
173 foreach ( $quant as $unit => $mag )
174 if ( doubleval($bytes) >= $mag )
175 return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit;
176
177 return false;
178}
179
180/**
181 * Get the week start and end from the datetime or date string from mysql.
182 *
183 * @since 0.71
184 *
185 * @param string $mysqlstring Date or datetime field type from mysql.
186 * @param int $start_of_week Optional. Start of the week as an integer.
187 * @return array Keys are 'start' and 'end'.
188 */
189function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
190 $my = substr( $mysqlstring, 0, 4 ); // Mysql string Year
191 $mm = substr( $mysqlstring, 8, 2 ); // Mysql string Month
192 $md = substr( $mysqlstring, 5, 2 ); // Mysql string day
193 $day = mktime( 0, 0, 0, $md, $mm, $my ); // The timestamp for mysqlstring day.
194 $weekday = date( 'w', $day ); // The day of the week from the timestamp
195 if ( !is_numeric($start_of_week) )
196 $start_of_week = get_option( 'start_of_week' );
197
198 if ( $weekday < $start_of_week )
199 $weekday += 7;
200
201 $start = $day - 86400 * ( $weekday - $start_of_week ); // The most recent week start day on or before $day
202 $end = $start + 604799; // $start + 7 days - 1 second
203 return compact( 'start', 'end' );
204}
205
206/**
207 * Unserialize value only if it was serialized.
208 *
209 * @since 2.0.0
210 *
211 * @param string $original Maybe unserialized original, if is needed.
212 * @return mixed Unserialized data can be any type.
213 */
214function maybe_unserialize( $original ) {
215 if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
216 return @unserialize( $original );//Possible Control Flow
217 return $original;
218}
219
220/**
221 * Check value to find if it was serialized.
222 *
223 * If $data is not an string, then returned value will always be false.
224 * Serialized data is always a string.
225 *
226 * @since 2.0.5
227 *
228 * @param mixed $data Value to check to see if was serialized.
229 * @return bool False if not serialized and true if it was.
230 */
231function is_serialized( $data ) {
232 // if it isn't a string, it isn't serialized
233 if ( !is_string( $data ) )
234 return false;
235 $data = trim( $data );
236 if ( 'N;' == $data )
237 return true;
238 if ( !preg_match( '/^([adObis]):/', $data, $badions ) )
239 return false;
240 switch ( $badions[1] ) {
241 case 'a' :
242 case 'O' :
243 case 's' :
244 if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) )
245 return true;
246 break;
247 case 'b' :
248 case 'i' :
249 case 'd' :
250 if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) )
251 return true;
252 break;
253 }
254 return false;
255}
256
257/**
258 * Check whether serialized data is of string type.
259 *
260 * @since 2.0.5
261 *
262 * @param mixed $data Serialized data
263 * @return bool False if not a serialized string, true if it is.
264 */
265function is_serialized_string( $data ) {
266 // if it isn't a string, it isn't a serialized string
267 if ( !is_string( $data ) )
268 return false;
269 $data = trim( $data );
270 if ( preg_match( '/^s:[0-9]+:.*;$/s', $data ) ) // this should fetch all serialized strings
271 return true;
272 return false;
273}
274
275/**
276 * Retrieve option value based on name of option.
277 *
278 * If the option does not exist or does not have a value, then the return value
279 * will be false. This is useful to check whether you need to install an option
280 * and is commonly used during installation of plugin options and to test
281 * whether upgrading is required.
282 *
283 * If the option was serialized then it will be unserialized when it is returned.
284 *
285 * @since 1.5.0
286 * @package WordPress
287 * @subpackage Option
288 * @uses apply_filters() Calls 'pre_option_$option' before checking the option.
289 * Any value other than false will "short-circuit" the retrieval of the option
290 * and return the returned value. You should not try to override special options,
291 * but you will not be prevented from doing so.
292 * @uses apply_filters() Calls 'option_$option', after checking the option, with
293 * the option value.
294 *
295 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
296 * @return mixed Value set for the option.
297 */
298function get_option( $option, $default = false ) {
299 global $wpdb;
300
301 // Allow plugins to short-circuit options.
302 $pre = apply_filters( 'pre_option_' . $option, false );
303 if ( false !== $pre )
304 return $pre;
305
306 $option = trim($option);
307 if ( empty($option) )
308 return false;
309
310 if ( defined( 'WP_SETUP_CONFIG' ) )
311 return false;
312
313 if ( ! defined( 'WP_INSTALLING' ) ) {
314 // prevent non-existent options from triggering multiple queries
315 $notoptions = wp_cache_get( 'notoptions', 'options' );
316 if ( isset( $notoptions[$option] ) )
317 return $default;
318
319 $alloptions = wp_load_alloptions();
320
321 if ( isset( $alloptions[$option] ) ) {
322 $value = $alloptions[$option];
323 } else {
324 $value = wp_cache_get( $option, 'options' );
325
326 if ( false === $value ) {
327 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
328
329 // Has to be get_row instead of get_var because of funkiness with 0, false, null values
330 if ( is_object( $row ) ) {
331 $value = $row->option_value;
332 wp_cache_add( $option, $value, 'options' );
333 } else { // option does not exist, so we must cache its non-existence
334 $notoptions[$option] = true;
335 wp_cache_set( 'notoptions', $notoptions, 'options' );
336 return $default;
337 }
338 }
339 }
340 } else {
341 $suppress = $wpdb->suppress_errors();
342 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
343 $wpdb->suppress_errors( $suppress );
344 if ( is_object( $row ) )
345 $value = $row->option_value;
346 else
347 return $default;
348 }
349
350 // If home is not set use siteurl.
351 if ( 'home' == $option && '' == $value )
352 return get_option( 'siteurl' );
353
354 if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
355 $value = untrailingslashit( $value );
356
357 return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );//Possible Control Flow
358}
359
360/**
361 * Protect WordPress special option from being modified.
362 *
363 * Will die if $option is in protected list. Protected options are 'alloptions'
364 * and 'notoptions' options.
365 *
366 * @since 2.2.0
367 * @package WordPress
368 * @subpackage Option
369 *
370 * @param string $option Option name.
371 */
372function wp_protect_special_option( $option ) {
373 $protected = array( 'alloptions', 'notoptions' );
374 if ( in_array( $option, $protected ) )
375 wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) );
376}
377
378/**
379 * Print option value after sanitizing for forms.
380 *
381 * @uses attr Sanitizes value.
382 * @since 1.5.0
383 * @package WordPress
384 * @subpackage Option
385 *
386 * @param string $option Option name.
387 */
388function form_option( $option ) {
389 echo esc_attr( get_option( $option ) );
390}
391
392/**
393 * Loads and caches all autoloaded options, if available or all options.
394 *
395 * @since 2.2.0
396 * @package WordPress
397 * @subpackage Option
398 *
399 * @return array List of all options.
400 */
401function wp_load_alloptions() {
402 global $wpdb;
403
404 if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
405 $alloptions = wp_cache_get( 'alloptions', 'options' );
406 else
407 $alloptions = false;
408
409 if ( !$alloptions ) {
410 $suppress = $wpdb->suppress_errors();
411 if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
412 $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
413 $wpdb->suppress_errors($suppress);
414 $alloptions = array();
415 foreach ( (array) $alloptions_db as $o )
416 $alloptions[$o->option_name] = $o->option_value;
417 if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
418 wp_cache_add( 'alloptions', $alloptions, 'options' );
419 }
420
421 return $alloptions;
422}
423
424/**
425 * Loads and caches certain often requested site options if is_multisite() and a peristent cache is not being used.
426 *
427 * @since 3.0.0
428 * @package WordPress
429 * @subpackage Option
430 *
431 * @param int $site_id Optional site ID for which to query the options. Defaults to the current site.
432 */
433function wp_load_core_site_options( $site_id = null ) {
434 global $wpdb, $_wp_using_ext_object_cache;
435
436 if ( !is_multisite() || $_wp_using_ext_object_cache || defined( 'WP_INSTALLING' ) )
437 return;
438
439 if ( empty($site_id) )
440 $site_id = $wpdb->siteid;
441
442 $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'dashboard_blog', 'can_compress_scripts', 'global_terms_enabled' );
443
444 $core_options_in = "'" . implode("', '", $core_options) . "'";
445 $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
446
447 foreach ( $options as $option ) {
448 $key = $option->meta_key;
449 $cache_key = "{$site_id}:$key";
450 $option->meta_value = maybe_unserialize( $option->meta_value );//Possible Control Flow
451
452 wp_cache_set( $cache_key, $option->meta_value, 'site-options' );
453 }
454}
455
456/**
457 * Update the value of an option that was already added.
458 *
459 * You do not need to serialize values. If the value needs to be serialized, then
460 * it will be serialized before it is inserted into the database. Remember,
461 * resources can not be serialized or added as an option.
462 *
463 * If the option does not exist, then the option will be added with the option
464 * value, but you will not be able to set whether it is autoloaded. If you want
465 * to set whether an option is autoloaded, then you need to use the add_option().
466 *
467 * @since 1.0.0
468 * @package WordPress
469 * @subpackage Option
470 *
471 * @uses apply_filters() Calls 'pre_update_option_$option' hook to allow overwriting the
472 * option value to be stored.
473 * @uses do_action() Calls 'update_option' hook before updating the option.
474 * @uses do_action() Calls 'update_option_$option' and 'updated_option' hooks on success.
475 *
476 * @param string $option Option name. Expected to not be SQL-escaped.
477 * @param mixed $newvalue Option value. Expected to not be SQL-escaped.
478 * @return bool False if value was not updated and true if value was updated.
479 */
480function update_option( $option, $newvalue ) {
481 global $wpdb;
482
483 $option = trim($option);
484 if ( empty($option) )
485 return false;
486
487 wp_protect_special_option( $option );
488
489 if ( is_object($newvalue) )
490 $newvalue = wp_clone($newvalue);
491
492 $newvalue = sanitize_option( $option, $newvalue );
493 $oldvalue = get_option( $option );
494 $newvalue = apply_filters( 'pre_update_option_' . $option, $newvalue, $oldvalue );
495
496 // If the new and old values are the same, no need to update.
497 if ( $newvalue === $oldvalue )
498 return false;
499
500 if ( false === $oldvalue )
501 return add_option( $option, $newvalue );
502
503 $notoptions = wp_cache_get( 'notoptions', 'options' );
504 if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
505 unset( $notoptions[$option] );
506 wp_cache_set( 'notoptions', $notoptions, 'options' );
507 }
508
509 $_newvalue = $newvalue;
510 $newvalue = maybe_serialize( $newvalue );
511
512 do_action( 'update_option', $option, $oldvalue, $_newvalue );
513 if ( ! defined( 'WP_INSTALLING' ) ) {
514 $alloptions = wp_load_alloptions();
515 if ( isset( $alloptions[$option] ) ) {
516 $alloptions[$option] = $_newvalue;
517 wp_cache_set( 'alloptions', $alloptions, 'options' );
518 } else {
519 wp_cache_set( $option, $_newvalue, 'options' );
520 }
521 }
522
523 $result = $wpdb->update( $wpdb->options, array( 'option_value' => $newvalue ), array( 'option_name' => $option ) );
524
525 if ( $result ) {
526 do_action( "update_option_{$option}", $oldvalue, $_newvalue );
527 do_action( 'updated_option', $option, $oldvalue, $_newvalue );
528 return true;
529 }
530 return false;
531}
532
533/**
534 * Add a new option.
535 *
536 * You do not need to serialize values. If the value needs to be serialized, then
537 * it will be serialized before it is inserted into the database. Remember,
538 * resources can not be serialized or added as an option.
539 *
540 * You can create options without values and then add values later. Does not
541 * check whether the option has already been added, but does check that you
542 * aren't adding a protected WordPress option. Care should be taken to not name
543 * options the same as the ones which are protected and to not add options
544 * that were already added.
545 *
546 * @package WordPress
547 * @subpackage Option
548 * @since 1.0.0
549 * @link http://alex.vort-x.net/blog/ Thanks Alex Stapleton
550 *
551 * @uses do_action() Calls 'add_option' hook before adding the option.
552 * @uses do_action() Calls 'add_option_$option' and 'added_option' hooks on success.
553 *
554 * @param string $option Name of option to add. Expected to not be SQL-escaped.
555 * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped.
556 * @param mixed $deprecated Optional. Description. Not used anymore.
557 * @param bool $autoload Optional. Default is enabled. Whether to load the option when WordPress starts up.
558 * @return null returns when finished.
559 */
560function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
561 global $wpdb;
562
563 if ( !empty( $deprecated ) )
564 _deprecated_argument( __FUNCTION__, '2.3' );
565
566 $option = trim($option);
567 if ( empty($option) )
568 return false;
569
570 wp_protect_special_option( $option );
571
572 if ( is_object($value) )
573 $value = wp_clone($value);
574
575 $value = sanitize_option( $option, $value );
576
577 // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
578 $notoptions = wp_cache_get( 'notoptions', 'options' );
579 if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
580 if ( false !== get_option( $option ) )
581 return;
582
583 $_value = $value;
584 $value = maybe_serialize( $value );
585 $autoload = ( 'no' === $autoload ) ? 'no' : 'yes';
586 do_action( 'add_option', $option, $_value );
587 if ( ! defined( 'WP_INSTALLING' ) ) {
588 if ( 'yes' == $autoload ) {
589 $alloptions = wp_load_alloptions();
590 $alloptions[$option] = $value;
591 wp_cache_set( 'alloptions', $alloptions, 'options' );
592 } else {
593 wp_cache_set( $option, $value, 'options' );
594 }
595 }
596
597 // This option exists now
598 $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh
599 if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
600 unset( $notoptions[$option] );
601 wp_cache_set( 'notoptions', $notoptions, 'options' );
602 }
603
604 $result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->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`)", $option, $value, $autoload ) );//Arbitrary command execution
605
606 if ( $result ) {
607 do_action( "add_option_{$option}", $option, $_value );
608 do_action( 'added_option', $option, $_value );
609 return true;
610 }
611 return false;
612}
613
614/**
615 * Removes option by name. Prevents removal of protected WordPress options.
616 *
617 * @package WordPress
618 * @subpackage Option
619 * @since 1.2.0
620 *
621 * @uses do_action() Calls 'delete_option' hook before option is deleted.
622 * @uses do_action() Calls 'deleted_option' and 'delete_option_$option' hooks on success.
623 *
624 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
625 * @return bool True, if option is successfully deleted. False on failure.
626 */
627function delete_option( $option ) {
628 global $wpdb;
629
630 wp_protect_special_option( $option );
631
632 // Get the ID, if no ID then return
633 $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) );
634 if ( is_null( $row ) )
635 return false;
636 do_action( 'delete_option', $option );
637 $result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->options WHERE option_name = %s", $option) );
638 if ( ! defined( 'WP_INSTALLING' ) ) {
639 if ( 'yes' == $row->autoload ) {
640 $alloptions = wp_load_alloptions();
641 if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) {
642 unset( $alloptions[$option] );
643 wp_cache_set( 'alloptions', $alloptions, 'options' );
644 }
645 } else {
646 wp_cache_delete( $option, 'options' );
647 }
648 }
649 if ( $result ) {
650 do_action( "delete_option_$option", $option );
651 do_action( 'deleted_option', $option );
652 return true;
653 }
654 return false;
655}
656
657/**
658 * Delete a transient
659 *
660 * @since 2.8.0
661 * @package WordPress
662 * @subpackage Transient
663 *
664 * @uses do_action() Calls 'delete_transient_$transient' hook before transient is deleted.
665 * @uses do_action() Calls 'deleted_transient' hook on success.
666 *
667 * @param string $transient Transient name. Expected to not be SQL-escaped.
668 * @return bool true if successful, false otherwise
669 */
670function delete_transient( $transient ) {
671 global $_wp_using_ext_object_cache;
672
673 do_action( 'delete_transient_' . $transient, $transient );
674
675 if ( $_wp_using_ext_object_cache ) {
676 $result = wp_cache_delete( $transient, 'transient' );
677 } else {
678 $option_timeout = '_transient_timeout_' . $transient;
679 $option = '_transient_' . $transient;
680 $result = delete_option( $option );
681 if ( $result )
682 delete_option( $option_timeout );
683 }
684
685 if ( $result )
686 do_action( 'deleted_transient', $transient );
687 return $result;
688}
689
690/**
691 * Get the value of a transient
692 *
693 * If the transient does not exist or does not have a value, then the return value
694 * will be false.
695 *
696 * @uses apply_filters() Calls 'pre_transient_$transient' hook before checking the transient.
697 * Any value other than false will "short-circuit" the retrieval of the transient
698 * and return the returned value.
699 * @uses apply_filters() Calls 'transient_$option' hook, after checking the transient, with
700 * the transient value.
701 *
702 * @since 2.8.0
703 * @package WordPress
704 * @subpackage Transient
705 *
706 * @param string $transient Transient name. Expected to not be SQL-escaped
707 * @return mixed Value of transient
708 */
709function get_transient( $transient ) {
710 global $_wp_using_ext_object_cache;
711
712 $pre = apply_filters( 'pre_transient_' . $transient, false );
713 if ( false !== $pre )
714 return $pre;
715
716 if ( $_wp_using_ext_object_cache ) {
717 $value = wp_cache_get( $transient, 'transient' );
718 } else {
719 $transient_option = '_transient_' . $transient;
720 if ( ! defined( 'WP_INSTALLING' ) ) {
721 // If option is not in alloptions, it is not autoloaded and thus has a timeout
722 $alloptions = wp_load_alloptions();
723 if ( !isset( $alloptions[$transient_option] ) ) {
724 $transient_timeout = '_transient_timeout_' . $transient;
725 if ( get_option( $transient_timeout ) < time() ) {
726 delete_option( $transient_option );
727 delete_option( $transient_timeout );
728 return false;
729 }
730 }
731 }
732
733 $value = get_option( $transient_option );
734 }
735
736 return apply_filters( 'transient_' . $transient, $value );
737}
738
739/**
740 * Set/update the value of a transient
741 *
742 * You do not need to serialize values. If the value needs to be serialized, then
743 * it will be serialized before it is set.
744 *
745 * @since 2.8.0
746 * @package WordPress
747 * @subpackage Transient
748 *
749 * @uses apply_filters() Calls 'pre_set_transient_$transient' hook to allow overwriting the
750 * transient value to be stored.
751 * @uses do_action() Calls 'set_transient_$transient' and 'setted_transient' hooks on success.
752 *
753 * @param string $transient Transient name. Expected to not be SQL-escaped.
754 * @param mixed $value Transient value. Expected to not be SQL-escaped.
755 * @param int $expiration Time until expiration in seconds, default 0
756 * @return bool False if value was not set and true if value was set.
757 */
758function set_transient( $transient, $value, $expiration = 0 ) {
759 global $_wp_using_ext_object_cache;
760
761 $value = apply_filters( 'pre_set_transient_' . $transient, $value );
762
763 if ( $_wp_using_ext_object_cache ) {
764 $result = wp_cache_set( $transient, $value, 'transient', $expiration );
765 } else {
766 $transient_timeout = '_transient_timeout_' . $transient;
767 $transient = '_transient_' . $transient;
768 if ( false === get_option( $transient ) ) {
769 $autoload = 'yes';
770 if ( $expiration ) {
771 $autoload = 'no';
772 add_option( $transient_timeout, time() + $expiration, '', 'no' );
773 }
774 $result = add_option( $transient, $value, '', $autoload );
775 } else {
776 if ( $expiration )
777 update_option( $transient_timeout, time() + $expiration );
778 $result = update_option( $transient, $value );
779 }
780 }
781 if ( $result ) {
782 do_action( 'set_transient_' . $transient );
783 do_action( 'setted_transient', $transient );
784 }
785 return $result;
786}
787
788/**
789 * Saves and restores user interface settings stored in a cookie.
790 *
791 * Checks if the current user-settings cookie is updated and stores it. When no
792 * cookie exists (different browser used), adds the last saved cookie restoring
793 * the settings.
794 *
795 * @package WordPress
796 * @subpackage Option
797 * @since 2.7.0
798 */
799function wp_user_settings() {
800
801 if ( ! is_admin() )
802 return;
803
804 if ( defined('DOING_AJAX') )
805 return;
806
807 if ( ! $user = wp_get_current_user() )
808 return;
809
810 $settings = get_user_option( 'user-settings', $user->ID );
811
812 if ( isset( $_COOKIE['wp-settings-' . $user->ID] ) ) {
813 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user->ID] );
814
815 if ( ! empty( $cookie ) && strpos( $cookie, '=' ) ) {
816 if ( $cookie == $settings )
817 return;
818
819 $last_time = (int) get_user_option( 'user-settings-time', $user->ID );
820 $saved = isset( $_COOKIE['wp-settings-time-' . $user->ID]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user->ID] ) : 0;
821
822 if ( $saved > $last_time ) {
823 update_user_option( $user->ID, 'user-settings', $cookie, false );
824 update_user_option( $user->ID, 'user-settings-time', time() - 5, false );
825 return;
826 }
827 }
828 }
829
830 setcookie( 'wp-settings-' . $user->ID, $settings, time() + 31536000, SITECOOKIEPATH );
831 setcookie( 'wp-settings-time-' . $user->ID, time(), time() + 31536000, SITECOOKIEPATH );
832 $_COOKIE['wp-settings-' . $user->ID] = $settings;
833}
834
835/**
836 * Retrieve user interface setting value based on setting name.
837 *
838 * @package WordPress
839 * @subpackage Option
840 * @since 2.7.0
841 *
842 * @param string $name The name of the setting.
843 * @param string $default Optional default value to return when $name is not set.
844 * @return mixed the last saved user setting or the default value/false if it doesn't exist.
845 */
846function get_user_setting( $name, $default = false ) {
847
848 $all = get_all_user_settings();
849
850 return isset($all[$name]) ? $all[$name] : $default;
851}
852
853/**
854 * Add or update user interface setting.
855 *
856 * Both $name and $value can contain only ASCII letters, numbers and underscores.
857 * This function has to be used before any output has started as it calls setcookie().
858 *
859 * @package WordPress
860 * @subpackage Option
861 * @since 2.8.0
862 *
863 * @param string $name The name of the setting.
864 * @param string $value The value for the setting.
865 * @return bool true if set successfully/false if not.
866 */
867function set_user_setting( $name, $value ) {
868
869 if ( headers_sent() )
870 return false;
871
872 $all = get_all_user_settings();
873 $name = preg_replace( '/[^A-Za-z0-9_]+/', '', $name );
874
875 if ( empty($name) )
876 return false;
877
878 $all[$name] = $value;
879
880 return wp_set_all_user_settings($all);
881}
882
883/**
884 * Delete user interface settings.
885 *
886 * Deleting settings would reset them to the defaults.
887 * This function has to be used before any output has started as it calls setcookie().
888 *
889 * @package WordPress
890 * @subpackage Option
891 * @since 2.7.0
892 *
893 * @param mixed $names The name or array of names of the setting to be deleted.
894 * @return bool true if deleted successfully/false if not.
895 */
896function delete_user_setting( $names ) {
897
898 if ( headers_sent() )
899 return false;
900
901 $all = get_all_user_settings();
902 $names = (array) $names;
903
904 foreach ( $names as $name ) {
905 if ( isset($all[$name]) ) {
906 unset($all[$name]);
907 $deleted = true;
908 }
909 }
910
911 if ( isset($deleted) )
912 return wp_set_all_user_settings($all);
913
914 return false;
915}
916
917/**
918 * Retrieve all user interface settings.
919 *
920 * @package WordPress
921 * @subpackage Option
922 * @since 2.7.0
923 *
924 * @return array the last saved user settings or empty array.
925 */
926function get_all_user_settings() {
927 global $_updated_user_settings;
928
929 if ( ! $user = wp_get_current_user() )
930 return array();
931
932 if ( isset($_updated_user_settings) && is_array($_updated_user_settings) )
933 return $_updated_user_settings;
934
935 $all = array();
936 if ( isset($_COOKIE['wp-settings-' . $user->ID]) ) {
937 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user->ID] );
938
939 if ( $cookie && strpos($cookie, '=') ) // the '=' cannot be 1st char
940 parse_str($cookie, $all);
941
942 } else {
943 $option = get_user_option('user-settings', $user->ID);
944 if ( $option && is_string($option) )
945 parse_str( $option, $all );
946 }
947
948 return $all;
949}
950
951/**
952 * Private. Set all user interface settings.
953 *
954 * @package WordPress
955 * @subpackage Option
956 * @since 2.8.0
957 *
958 * @param unknown $all
959 * @return bool
960 */
961function wp_set_all_user_settings($all) {
962 global $_updated_user_settings;
963
964 if ( ! $user = wp_get_current_user() )
965 return false;
966
967 $_updated_user_settings = $all;
968 $settings = '';
969 foreach ( $all as $k => $v ) {
970 $v = preg_replace( '/[^A-Za-z0-9_]+/', '', $v );
971 $settings .= $k . '=' . $v . '&';
972 }
973
974 $settings = rtrim($settings, '&');
975
976 update_user_option( $user->ID, 'user-settings', $settings, false );
977 update_user_option( $user->ID, 'user-settings-time', time(), false );
978
979 return true;
980}
981
982/**
983 * Delete the user settings of the current user.
984 *
985 * @package WordPress
986 * @subpackage Option
987 * @since 2.7.0
988 */
989function delete_all_user_settings() {
990 if ( ! $user = wp_get_current_user() )
991 return;
992
993 update_user_option( $user->ID, 'user-settings', '', false );
994 setcookie('wp-settings-' . $user->ID, ' ', time() - 31536000, SITECOOKIEPATH);
995}
996
997/**
998 * Serialize data, if needed.
999 *
1000 * @since 2.0.5
/var/www/wordpress/wp-includes/functions.wp-scripts.php
/var/www/wordpress/wp-includes/functions.wp-styles.php
/var/www/wordpress/wp-includes/general-template.php
/var/www/wordpress/wp-includes/http.php
/var/www/wordpress/wp-includes/kses.php
/var/www/wordpress/wp-includes/l10n.php
/var/www/wordpress/wp-includes/link-template.php
/var/www/wordpress/wp-includes/load.php
/var/www/wordpress/wp-includes/locale.php
/var/www/wordpress/wp-includes/media.php
/var/www/wordpress/wp-includes/meta.php
/var/www/wordpress/wp-includes/ms-blogs.php
/var/www/wordpress/wp-includes/ms-default-constants.php
/var/www/wordpress/wp-includes/ms-default-filters.php
/var/www/wordpress/wp-includes/ms-deprecated.php
/var/www/wordpress/wp-includes/ms-files.php
/var/www/wordpress/wp-includes/ms-functions.php
/var/www/wordpress/wp-includes/ms-load.php
/var/www/wordpress/wp-includes/ms-settings.php
/var/www/wordpress/wp-includes/nav-menu-template.php
/var/www/wordpress/wp-includes/nav-menu.php
/var/www/wordpress/wp-includes/pluggable-deprecated.php
/var/www/wordpress/wp-includes/pluggable.php
/var/www/wordpress/wp-includes/plugin.php
/var/www/wordpress/wp-includes/post-template.php
/var/www/wordpress/wp-includes/post-thumbnail-template.php
/var/www/wordpress/wp-includes/post.php
/var/www/wordpress/wp-includes/query.php
/var/www/wordpress/wp-includes/registration-functions.php
/var/www/wordpress/wp-includes/registration.php
/var/www/wordpress/wp-includes/rewrite.php
/var/www/wordpress/wp-includes/rss-functions.php
/var/www/wordpress/wp-includes/rss.php
/var/www/wordpress/wp-includes/script-loader.php
/var/www/wordpress/wp-includes/shortcodes.php
/var/www/wordpress/wp-includes/taxonomy.php
/var/www/wordpress/wp-includes/template-loader.php
/var/www/wordpress/wp-includes/theme.php
/var/www/wordpress/wp-includes/update.php
/var/www/wordpress/wp-includes/user.php
/var/www/wordpress/wp-includes/vars.php
/var/www/wordpress/wp-includes/version.php
/var/www/wordpress/wp-includes/widgets.php
/var/www/wordpress/wp-includes/wp-db.php
/var/www/wordpress/wp-includes/wp-diff.php
/var/www/wordpress/index.php
/var/www/wordpress/wp-activate.php
/var/www/wordpress/wp-app.php
/var/www/wordpress/wp-atom.php
/var/www/wordpress/wp-blog-header.php
/var/www/wordpress/wp-comments-post.php
/var/www/wordpress/wp-commentsrss2.php
/var/www/wordpress/wp-config-sample.php
/var/www/wordpress/wp-cron.php
/var/www/wordpress/wp-feed.php
/var/www/wordpress/wp-links-opml.php
/var/www/wordpress/wp-load.php
/var/www/wordpress/wp-login.php
/var/www/wordpress/wp-mail.php
/var/www/wordpress/wp-pass.php
/var/www/wordpress/wp-rdf.php
/var/www/wordpress/wp-register.php
/var/www/wordpress/wp-rss.php
/var/www/wordpress/wp-rss2.php
/var/www/wordpress/wp-settings.php
/var/www/wordpress/wp-signup.php
/var/www/wordpress/wp-trackback.php
/var/www/wordpress/xmlrpc.php