Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_pages

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
3721      if ( ! $last_changed ) {
3722           $last_changed = microtime();
3723           wp_cache_set( 'last_changed', $last_changed, 'posts' );
3724      }
3725
3726      $cache_key = "get_pages:$key:$last_changed";
3727      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
3728           // Convert to WP_Post instances
3729           $pages = array_map( 'get_post', $cache );
3730           $pages = apply_filters('get_pages', $pages, $r);
3731           return $pages;
3732      }
3733
3734      if ( !is_array($cache) )
3735           $cache = array();
3736
3737      $inclusions = '';
3738      if ( ! empty( $include ) ) {
3739           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
 
Line Code
3851      $query .= $author_query;
3852      $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
3853
3854      if ( !empty($number) )
3855           $query .= ' LIMIT ' . $offset . ',' . $number;
3856
3857      $pages = $wpdb->get_results($query);
3858
3859      if ( empty($pages) ) {
3860           $pages = apply_filters('get_pages', array(), $r);
3861           return $pages;
3862      }
3863
3864      // Sanitize before caching so it'll only get done once
3865      $num_pages = count($pages);
3866      for ($i = 0; $i < $num_pages; $i++) {
3867           $pages[$i] = sanitize_post($pages[$i], 'raw');
3868      }
3869
 
Line Code
3890      $page_structure = array();
3891      foreach ( $pages as $page )
3892           $page_structure[] = $page->ID;
3893
3894      wp_cache_set( $cache_key, $page_structure, 'posts' );
3895
3896      // Convert to WP_Post instances
3897      $pages = array_map( 'get_post', $pages );
3898
3899      $pages = apply_filters('get_pages', $pages, $r);
3900
3901      return $pages;
3902 }
3903
3904 //
3905 // Attachment functions
3906 //
3907
3908 /**