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
4166           $last_changed = microtime();
4167           wp_cache_set( 'last_changed', $last_changed, 'posts' );
4168      }
4169
4170      $cache_key = "get_pages:$key:$last_changed";
4171      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4172           // Convert to WP_Post instances
4173           $pages = array_map( 'get_post', $cache );
4174           /** This filter is documented in wp-includes/post.php */
4175           $pages = apply_filters( 'get_pages', $pages, $r );
4176           return $pages;
4177      }
4178
4179      if ( !is_array($cache) )
4180           $cache = array();
4181
4182      $inclusions = '';
4183      if ( ! empty( $include ) ) {
4184           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
 
Line Code
4297      $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
4298
4299      if ( !empty($number) )
4300           $query .= ' LIMIT ' . $offset . ',' . $number;
4301
4302      $pages = $wpdb->get_results($query);
4303
4304      if ( empty($pages) ) {
4305           /** This filter is documented in wp-includes/post.php */
4306           $pages = apply_filters( 'get_pages', array(), $r );
4307           return $pages;
4308      }
4309
4310      // Sanitize before caching so it'll only get done once
4311      $num_pages = count($pages);
4312      for ($i = 0; $i < $num_pages; $i++) {
4313           $pages[$i] = sanitize_post($pages[$i], 'raw');
4314      }
4315
 
Line Code
4347
4348      /**
4349       * Filter the retrieved list of pages.
4350       *
4351       * @since 2.1.0
4352       *
4353       * @param array $pages List of pages to retrieve.
4354       * @param array $r     Array of get_pages() arguments.
4355       */
4356      $pages = apply_filters( 'get_pages', $pages, $r );
4357
4358      return $pages;
4359 }
4360
4361 //
4362 // Attachment functions
4363 //
4364
4365 /**