Skip to main content
We are Brand SEO Beijing serving international business, your marketing partner, Contact us by mi@mgsh.com.cn

Detailed explanation of the wp-setting.php file

Description: Programs and class libraries used to set public variables, load WP (where the folders where WP functions, classes, and core content are stored) are stored.The user does not need to modify this file, but it can be configured by modifying the wp-config.php file.

    1. Define the WPINC constants and import the files required for initialization:
      1. WPINC/load.php, which defines a set of functions required to load WP, ​​without executing code;
      2. WPINC/default-constants.php, defines a set of functions that assign default assignments to constants and global variables that can be overridden, they can usually be reconfigured in wp-config.php without executing code;
      3. WPINC/version.php, defines version-related variables, and assigns values ​​to these variables.
    2. Call the wp_initial_constants() function to initialize the constants WP_MEMORY_LIMIT, WP_DEBUG, WP_CONTENT_DIR and WP_CACHE.
    3. Turn off runtime magic references, which will be added later via wpdb in wp-settings.php.
    4. Sets the default timezone for PHP5.
    5. Call the wp_unregister_GLOBALS() function to close register_globals.
    6. Unset global variables $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate to make sure they don't exist.
    7. Call the function wp_fix_server_vars() to specify the $_SERVER variable settings.
    8. Call the function wp_check_php_mysql_versions() to check the required PHP version and MySQL extension or database drop-in.
    9. Call the function wp_favicon_request() to check if a request is received due to a missing favicon.ico.
    10. Check if you are in maintenance mode.
    11. Start the loading timer.
    12. Check if you are in WP_DEBUG mode.
    13. Whether and how to load the file is determined according to the WP_CACHE and WP_DEBUG constants:
      1. WP_CONTENT_DIR/advanced-cache.php belongs to drop-in and is used by advanced cache plugins.
    14. Call the wp_set_lang_dir() function to set the constant WP_LANG_DIR.
    15. Load WP file:
      1. WPINC/compat.php, which provides functions that are missing in some PHP versions (to support compatibility and porting on different versions of PHP), no executable code;
      2. WPINC/functions.php, defines the main API of WP, no executable code;
      3. WPINC/classes.php, defines the main classes of WP, no executable code.
    16. Call the require_wp_db() function, import the wpdb class, or drop-in the database into db.php (if it exists).
    17. Call the wp_set_wpdb_vars() function to set the database table prefix and format specifiers for the database table columns
    18. Call the wp_start_object_cache() function to enable the WP object cache, or expand the object cache (if the corresponding drop-in exists).
    19. Load WP file:
      1. WPINC/plugin.php, defines plugin APIs, which are used to create action, filter, and hook functions and methods, without executing code;
      2. WPINC/default-filters.php, set default actions and filters for hooks in WP;
      3. WPINC/pomo/mo.php, defines the language processing class MO, and loads the file, no executable code:
        • WPINC/pomo/translations.php, define the relevant classes for translating entry, and load the file, no execution code:
          • WPINC/pomo/entry.php, defines the translation entity class Translation_Entry, no executable code;
        • WPINC/pomo/streams.php, defines a set of classes for reading data streams from files, without executing code.
    20. If multisite is enabled, load the file; otherwise set the constant MULTISITE to false:
      1. WPINC/ms-blogs.php, defines a set of Site/blog functions for manipulating the blogs table and related data;
      2. WPINC/ms-settings.php (files involving multiple sites are not considered for now).

——If only basic functions are required (ie, the SHORTINIT constant is true), the wp-setting.php file will return to this point! ————

  1. Load the l18n library:
    1. WPINC/l10n.php, defines a set of APIs/functions for language translation, no executable code.
  2. Call the wp_not_installed() function to start the installer if WP has not been installed.
  3. Load the *most of WP* of WP, a total of 33 files:
    1. WPINC/formatting.php, defines the main formatting API of WP, which is used to format text, strings, and function output without executing code;
    2. WPINC/capabilities.php, defines a set of classes WP_Roles, WP_Role, WP_User and functions for manipulating roles and permissions;
    3. WPINC/query.php, defines a set of WP query APIs, no execution code;
    4. WPINC/theme.php, defines a set of themes, templates and stylesheet functions, no code to execute;
    5. WPINC/user.php, defines a set of WP user APIs, no executable code;
    6. WPINC/meta.php, defines a set of metadata APIs, which are used to obtain and manipulate the metadata of various object types in WP. The metadata of an object is simply represented as a key-value pair, and the object may contain multiple metadata Entities, they have the same key but different values, no code to execute;
    7. WPINC/general-template.php, defines commonly used template tags, which can be used arbitrarily in templates without executable code;
    8. WPINC/link-template.php, which defines functions in a set of templates that handle links (such as handling permalinks), without executable code;
    9. WPINC/author-template.php, defines a set of functions for dealing with authors in the template, these functions are used in the theme, and must appear in WP LOOP, no executable code;
    10. WPINC/post.php, define a set of post-related functions, and add add_action( 'init', 'create_initial_post_types', 0 );
    11. WPINC/post-template.php, defines a set of functions for processing articles in templates, used to obtain the content of the current article in the Loop, no executable code;
    12. WPINC/category.php, defines a set of WP catalog APIs, no executable code;
    13. WPINC/category-template.php, which defines template tags and APIs for a set of directories, no executable code;
    14. WPINC/comment.php, defines a set of WP comment APIs, no executable code;
    15. WPINC/comment-template.php, which defines a set of comment template tags, designed to be useful in Loops, without executable code;
    16. WPINC/rewrite.php, defines a set of WP rewrite API and WP_Rewrite class, used to rewrite the link format; and this file also defines a set of constants EP_NONE, EP_PERMALINK, EP_ATTACHMENT, EP_DATE, EP_YEAR, EP_MONTH, EP_DAY, EP_ROOT , EP_COMMENTS, EP_SEARCH, EP_CATEGORIES, EP_TAGS, EP_AUTHORS, EP_PAGES, EP_ALL;
    17. WPINC/feed.php, defines a set of WP Feed APIs, most of which are only used in Loop, without executable code;
    18. WPINC/bookmark.php, defines a set of WP friendly link/bookmark API, no executable code;
    19. WPINC/bookmark-template.php, which defines a set of bookmark template tags, no executable code;
    20. WPINC/kses.php, defines a set of HTML/XHTML filter API, and defines a set of tag arrays, adds two actions: add_action('init', 'kses_init');add_action('set_current_user', 'kses_init' );
    21. WPINC/cron.php, defines a set of WP CRON (timed task) APIs for event scheduling, no executable code;
    22. WPIN/deprecated.php, a set of deprecated APIs with no executable code;
    23. WPINC/script-loader.php, the default loader API for scripts and stylesheets in WP, and loads the following files:
      • /class.wp-dependencies.php, defines classes WP_Dependencies and _WP_Dependency for backpressure script queue, these classes are refactored from WP_Scripts class and WP script queue API, no executable code;
      • /class.wp-scripts.php, defines the class WP_Scripts, inherits from WP_Dependencies, the function is the same as above, no executable code;
      • /functions.wp-scripts.php, defines a set of WP script queue API, the same function as above, no executable code;
      • /class.wp-styles.php, defines the class WP_Styles, which inherits from WP_Dependencies and is used for backpressure style sheet queue;
      • /functions.wp-styles.php, defines a set of WP style queue API, no executable code.

      And added the following action and filter:

      • add_action( 'wp_default_scripts', 'wp_default_scripts' );
      • add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
      • add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
      • add_action( 'wp_default_styles', 'wp_default_styles' );
      • add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
    24. WPINC/taxonomy.php, defines a set of WP classification methods (different from the concept of catalog, it is a classification on the catalog) API, no executable code;
    25. WPINC/update.php, defines a set of APIs for checking version upgrade information, adds a set of actions, and dispatches events:
      • add_action( 'admin_init', '_maybe_update_core' );
      • add_action( 'wp_version_check', 'wp_version_check' );
      • add_action( 'load-plugins.php', 'wp_update_plugins' );
      • add_action( 'load-update.php', 'wp_update_plugins' );
      • add_action( 'load-update-core.php', 'wp_update_plugins' );
      • add_action( 'admin_init', '_maybe_update_plugins' );
      • add_action( 'wp_update_plugins', 'wp_update_plugins' );
      • add_action( 'load-themes.php', 'wp_update_themes' );
      • add_action( 'load-update.php', 'wp_update_themes' );
      • add_action( 'load-update-core.php', 'wp_update_themes' );
      • add_action( 'admin_init', '_maybe_update_themes' );
      • add_action( 'wp_update_themes', 'wp_update_themes' );
    26. WPINC/canonical.php, defines a set of redirection canonical functions for handling redirection in WP, and adds action:
      • add_action('template_redirect', 'redirect_canonical');
    27. WPINC/shortcodes.php, defines a set of WP shortcode API, and defines the array $shortcode_tags, add filter:
      • add_filter('the_content', 'do_shortcode', 11);
    28. WPINC/media.php, define a set of media (video, picture, etc.) display related API and class WP_Embed, and create $wp_embed = new WP_Embed() variable, add shortcode:
      • add_shortcode('wp_caption', 'img_caption_shortcode');
      • add_shortcode('caption', 'img_caption_shortcode');
      • add_shortcode('gallery', 'gallery_shortcode');
    29. WPINC/http.php, defines a set of APIs that simplify and unify HTTP requests, no executable code;
    30. WPINC/class-http.php, defines a set of classes that simplify and unify http requests WP_Http, WP_Http_Fsockopen, WP_Http_Fopen, WP_Http_Streams, WP_Http_ExtHTTP, WP_Http_Curl, WP_HTTP_Proxy, WP_Http_Cookie, WP_Http_Encoding, for standardizing http requests, handling cookies and gzip encoding and decoding, no executable code;
    31. WPINC/widgets.php, defines a set of APIs and classes for creating dynamic sidebars, WP_Widget, WP_Widget_Factory, and defines a set of global variables;
    32. WPINC/nav-menu.php, which defines a set of navigation menu APIs in WP, is a newly added function of WP3.0, and has no executable code;
    33. WPINC/nav-menu-template.php, defines a set of template tags and APIs for navigation menus, no executable code.
  4. Load multisite specific files:
    1. WPINC/ms-functions.php,
    2. WPINC/ms-default-filters.php,
    3. WPINC/ms-deprecated.php.
  5. Call the wp_plugin_directory_constants() function, define constants that depend on the API to get default values, and define the plugin folder constants that must be used, which may be overridden in the sunset.php drop-in.
  6. Use the function wp_get_mu_plugins() to load the plugins that must be used, and trigger the mount point do_action( 'muplugins_loaded' );
  7. Call the function ms_cookie_constants() to set cookie constants for multisite.
  8. Call the function wp_cookie_constants() to define constants after multisite loading, cookie related constants may be overwritten in ms_network_cookies().
  9. Call the function wp_ssl_constants() to define and implement SSL constants.
  10. Load the file to create public global variables:
    1. WPINC/vars.php to create public variables for the rest of WP.
  11. Call the functions create_initial_taxonomies() and create_initial_post_types() to make taxonomies and posts visible to plugins and themes.Note to plugin authors: these are registered again when the hook is initialized.
  12. Active plugins are loaded using the function wp_get_active_and_valid_plugins().
  13. Load the function library file of pluggable:
    1. WPINC/pluggable.php, the functions in this can be overridden by plugins. If the plugin does not redefine these functions, these functions will be used without executable code;
    2. WPINC/pluggable-deprecated.php, deprecated pluggable override function, no executable code.
  14. Call the function wp_set_internal_encoding() to set the internal encoding.
  15. This function is called if WP_CACHE is on and the wp_cache_postload() function exists.
  16. Trigger mount point do_action( 'plugins_loaded' ).
  17. Call the function wp_functionality_constants() to define constants that are not yet defined but affect functionality.
  18. Call the function wp_magic_quotes() to add magic quotes and assemble $_REQUEST ( $_GET + $_POST ).
  19. Trigger mount point do_action( 'sanitize_comment_cookies' ) (harmless comment cookies).
  20. Create a global WP query object $wp_the_query =& new WP_Query(), and save the reference of $wp_the_query to $wp_query, and use $wp_query to query.
  21. Create a WP rewrite object $wp_rewrite =& new WP_Rewrite() to create nice URLs.
  22. Create WP object $wp =& new WP().
  23. Create a WP Widget factory object $wp_widget_factory =& new WP_Widget_Factory().
  24. Trigger mount point do_action( 'setup_theme' ).
  25. Call the function wp_templating_constants() to set template related constants.
  26. Call the function load_default_textdomain() to load the default text localization domain.
  27. Find blog locale $locale = get_locale().
  28. After loading the text field, load the localization data:
    1. WPINC/locale.php, localization object class WP_Locale that defines date and time, no executable code.
  29. Create localization object $wp_locale =& new WP_Locale() to load localization domain data and various strings.
  30. Load the library file of the active theme:
    1. TEMPLATEPATH/functions.php, loads the functions that come with the template.
  31. Trigger mount point do_action( 'after_setup_theme' ).
  32. Call the function require_if_theme_supports() to load all the functions supported by the theme.
  33. Register the shutdown function register_shutdown_function( 'shutdown_action_hook' ).
  34. Create the current user $wp->init().
  35. The mount point do_action( 'init' ) is triggered, at this stage most of the WP is loaded and the user is authenticated. WP will continue to load mounters on init hooks, such as widgets and various plugin instances.If you want to insert an action after WP loads, use the wp_loaded hook below.
  36. If it is multi-site, check the status of the site.
  37. Trigger the mount point do_action('wp_loaded'), when WP, all plugins and themes are fully loaded and instantiated, the hook will be dismissed. Ajax requests should use wp-admin/admin-ajax.php, admin-ajax.php can handle requests from users who are not logged in.

Source of this article: www.cnblogs.com/vicenteforever/category/224217.html

Back to Top