PageRenderTime 46ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-includes/load.php

https://gitlab.com/endomorphosis/reservationtelco
PHP | 586 lines | 281 code | 57 blank | 248 comment | 90 complexity | 85f0036bd17bf44076a3c09bc1ee9a66 MD5 | raw file
  1. <?php
  2. /**
  3. * These functions are needed to load WordPress.
  4. *
  5. * @package WordPress
  6. */
  7. /**
  8. * Turn register globals off.
  9. *
  10. * @access private
  11. * @since 2.1.0
  12. * @return null Will return null if register_globals PHP directive was disabled
  13. */
  14. function wp_unregister_GLOBALS() {
  15. if ( !ini_get( 'register_globals' ) )
  16. return;
  17. if ( isset( $_REQUEST['GLOBALS'] ) )
  18. die( /*WP_I18N_GLOBALS_OVERWRITE*/'GLOBALS overwrite attempt detected'/*/WP_I18N_GLOBALS_OVERWRITE*/ );
  19. // Variables that shouldn't be unset
  20. $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );
  21. $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
  22. foreach ( $input as $k => $v )
  23. if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) {
  24. $GLOBALS[$k] = null;
  25. unset( $GLOBALS[$k] );
  26. }
  27. }
  28. /**
  29. * Fix $_SERVER variables for various setups.
  30. *
  31. * @access private
  32. * @since 3.0.0
  33. */
  34. function wp_fix_server_vars() {
  35. global $PHP_SELF;
  36. $default_server_values = array(
  37. 'SERVER_SOFTWARE' => '',
  38. 'REQUEST_URI' => '',
  39. );
  40. $_SERVER = array_merge( $default_server_values, $_SERVER );
  41. // Fix for IIS when running with PHP ISAPI
  42. if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
  43. // IIS Mod-Rewrite
  44. if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
  45. $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
  46. }
  47. // IIS Isapi_Rewrite
  48. else if ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
  49. $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
  50. } else {
  51. // Use ORIG_PATH_INFO if there is no PATH_INFO
  52. if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
  53. $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
  54. // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
  55. if ( isset( $_SERVER['PATH_INFO'] ) ) {
  56. if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
  57. $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
  58. else
  59. $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
  60. }
  61. // Append the query string if it exists and isn't null
  62. if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
  63. $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
  64. }
  65. }
  66. }
  67. // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
  68. if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) )
  69. $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
  70. // Fix for Dreamhost and other PHP as CGI hosts
  71. if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false )
  72. unset( $_SERVER['PATH_INFO'] );
  73. // Fix empty PHP_SELF
  74. $PHP_SELF = $_SERVER['PHP_SELF'];
  75. if ( empty( $PHP_SELF ) )
  76. $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] );
  77. }
  78. /**
  79. * Check for the required PHP version, and the MySQL extension or a database drop-in.
  80. *
  81. * Dies if requirements are not met.
  82. *
  83. * @access private
  84. * @since 3.0.0
  85. */
  86. function wp_check_php_mysql_versions() {
  87. // we can probably extend this function to check if wp_die() exists then use translated strings, and then use it in install.php etc.
  88. global $required_php_version, $wp_version;
  89. $php_version = phpversion();
  90. if ( version_compare( $required_php_version, $php_version, '>' ) )
  91. die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %1$s but WordPress %2%s requires at least %2%s.'/*/WP_I18N_OLD_PHP*/, $php_version, $wp_version, $required_php_version ) );
  92. if ( !extension_loaded( 'mysql' ) && !file_exists( WP_CONTENT_DIR . '/db.php' ) )
  93. die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
  94. }
  95. /**
  96. * Don't load all of WordPress when handling a favicon.ico request.
  97. * Instead, send the headers for a zero-length favicon and bail.
  98. *
  99. * @since 3.0.0
  100. */
  101. function wp_favicon_request() {
  102. if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) {
  103. header('Content-Type: image/vnd.microsoft.icon');
  104. header('Content-Length: 0');
  105. exit;
  106. }
  107. }
  108. /**
  109. * Dies with a maintenance message when conditions are met.
  110. *
  111. * Checks for a file in the WordPress root directory named ".maintenance".
  112. * This file will contain the variable $upgrading, set to the time the file
  113. * was created. If the file was created less than 10 minutes ago, WordPress
  114. * enters maintenance mode and displays a message.
  115. *
  116. * The default message can be replaced by using a drop-in (maintenance.php in
  117. * the wp-content directory).
  118. *
  119. * @access private
  120. * @since 3.0.0
  121. */
  122. function wp_maintenance() {
  123. if ( !file_exists( ABSPATH . '.maintenance' ) || defined( 'WP_INSTALLING' ) )
  124. return;
  125. include( ABSPATH . '.maintenance' );
  126. // If the $upgrading timestamp is older than 10 minutes, don't die.
  127. if ( ( time() - $upgrading ) >= 600 )
  128. return;
  129. if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
  130. require_once( WP_CONTENT_DIR . '/maintenance.php' );
  131. die();
  132. }
  133. $protocol = $_SERVER["SERVER_PROTOCOL"];
  134. if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
  135. $protocol = 'HTTP/1.0';
  136. header( "$protocol 503 Service Unavailable", true, 503 );
  137. header( 'Content-Type: text/html; charset=utf-8' );
  138. header( 'Retry-After: 600' );
  139. ?>
  140. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  141. <html xmlns="http://www.w3.org/1999/xhtml">
  142. <head>
  143. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  144. <title><?php echo /*WP_I18N_MAINTENANCE*/'Maintenance'/*/WP_I18N_MAINTENANCE*/; ?></title>
  145. </head>
  146. <body>
  147. <h1><?php echo /*WP_I18N_MAINT_MSG*/'Briefly unavailable for scheduled maintenance. Check back in a minute.'/*/WP_I18N_MAINT_MSG*/; ?></h1>
  148. </body>
  149. </html>
  150. <?php
  151. die();
  152. }
  153. /**
  154. * PHP 4 standard microtime start capture.
  155. *
  156. * @access private
  157. * @since 0.71
  158. * @global int $timestart Seconds and Microseconds added together from when function is called.
  159. * @return bool Always returns true.
  160. */
  161. function timer_start() {
  162. global $timestart;
  163. $mtime = explode( ' ', microtime() );
  164. $timestart = $mtime[1] + $mtime[0];
  165. return true;
  166. }
  167. /**
  168. * Return and/or display the time from the page start to when function is called.
  169. *
  170. * You can get the results and print them by doing:
  171. * <code>
  172. * $nTimePageTookToExecute = timer_stop();
  173. * echo $nTimePageTookToExecute;
  174. * </code>
  175. *
  176. * Or instead, you can do:
  177. * <code>
  178. * timer_stop(1);
  179. * </code>
  180. * which will do what the above does. If you need the result, you can assign it to a variable, but
  181. * most cases, you only need to echo it.
  182. *
  183. * @since 0.71
  184. * @global int $timestart Seconds and Microseconds added together from when timer_start() is called
  185. * @global int $timeend Seconds and Microseconds added together from when function is called
  186. *
  187. * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
  188. * @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
  189. * @return float The "second.microsecond" finished time calculation
  190. */
  191. function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_stop(1), will echo $timetotal
  192. global $timestart, $timeend;
  193. $mtime = microtime();
  194. $mtime = explode( ' ', $mtime );
  195. $timeend = $mtime[1] + $mtime[0];
  196. $timetotal = $timeend - $timestart;
  197. $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
  198. if ( $display )
  199. echo $r;
  200. return $r;
  201. }
  202. /**
  203. * Sets PHP error handling and handles WordPress debug mode.
  204. *
  205. * Uses three constants: WP_DEBUG, WP_DEBUG_DISPLAY, and WP_DEBUG_LOG. All three can be
  206. * defined in wp-config.php. Example: <code> define( 'WP_DEBUG', true ); </code>
  207. *
  208. * WP_DEBUG_DISPLAY and WP_DEBUG_LOG perform no function unless WP_DEBUG is true.
  209. * WP_DEBUG defaults to false.
  210. *
  211. * When WP_DEBUG is true, all PHP notices are reported. WordPress will also display
  212. * notices, including one when a deprecated WordPress function, function argument,
  213. * or file is used. Deprecated code may be removed from a later version.
  214. *
  215. * It is strongly recommended that plugin and theme developers use WP_DEBUG in their
  216. * development environments.
  217. *
  218. * When WP_DEBUG_DISPLAY is true, WordPress will force errors to be displayed.
  219. * WP_DEBUG_DISPLAY defaults to true. Defining it as false prevents WordPress from
  220. * changing the global configuration setting. (Defining WP_DEBUG_DISPLAY as false
  221. * will never force errors to be hidden.)
  222. *
  223. * When WP_DEBUG_LOG is true, errors will be logged to wp-content/debug.log.
  224. * WP_DEBUG_LOG defaults to false.
  225. *
  226. * @access private
  227. * @since 3.0.0
  228. */
  229. function wp_debug_mode() {
  230. if ( WP_DEBUG ) {
  231. if ( defined( 'E_DEPRECATED' ) )
  232. error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
  233. else
  234. error_reporting( E_ALL );
  235. if ( WP_DEBUG_DISPLAY )
  236. ini_set( 'display_errors', 1 );
  237. if ( WP_DEBUG_LOG ) {
  238. ini_set( 'log_errors', 1 );
  239. ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
  240. }
  241. } else {
  242. if ( defined( 'E_RECOVERABLE_ERROR' ) )
  243. error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
  244. else
  245. error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING );
  246. }
  247. }
  248. /**
  249. * Sets the location of the language directory.
  250. *
  251. * To set directory manually, define <code>WP_LANG_DIR</code> in wp-config.php.
  252. *
  253. * First looks for language folder in WP_CONTENT_DIR and uses that folder if it
  254. * exists. Or it uses the "languages" folder in WPINC.
  255. *
  256. * The WP_LANG_DIR constant was introduced in 2.1.0.
  257. *
  258. * @access private
  259. * @since 3.0.0
  260. */
  261. function wp_set_lang_dir() {
  262. if ( !defined( 'WP_LANG_DIR' ) ) {
  263. if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) {
  264. define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
  265. if ( !defined( 'LANGDIR' ) ) {
  266. // Old static relative path maintained for limited backwards compatibility - won't work in some cases
  267. define( 'LANGDIR', 'wp-content/languages' );
  268. }
  269. } else {
  270. define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
  271. if ( !defined( 'LANGDIR' ) ) {
  272. // Old relative path maintained for backwards compatibility
  273. define( 'LANGDIR', WPINC . '/languages' );
  274. }
  275. }
  276. }
  277. }
  278. /**
  279. * Sets the database table prefix and the format specifiers for database table columns.
  280. *
  281. * Columns not listed here default to %s.
  282. *
  283. * @see wpdb::$field_types Since 2.8.0
  284. * @see wpdb::prepare()
  285. * @see wpdb::insert()
  286. * @see wpdb::update()
  287. * @see wpdb::set_prefix()
  288. *
  289. * @access private
  290. * @since 3.0.0
  291. */
  292. function wp_set_wpdb_vars() {
  293. global $wpdb, $table_prefix;
  294. if ( !empty( $wpdb->error ) )
  295. dead_db();
  296. $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
  297. 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
  298. 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
  299. 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',
  300. // multisite:
  301. 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',
  302. );
  303. $prefix = $wpdb->set_prefix( $table_prefix );
  304. if ( is_wp_error( $prefix ) )
  305. wp_die( /*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/ );
  306. }
  307. /**
  308. * Starts the WordPress object cache.
  309. *
  310. * If an object-cache.php file exists in the wp-content directory,
  311. * it uses that drop-in as an external object cache.
  312. *
  313. * @access private
  314. * @since 3.0.0
  315. */
  316. function wp_start_object_cache() {
  317. global $_wp_using_ext_object_cache;
  318. $first_init = false;
  319. if ( ! function_exists( 'wp_cache_init' ) ) {
  320. if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
  321. require_once ( WP_CONTENT_DIR . '/object-cache.php' );
  322. $_wp_using_ext_object_cache = true;
  323. } else {
  324. require_once ( ABSPATH . WPINC . '/cache.php' );
  325. $_wp_using_ext_object_cache = false;
  326. }
  327. $first_init = true;
  328. } else if ( !$_wp_using_ext_object_cache && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
  329. // Sometimes advanced-cache.php can load object-cache.php before it is loaded here.
  330. // This breaks the function_exists check above and can result in $_wp_using_ext_object_cache
  331. // being set incorrectly. Double check if an external cache exists.
  332. $_wp_using_ext_object_cache = true;
  333. }
  334. // If cache supports reset, reset instead of init if already initialized.
  335. // Reset signals to the cache that global IDs have changed and it may need to update keys
  336. // and cleanup caches.
  337. if ( !$first_init && function_exists('wp_cache_reset') )
  338. wp_cache_reset();
  339. else
  340. wp_cache_init();
  341. if ( function_exists( 'wp_cache_add_global_groups' ) ) {
  342. wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) );
  343. wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
  344. }
  345. }
  346. /**
  347. * Redirects to the installer if WordPress is not installed.
  348. *
  349. * Dies with an error message when multisite is enabled.
  350. *
  351. * @access private
  352. * @since 3.0.0
  353. */
  354. function wp_not_installed() {
  355. if ( is_multisite() ) {
  356. if ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) )
  357. wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
  358. } elseif ( ! is_blog_installed() && false === strpos( $_SERVER['PHP_SELF'], 'install.php' ) && !defined( 'WP_INSTALLING' ) ) {
  359. if ( defined( 'WP_SITEURL' ) )
  360. $link = WP_SITEURL . '/wp-admin/install.php';
  361. elseif ( false !== strpos( $_SERVER['PHP_SELF'], 'wp-admin' ) )
  362. $link = preg_replace( '|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF'] ) . 'wp-admin/install.php';
  363. else
  364. $link = preg_replace( '|/[^/]+?$|', '/', $_SERVER['PHP_SELF'] ) . 'wp-admin/install.php';
  365. require( ABSPATH . WPINC . '/kses.php' );
  366. require( ABSPATH . WPINC . '/pluggable.php' );
  367. require( ABSPATH . WPINC . '/formatting.php' );
  368. wp_redirect( $link );
  369. die();
  370. }
  371. }
  372. /**
  373. * Returns array of must-use plugin files to be included in global scope.
  374. *
  375. * The default directory is wp-content/mu-plugins. To change the default directory
  376. * manually, define <code>WPMU_PLUGIN_DIR</code> and <code>WPMU_PLUGIN_URL</code>
  377. * in wp-config.php.
  378. *
  379. * @access private
  380. * @since 3.0.0
  381. * @return array Files to include
  382. */
  383. function wp_get_mu_plugins() {
  384. $mu_plugins = array();
  385. if ( !is_dir( WPMU_PLUGIN_DIR ) )
  386. return $mu_plugins;
  387. if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) )
  388. return $mu_plugins;
  389. while ( ( $plugin = readdir( $dh ) ) !== false ) {
  390. if ( substr( $plugin, -4 ) == '.php' )
  391. $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
  392. }
  393. closedir( $dh );
  394. sort( $mu_plugins );
  395. return $mu_plugins;
  396. }
  397. /**
  398. * Returns array of plugin files to be included in global scope.
  399. *
  400. * The default directory is wp-content/plugins. To change the default directory
  401. * manually, define <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>
  402. * in wp-config.php.
  403. *
  404. * @access private
  405. * @since 3.0.0
  406. * @return array Files to include
  407. */
  408. function wp_get_active_and_valid_plugins() {
  409. $plugins = array();
  410. $active_plugins = (array) get_option( 'active_plugins', array() );
  411. // Get active network plugins
  412. if ( is_multisite() ) {
  413. $active_sitewide_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
  414. if ( !empty($active_sitewide_plugins) ) {
  415. $active_plugins = array_merge( $active_plugins, array_keys( $active_sitewide_plugins ) );
  416. sort( $active_plugins );
  417. }
  418. }
  419. // Check for hacks file if the option is enabled
  420. if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
  421. _deprecated_file( 'my-hacks.php', '1.5' );
  422. array_unshift( $plugins, ABSPATH . 'my-hacks.php' );
  423. }
  424. if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) )
  425. return $plugins;
  426. foreach ( $active_plugins as $plugin ) {
  427. if ( ! validate_file( $plugin ) // $plugin must validate as file
  428. && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
  429. && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
  430. )
  431. $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
  432. }
  433. return $plugins;
  434. }
  435. /**
  436. * Sets internal encoding using mb_internal_encoding().
  437. *
  438. * In most cases the default internal encoding is latin1, which is of no use,
  439. * since we want to use the mb_ functions for utf-8 strings.
  440. *
  441. * @access private
  442. * @since 3.0.0
  443. */
  444. function wp_set_internal_encoding() {
  445. if ( function_exists( 'mb_internal_encoding' ) ) {
  446. if ( !@mb_internal_encoding( get_option( 'blog_charset' ) ) )
  447. mb_internal_encoding( 'UTF-8' );
  448. }
  449. }
  450. /**
  451. * Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
  452. *
  453. * Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
  454. * or $_ENV are needed, use those superglobals directly.
  455. *
  456. * @access private
  457. * @since 3.0.0
  458. */
  459. function wp_magic_quotes() {
  460. // If already slashed, strip.
  461. if ( get_magic_quotes_gpc() ) {
  462. $_GET = stripslashes_deep( $_GET );
  463. $_POST = stripslashes_deep( $_POST );
  464. $_COOKIE = stripslashes_deep( $_COOKIE );
  465. }
  466. // Escape with wpdb.
  467. $_GET = add_magic_quotes( $_GET );
  468. $_POST = add_magic_quotes( $_POST );
  469. $_COOKIE = add_magic_quotes( $_COOKIE );
  470. $_SERVER = add_magic_quotes( $_SERVER );
  471. // Force REQUEST to be GET + POST.
  472. $_REQUEST = array_merge( $_GET, $_POST );
  473. }
  474. /**
  475. * Runs just before PHP shuts down execution.
  476. *
  477. * @access private
  478. * @since 1.2.0
  479. */
  480. function shutdown_action_hook() {
  481. do_action( 'shutdown' );
  482. wp_cache_close();
  483. }
  484. /**
  485. * Copy an object.
  486. *
  487. * Returns a cloned copy of an object.
  488. *
  489. * @since 2.7.0
  490. *
  491. * @param object $object The object to clone
  492. * @return object The cloned object
  493. */
  494. function wp_clone( $object ) {
  495. static $can_clone;
  496. if ( !isset( $can_clone ) )
  497. $can_clone = version_compare( phpversion(), '5.0', '>=' );
  498. return $can_clone ? clone( $object ) : $object;
  499. }
  500. /**
  501. * Whether the current request is in WordPress admin Panel
  502. *
  503. * Does not inform on whether the user is an admin! Use capability checks to
  504. * tell if the user should be accessing a section or not.
  505. *
  506. * @since 1.5.1
  507. *
  508. * @return bool True if inside WordPress administration pages.
  509. */
  510. function is_admin() {
  511. if ( defined( 'WP_ADMIN' ) )
  512. return WP_ADMIN;
  513. return false;
  514. }
  515. /**
  516. * Whether Multisite support is enabled
  517. *
  518. * @since 3.0.0
  519. *
  520. * @return bool True if multisite is enabled, false otherwise.
  521. */
  522. function is_multisite() {
  523. if ( defined( 'MULTISITE' ) )
  524. return MULTISITE;
  525. if ( defined( 'VHOST' ) || defined( 'SUNRISE' ) )
  526. return true;
  527. return false;
  528. }
  529. ?>