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
5285      $key          = md5( serialize( wp_array_slice_assoc( $parsed_args, array_keys( $defaults ) ) ) );
5286      $last_changed = wp_cache_get_last_changed( 'posts' );
5287
5288      $cache_key = "get_pages:$key:$last_changed";
5289      $cache     = wp_cache_get( $cache_key, 'posts' );
5290      if ( false !== $cache ) {
5291           // Convert to WP_Post instances.
5292           $pages = array_map( 'get_post', $cache );
5293           /** This filter is documented in wp-includes/post.php */
5294           $pages = apply_filters( 'get_pages', $pages, $parsed_args );
5295           return $pages;
5296      }
5297
5298      $inclusions = '';
5299      if ( ! empty( $parsed_args['include'] ) ) {
5300           $child_of     = 0; // Ignore child_of, parent, exclude, meta_key, and meta_value params if using include.
5301           $parent       = -1;
5302           $exclude      = '';
5303           $meta_key     = '';
 
Line Code
5445           $query .= ' LIMIT ' . $offset . ',' . $number;
5446      }
5447
5448      $pages = $wpdb->get_results( $query );
5449
5450      if ( empty( $pages ) ) {
5451           wp_cache_set( $cache_key, array(), 'posts' );
5452
5453           /** This filter is documented in wp-includes/post.php */
5454           $pages = apply_filters( 'get_pages', array(), $parsed_args );
5455           return $pages;
5456      }
5457
5458      // Sanitize before caching so it'll only get done once.
5459      $num_pages = count( $pages );
5460      for ( $i = 0; $i < $num_pages; $i++ ) {
5461           $pages[ $i ] = sanitize_post( $pages[ $i ], 'raw' );
5462      }
5463
 
Line Code
5497
5498      /**
5499       * Filters the retrieved list of pages.
5500       *
5501       * @since 2.1.0
5502       *
5503       * @param WP_Post[] $pages       Array of page objects.
5504       * @param array     $parsed_args Array of get_pages() arguments.
5505       */
5506      return apply_filters( 'get_pages', $pages, $parsed_args );
5507 }
5508
5509 //
5510 // Attachment functions.
5511 //
5512
5513 /**
5514  * Determines whether an attachment URI is local and really an attachment.
5515  *