| [ Index ] |
PHP Cross Reference of BackPress |
[Summary view] [Print] [Text view]
1 <?php 2 // Last sync [WP11544] 3 4 /** 5 * From WP wp-includes/functions.php 6 * 7 * Missing functions are indicated in comments 8 */ 9 10 /** 11 * Main BackPress API 12 * 13 * @package BackPress 14 */ 15 16 // ! function mysql2date() 17 18 if ( !function_exists('current_time') ) : 19 /** 20 * Retrieve the current time based on specified type. 21 * 22 * The 'mysql' type will return the time in the format for MySQL DATETIME field. 23 * The 'timestamp' type will return the current timestamp. 24 * 25 * If $gmt is set to either '1' or 'true', then both types will use GMT time. 26 * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option. 27 * 28 * @since 1.0.0 29 * 30 * @param string $type Either 'mysql' or 'timestamp'. 31 * @param int|bool $gmt Optional. Whether to use GMT timezone. Default is false. 32 * @return int|string String if $type is 'gmt', int if $type is 'timestamp'. 33 */ 34 function current_time( $type, $gmt = 0 ) { 35 switch ( $type ) { 36 case 'mysql': 37 return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( backpress_get_option( 'gmt_offset' ) * 3600 ) ) ); 38 break; 39 case 'timestamp': 40 return ( $gmt ) ? time() : time() + ( backpress_get_option( 'gmt_offset' ) * 3600 ); 41 break; 42 } 43 } 44 endif; 45 46 // ! function date_i18n() 47 // ! function number_format_i18n() 48 // ! function size_format() 49 // ! function get_weekstartend() 50 51 if ( !function_exists('maybe_unserialize') ) : 52 /** 53 * Unserialize value only if it was serialized. 54 * 55 * @since 2.0.0 56 * 57 * @param string $original Maybe unserialized original, if is needed. 58 * @return mixed Unserialized data can be any type. 59 */ 60 function maybe_unserialize( $original ) { 61 if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in 62 return @unserialize( $original ); 63 return $original; 64 } 65 endif; 66 67 if ( !function_exists('is_serialized') ) : 68 /** 69 * Check value to find if it was serialized. 70 * 71 * If $data is not an string, then returned value will always be false. 72 * Serialized data is always a string. 73 * 74 * @since 2.0.5 75 * 76 * @param mixed $data Value to check to see if was serialized. 77 * @return bool False if not serialized and true if it was. 78 */ 79 function is_serialized( $data ) { 80 // if it isn't a string, it isn't serialized 81 if ( !is_string( $data ) ) 82 return false; 83 $data = trim( $data ); 84 if ( 'N;' == $data ) 85 return true; 86 if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) 87 return false; 88 switch ( $badions[1] ) { 89 case 'a' : 90 case 'O' : 91 case 's' : 92 if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) 93 return true; 94 break; 95 case 'b' : 96 case 'i' : 97 case 'd' : 98 if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) 99 return true; 100 break; 101 } 102 return false; 103 } 104 endif; 105 106 if ( !function_exists('is_serialized_string') ) : 107 /** 108 * Check whether serialized data is of string type. 109 * 110 * @since 2.0.5 111 * 112 * @param mixed $data Serialized data 113 * @return bool False if not a serialized string, true if it is. 114 */ 115 function is_serialized_string( $data ) { 116 // if it isn't a string, it isn't a serialized string 117 if ( !is_string( $data ) ) 118 return false; 119 $data = trim( $data ); 120 if ( preg_match( '/^s:[0-9]+:.*;$/s', $data ) ) // this should fetch all serialized strings 121 return true; 122 return false; 123 } 124 endif; 125 126 // ! function get_option() 127 // ! function wp_protect_special_option() 128 // ! function form_option() 129 // ! function get_alloptions() 130 // ! function wp_load_alloptions() 131 // ! function update_option() 132 // ! function add_option() 133 // ! function delete_option() 134 // ! function delete_transient() 135 // ! function get_transient() 136 // ! function set_transient() 137 // ! function wp_user_settings() 138 // ! function get_user_setting() 139 // ! function set_user_setting() 140 // ! function delete_user_setting() 141 // ! function get_all_user_settings() 142 // ! function wp_set_all_user_settings() 143 // ! function delete_all_user_settings() 144 145 if ( !function_exists('maybe_serialize') ) : 146 /** 147 * Serialize data, if needed. 148 * 149 * @since 2.0.5 150 * 151 * @param mixed $data Data that might be serialized. 152 * @return mixed A scalar data 153 */ 154 function maybe_serialize( $data ) { 155 if ( is_array( $data ) || is_object( $data ) ) 156 return serialize( $data ); 157 158 if ( is_serialized( $data ) ) 159 return serialize( $data ); 160 161 return $data; 162 } 163 endif; 164 165 // ! function make_url_footnote() 166 // ! function xmlrpc_getposttitle() 167 // ! function xmlrpc_getpostcategory() 168 // ! function xmlrpc_removepostdata() 169 // ! function debug_fopen() 170 // ! function debug_fwrite() 171 // ! function debug_fclose() 172 // ! function do_enclose() 173 // ! function wp_get_http() 174 // ! function wp_get_http_headers() 175 // ! function is_new_day() 176 177 if ( !function_exists( 'build_query' ) ) : 178 /** 179 * Build URL query based on an associative and, or indexed array. 180 * 181 * This is a convenient function for easily building url queries. It sets the 182 * separator to '&' and uses _http_build_query() function. 183 * 184 * @see _http_build_query() Used to build the query 185 * @link http://us2.php.net/manual/en/function.http-build-query.php more on what 186 * http_build_query() does. 187 * 188 * @since 2.3.0 189 * 190 * @param array $data URL-encode key/value pairs. 191 * @return string URL encoded string 192 */ 193 function build_query( $data ) { 194 return _http_build_query( $data, null, '&', '', false ); 195 } 196 endif; 197 198 if ( !function_exists( 'add_query_arg' ) ) : 199 /** 200 * Retrieve a modified URL query string. 201 * 202 * You can rebuild the URL and append a new query variable to the URL query by 203 * using this function. You can also retrieve the full URL with query data. 204 * 205 * Adding a single key & value or an associative array. Setting a key value to 206 * emptystring removes the key. Omitting oldquery_or_uri uses the $_SERVER 207 * value. 208 * 209 * @since 1.5.0 210 * 211 * @param mixed $param1 Either newkey or an associative_array 212 * @param mixed $param2 Either newvalue or oldquery or uri 213 * @param mixed $param3 Optional. Old query or uri 214 * @return string New URL query string. 215 */ 216 function add_query_arg() { 217 $ret = ''; 218 if ( is_array( func_get_arg(0) ) ) { 219 if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) ) 220 $uri = $_SERVER['REQUEST_URI']; 221 else 222 $uri = @func_get_arg( 1 ); 223 } else { 224 if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) ) 225 $uri = $_SERVER['REQUEST_URI']; 226 else 227 $uri = @func_get_arg( 2 ); 228 } 229 230 if ( $frag = strstr( $uri, '#' ) ) 231 $uri = substr( $uri, 0, -strlen( $frag ) ); 232 else 233 $frag = ''; 234 235 if ( preg_match( '|^https?://|i', $uri, $matches ) ) { 236 $protocol = $matches[0]; 237 $uri = substr( $uri, strlen( $protocol ) ); 238 } else { 239 $protocol = ''; 240 } 241 242 if ( strpos( $uri, '?' ) !== false ) { 243 $parts = explode( '?', $uri, 2 ); 244 if ( 1 == count( $parts ) ) { 245 $base = '?'; 246 $query = $parts[0]; 247 } else { 248 $base = $parts[0] . '?'; 249 $query = $parts[1]; 250 } 251 } elseif ( !empty( $protocol ) || strpos( $uri, '=' ) === false ) { 252 $base = $uri . '?'; 253 $query = ''; 254 } else { 255 $base = ''; 256 $query = $uri; 257 } 258 259 wp_parse_str( $query, $qs ); 260 $qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string 261 if ( is_array( func_get_arg( 0 ) ) ) { 262 $kayvees = func_get_arg( 0 ); 263 $qs = array_merge( $qs, $kayvees ); 264 } else { 265 $qs[func_get_arg( 0 )] = func_get_arg( 1 ); 266 } 267 268 foreach ( (array) $qs as $k => $v ) { 269 if ( $v === false ) 270 unset( $qs[$k] ); 271 } 272 273 $ret = build_query( $qs ); 274 $ret = trim( $ret, '?' ); 275 $ret = preg_replace( '#=(&|$)#', '$1', $ret ); 276 $ret = $protocol . $base . $ret . $frag; 277 $ret = rtrim( $ret, '?' ); 278 return $ret; 279 } 280 endif; 281 282 if ( !function_exists( 'remove_query_arg' ) ) : 283 /** 284 * Removes an item or list from the query string. 285 * 286 * @since 1.5.0 287 * 288 * @param string|array $key Query key or keys to remove. 289 * @param bool $query When false uses the $_SERVER value. 290 * @return string New URL query string. 291 */ 292 function remove_query_arg( $key, $query=false ) { 293 if ( is_array( $key ) ) { // removing multiple keys 294 foreach ( $key as $k ) 295 $query = add_query_arg( $k, false, $query ); 296 return $query; 297 } 298 return add_query_arg( $key, false, $query ); 299 } 300 endif; 301 302 // ! function add_magic_quotes() 303 304 if ( !function_exists( 'wp_remote_fopen' ) ) : 305 /** 306 * HTTP request for URI to retrieve content. 307 * 308 * @since 1.5.1 309 * @uses wp_remote_get() 310 * 311 * @param string $uri URI/URL of web page to retrieve. 312 * @return bool|string HTTP content. False on failure. 313 */ 314 function wp_remote_fopen( $uri ) { 315 $parsed_url = @parse_url( $uri ); 316 317 if ( !$parsed_url || !is_array( $parsed_url ) ) 318 return false; 319 320 $options = array(); 321 $options['timeout'] = 10; 322 323 $response = wp_remote_get( $uri, $options ); 324 325 if ( is_wp_error( $response ) ) 326 return false; 327 328 return $response['body']; 329 } 330 endif; 331 332 // ! function wp() 333 334 if ( !function_exists( 'get_status_header_desc' ) ) : 335 /** 336 * Retrieve the description for the HTTP status. 337 * 338 * @since 2.3.0 339 * 340 * @param int $code HTTP status code. 341 * @return string Empty string if not found, or description if found. 342 */ 343 function get_status_header_desc( $code ) { 344 global $wp_header_to_desc; 345 346 $code = absint( $code ); 347 348 if ( !isset( $wp_header_to_desc ) ) { 349 $wp_header_to_desc = array( 350 100 => 'Continue', 351 101 => 'Switching Protocols', 352 102 => 'Processing', 353 354 200 => 'OK', 355 201 => 'Created', 356 202 => 'Accepted', 357 203 => 'Non-Authoritative Information', 358 204 => 'No Content', 359 205 => 'Reset Content', 360 206 => 'Partial Content', 361 207 => 'Multi-Status', 362 226 => 'IM Used', 363 364 300 => 'Multiple Choices', 365 301 => 'Moved Permanently', 366 302 => 'Found', 367 303 => 'See Other', 368 304 => 'Not Modified', 369 305 => 'Use Proxy', 370 306 => 'Reserved', 371 307 => 'Temporary Redirect', 372 373 400 => 'Bad Request', 374 401 => 'Unauthorized', 375 402 => 'Payment Required', 376 403 => 'Forbidden', 377 404 => 'Not Found', 378 405 => 'Method Not Allowed', 379 406 => 'Not Acceptable', 380 407 => 'Proxy Authentication Required', 381 408 => 'Request Timeout', 382 409 => 'Conflict', 383 410 => 'Gone', 384 411 => 'Length Required', 385 412 => 'Precondition Failed', 386 413 => 'Request Entity Too Large', 387 414 => 'Request-URI Too Long', 388 415 => 'Unsupported Media Type', 389 416 => 'Requested Range Not Satisfiable', 390 417 => 'Expectation Failed', 391 422 => 'Unprocessable Entity', 392 423 => 'Locked', 393 424 => 'Failed Dependency', 394 426 => 'Upgrade Required', 395 396 500 => 'Internal Server Error', 397 501 => 'Not Implemented', 398 502 => 'Bad Gateway', 399 503 => 'Service Unavailable', 400 504 => 'Gateway Timeout', 401 505 => 'HTTP Version Not Supported', 402 506 => 'Variant Also Negotiates', 403 507 => 'Insufficient Storage', 404 510 => 'Not Extended' 405 ); 406 } 407 408 if ( isset( $wp_header_to_desc[$code] ) ) 409 return $wp_header_to_desc[$code]; 410 else 411 return ''; 412 } 413 endif; 414 415 if ( !function_exists( 'status_header' ) ) : 416 /** 417 * Set HTTP status header. 418 * 419 * @since 2.0.0 420 * @uses apply_filters() Calls 'status_header' on status header string, HTTP 421 * HTTP code, HTTP code description, and protocol string as separate 422 * parameters. 423 * 424 * @param int $header HTTP status code 425 * @return null Does not return anything. 426 */ 427 function status_header( $header ) { 428 $text = get_status_header_desc( $header ); 429 430 if ( empty( $text ) ) 431 return false; 432 433 $protocol = $_SERVER["SERVER_PROTOCOL"]; 434 if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) 435 $protocol = 'HTTP/1.0'; 436 $status_header = "$protocol $header $text"; 437 if ( function_exists( 'apply_filters' ) ) 438 $status_header = apply_filters( 'status_header', $status_header, $header, $text, $protocol ); 439 440 return @header( $status_header, true, $header ); 441 } 442 endif; 443 444 if ( !function_exists( 'wp_get_nocache_headers' ) ) : 445 /** 446 * Gets the header information to prevent caching. 447 * 448 * The several different headers cover the different ways cache prevention is handled 449 * by different browsers 450 * 451 * @since 2.8 452 * 453 * @uses apply_filters() 454 * @return array The associative array of header names and field values. 455 */ 456 function wp_get_nocache_headers() { 457 $headers = array( 458 'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 459 'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT', 460 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', 461 'Pragma' => 'no-cache', 462 ); 463 464 if ( function_exists('apply_filters') ) { 465 $headers = apply_filters('nocache_headers', $headers); 466 } 467 return $headers; 468 } 469 endif; 470 471 if ( !function_exists( 'nocache_headers' ) ) : 472 /** 473 * Sets the headers to prevent caching for the different browsers. 474 * 475 * Different browsers support different nocache headers, so several headers must 476 * be sent so that all of them get the point that no caching should occur. 477 * 478 * @since 2.0.0 479 * @uses wp_get_nocache_headers() 480 */ 481 function nocache_headers() { 482 $headers = wp_get_nocache_headers(); 483 foreach( (array) $headers as $name => $field_value ) 484 @header("{$name}: {$field_value}"); 485 } 486 endif; 487 488 if ( !function_exists( 'cache_javascript_headers' ) ) : 489 /** 490 * Set the headers for caching for 10 days with JavaScript content type. 491 * 492 * @since 2.1.0 493 */ 494 function cache_javascript_headers() { 495 $expiresOffset = 864000; // 10 days 496 header( "Content-Type: text/javascript; charset=" . backpress_get_option( 'charset' ) ); 497 header( "Vary: Accept-Encoding" ); // Handle proxies 498 header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" ); 499 } 500 endif; 501 502 // ! function get_num_queries() 503 // ! function bool_from_yn() 504 // ! function do_feed() 505 // ! function do_feed_rdf() 506 // ! function do_feed_rss() 507 // ! function do_feed_rss2() 508 // ! function do_feed_atom() 509 // ! function do_robots() 510 // ! function is_blog_installed() 511 // ! function wp_nonce_url() 512 // ! function wp_nonce_field() 513 514 if ( !function_exists( 'wp_referer_field' ) ) : 515 /** 516 * Retrieve or display referer hidden field for forms. 517 * 518 * The referer link is the current Request URI from the server super global. The 519 * input name is '_wp_http_referer', in case you wanted to check manually. 520 * 521 * @package WordPress 522 * @subpackage Security 523 * @since 2.0.4 524 * 525 * @param bool $echo Whether to echo or return the referer field. 526 * @return string Referer field. 527 */ 528 function wp_referer_field( $echo = true) { 529 $ref = esc_attr( $_SERVER['REQUEST_URI'] ); 530 $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />'; 531 532 if ( $echo ) 533 echo $referer_field; 534 return $referer_field; 535 } 536 endif; 537 538 if ( !function_exists( 'wp_original_referer_field' ) ) : 539 /** 540 * Retrieve or display original referer hidden field for forms. 541 * 542 * The input name is '_wp_original_http_referer' and will be either the same 543 * value of {@link wp_referer_field()}, if that was posted already or it will 544 * be the current page, if it doesn't exist. 545 * 546 * @package WordPress 547 * @subpackage Security 548 * @since 2.0.4 549 * 550 * @param bool $echo Whether to echo the original http referer 551 * @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to. 552 * @return string Original referer field. 553 */ 554 function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) { 555 $jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI']; 556 $ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to; 557 $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( stripslashes( $ref ) ) . '" />'; 558 if ( $echo ) 559 echo $orig_referer_field; 560 return $orig_referer_field; 561 } 562 endif; 563 564 if ( !function_exists( 'wp_get_referer' ) ) : 565 /** 566 * Retrieve referer from '_wp_http_referer', HTTP referer, or current page respectively. 567 * 568 * @package WordPress 569 * @subpackage Security 570 * @since 2.0.4 571 * 572 * @return string|bool False on failure. Referer URL on success. 573 */ 574 function wp_get_referer() { 575 $ref = ''; 576 if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) 577 $ref = $_REQUEST['_wp_http_referer']; 578 else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) 579 $ref = $_SERVER['HTTP_REFERER']; 580 581 if ( $ref !== $_SERVER['REQUEST_URI'] ) 582 return $ref; 583 return false; 584 } 585 endif; 586 587 if ( !function_exists( 'wp_get_original_referer' ) ) : 588 /** 589 * Retrieve original referer that was posted, if it exists. 590 * 591 * @package WordPress 592 * @subpackage Security 593 * @since 2.0.4 594 * 595 * @return string|bool False if no original referer or original referer if set. 596 */ 597 function wp_get_original_referer() { 598 if ( !empty( $_REQUEST['_wp_original_http_referer'] ) ) 599 return $_REQUEST['_wp_original_http_referer']; 600 return false; 601 } 602 endif; 603 604 // ! function wp_mkdir_p() 605 // ! function path_is_absolute() 606 // ! function path_join() 607 // ! function wp_upload_dir() 608 // ! function wp_unique_filename() 609 // ! function wp_upload_bits() 610 // ! function wp_ext2type() 611 // ! function wp_check_filetype() 612 // ! function wp_explain_nonce() 613 // ! function wp_nonce_ays() 614 // ! function wp_die() 615 // ! function _config_wp_home() 616 // ! function _config_wp_siteurl() 617 // ! function _mce_set_direction() 618 // ! function smilies_init() 619 620 if ( !function_exists('wp_parse_args') ) : 621 /** 622 * Merge user defined arguments into defaults array. 623 * 624 * This function is used throughout WordPress to allow for both string or array 625 * to be merged into another array. 626 * 627 * @since 2.2.0 628 * 629 * @param string|array $args Value to merge with $defaults 630 * @param array $defaults Array that serves as the defaults. 631 * @return array Merged user defined values with defaults. 632 */ 633 function wp_parse_args( $args, $defaults = '' ) { 634 if ( is_object( $args ) ) 635 $r = get_object_vars( $args ); 636 elseif ( is_array( $args ) ) 637 $r =& $args; 638 else 639 wp_parse_str( $args, $r ); 640 641 if ( is_array( $defaults ) ) 642 return array_merge( $defaults, $r ); 643 return $r; 644 } 645 endif; 646 647 // ! function wp_maybe_load_widgets() 648 // ! function wp_widgets_add_menu() 649 // ! function wp_ob_end_flush_all() 650 // ! function require_wp_db() 651 // ! function dead_db() 652 653 if ( !function_exists('absint') ) : 654 /** 655 * Converts value to nonnegative integer. 656 * 657 * @since 2.5.0 658 * 659 * @param mixed $maybeint Data you wish to have convered to an nonnegative integer 660 * @return int An nonnegative integer 661 */ 662 function absint( $maybeint ) { 663 return abs( intval( $maybeint ) ); 664 } 665 endif; 666 667 // ! function url_is_accessable_via_ssl() 668 // ! function atom_service_url_filter() 669 // ! function _deprecated_function() 670 // ! function _deprecated_file() 671 672 if ( !function_exists('is_lighttpd_before_150') ) : 673 /** 674 * Is the server running earlier than 1.5.0 version of lighttpd 675 * 676 * @since 2.5.0 677 * 678 * @return bool Whether the server is running lighttpd < 1.5.0 679 */ 680 function is_lighttpd_before_150() { 681 $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' ); 682 $server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : ''; 683 return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ); 684 } 685 endif; 686 687 if ( !function_exists('apache_mod_loaded') ) : 688 /** 689 * Does the specified module exist in the apache config? 690 * 691 * @since 2.5.0 692 * 693 * @param string $mod e.g. mod_rewrite 694 * @param bool $default The default return value if the module is not found 695 * @return bool 696 */ 697 function apache_mod_loaded($mod, $default = false) { 698 global $is_apache; 699 700 if ( !$is_apache ) 701 return false; 702 703 if ( function_exists('apache_get_modules') ) { 704 $mods = apache_get_modules(); 705 if ( in_array($mod, $mods) ) 706 return true; 707 } elseif ( function_exists('phpinfo') ) { 708 ob_start(); 709 phpinfo(8); 710 $phpinfo = ob_get_clean(); 711 if ( false !== strpos($phpinfo, $mod) ) 712 return true; 713 } 714 return $default; 715 } 716 endif; 717 718 if ( !function_exists('validate_file') ) : 719 /** 720 * File validates against allowed set of defined rules. 721 * 722 * A return value of '1' means that the $file contains either '..' or './'. A 723 * return value of '2' means that the $file contains ':' after the first 724 * character. A return value of '3' means that the file is not in the allowed 725 * files list. 726 * 727 * @since 1.2.0 728 * 729 * @param string $file File path. 730 * @param array $allowed_files List of allowed files. 731 * @return int 0 means nothing is wrong, greater than 0 means something was wrong. 732 */ 733 function validate_file( $file, $allowed_files = '' ) { 734 if ( false !== strpos( $file, '..' )) 735 return 1; 736 737 if ( false !== strpos( $file, './' )) 738 return 1; 739 740 if (':' == substr( $file, 1, 1 )) 741 return 2; 742 743 if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) ) 744 return 3; 745 746 return 0; 747 } 748 endif; 749 750 if ( !function_exists('is_ssl') ) : 751 /** 752 * Determine if SSL is used. 753 * 754 * @since 2.6.0 755 * 756 * @return bool True if SSL, false if not used. 757 */ 758 function is_ssl() { 759 if ( isset($_SERVER['HTTPS']) ) { 760 if ( 'on' == strtolower($_SERVER['HTTPS']) ) 761 return true; 762 if ( '1' == $_SERVER['HTTPS'] ) 763 return true; 764 } elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { 765 return true; 766 } 767 return false; 768 } 769 endif; 770 771 if ( !function_exists('force_ssl_login') ) : 772 /** 773 * Whether SSL login should be forced. 774 * 775 * @since 2.6.0 776 * 777 * @param string|bool $force Optional. 778 * @return bool True if forced, false if not forced. 779 */ 780 function force_ssl_login($force = '') { 781 static $forced; 782 783 if ( '' != $force ) { 784 $old_forced = $forced; 785 $forced = $force; 786 return $old_forced; 787 } 788 789 return $forced; 790 } 791 endif; 792 793 if ( !function_exists('force_ssl_admin') ) : 794 /** 795 * Whether to force SSL used for the Administration Panels. 796 * 797 * @since 2.6.0 798 * 799 * @param string|bool $force 800 * @return bool True if forced, false if not forced. 801 */ 802 function force_ssl_admin($force = '') { 803 static $forced; 804 805 if ( '' != $force ) { 806 $old_forced = $forced; 807 $forced = $force; 808 return $old_forced; 809 } 810 811 return $forced; 812 } 813 endif; 814 815 // ! function wp_guess_url() 816 // ! function wp_suspend_cache_invalidation() 817 // ! function get_site_option() 818 // ! function add_site_option() 819 // ! function update_site_option() 820 821 if ( !function_exists('wp_timezone_override_offset') ) : 822 /** 823 * gmt_offset modification for smart timezone handling 824 * 825 * Overrides the gmt_offset option if we have a timezone_string available 826 */ 827 function wp_timezone_override_offset() { 828 if ( !wp_timezone_supported() ) { 829 return false; 830 } 831 if ( !$timezone_string = backpress_get_option( 'timezone_string' ) ) { 832 return false; 833 } 834 835 @date_default_timezone_set( $timezone_string ); 836 $timezone_object = timezone_open( $timezone_string ); 837 $datetime_object = date_create(); 838 if ( false === $timezone_object || false === $datetime_object ) { 839 return false; 840 } 841 return round( timezone_offset_get( $timezone_object, $datetime_object ) / 3600, 2 ); 842 } 843 endif; 844 845 if ( !function_exists('wp_timezone_supported') ) : 846 /** 847 * Check for PHP timezone support 848 */ 849 function wp_timezone_supported() { 850 $support = false; 851 if ( 852 function_exists( 'date_default_timezone_set' ) && 853 function_exists( 'timezone_identifiers_list' ) && 854 function_exists( 'timezone_open' ) && 855 function_exists( 'timezone_offset_get' ) 856 ) { 857 $support = true; 858 } 859 return apply_filters( 'timezone_support', $support ); 860 } 861 endif; 862 863 if ( !function_exists('_wp_timezone_choice_usort_callback') ) : 864 function _wp_timezone_choice_usort_callback( $a, $b ) { 865 // Don't use translated versions of Etc 866 if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) { 867 // Make the order of these more like the old dropdown 868 if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) { 869 return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) ); 870 } 871 if ( 'UTC' === $a['city'] ) { 872 if ( 'GMT+' === substr( $b['city'], 0, 4 ) ) { 873 return 1; 874 } 875 return -1; 876 } 877 if ( 'UTC' === $b['city'] ) { 878 if ( 'GMT+' === substr( $a['city'], 0, 4 ) ) { 879 return -1; 880 } 881 return 1; 882 } 883 return strnatcasecmp( $a['city'], $b['city'] ); 884 } 885 if ( $a['t_continent'] == $b['t_continent'] ) { 886 if ( $a['t_city'] == $b['t_city'] ) { 887 return strnatcasecmp( $a['t_subcity'], $b['t_subcity'] ); 888 } 889 return strnatcasecmp( $a['t_city'], $b['t_city'] ); 890 } else { 891 // Force Etc to the bottom of the list 892 if ( 'Etc' === $a['continent'] ) { 893 return 1; 894 } 895 if ( 'Etc' === $b['continent'] ) { 896 return -1; 897 } 898 return strnatcasecmp( $a['t_continent'], $b['t_continent'] ); 899 } 900 } 901 endif; 902 903 if ( !function_exists('wp_timezone_choice') ) : 904 /** 905 * Gives a nicely formatted list of timezone strings // temporary! Not in final 906 * 907 * @param $selected_zone string Selected Zone 908 * 909 */ 910 function wp_timezone_choice( $selected_zone ) { 911 static $mo_loaded = false; 912 913 $continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'Etc' ); 914 915 // Load translations for continents and cities 916 if ( !$mo_loaded ) { 917 $locale = backpress_get_option( 'language_locale' ); 918 $mofile = backpress_get_option( 'language_directory' ) . 'continents-cities-' . $locale . '.mo'; 919 load_textdomain( 'continents-cities', $mofile ); 920 $mo_loaded = true; 921 } 922 923 $zonen = array(); 924 foreach ( timezone_identifiers_list() as $zone ) { 925 $zone = explode( '/', $zone ); 926 if ( !in_array( $zone[0], $continents ) ) { 927 continue; 928 } 929 if ( 'Etc' === $zone[0] && in_array( $zone[1], array( 'UCT', 'GMT', 'GMT0', 'GMT+0', 'GMT-0', 'Greenwich', 'Universal', 'Zulu' ) ) ) { 930 continue; 931 } 932 933 // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later 934 $exists = array( 935 0 => ( isset( $zone[0] ) && $zone[0] ) ? true : false, 936 1 => ( isset( $zone[1] ) && $zone[1] ) ? true : false, 937 2 => ( isset( $zone[2] ) && $zone[2] ) ? true : false 938 ); 939 $exists[3] = ( $exists[0] && 'Etc' !== $zone[0] ) ? true : false; 940 $exists[4] = ( $exists[1] && $exists[3] ) ? true : false; 941 $exists[5] = ( $exists[2] && $exists[3] ) ? true : false; 942 943 $zonen[] = array( 944 'continent' => ( $exists[0] ? $zone[0] : '' ), 945 'city' => ( $exists[1] ? $zone[1] : '' ), 946 'subcity' => ( $exists[2] ? $zone[2] : '' ), 947 't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ), 948 't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ), 949 't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' ) 950 ); 951 } 952 usort( $zonen, '_wp_timezone_choice_usort_callback' ); 953 954 $structure = array(); 955 956 if ( empty( $selected_zone ) ) { 957 $structure[] = '<option selected="selected" value="">' . __( 'Select a city' ) . '</option>'; 958 } 959 960 foreach ( $zonen as $key => $zone ) { 961 // Build value in an array to join later 962 $value = array( $zone['continent'] ); 963 964 if ( empty( $zone['city'] ) ) { 965 // It's at the continent level (generally won't happen) 966 $display = $zone['t_continent']; 967 } else { 968 // It's inside a continent group 969 970 // Continent optgroup 971 if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) { 972 $label = ( 'Etc' === $zone['continent'] ) ? __( 'Manual offsets' ) : $zone['t_continent']; 973 $structure[] = '<optgroup label="'. esc_attr( $label ) .'">'; 974 } 975 976 // Add the city to the value 977 $value[] = $zone['city']; 978 if ( 'Etc' === $zone['continent'] ) { 979 if ( 'UTC' === $zone['city'] ) { 980 $display = ''; 981 } else { 982 $display = str_replace( 'GMT', '', $zone['city'] ); 983 $display = strtr( $display, '+-', '-+' ) . ':00'; 984 } 985 $display = sprintf( __( 'UTC %s' ), $display ); 986 } else { 987 $display = $zone['t_city']; 988 if ( !empty( $zone['subcity'] ) ) { 989 // Add the subcity to the value 990 $value[] = $zone['subcity']; 991 $display .= ' - ' . $zone['t_subcity']; 992 } 993 } 994 } 995 996 // Build the value 997 $value = join( '/', $value ); 998 $selected = ''; 999 if ( $value === $selected_zone ) { 1000 $selected = 'selected="selected" '; 1001 } 1002 $structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . "</option>"; 1003 1004 // Close continent optgroup 1005 if ( !empty( $zone['city'] ) && ( !isset($zonen[$key + 1]) || (isset( $zonen[$key + 1] ) && $zonen[$key + 1]['continent'] !== $zone['continent']) ) ) { 1006 $structure[] = '</optgroup>'; 1007 } 1008 } 1009 1010 return join( "\n", $structure ); 1011 } 1012 endif; 1013 1014 if ( !function_exists('_cleanup_header_comment') ) : 1015 /** 1016 * Strip close comment and close php tags from file headers used by WP 1017 * See http://core.trac.wordpress.org/ticket/8497 1018 * 1019 * @since 2.8 1020 */ 1021 function _cleanup_header_comment($str) { 1022 return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str)); 1023 } 1024 endif; 1025 1026 /** 1027 * Returns true. 1028 * 1029 * Useful for returning true to filters easily. 1030 * 1031 * @since 3.0.0 1032 * @see __return_false() 1033 * @return bool true 1034 */ 1035 function __return_true() { 1036 return true; 1037 } 1038 1039 /** 1040 * Returns false. 1041 * 1042 * Useful for returning false to filters easily. 1043 * 1044 * @since 3.0.0 1045 * @see __return_true() 1046 * @return bool false 1047 */ 1048 function __return_false() { 1049 return false; 1050 } 1051 1052 /** 1053 * Returns 0. 1054 * 1055 * Useful for returning 0 to filters easily. 1056 * 1057 * @since 3.0.0 1058 * @see __return_zero() 1059 * @return int 0 1060 */ 1061 function __return_zero() { 1062 return 0; 1063 } 1064 1065 /** 1066 * Returns an empty array. 1067 * 1068 * Useful for returning an empty array to filters easily. 1069 * 1070 * @since 3.0.0 1071 * @see __return_zero() 1072 * @return array Empty array 1073 */ 1074 function __return_empty_array() { 1075 return array(); 1076 } 1077 1078 /** 1079 * Returns null. 1080 * 1081 * Useful for returning null to filters easily. 1082 * 1083 * @since 3.4.0 1084 * @return null 1085 */ 1086 function __return_null() { 1087 return null; 1088 } 1089 1090 1091 /** 1092 * From WP wp-settings.php 1093 */ 1094 1095 if ( !function_exists( 'wp_clone' ) ) : 1096 /** 1097 * Copy an object. 1098 * 1099 * Returns a cloned copy of an object. 1100 * 1101 * @since 2.7.0 1102 * 1103 * @param object $object The object to clone 1104 * @return object The cloned object 1105 */ 1106 function wp_clone( $object ) { 1107 static $can_clone; 1108 if ( !isset( $can_clone ) ) { 1109 $can_clone = version_compare( phpversion(), '5.0', '>=' ); 1110 } 1111 return $can_clone ? clone( $object ) : $object; 1112 } 1113 endif; 1114 1115 1116 1117 /** 1118 * BackPress only below 1119 */ 1120 1121 if ( !function_exists('backpress_gmt_strtotime') ) : 1122 function backpress_gmt_strtotime( $string ) { 1123 if ( is_numeric($string) ) 1124 return $string; 1125 if ( !is_string($string) ) 1126 return -1; 1127 1128 if ( stristr($string, 'utc') || stristr($string, 'gmt') || stristr($string, '+0000') ) 1129 return strtotime($string); 1130 1131 if ( -1 == $time = strtotime($string . ' +0000') ) 1132 return strtotime($string); 1133 1134 return $time; 1135 } 1136 endif; 1137 1138 if ( !function_exists('backpress_convert_object') ) : 1139 function backpress_convert_object( &$object, $output ) { 1140 if ( is_array( $object ) ) { 1141 foreach ( array_keys( $object ) as $key ) 1142 backpress_convert_object( $object[$key], $output ); 1143 } else { 1144 switch ( $output ) { 1145 case OBJECT : break; 1146 case ARRAY_A : $object = get_object_vars($object); break; 1147 case ARRAY_N : $object = array_values(get_object_vars($object)); break; 1148 } 1149 } 1150 } 1151 endif; 1152 1153 if ( !function_exists('backpress_die') ) : 1154 /** 1155 * Kill BackPress execution and display HTML message with error message. 1156 * 1157 * This function calls the die() PHP function. The difference is that a message 1158 * in HTML will be displayed to the user. It is recommended to use this function 1159 * only when the execution should not continue any further. It is not 1160 * recommended to call this function very often and normally you should try to 1161 * handle as many errors as possible silently. 1162 * 1163 * @param string $message Error message. 1164 * @param string $title Error title. 1165 * @param string|array $args Optional arguments to control behaviour. 1166 */ 1167 function backpress_die( $message, $title = '', $args = array() ) 1168 { 1169 $defaults = array( 'response' => 500, 'language' => 'en-US', 'text_direction' => 'ltr' ); 1170 $r = wp_parse_args( $args, $defaults ); 1171 1172 if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { 1173 if ( empty( $title ) ) { 1174 $error_data = $message->get_error_data(); 1175 if ( is_array( $error_data ) && isset( $error_data['title'] ) ) { 1176 $title = $error_data['title']; 1177 } 1178 } 1179 $errors = $message->get_error_messages(); 1180 switch ( count( $errors ) ) { 1181 case 0: 1182 $message = ''; 1183 break; 1184 case 1: 1185 $message = '<p>' . $errors[0] . '</p>'; 1186 break; 1187 default: 1188 $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>"; 1189 break; 1190 } 1191 } elseif ( is_string( $message ) ) { 1192 $message = '<p>' . $message . '</p>'; 1193 } 1194 1195 if ( !headers_sent() ) { 1196 status_header( $r['response'] ); 1197 nocache_headers(); 1198 header( 'Content-Type: text/html; charset=utf-8' ); 1199 } 1200 1201 if ( empty( $title ) ) { 1202 if ( function_exists( '__' ) ) { 1203 $title = __( 'BackPress › Error' ); 1204 } else { 1205 $title = 'BackPress › Error'; 1206 } 1207 } 1208 1209 if ( $r['text_direction'] ) { 1210 $language_attributes = ' dir="' . $r['text_direction'] . '"'; 1211 } 1212 1213 if ( $r['language'] ) { 1214 // Always XHTML 1.1 style 1215 $language_attributes .= ' lang="' . $r['language'] . '"'; 1216 } 1217 ?> 1218 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 1219 <html xmlns="http://www.w3.org/1999/xhtml"<?php echo $language_attributes; ?>> 1220 <head> 1221 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 1222 <title><?php echo $title ?></title> 1223 <style type="text/css" media="screen"> 1224 html { background: #f7f7f7; } 1225 1226 body { 1227 background: #fff; 1228 color: #333; 1229 font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; 1230 margin: 2em auto 0 auto; 1231 width: 700px; 1232 padding: 1em 2em; 1233 -moz-border-radius: 11px; 1234 -khtml-border-radius: 11px; 1235 -webkit-border-radius: 11px; 1236 border-radius: 11px; 1237 border: 1px solid #dfdfdf; 1238 } 1239 1240 a { color: #2583ad; text-decoration: none; } 1241 1242 a:hover { color: #d54e21; } 1243 1244 h1 { 1245 border-bottom: 1px solid #dadada; 1246 clear: both; 1247 color: #666; 1248 font: 24px Georgia, "Times New Roman", Times, serif; 1249 margin: 5px 0 0 -4px; 1250 padding: 0; 1251 padding-bottom: 7px; 1252 } 1253 1254 h2 { font-size: 16px; } 1255 1256 p, li { 1257 padding-bottom: 2px; 1258 font-size: 12px; 1259 line-height: 18px; 1260 } 1261 1262 code { font-size: 13px; } 1263 1264 ul, ol { padding: 5px 5px 5px 22px; } 1265 1266 #error-page { margin-top: 50px; } 1267 1268 #error-page p { 1269 font-size: 12px; 1270 line-height: 18px; 1271 margin: 25px 0 20px; 1272 } 1273 1274 #error-page code { font-family: Consolas, Monaco, Courier, monospace; } 1275 <?php 1276 if ( $r['text_direction'] === 'rtl') { 1277 ?> 1278 body { 1279 font-family: Tahoma, "Times New Roman"; 1280 } 1281 1282 h1 { 1283 font-family: Tahoma, "Times New Roman"; 1284 margin: 5px -4px 0 0; 1285 } 1286 1287 ul, ol { padding: 5px 22px 5px 5px; } 1288 <?php 1289 } 1290 ?> 1291 </style> 1292 </head> 1293 <body id="error-page"> 1294 <?php echo $message; ?> 1295 </body> 1296 </html> 1297 <?php 1298 die(); 1299 } 1300 endif; 1301 1302 /** 1303 * Acts the same as core PHP setcookie() but its arguments are run through the backpress_set_cookie filter. 1304 * 1305 * If the filter returns false, setcookie() isn't called. 1306 */ 1307 function backpress_set_cookie() { 1308 $args = func_get_args(); 1309 $args = apply_filters( 'backpress_set_cookie', $args ); 1310 if ( $args === false ) return; 1311 call_user_func_array( 'setcookie', $args ); 1312 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu May 23 03:58:28 2013 | Hosted by follow the white rabbit. |