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.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

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
1868           'authors' => ''
1869      );
1870
1871      $r = wp_parse_args( $args, $defaults );
1872      extract( $r, EXTR_SKIP );
1873
1874      $key = md5( serialize( $r ) );
1875      if ( $cache = wp_cache_get( 'get_pages', 'posts' ) )
1876           if ( isset( $cache[ $key ] ) )
1877                return apply_filters('get_pages', $cache[ $key ], $r );
1878
1879      $inclusions = '';
1880      if ( !empty($include) ) {
1881           $child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include
1882           $exclude = '';
1883           $meta_key = '';
1884           $meta_value = '';
1885           $hierarchical = false;
1886           $incpages = preg_split('/[\s,]+/',$include);
 
Line Code
1942      $query .= " WHERE (post_type = 'page' AND post_status = 'publish') $exclusions $inclusions " ;
1943      // expected_slashed ($meta_key, $meta_value) -- also, it looks funky
1944      $query .= ( empty( $meta_key ) | empty($meta_value)  ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" ) ;
1945      $query .= $author_query;
1946      $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
1947
1948      $pages = $wpdb->get_results($query);
1949
1950      if ( empty($pages) )
1951           return apply_filters('get_pages', array(), $r);
1952
1953      // Update cache.
1954      update_page_cache($pages);
1955
1956      if ( $child_of || $hierarchical )
1957           $pages = & get_page_children($child_of, $pages);
1958
1959      $cache[ $key ] = $pages;
1960      wp_cache_set( 'get_pages', $cache, 'posts' );
1961
1962      $pages = apply_filters('get_pages', $pages, $r);
1963
1964      return $pages;
1965 }
1966
1967 //
1968 // Attachment functions
1969 //
1970
1971 /**