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
3728      if ( ! $last_changed ) {
3729           $last_changed = microtime();
3730           wp_cache_set( 'last_changed', $last_changed, 'posts' );
3731      }
3732
3733      $cache_key = "get_pages:$key:$last_changed";
3734      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
3735           // Convert to WP_Post instances
3736           $pages = array_map( 'get_post', $cache );
3737           $pages = apply_filters('get_pages', $pages, $r);
3738           return $pages;
3739      }
3740
3741      if ( !is_array($cache) )
3742           $cache = array();
3743
3744      $inclusions = '';
3745      if ( ! empty( $include ) ) {
3746           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
 
Line Code
3858      $query .= $author_query;
3859      $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
3860
3861      if ( !empty($number) )
3862           $query .= ' LIMIT ' . $offset . ',' . $number;
3863
3864      $pages = $wpdb->get_results($query);
3865
3866      if ( empty($pages) ) {
3867           $pages = apply_filters('get_pages', array(), $r);
3868           return $pages;
3869      }
3870
3871      // Sanitize before caching so it'll only get done once
3872      $num_pages = count($pages);
3873      for ($i = 0; $i < $num_pages; $i++) {
3874           $pages[$i] = sanitize_post($pages[$i], 'raw');
3875      }
3876
 
Line Code
3897      $page_structure = array();
3898      foreach ( $pages as $page )
3899           $page_structure[] = $page->ID;
3900
3901      wp_cache_set( $cache_key, $page_structure, 'posts' );
3902
3903      // Convert to WP_Post instances
3904      $pages = array_map( 'get_post', $pages );
3905
3906      $pages = apply_filters('get_pages', $pages, $r);
3907
3908      return $pages;
3909 }
3910
3911 //
3912 // Attachment functions
3913 //
3914
3915 /**