| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) { |
|---|
| 26 |
global $wp_locale; |
|---|
| 27 |
$m = $mysqlstring; |
|---|
| 28 |
if ( empty( $m ) ) |
|---|
| 29 |
return false; |
|---|
| 30 |
|
|---|
| 31 |
if( 'G' == $dateformatstring ) { |
|---|
| 32 |
return gmmktime( |
|---|
| 33 |
(int) substr( $m, 11, 2 ), (int) substr( $m, 14, 2 ), (int) substr( $m, 17, 2 ), |
|---|
| 34 |
(int) substr( $m, 5, 2 ), (int) substr( $m, 8, 2 ), (int) substr( $m, 0, 4 ) |
|---|
| 35 |
); |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
$i = mktime( |
|---|
| 39 |
(int) substr( $m, 11, 2 ), (int) substr( $m, 14, 2 ), (int) substr( $m, 17, 2 ), |
|---|
| 40 |
(int) substr( $m, 5, 2 ), (int) substr( $m, 8, 2 ), (int) substr( $m, 0, 4 ) |
|---|
| 41 |
); |
|---|
| 42 |
|
|---|
| 43 |
if( 'U' == $dateformatstring ) |
|---|
| 44 |
return $i; |
|---|
| 45 |
|
|---|
| 46 |
if ( -1 == $i || false == $i ) |
|---|
| 47 |
$i = 0; |
|---|
| 48 |
|
|---|
| 49 |
if ( !empty( $wp_locale->month ) && !empty( $wp_locale->weekday ) && $translate ) { |
|---|
| 50 |
$datemonth = $wp_locale->get_month( date( 'm', $i ) ); |
|---|
| 51 |
$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); |
|---|
| 52 |
$dateweekday = $wp_locale->get_weekday( date( 'w', $i ) ); |
|---|
| 53 |
$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); |
|---|
| 54 |
$datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) ); |
|---|
| 55 |
$datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) ); |
|---|
| 56 |
$dateformatstring = ' ' . $dateformatstring; |
|---|
| 57 |
$dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); |
|---|
| 58 |
$dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring ); |
|---|
| 59 |
$dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring ); |
|---|
| 60 |
$dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring ); |
|---|
| 61 |
$dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring ); |
|---|
| 62 |
$dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring ); |
|---|
| 63 |
|
|---|
| 64 |
$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); |
|---|
| 65 |
} |
|---|
| 66 |
$j = @date( $dateformatstring, $i ); |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
if ( !$j ) // for debug purposes |
|---|
| 70 |
echo $i." ".$mysqlstring; |
|---|
| 71 |
*/ |
|---|
| 72 |
|
|---|
| 73 |
return $j; |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
function current_time( $type, $gmt = 0 ) { |
|---|
| 92 |
switch ( $type ) { |
|---|
| 93 |
case 'mysql': |
|---|
| 94 |
return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) ); |
|---|
| 95 |
break; |
|---|
| 96 |
case 'timestamp': |
|---|
| 97 |
return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * 3600 ); |
|---|
| 98 |
break; |
|---|
| 99 |
} |
|---|
| 100 |
} |
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { |
|---|
| 116 |
global $wp_locale; |
|---|
| 117 |
$i = $unixtimestamp; |
|---|
| 118 |
|
|---|
| 119 |
if ( false === $i || intval($i) < 0 ) { |
|---|
| 120 |
if ( ! $gmt ) |
|---|
| 121 |
$i = current_time( 'timestamp' ); |
|---|
| 122 |
else |
|---|
| 123 |
$i = time(); |
|---|
| 124 |
|
|---|
| 125 |
// specially computed timestamp |
|---|
| 126 |
$gmt = true; |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
$datefunc = $gmt? 'gmdate' : 'date'; |
|---|
| 130 |
|
|---|
| 131 |
if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { |
|---|
| 132 |
$datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) ); |
|---|
| 133 |
$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); |
|---|
| 134 |
$dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) ); |
|---|
| 135 |
$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); |
|---|
| 136 |
$datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) ); |
|---|
| 137 |
$datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) ); |
|---|
| 138 |
$dateformatstring = ' '.$dateformatstring; |
|---|
| 139 |
$dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); |
|---|
| 140 |
$dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring ); |
|---|
| 141 |
$dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring ); |
|---|
| 142 |
$dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring ); |
|---|
| 143 |
$dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring ); |
|---|
| 144 |
$dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring ); |
|---|
| 145 |
|
|---|
| 146 |
$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); |
|---|
| 147 |
} |
|---|
| 148 |
$j = @$datefunc( $dateformatstring, $i ); |
|---|
| 149 |
return $j; |
|---|
| 150 |
} |
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
function number_format_i18n( $number, $decimals = null ) { |
|---|
| 162 |
global $wp_locale; |
|---|
| 163 |
|
|---|
| 164 |
$decimals = ( is_null( $decimals ) ) ? $wp_locale->number_format['decimals'] : intval( $decimals ); |
|---|
| 165 |
|
|---|
| 166 |
return number_format( $number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] ); |
|---|
| 167 |
} |
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
function size_format( $bytes, $decimals = null ) { |
|---|
| 191 |
$quant = array( |
|---|
| 192 |
|
|---|
| 193 |
'TB' => 1099511627776, |
|---|
| 194 |
'GB' => 1073741824, |
|---|
| 195 |
'MB' => 1048576, |
|---|
| 196 |
'kB' => 1024, |
|---|
| 197 |
'B ' => 1, |
|---|
| 198 |
); |
|---|
| 199 |
|
|---|
| 200 |
foreach ( $quant as $unit => $mag ) |
|---|
| 201 |
if ( doubleval($bytes) >= $mag ) |
|---|
| 202 |
return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit; |
|---|
| 203 |
|
|---|
| 204 |
return false; |
|---|
| 205 |
} |
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
function get_weekstartend( $mysqlstring, $start_of_week = '' ) { |
|---|
| 217 |
$my = substr( $mysqlstring, 0, 4 ); |
|---|
| 218 |
$mm = substr( $mysqlstring, 8, 2 ); |
|---|
| 219 |
$md = substr( $mysqlstring, 5, 2 ); |
|---|
| 220 |
$day = mktime( 0, 0, 0, $md, $mm, $my ); |
|---|
| 221 |
$weekday = date( 'w', $day ); |
|---|
| 222 |
$i = 86400; |
|---|
| 223 |
if( !is_numeric($start_of_week) ) |
|---|
| 224 |
$start_of_week = get_option( 'start_of_week' ); |
|---|
| 225 |
|
|---|
| 226 |
if ( $weekday < $start_of_week ) |
|---|
| 227 |
$weekday = 7 - $start_of_week - $weekday; |
|---|
| 228 |
|
|---|
| 229 |
while ( $weekday > $start_of_week ) { |
|---|
| 230 |
$weekday = date( 'w', $day ); |
|---|
| 231 |
if ( $weekday < $start_of_week ) |
|---|
| 232 |
$weekday = 7 - $start_of_week - $weekday; |
|---|
| 233 |
|
|---|
| 234 |
$day -= 86400; |
|---|
| 235 |
$i = 0; |
|---|
| 236 |
} |
|---|
| 237 |
$week['start'] = $day + 86400 - $i; |
|---|
| 238 |
$week['end'] = $week['start'] + 604799; |
|---|
| 239 |
return $week; |
|---|
| 240 |
} |
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
function maybe_unserialize( $original ) { |
|---|
| 251 |
if ( is_serialized( $original ) ) |
|---|
| 252 |
if ( false !== $gm = @unserialize( $original ) ) |
|---|
| 253 |
return $gm; |
|---|
| 254 |
return $original; |
|---|
| 255 |
} |
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
function is_serialized( $data ) { |
|---|
| 269 |
|
|---|
| 270 |
if ( !is_string( $data ) ) |
|---|
| 271 |
return false; |
|---|
| 272 |
$data = trim( $data ); |
|---|
| 273 |
if ( 'N;' == $data ) |
|---|
| 274 |
return true; |
|---|
| 275 |
if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) |
|---|
| 276 |
return false; |
|---|
| 277 |
switch ( $badions[1] ) { |
|---|
| 278 |
case 'a' : |
|---|
| 279 |
case 'O' : |
|---|
| 280 |
case 's' : |
|---|
| 281 |
if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) |
|---|
| 282 |
return true; |
|---|
| 283 |
break; |
|---|
| 284 |
case 'b' : |
|---|
| 285 |
case 'i' : |
|---|
| 286 |
case 'd' : |
|---|
| 287 |
if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) |
|---|
| 288 |
return true; |
|---|
| 289 |
break; |
|---|
| 290 |
} |
|---|
| 291 |
return false; |
|---|
| 292 |
} |
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 |
|
|---|
| 302 |
function is_serialized_string( $data ) { |
|---|
| 303 |
|
|---|
| 304 |
if ( !is_string( $data ) ) |
|---|
| 305 |
return false; |
|---|
| 306 |
$data = trim( $data ); |
|---|
| 307 |
if ( preg_match( '/^s:[0-9]+:.*;$/s', $data ) ) |
|---|
| 308 |
return true; |
|---|
| 309 |
return false; |
|---|
| 310 |
} |
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 |
|
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 |
|
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 |
|
|---|
| 334 |
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
function get_option( $setting, $default = false ) { |
|---|
| 343 |
global $wpdb, $switched, $current_blog; |
|---|
| 344 |
|
|---|
| 345 |
$wpdb->hide_errors(); |
|---|
| 346 |
|
|---|
| 347 |
$pre = apply_filters( 'pre_option_' . $setting, false ); |
|---|
| 348 |
if ( false !== $pre ) |
|---|
| 349 |
return $pre; |
|---|
| 350 |
|
|---|
| 351 |
$value = _get_option_cache( $setting ); |
|---|
| 352 |
if ( false === $value ) |
|---|
| 353 |
return $default; |
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
if ( 'home' == $setting && '' == $value ) |
|---|
| 357 |
return get_option( 'siteurl' ); |
|---|
| 358 |
|
|---|
| 359 |
if ( in_array( $setting, array('siteurl', 'home', 'category_base', 'tag_base') ) ) |
|---|
| 360 |
$value = untrailingslashit( $value ); |
|---|
| 361 |
|
|---|
| 362 |
if (! unserialize($value) ) |
|---|
| 363 |
$value = stripslashes( $value ); |
|---|
| 364 |
|
|---|
| 365 |
return apply_filters( 'option_' . $setting, maybe_unserialize( $value ) ); |
|---|
| 366 |
} |
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 |
|
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 |
|
|---|
| 378 |
|
|---|
| 379 |
|
|---|
| 380 |
function wp_protect_special_option( $option ) { |
|---|
| 381 |
$protected = array( 'alloptions', 'notoptions' ); |
|---|
| 382 |
if ( in_array( $option, $protected ) ) |
|---|
| 383 |
die( sprintf( __( '%s is a protected WP option and may not be modified' ), wp_specialchars( $option ) ) ); |
|---|
| 384 |
} |
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 |
|
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 |
|
|---|
| 395 |
|
|---|
| 396 |
function form_option( $option ) { |
|---|
| 397 |
echo attribute_escape (get_option( $option ) ); |
|---|
| 398 |
} |
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 |
|
|---|
| 412 |
|
|---|
| 413 |
|
|---|
| 414 |
|
|---|
| 415 |
function get_alloptions() { |
|---|
| 416 |
global $wpdb; |
|---|
| 417 |
$show = $wpdb->hide_errors(); |
|---|
| 418 |
if ( !$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) |
|---|
| 419 |
$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); |
|---|
| 420 |
$wpdb->show_errors($show); |
|---|
| 421 |
|
|---|
| 422 |
foreach ( (array) $options as $option ) { |
|---|
| 423 |
|
|---|
| 424 |
// never underestimate the ingenuity of the fools :)" -- Dougal |
|---|
| 425 |
if ( in_array( $option->option_name, array( 'siteurl', 'home', 'category_base', 'tag_base' ) ) ) |
|---|
| 426 |
$option->option_value = untrailingslashit( $option->option_value ); |
|---|
| 427 |
$value = maybe_unserialize( $option->option_value ); |
|---|
| 428 |
$all_options->{$option->option_name} = apply_filters( 'pre_option_' . $option->option_name, $value ); |
|---|
| 429 |
} |
|---|
| 430 |
return apply_filters( 'all_options', $all_options ); |
|---|
| 431 |
} |
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 |
|
|---|
| 435 |
|
|---|
| 436 |
|
|---|
| 437 |
|
|---|
| 438 |
|
|---|
| 439 |
|
|---|
| 440 |
|
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
|
|---|
| 444 |
|
|---|
| 445 |
function wp_load_alloptions() { |
|---|
| 446 |
global $wpdb; |
|---|
| 447 |
global $_wp_alloptions; |
|---|
| 448 |
global $blog_id; |
|---|
| 449 |
|
|---|
| 450 |
if( !defined( 'WP_INSTALLING' ) ) { |
|---|
| 451 |
if ( !empty($_wp_alloptions[$blog_id]) ) |
|---|
| 452 |
return $_wp_alloptions[$blog_id]; |
|---|
| 453 |
|
|---|
| 454 |
$alloptions = wp_cache_get('alloptions', 'options'); |
|---|
| 455 |
|
|---|
| 456 |
if ( false !== $alloptions ) { |
|---|
| 457 |
$_wp_alloptions[$blog_id] = $alloptions; |
|---|
| 458 |
return $alloptions; |
|---|
| 459 |
} |
|---|
| 460 |
|
|---|
| 461 |
$_wp_alloptions[$blog_id] = array(); |
|---|
| 462 |
} |
|---|
| 463 |
|
|---|
| 464 |
$suppress = $wpdb->suppress_errors(); |
|---|
| 465 |
|
|---|
| 466 |
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options FORCE INDEX(PRIMARY) ORDER BY option_id ASC" ); |
|---|
| 467 |
$wpdb->suppress_errors($suppress); |
|---|
| 468 |
foreach ( (array) $alloptions_db as $o ) |
|---|
| 469 |
$_wp_alloptions[$blog_id][$o->option_name] = $o->option_value; |
|---|
| 470 |
|
|---|
| 471 |
wp_cache_set('alloptions', $_wp_alloptions[$blog_id], 'options'); |
|---|
| 472 |
|
|---|
| 473 |
return $_wp_alloptions[$blog_id]; |
|---|
| 474 |
} |
|---|
| 475 |
|
|---|
| 476 |
function _get_option_cache( $setting ) { |
|---|
| 477 |
global $_wp_alloptions; |
|---|
| 478 |
global $blog_id; |
|---|
| 479 |
|
|---|
| 480 |
wp_load_alloptions(); |
|---|
| 481 |
|
|---|
| 482 |
if ( isset($_wp_alloptions[$blog_id][$setting]) ) |
|---|
| 483 |
return $_wp_alloptions[$blog_id][$setting]; |
|---|
| 484 |
|
|---|
| 485 |
return false; |
|---|
| 486 |
} |
|---|
| 487 |
|
|---|
| 488 |
function _set_option_cache( $setting, $value ) { |
|---|
| 489 |
global $_wp_alloptions; |
|---|
| 490 |
global $blog_id; |
|---|
| 491 |
|
|---|
| 492 |
wp_load_alloptions(); |
|---|
| 493 |
|
|---|
| 494 |
$_wp_alloptions[$blog_id][$setting] = $value; |
|---|
| 495 |
|
|---|
| 496 |
wp_cache_delete('alloptions', 'options'); |
|---|
| 497 |
} |
|---|
| 498 |
|
|---|
| 499 |
function _delete_option_cache( $setting ) { |
|---|
| 500 |
global $_wp_alloptions; |
|---|
| 501 |
global $blog_id; |
|---|
| 502 |
|
|---|
| 503 |
wp_load_alloptions(); |
|---|
| 504 |
|
|---|
| 505 |
if ( isset($_wp_alloptions[$blog_id][$setting]) ) |
|---|
| 506 |
unset($_wp_alloptions[$blog_id][$setting]); |
|---|
| 507 |
|
|---|
| 508 |
wp_cache_delete('alloptions', 'options'); |
|---|
| 509 |
} |
|---|
| 510 |
|
|---|
| 511 |
|
|---|
| 512 |
|
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 |
|
|---|
| 516 |
|
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 |
|
|---|
| 520 |
|
|---|
| 521 |
|
|---|
| 522 |
|
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
|
|---|
| 532 |
|
|---|
| 533 |
|
|---|
| 534 |
|
|---|
| 535 |
function update_option( $option_name, $newvalue ) { |
|---|
| 536 |
global $wpdb; |
|---|
| 537 |
|
|---|
| 538 |
wp_protect_special_option( $option_name ); |
|---|
| 539 |
|
|---|
| 540 |
$safe_option_name = $wpdb->escape( $option_name ); |
|---|
| 541 |
$newvalue = sanitize_option( $option_name, $newvalue ); |
|---|
| 542 |
|
|---|
| 543 |
$oldvalue = get_option( $safe_option_name ); |
|---|
| 544 |
|
|---|
| 545 |
$newvalue = apply_filters( 'pre_update_option_' . $option_name, $newvalue, $oldvalue ); |
|---|
| 546 |
|
|---|
| 547 |
|
|---|
| 548 |
if ( $newvalue === $oldvalue ) |
|---|
| 549 |
return false; |
|---|
| 550 |
|
|---|
| 551 |
if ( false === $oldvalue ) { |
|---|
| 552 |
add_option( $option_name, $newvalue ); |
|---|
| 553 |
return true; |
|---|
| 554 |
} |
|---|
| 555 |
|
|---|
| 556 |
$_newvalue = $newvalue; |
|---|
| 557 |
$newvalue = maybe_serialize( $newvalue ); |
|---|
| 558 |
|
|---|
| 559 |
_ |
|---|