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
3615      if ( ! $last_changed ) {
3616           $last_changed = microtime();
3617           wp_cache_set( 'last_changed', $last_changed, 'posts' );
3618      }
3619
3620      $cache_key = "get_pages:$key:$last_changed";
3621      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
3622           // Convert to WP_Post instances
3623           $pages = array_map( 'get_post', $cache );
3624           $pages = apply_filters('get_pages', $pages, $r);
3625           return $pages;
3626      }
3627
3628      if ( !is_array($cache) )
3629           $cache = array();
3630
3631      $inclusions = '';
3632      if ( !empty($include) ) {
3633           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
 
Line Code
3756      $query .= $author_query;
3757      $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
3758
3759      if ( !empty($number) )
3760           $query .= ' LIMIT ' . $offset . ',' . $number;
3761
3762      $pages = $wpdb->get_results($query);
3763
3764      if ( empty($pages) ) {
3765           $pages = apply_filters('get_pages', array(), $r);
3766           return $pages;
3767      }
3768
3769      // Sanitize before caching so it'll only get done once
3770      $num_pages = count($pages);
3771      for ($i = 0; $i < $num_pages; $i++) {
3772           $pages[$i] = sanitize_post($pages[$i], 'raw');
3773      }
3774
 
Line Code
3795      $page_structure = array();
3796      foreach ( $pages as $page )
3797           $page_structure[] = $page->ID;
3798
3799      wp_cache_set( $cache_key, $page_structure, 'posts' );
3800
3801      // Convert to WP_Post instances
3802      $pages = array_map( 'get_post', $pages );
3803
3804      $pages = apply_filters('get_pages', $pages, $r);
3805
3806      return $pages;
3807 }
3808
3809 //
3810 // Attachment functions
3811 //
3812
3813 /**