Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jakestack/aa9b6fe5d35fc8698444b92e013b8972 to your computer and use it in GitHub Desktop.
Save jakestack/aa9b6fe5d35fc8698444b92e013b8972 to your computer and use it in GitHub Desktop.

Revisions

  1. @johnbillion johnbillion revised this gist Nov 7, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -39,6 +39,7 @@ $wp->parse_request()
    APPLY_FILTERS 'request' to the request variables
    DO_ACTION_REF_ARRAY 'parse_request' with array of request vars (query vars, request, matched rewrite rules, etc)

    DO_ACTION_REF_ARRAY 'send_headers' with the 'WP' object.

    THE MAIN QUERY
    ==============
  2. @johnbillion johnbillion revised this gist Mar 17, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,11 @@ INITIALISATION

    load wp-config.php
    set up default constants
    load advanced-cache.php if it exists
    load wp-content/advanced-cache.php if it exists
    load wp-content/db.php if it exists
    connect to mysql, select db
    load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
    load wp-content/sunrise.php if it exists (multisite only)
    load l10n library
    load mu plugins
    DO_ACTION 'muplugins_loaded' (only accessible to mu plugins)
  3. @johnbillion johnbillion created this gist Mar 17, 2015.
    92 changes: 92 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    INITIALISATION
    ==============

    load wp-config.php
    set up default constants
    load advanced-cache.php if it exists
    connect to mysql, select db
    load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
    load l10n library
    load mu plugins
    DO_ACTION 'muplugins_loaded' (only accessible to mu plugins)
    load active plugins
    load pluggables.php
    DO_ACTION 'plugins_loaded' (first hook available to plugins)
    load rewrite rules
    instantiate $wp_query, $wp_rewrite and $wp.
    $wp_query is a global instance of the WP_Query class. For more info, see ANY QUERY
    $wp_rewrite is a global instance of the WP_Rewrite class and contains our rewrite rules and functions
    $wp is a global instance of the WP class and contains the functions that will parse our request and perform the main query (see REQUEST)
    DO_ACTION 'setup_theme'
    include child theme functions.php
    include parent theme functions.php
    DO_ACTION 'after_setup_theme' (first hook available to themes)
    set up current user object
    DO_ACTION 'init'
    register widgets (DO_ACTION 'widget_init')
    call wp() (which calls $wp->main())


    REQUEST
    =======

    $wp->parse_request()
    loop over rewrite rules to find a match
    APPLY_FILTERS 'query_vars' to the publicly available query vars
    fill query vars with $_POSTs, $_GETs, and rewritten vars
    APPLY_FILTERS 'request' to the request variables
    DO_ACTION_REF_ARRAY 'parse_request' with array of request vars (query vars, request, matched rewrite rules, etc)


    THE MAIN QUERY
    ==============

    $wp->query_posts()
    goto ANY QUERY

    if posts are empty, set is_404() (and send 404 headers)
    set all the query_vars to global variables
    DO_ACTION_REF_ARRAY 'wp' with the main WP object


    ANY QUERY
    =========

    WP_Query->query( query vars )
    WP_Query->parse_query( query vars )
    build query parameters based off query vars
    set WP_Query->is_* vars based off query parameters
    if this query is $wp_the_query then these determine the values of the global is_*() functions too
    DO_ACTION_REF_ARRAY 'parse_query' with WP_Query object (query parameters, query vars, conditionals)
    WP_Query->get_posts()
    DO_ACTION_REF_ARRAY 'pre_get_posts' with WP_Query object
    APPLY_FILTERS_REF_ARRAY 'posts_search' with search SQL
    series of APPLY_FILTERS on the query SQL (if suppress_filters=false):
    * posts_where
    * posts_join
    * posts_where_paged
    * posts_groupby
    * posts_join_paged
    * posts_orderby
    * posts_distinct
    * post_limits
    * posts_fields
    * posts_clauses
    APPLY_FILTERS_REF_ARRAY 'posts_request' (if suppress_filters=false)
    fetch posts from the database
    APPLY_FILTERS_REF_ARRAY 'posts_results' (if suppress_filters=false)
    prepend sticky posts
    APPLY_FILTERS_REF_ARRAY 'the_posts' (if suppress_filters=false)
    return posts

    TEMPLATE
    ========

    DO_ACTION 'template_redirect'
    if is_feed()
    load the feed template
    else
    look for template file in theme based on template hierarchy
    APPLY_FILTERS 'template_include'
    load the template file (which usually runs a loop @TODO document a loop)
    DO_ACTION 'shutdown'