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
2234      $r = wp_parse_args( $args, $defaults );
2235      extract( $r, EXTR_SKIP );
2236      $number = (int) $number;
2237      $offset = (int) $offset;
2238
2239      $cache = array();
2240      $key = md5( serialize( compact(array_keys($defaults)) ) );
2241      if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) {
2242           if ( is_array($cache) && isset( $cache[ $key ] ) ) {
2243                $pages = apply_filters('get_pages', $cache[ $key ], $r );
2244                return $pages;
2245           }
2246      }
2247
2248      if ( !is_array($cache) )
2249           $cache = array();
2250
2251      $inclusions = '';
2252      if ( !empty($include) ) {
 
Line Code
2332      $query .= $author_query;
2333      $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
2334
2335      if ( !empty($number) )
2336           $query .= ' LIMIT ' . $offset . ',' . $number;
2337
2338      $pages = $wpdb->get_results($query);
2339
2340      if ( empty($pages) ) {
2341           $pages = apply_filters('get_pages', array(), $r);
2342           return $pages;
2343      }
2344
2345      // Update cache.
2346      update_page_cache($pages);
2347
2348      if ( $child_of || $hierarchical )
2349           $pages = & get_page_children($child_of, $pages);
2350
 
Line Code
2361           for ( $i = 0; $i < $total; $i++ ) {
2362                if ( in_array($pages[$i]->ID, $excludes) )
2363                     unset($pages[$i]);
2364           }
2365      }
2366
2367      $cache[ $key ] = $pages;
2368      wp_cache_set( 'get_pages', $cache, 'posts' );
2369
2370      $pages = apply_filters('get_pages', $pages, $r);
2371
2372      return $pages;
2373 }
2374
2375 //
2376 // Attachment functions
2377 //
2378
2379 /**