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
4451           $last_changed = microtime();
4452           wp_cache_set( 'last_changed', $last_changed, 'posts' );
4453      }
4454
4455      $cache_key = "get_pages:$key:$last_changed";
4456      if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4457           // Convert to WP_Post instances.
4458           $pages = array_map( 'get_post', $cache );
4459           /** This filter is documented in wp-includes/post.php */
4460           $pages = apply_filters( 'get_pages', $pages, $r );
4461           return $pages;
4462      }
4463
4464      $inclusions = '';
4465      if ( ! empty( $r['include'] ) ) {
4466           $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4467           $parent = -1;
4468           $exclude = '';
4469           $meta_key = '';
 
Line Code
4593
4594      if ( ! empty( $number ) ) {
4595           $query .= ' LIMIT ' . $offset . ',' . $number;
4596      }
4597
4598      $pages = $wpdb->get_results($query);
4599
4600      if ( empty($pages) ) {
4601           /** This filter is documented in wp-includes/post.php */
4602           $pages = apply_filters( 'get_pages', array(), $r );
4603           return $pages;
4604      }
4605
4606      // Sanitize before caching so it'll only get done once.
4607      $num_pages = count($pages);
4608      for ($i = 0; $i < $num_pages; $i++) {
4609           $pages[$i] = sanitize_post($pages[$i], 'raw');
4610      }
4611
 
Line Code
4645
4646      /**
4647       * Filters the retrieved list of pages.
4648       *
4649       * @since 2.1.0
4650       *
4651       * @param array $pages List of pages to retrieve.
4652       * @param array $r     Array of get_pages() arguments.
4653       */
4654      return apply_filters( 'get_pages', $pages, $r );
4655 }
4656
4657 //
4658 // Attachment functions
4659 //
4660
4661 /**
4662  * Check if the attachment URI is local one and is really an attachment.
4663  *