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
3072
3073      // Make sure we have a valid post status
3074      if ( !in_array($post_status, get_post_stati()) )
3075           return false;
3076
3077      $cache = array();
3078      $key = md5( serialize( compact(array_keys($defaults)) ) );
3079      if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) {
3080           if ( is_array($cache) && isset( $cache[ $key ] ) ) {
3081                $pages = apply_filters('get_pages', $cache[ $key ], $r );
3082                return $pages;
3083           }
3084      }
3085
3086      if ( !is_array($cache) )
3087           $cache = array();
3088
3089      $inclusions = '';
3090      if ( !empty($include) ) {
 
Line Code
3172      $query .= $author_query;
3173      $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
3174
3175      if ( !empty($number) )
3176           $query .= ' LIMIT ' . $offset . ',' . $number;
3177
3178      $pages = $wpdb->get_results($query);
3179
3180      if ( empty($pages) ) {
3181           $pages = apply_filters('get_pages', array(), $r);
3182           return $pages;
3183      }
3184
3185      // Sanitize before caching so it'll only get done once
3186      $num_pages = count($pages);
3187      for ($i = 0; $i < $num_pages; $i++) {
3188           $pages[$i] = sanitize_post($pages[$i], 'raw');
3189      }
3190
 
Line Code
3205           for ( $i = 0; $i < $num_pages; $i++ ) {
3206                if ( in_array($pages[$i]->ID, $excludes) )
3207                     unset($pages[$i]);
3208           }
3209      }
3210
3211      $cache[ $key ] = $pages;
3212      wp_cache_set( 'get_pages', $cache, 'posts' );
3213
3214      $pages = apply_filters('get_pages', $pages, $r);
3215
3216      return $pages;
3217 }
3218
3219 //
3220 // Attachment functions
3221 //
3222
3223 /**