PageRenderTime 52ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/public_html/wp-includes/load.php

https://github.com/terry69/fluxflex_wordpress
PHP | 653 lines | 296 code | 67 blank | 290 comment | 95 complexity | 30af3662286cd7e64b9b6454488d5a66 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 を上書きしようとしているようです。'/*/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*/'サーバーの PHP バージョンは %1$s ですが WordPress %2$s は %3$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*/'お使いのサーバーの PHP では WordPress に必要な MySQL 拡張を利用できないようです。'/*/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. global $upgrading;
  126. include( ABSPATH . '.maintenance' );
  127. // If the $upgrading timestamp is older than 10 minutes, don't die.
  128. if ( ( time() - $upgrading ) >= 600 )
  129. return;
  130. if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
  131. require_once( WP_CONTENT_DIR . '/maintenance.php' );
  132. die();
  133. }
  134. $protocol = $_SERVER["SERVER_PROTOCOL"];
  135. if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
  136. $protocol = 'HTTP/1.0';
  137. header( "$protocol 503 Service Unavailable", true, 503 );
  138. header( 'Content-Type: text/html; charset=utf-8' );
  139. header( 'Retry-After: 600' );
  140. ?>
  141. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  142. <html xmlns="http://www.w3.org/1999/xhtml">
  143. <head>
  144. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  145. <title><?php echo /*WP_I18N_MAINTENANCE*/'メンテナンス'/*/WP_I18N_MAINTENANCE*/; ?></title>
  146. </head>
  147. <body>
  148. <h1><?php echo /*WP_I18N_MAINT_MSG*/'予定に基づいたメンテナンスを行っているためしばらくの間ご利用できません。少し間をおいて再度確認してください。'/*/WP_I18N_MAINT_MSG*/; ?></h1>
  149. </body>
  150. </html>
  151. <?php
  152. die();
  153. }
  154. /**
  155. * PHP 4 standard microtime start capture.
  156. *
  157. * @access private
  158. * @since 0.71
  159. * @global int $timestart Seconds and Microseconds added together from when function is called.
  160. * @return bool Always returns true.
  161. */
  162. function timer_start() {
  163. global $timestart;
  164. $mtime = explode( ' ', microtime() );
  165. $timestart = $mtime[1] + $mtime[0];
  166. return true;
  167. }
  168. /**
  169. * Return and/or display the time from the page start to when function is called.
  170. *
  171. * You can get the results and print them by doing:
  172. * <code>
  173. * $nTimePageTookToExecute = timer_stop();
  174. * echo $nTimePageTookToExecute;
  175. * </code>
  176. *
  177. * Or instead, you can do:
  178. * <code>
  179. * timer_stop(1);
  180. * </code>
  181. * which will do what the above does. If you need the result, you can assign it to a variable, but
  182. * most cases, you only need to echo it.
  183. *
  184. * @since 0.71
  185. * @global int $timestart Seconds and Microseconds added together from when timer_start() is called
  186. * @global int $timeend Seconds and Microseconds added together from when function is called
  187. *
  188. * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
  189. * @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
  190. * @return float The "second.microsecond" finished time calculation
  191. */
  192. function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_stop(1), will echo $timetotal
  193. global $timestart, $timeend;
  194. $mtime = microtime();
  195. $mtime = explode( ' ', $mtime );
  196. $timeend = $mtime[1] + $mtime[0];
  197. $timetotal = $timeend - $timestart;
  198. $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
  199. if ( $display )
  200. echo $r;
  201. return $r;
  202. }
  203. /**
  204. * Sets PHP error handling and handles WordPress debug mode.
  205. *
  206. * Uses three constants: WP_DEBUG, WP_DEBUG_DISPLAY, and WP_DEBUG_LOG. All three can be
  207. * defined in wp-config.php. Example: <code> define( 'WP_DEBUG', true ); </code>
  208. *
  209. * WP_DEBUG_DISPLAY and WP_DEBUG_LOG perform no function unless WP_DEBUG is true.
  210. * WP_DEBUG defaults to false.
  211. *
  212. * When WP_DEBUG is true, all PHP notices are reported. WordPress will also display
  213. * notices, including one when a deprecated WordPress function, function argument,
  214. * or file is used. Deprecated code may be removed from a later version.
  215. *
  216. * It is strongly recommended that plugin and theme developers use WP_DEBUG in their
  217. * development environments.
  218. *
  219. * When WP_DEBUG_DISPLAY is true, WordPress will force errors to be displayed.
  220. * WP_DEBUG_DISPLAY defaults to true. Defining it as false prevents WordPress from
  221. * changing the global configuration setting. (Defining WP_DEBUG_DISPLAY as false
  222. * will never force errors to be hidden.)
  223. *
  224. * When WP_DEBUG_LOG is true, errors will be logged to wp-content/debug.log.
  225. * WP_DEBUG_LOG defaults to false.
  226. *
  227. * @access private
  228. * @since 3.0.0
  229. */
  230. function wp_debug_mode() {
  231. if ( WP_DEBUG ) {
  232. // E_DEPRECATED is a core PHP constant in PHP 5.3. Don't define this yourself.
  233. // The two statements are equivalent, just one is for 5.3+ and for less than 5.3.
  234. if ( defined( 'E_DEPRECATED' ) )
  235. error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
  236. else
  237. error_reporting( E_ALL );
  238. if ( WP_DEBUG_DISPLAY )
  239. ini_set( 'display_errors', 1 );
  240. if ( WP_DEBUG_LOG ) {
  241. ini_set( 'log_errors', 1 );
  242. ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
  243. }
  244. } else {
  245. if ( defined( 'E_RECOVERABLE_ERROR' ) )
  246. 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 );
  247. else
  248. error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING );
  249. }
  250. }
  251. /**
  252. * Sets the location of the language directory.
  253. *
  254. * To set directory manually, define <code>WP_LANG_DIR</code> in wp-config.php.
  255. *
  256. * First looks for language folder in WP_CONTENT_DIR and uses that folder if it
  257. * exists. Or it uses the "languages" folder in WPINC.
  258. *
  259. * The WP_LANG_DIR constant was introduced in 2.1.0.
  260. *
  261. * @access private
  262. * @since 3.0.0
  263. */
  264. function wp_set_lang_dir() {
  265. if ( !defined( 'WP_LANG_DIR' ) ) {
  266. if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) {
  267. define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
  268. if ( !defined( 'LANGDIR' ) ) {
  269. // Old static relative path maintained for limited backwards compatibility - won't work in some cases
  270. define( 'LANGDIR', 'wp-content/languages' );
  271. }
  272. } else {
  273. define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
  274. if ( !defined( 'LANGDIR' ) ) {
  275. // Old relative path maintained for backwards compatibility
  276. define( 'LANGDIR', WPINC . '/languages' );
  277. }
  278. }
  279. }
  280. }
  281. /**
  282. * Load the correct database class file.
  283. *
  284. * This function is used to load the database class file either at runtime or by
  285. * wp-admin/setup-config.php. We must globalize $wpdb to ensure that it is
  286. * defined globally by the inline code in wp-db.php.
  287. *
  288. * @since 2.5.0
  289. * @global $wpdb WordPress Database Object
  290. */
  291. function require_wp_db() {
  292. global $wpdb;
  293. require_once( ABSPATH . WPINC . '/wp-db.php' );
  294. if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
  295. require_once( WP_CONTENT_DIR . '/db.php' );
  296. if ( isset( $wpdb ) )
  297. return;
  298. $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
  299. }
  300. /**
  301. * Sets the database table prefix and the format specifiers for database table columns.
  302. *
  303. * Columns not listed here default to %s.
  304. *
  305. * @see wpdb::$field_types Since 2.8.0
  306. * @see wpdb::prepare()
  307. * @see wpdb::insert()
  308. * @see wpdb::update()
  309. * @see wpdb::set_prefix()
  310. *
  311. * @access private
  312. * @since 3.0.0
  313. */
  314. function wp_set_wpdb_vars() {
  315. global $wpdb, $table_prefix;
  316. if ( !empty( $wpdb->error ) )
  317. dead_db();
  318. $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
  319. 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
  320. 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
  321. 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',
  322. // multisite:
  323. 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',
  324. );
  325. $prefix = $wpdb->set_prefix( $table_prefix );
  326. if ( is_wp_error( $prefix ) )
  327. wp_die( /*WP_I18N_BAD_PREFIX*/'<strong>エラー</strong>: <code>wp-config.php</code> 内の <code>$table_prefix</code> には半角英数字と下線のみしか使えません。'/*/WP_I18N_BAD_PREFIX*/ );
  328. }
  329. /**
  330. * Starts the WordPress object cache.
  331. *
  332. * If an object-cache.php file exists in the wp-content directory,
  333. * it uses that drop-in as an external object cache.
  334. *
  335. * @access private
  336. * @since 3.0.0
  337. */
  338. function wp_start_object_cache() {
  339. global $_wp_using_ext_object_cache;
  340. $first_init = false;
  341. if ( ! function_exists( 'wp_cache_init' ) ) {
  342. if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
  343. require_once ( WP_CONTENT_DIR . '/object-cache.php' );
  344. $_wp_using_ext_object_cache = true;
  345. } else {
  346. require_once ( ABSPATH . WPINC . '/cache.php' );
  347. $_wp_using_ext_object_cache = false;
  348. }
  349. $first_init = true;
  350. } else if ( !$_wp_using_ext_object_cache && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
  351. // Sometimes advanced-cache.php can load object-cache.php before it is loaded here.
  352. // This breaks the function_exists check above and can result in $_wp_using_ext_object_cache
  353. // being set incorrectly. Double check if an external cache exists.
  354. $_wp_using_ext_object_cache = true;
  355. }
  356. // If cache supports reset, reset instead of init if already initialized.
  357. // Reset signals to the cache that global IDs have changed and it may need to update keys
  358. // and cleanup caches.
  359. if ( !$first_init && function_exists('wp_cache_reset') )
  360. wp_cache_reset();
  361. else
  362. wp_cache_init();
  363. if ( function_exists( 'wp_cache_add_global_groups' ) ) {
  364. wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) );
  365. wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
  366. }
  367. }
  368. /**
  369. * Redirects to the installer if WordPress is not installed.
  370. *
  371. * Dies with an error message when multisite is enabled.
  372. *
  373. * @access private
  374. * @since 3.0.0
  375. */
  376. function wp_not_installed() {
  377. if ( is_multisite() ) {
  378. if ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) )
  379. wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
  380. } elseif ( ! is_blog_installed() && false === strpos( $_SERVER['PHP_SELF'], 'install.php' ) && !defined( 'WP_INSTALLING' ) ) {
  381. $link = wp_guess_url() . '/wp-admin/install.php';
  382. require( ABSPATH . WPINC . '/kses.php' );
  383. require( ABSPATH . WPINC . '/pluggable.php' );
  384. require( ABSPATH . WPINC . '/formatting.php' );
  385. wp_redirect( $link );
  386. die();
  387. }
  388. }
  389. /**
  390. * Returns array of must-use plugin files to be included in global scope.
  391. *
  392. * The default directory is wp-content/mu-plugins. To change the default directory
  393. * manually, define <code>WPMU_PLUGIN_DIR</code> and <code>WPMU_PLUGIN_URL</code>
  394. * in wp-config.php.
  395. *
  396. * @access private
  397. * @since 3.0.0
  398. * @return array Files to include
  399. */
  400. function wp_get_mu_plugins() {
  401. $mu_plugins = array();
  402. if ( !is_dir( WPMU_PLUGIN_DIR ) )
  403. return $mu_plugins;
  404. if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) )
  405. return $mu_plugins;
  406. while ( ( $plugin = readdir( $dh ) ) !== false ) {
  407. if ( substr( $plugin, -4 ) == '.php' )
  408. $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
  409. }
  410. closedir( $dh );
  411. sort( $mu_plugins );
  412. return $mu_plugins;
  413. }
  414. /**
  415. * Returns array of plugin files to be included in global scope.
  416. *
  417. * The default directory is wp-content/plugins. To change the default directory
  418. * manually, define <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>
  419. * in wp-config.php.
  420. *
  421. * @access private
  422. * @since 3.0.0
  423. * @return array Files to include
  424. */
  425. function wp_get_active_and_valid_plugins() {
  426. $plugins = array();
  427. $active_plugins = (array) get_option( 'active_plugins', array() );
  428. // Check for hacks file if the option is enabled
  429. if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
  430. _deprecated_file( 'my-hacks.php', '1.5' );
  431. array_unshift( $plugins, ABSPATH . 'my-hacks.php' );
  432. }
  433. if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) )
  434. return $plugins;
  435. $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
  436. foreach ( $active_plugins as $plugin ) {
  437. if ( ! validate_file( $plugin ) // $plugin must validate as file
  438. && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
  439. && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
  440. // not already included as a network plugin
  441. && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
  442. )
  443. $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
  444. }
  445. return $plugins;
  446. }
  447. /**
  448. * Sets internal encoding using mb_internal_encoding().
  449. *
  450. * In most cases the default internal encoding is latin1, which is of no use,
  451. * since we want to use the mb_ functions for utf-8 strings.
  452. *
  453. * @access private
  454. * @since 3.0.0
  455. */
  456. function wp_set_internal_encoding() {
  457. if ( function_exists( 'mb_internal_encoding' ) ) {
  458. if ( !@mb_internal_encoding( get_option( 'blog_charset' ) ) )
  459. mb_internal_encoding( 'UTF-8' );
  460. }
  461. }
  462. /**
  463. * Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
  464. *
  465. * Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
  466. * or $_ENV are needed, use those superglobals directly.
  467. *
  468. * @access private
  469. * @since 3.0.0
  470. */
  471. function wp_magic_quotes() {
  472. // If already slashed, strip.
  473. if ( get_magic_quotes_gpc() ) {
  474. $_GET = stripslashes_deep( $_GET );
  475. $_POST = stripslashes_deep( $_POST );
  476. $_COOKIE = stripslashes_deep( $_COOKIE );
  477. }
  478. // Escape with wpdb.
  479. $_GET = add_magic_quotes( $_GET );
  480. $_POST = add_magic_quotes( $_POST );
  481. $_COOKIE = add_magic_quotes( $_COOKIE );
  482. $_SERVER = add_magic_quotes( $_SERVER );
  483. // Force REQUEST to be GET + POST.
  484. $_REQUEST = array_merge( $_GET, $_POST );
  485. }
  486. /**
  487. * Runs just before PHP shuts down execution.
  488. *
  489. * @access private
  490. * @since 1.2.0
  491. */
  492. function shutdown_action_hook() {
  493. do_action( 'shutdown' );
  494. wp_cache_close();
  495. }
  496. /**
  497. * Copy an object.
  498. *
  499. * Returns a cloned copy of an object.
  500. *
  501. * @since 2.7.0
  502. *
  503. * @param object $object The object to clone
  504. * @return object The cloned object
  505. */
  506. function wp_clone( $object ) {
  507. static $can_clone;
  508. if ( !isset( $can_clone ) )
  509. $can_clone = version_compare( phpversion(), '5.0', '>=' );
  510. return $can_clone ? clone( $object ) : $object;
  511. }
  512. /**
  513. * Whether the current request is for a network or blog admin page
  514. *
  515. * Does not inform on whether the user is an admin! Use capability checks to
  516. * tell if the user should be accessing a section or not.
  517. *
  518. * @since 1.5.1
  519. *
  520. * @return bool True if inside WordPress administration pages.
  521. */
  522. function is_admin() {
  523. if ( defined( 'WP_ADMIN' ) )
  524. return WP_ADMIN;
  525. return false;
  526. }
  527. /**
  528. * Whether the current request is for a blog admin screen /wp-admin/
  529. *
  530. * Does not inform on whether the user is a blog admin! Use capability checks to
  531. * tell if the user should be accessing a section or not.
  532. *
  533. * @since 3.1.0
  534. *
  535. * @return bool True if inside WordPress network administration pages.
  536. */
  537. function is_blog_admin() {
  538. if ( defined( 'WP_BLOG_ADMIN' ) )
  539. return WP_BLOG_ADMIN;
  540. return false;
  541. }
  542. /**
  543. * Whether the current request is for a network admin screen /wp-admin/network/
  544. *
  545. * Does not inform on whether the user is a network admin! Use capability checks to
  546. * tell if the user should be accessing a section or not.
  547. *
  548. * @since 3.1.0
  549. *
  550. * @return bool True if inside WordPress network administration pages.
  551. */
  552. function is_network_admin() {
  553. if ( defined( 'WP_NETWORK_ADMIN' ) )
  554. return WP_NETWORK_ADMIN;
  555. return false;
  556. }
  557. /**
  558. * Whether the current request is for a user admin screen /wp-admin/user/
  559. *
  560. * Does not inform on whether the user is an admin! Use capability checks to
  561. * tell if the user should be accessing a section or not.
  562. *
  563. * @since 3.1.0
  564. *
  565. * @return bool True if inside WordPress user administration pages.
  566. */
  567. function is_user_admin() {
  568. if ( defined( 'WP_USER_ADMIN' ) )
  569. return WP_USER_ADMIN;
  570. return false;
  571. }
  572. /**
  573. * Whether Multisite support is enabled
  574. *
  575. * @since 3.0.0
  576. *
  577. * @return bool True if multisite is enabled, false otherwise.
  578. */
  579. function is_multisite() {
  580. if ( defined( 'MULTISITE' ) )
  581. return MULTISITE;
  582. if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
  583. return true;
  584. return false;
  585. }
  586. ?>