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
5246      $key          = md5( serialize( wp_array_slice_assoc( $parsed_args, array_keys( $defaults ) ) ) );
5247      $last_changed = wp_cache_get_last_changed( 'posts' );
5248
5249      $cache_key = "get_pages:$key:$last_changed";
5250      $cache     = wp_cache_get( $cache_key, 'posts' );
5251      if ( false !== $cache ) {
5252           // Convert to WP_Post instances.
5253           $pages = array_map( 'get_post', $cache );
5254           /** This filter is documented in wp-includes/post.php */
5255           $pages = apply_filters( 'get_pages', $pages, $parsed_args );
5256           return $pages;
5257      }
5258
5259      $inclusions = '';
5260      if ( ! empty( $parsed_args['include'] ) ) {
5261           $child_of     = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
5262           $parent       = -1;
5263           $exclude      = '';
5264           $meta_key     = '';
 
Line Code
5406           $query .= ' LIMIT ' . $offset . ',' . $number;
5407      }
5408
5409      $pages = $wpdb->get_results( $query );
5410
5411      if ( empty( $pages ) ) {
5412           wp_cache_set( $cache_key, array(), 'posts' );
5413
5414           /** This filter is documented in wp-includes/post.php */
5415           $pages = apply_filters( 'get_pages', array(), $parsed_args );
5416           return $pages;
5417      }
5418
5419      // Sanitize before caching so it'll only get done once.
5420      $num_pages = count( $pages );
5421      for ( $i = 0; $i < $num_pages; $i++ ) {
5422           $pages[ $i ] = sanitize_post( $pages[ $i ], 'raw' );
5423      }
5424
 
Line Code
5458
5459      /**
5460       * Filters the retrieved list of pages.
5461       *
5462       * @since 2.1.0
5463       *
5464       * @param array $pages List of pages to retrieve.
5465       * @param array $parsed_args     Array of get_pages() arguments.
5466       */
5467      return apply_filters( 'get_pages', $pages, $parsed_args );
5468 }
5469
5470 //
5471 // Attachment functions
5472 //
5473
5474 /**
5475  * Determines whether an attachment URI is local and really an attachment.
5476  *