PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-settings.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 323 lines | 151 code | 62 blank | 110 comment | 18 complexity | 341c3263ead4608f6e90a517af87db1a MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Used to set up and fix common variables and include
  4. * the WordPress procedural and class library.
  5. *
  6. * Allows for some configuration in wp-config.php (see default-constants.php)
  7. *
  8. * @internal This file must be parsable by PHP4.
  9. *
  10. * @package WordPress
  11. */
  12. /**
  13. * Stores the location of the WordPress directory of functions, classes, and core content.
  14. *
  15. * @since 1.0.0
  16. */
  17. define( 'WPINC', 'wp-includes' );
  18. // Include files required for initialization.
  19. require( ABSPATH . WPINC . '/load.php' );
  20. require( ABSPATH . WPINC . '/default-constants.php' );
  21. require( ABSPATH . WPINC . '/version.php' );
  22. // Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, WP_CONTENT_DIR and WP_CACHE.
  23. wp_initial_constants( );
  24. // Check for the required PHP version and for the MySQL extension or a database drop-in.
  25. wp_check_php_mysql_versions();
  26. // Disable magic quotes at runtime. Magic quotes are added using wpdb later in wp-settings.php.
  27. @ini_set( 'magic_quotes_runtime', 0 );
  28. @ini_set( 'magic_quotes_sybase', 0 );
  29. // Set default timezone in PHP 5.
  30. if ( function_exists( 'date_default_timezone_set' ) )
  31. date_default_timezone_set( 'UTC' );
  32. // Turn register_globals off.
  33. wp_unregister_GLOBALS();
  34. // Ensure these global variables do not exist so they do not interfere with WordPress.
  35. unset( $wp_filter, $cache_lastcommentmodified );
  36. // Standardize $_SERVER variables across setups.
  37. wp_fix_server_vars();
  38. // Check if we have received a request due to missing favicon.ico
  39. wp_favicon_request();
  40. // Check if we're in maintenance mode.
  41. wp_maintenance();
  42. // Start loading timer.
  43. timer_start();
  44. // Check if we're in WP_DEBUG mode.
  45. wp_debug_mode();
  46. // For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
  47. if ( WP_CACHE )
  48. WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' );
  49. // Define WP_LANG_DIR if not set.
  50. wp_set_lang_dir();
  51. // Load early WordPress files.
  52. require( ABSPATH . WPINC . '/compat.php' );
  53. require( ABSPATH . WPINC . '/functions.php' );
  54. require( ABSPATH . WPINC . '/class-wp.php' );
  55. require( ABSPATH . WPINC . '/class-wp-error.php' );
  56. require( ABSPATH . WPINC . '/plugin.php' );
  57. require( ABSPATH . WPINC . '/pomo/mo.php' );
  58. // Include the wpdb class and, if present, a db.php database drop-in.
  59. require_wp_db();
  60. // Set the database table prefix and the format specifiers for database table columns.
  61. $GLOBALS['table_prefix'] = $table_prefix;
  62. wp_set_wpdb_vars();
  63. // Start the WordPress object cache, or an external object cache if the drop-in is present.
  64. wp_start_object_cache();
  65. // Attach the default filters.
  66. require( ABSPATH . WPINC . '/default-filters.php' );
  67. // Initialize multisite if enabled.
  68. if ( is_multisite() ) {
  69. require( ABSPATH . WPINC . '/ms-blogs.php' );
  70. require( ABSPATH . WPINC . '/ms-settings.php' );
  71. } elseif ( ! defined( 'MULTISITE' ) ) {
  72. define( 'MULTISITE', false );
  73. }
  74. register_shutdown_function( 'shutdown_action_hook' );
  75. // Stop most of WordPress from being loaded if we just want the basics.
  76. if ( SHORTINIT )
  77. return false;
  78. // Load the L10n library.
  79. require_once( ABSPATH . WPINC . '/l10n.php' );
  80. // Run the installer if WordPress is not installed.
  81. wp_not_installed();
  82. // Load most of WordPress.
  83. require( ABSPATH . WPINC . '/class-wp-walker.php' );
  84. require( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
  85. require( ABSPATH . WPINC . '/formatting.php' );
  86. require( ABSPATH . WPINC . '/capabilities.php' );
  87. require( ABSPATH . WPINC . '/query.php' );
  88. require( ABSPATH . WPINC . '/theme.php' );
  89. require( ABSPATH . WPINC . '/class-wp-theme.php' );
  90. require( ABSPATH . WPINC . '/template.php' );
  91. require( ABSPATH . WPINC . '/user.php' );
  92. require( ABSPATH . WPINC . '/meta.php' );
  93. require( ABSPATH . WPINC . '/general-template.php' );
  94. require( ABSPATH . WPINC . '/link-template.php' );
  95. require( ABSPATH . WPINC . '/author-template.php' );
  96. require( ABSPATH . WPINC . '/post.php' );
  97. require( ABSPATH . WPINC . '/post-template.php' );
  98. require( ABSPATH . WPINC . '/post-thumbnail-template.php' );
  99. require( ABSPATH . WPINC . '/category.php' );
  100. require( ABSPATH . WPINC . '/category-template.php' );
  101. require( ABSPATH . WPINC . '/comment.php' );
  102. require( ABSPATH . WPINC . '/comment-template.php' );
  103. require( ABSPATH . WPINC . '/rewrite.php' );
  104. require( ABSPATH . WPINC . '/feed.php' );
  105. require( ABSPATH . WPINC . '/bookmark.php' );
  106. require( ABSPATH . WPINC . '/bookmark-template.php' );
  107. require( ABSPATH . WPINC . '/kses.php' );
  108. require( ABSPATH . WPINC . '/cron.php' );
  109. require( ABSPATH . WPINC . '/deprecated.php' );
  110. require( ABSPATH . WPINC . '/script-loader.php' );
  111. require( ABSPATH . WPINC . '/taxonomy.php' );
  112. require( ABSPATH . WPINC . '/update.php' );
  113. require( ABSPATH . WPINC . '/canonical.php' );
  114. require( ABSPATH . WPINC . '/shortcodes.php' );
  115. require( ABSPATH . WPINC . '/media.php' );
  116. require( ABSPATH . WPINC . '/http.php' );
  117. require( ABSPATH . WPINC . '/class-http.php' );
  118. require( ABSPATH . WPINC . '/widgets.php' );
  119. require( ABSPATH . WPINC . '/nav-menu.php' );
  120. require( ABSPATH . WPINC . '/nav-menu-template.php' );
  121. require( ABSPATH . WPINC . '/admin-bar.php' );
  122. // Load multisite-specific files.
  123. if ( is_multisite() ) {
  124. require( ABSPATH . WPINC . '/ms-functions.php' );
  125. require( ABSPATH . WPINC . '/ms-default-filters.php' );
  126. require( ABSPATH . WPINC . '/ms-deprecated.php' );
  127. }
  128. // Define constants that rely on the API to obtain the default value.
  129. // Define must-use plugin directory constants, which may be overridden in the sunrise.php drop-in.
  130. wp_plugin_directory_constants( );
  131. // Load must-use plugins.
  132. foreach ( wp_get_mu_plugins() as $mu_plugin ) {
  133. include_once( $mu_plugin );
  134. }
  135. unset( $mu_plugin );
  136. // Load network activated plugins.
  137. if ( is_multisite() ) {
  138. foreach( wp_get_active_network_plugins() as $network_plugin ) {
  139. include_once( $network_plugin );
  140. }
  141. unset( $network_plugin );
  142. }
  143. do_action( 'muplugins_loaded' );
  144. if ( is_multisite() )
  145. ms_cookie_constants( );
  146. // Define constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
  147. wp_cookie_constants( );
  148. // Define and enforce our SSL constants
  149. wp_ssl_constants( );
  150. // Create common globals.
  151. require( ABSPATH . WPINC . '/vars.php' );
  152. // Make taxonomies and posts available to plugins and themes.
  153. // @plugin authors: warning: these get registered again on the init hook.
  154. create_initial_taxonomies();
  155. create_initial_post_types();
  156. // Register the default theme directory root
  157. register_theme_directory( get_theme_root() );
  158. // Load active plugins.
  159. foreach ( wp_get_active_and_valid_plugins() as $plugin )
  160. include_once( $plugin );
  161. unset( $plugin );
  162. // Load pluggable functions.
  163. require( ABSPATH . WPINC . '/pluggable.php' );
  164. require( ABSPATH . WPINC . '/pluggable-deprecated.php' );
  165. // Set internal encoding.
  166. wp_set_internal_encoding();
  167. // Run wp_cache_postload() if object cache is enabled and the function exists.
  168. if ( WP_CACHE && function_exists( 'wp_cache_postload' ) )
  169. wp_cache_postload();
  170. do_action( 'plugins_loaded' );
  171. // Define constants which affect functionality if not already defined.
  172. wp_functionality_constants( );
  173. // Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
  174. wp_magic_quotes();
  175. do_action( 'sanitize_comment_cookies' );
  176. /**
  177. * WordPress Query object
  178. * @global object $wp_the_query
  179. * @since 2.0.0
  180. */
  181. $wp_the_query = new WP_Query();
  182. /**
  183. * Holds the reference to @see $wp_the_query
  184. * Use this global for WordPress queries
  185. * @global object $wp_query
  186. * @since 1.5.0
  187. */
  188. $wp_query =& $wp_the_query;
  189. /**
  190. * Holds the WordPress Rewrite object for creating pretty URLs
  191. * @global object $wp_rewrite
  192. * @since 1.5.0
  193. */
  194. $GLOBALS['wp_rewrite'] = new WP_Rewrite();
  195. /**
  196. * WordPress Object
  197. * @global object $wp
  198. * @since 2.0.0
  199. */
  200. $wp = new WP();
  201. /**
  202. * WordPress Widget Factory Object
  203. * @global object $wp_widget_factory
  204. * @since 2.8.0
  205. */
  206. $GLOBALS['wp_widget_factory'] = new WP_Widget_Factory();
  207. do_action( 'setup_theme' );
  208. // Define the template related constants.
  209. wp_templating_constants( );
  210. // Load the default text localization domain.
  211. load_default_textdomain();
  212. $locale = get_locale();
  213. $locale_file = WP_LANG_DIR . "/$locale.php";
  214. if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) )
  215. require( $locale_file );
  216. unset( $locale_file );
  217. // Pull in locale data after loading text domain.
  218. require_once( ABSPATH . WPINC . '/locale.php' );
  219. /**
  220. * WordPress Locale object for loading locale domain date and various strings.
  221. * @global object $wp_locale
  222. * @since 2.1.0
  223. */
  224. $GLOBALS['wp_locale'] = new WP_Locale();
  225. // Load the functions for the active theme, for both parent and child theme if applicable.
  226. if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
  227. if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
  228. include( STYLESHEETPATH . '/functions.php' );
  229. if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
  230. include( TEMPLATEPATH . '/functions.php' );
  231. }
  232. do_action( 'after_setup_theme' );
  233. // Set up current user.
  234. $wp->init();
  235. /**
  236. * Most of WP is loaded at this stage, and the user is authenticated. WP continues
  237. * to load on the init hook that follows (e.g. widgets), and many plugins instantiate
  238. * themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
  239. *
  240. * If you wish to plug an action once WP is loaded, use the wp_loaded hook below.
  241. */
  242. do_action( 'init' );
  243. // Check site status
  244. if ( is_multisite() ) {
  245. if ( true !== ( $file = ms_site_check() ) ) {
  246. require( $file );
  247. die();
  248. }
  249. unset($file);
  250. }
  251. /**
  252. * This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
  253. *
  254. * AJAX requests should use wp-admin/admin-ajax.php. admin-ajax.php can handle requests for
  255. * users not logged in.
  256. *
  257. * @link http://codex.wordpress.org/AJAX_in_Plugins
  258. *
  259. * @since 3.0.0
  260. */
  261. do_action('wp_loaded');