]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/post-template.php
Wordpress 2.9
[autoinstalls/wordpress.git] / wp-includes / post-template.php
index 30856c58465027aef2fdbf9e4d7549a06a6b686f..9b6efcdac3e8ee1bd37fc04b6649eab689fca9b6 100644 (file)
@@ -160,10 +160,9 @@ function get_the_guid( $id = 0 ) {
  *
  * @param string $more_link_text Optional. Content for when there is more text.
  * @param string $stripteaser Optional. Teaser content before the more text.
- * @param string $more_file Optional. Not used.
  */
-function the_content($more_link_text = null, $stripteaser = 0, $more_file = '') {
-       $content = get_the_content($more_link_text, $stripteaser, $more_file);
+function the_content($more_link_text = null, $stripteaser = 0) {
+       $content = get_the_content($more_link_text, $stripteaser);
        $content = apply_filters('the_content', $content);
        $content = str_replace(']]>', ']]>', $content);
        echo $content;
@@ -176,10 +175,9 @@ function the_content($more_link_text = null, $stripteaser = 0, $more_file = '')
  *
  * @param string $more_link_text Optional. Content for when there is more text.
  * @param string $stripteaser Optional. Teaser content before the more text.
- * @param string $more_file Optional. Not used.
  * @return string
  */
-function get_the_content($more_link_text = null, $stripteaser = 0, $more_file = '') {
+function get_the_content($more_link_text = null, $stripteaser = 0) {
        global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow;
 
        if ( null === $more_link_text )
@@ -194,11 +192,6 @@ function get_the_content($more_link_text = null, $stripteaser = 0, $more_file =
                return $output;
        }
 
-       if ( $more_file != '' )
-               $file = $more_file;
-       else
-               $file = $pagenow; //$_SERVER['PHP_SELF'];
-
        if ( $page > count($pages) ) // if the requested page doesn't exist
                $page = count($pages); // give them the highest numbered page that DOES exist
 
@@ -254,7 +247,6 @@ function the_excerpt() {
  */
 function get_the_excerpt($deprecated = '') {
        global $post;
-       $output = '';
        $output = $post->post_excerpt;
        if ( post_password_required($post) ) {
                $output = __('There is no excerpt because this is a protected post.');
@@ -312,6 +304,9 @@ function get_post_class( $class = '', $post_id = null ) {
 
        $classes = array();
 
+       if ( empty($post) )
+               return $classes;
+
        $classes[] = 'post-' . $post->ID;
        $classes[] = $post->post_type;
 
@@ -342,6 +337,8 @@ function get_post_class( $class = '', $post_id = null ) {
                $classes = array_merge($classes, $class);
        }
 
+       $classes = array_map('esc_attr', $classes);
+
        return apply_filters('post_class', $classes, $class, $post_id);
 }
 
@@ -407,7 +404,7 @@ function get_body_class( $class = '' ) {
                if ( is_author() ) {
                        $author = $wp_query->get_queried_object();
                        $classes[] = 'author';
-                       $classes[] = 'author-' . sanitize_html_class($author->user_nicename , $author->user_id);
+                       $classes[] = 'author-' . sanitize_html_class($author->user_nicename , $author->ID);
                } elseif ( is_category() ) {
                        $cat = $wp_query->get_queried_object();
                        $classes[] = 'category';
@@ -430,13 +427,14 @@ function get_body_class( $class = '' ) {
                if ( $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' LIMIT 1", $pageID) ) )
                        $classes[] = 'page-parent';
 
-               if ( $wp_query->post->post_parent )
+               if ( $wp_query->post->post_parent ) {
                        $classes[] = 'page-child';
                        $classes[] = 'parent-pageid-' . $wp_query->post->post_parent;
-
-               if ( is_page_template() )
+               }
+               if ( is_page_template() ) {
                        $classes[] = 'page-template';
                        $classes[] = 'page-template-' . str_replace( '.php', '-php', get_post_meta( $pageID, '_wp_page_template', true ) );
+               }
        } elseif ( is_search() ) {
                if ( !empty($wp_query->posts) )
                        $classes[] = 'search-results';
@@ -477,6 +475,8 @@ function get_body_class( $class = '' ) {
                $classes = array_merge($classes, $class);
        }
 
+       $classes = array_map('esc_attr', $classes);
+
        return apply_filters('body_class', $classes, $class);
 }
 
@@ -544,8 +544,6 @@ function sticky_class( $post_id = null ) {
  *      each bookmarks.
  * 'after' - Default is '</p>' (string). The html or text to append to each
  *      bookmarks.
- * 'more_file' - Default is '' (string) Page the links should point to. Defaults
- *      to the current page.
  * 'link_before' - Default is '' (string). The html or text to prepend to each
  *      Pages link inside the <a> tag.
  * 'link_after' - Default is '' (string). The html or text to append to each
@@ -563,17 +561,13 @@ function wp_link_pages($args = '') {
                'link_before' => '', 'link_after' => '',
                'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
                'previouspagelink' => __('Previous page'), 'pagelink' => '%',
-               'more_file' => '', 'echo' => 1
+               'echo' => 1
        );
 
        $r = wp_parse_args( $args, $defaults );
        extract( $r, EXTR_SKIP );
 
        global $post, $page, $numpages, $multipage, $more, $pagenow;
-       if ( $more_file != '' )
-               $file = $more_file;
-       else
-               $file = $pagenow;
 
        $output = '';
        if ( $multipage ) {
@@ -705,6 +699,7 @@ function wp_dropdown_pages($args = '') {
 
        $pages = get_pages($r);
        $output = '';
+       $name = esc_attr($name);
 
        if ( ! empty($pages) ) {
                $output = "<select name=\"$name\" id=\"$name\">\n";
@@ -739,7 +734,7 @@ function wp_list_pages($args = '') {
                'child_of' => 0, 'exclude' => '',
                'title_li' => __('Pages'), 'echo' => 1,
                'authors' => '', 'sort_column' => 'menu_order, post_title',
-               'link_before' => '', 'link_after' => ''
+               'link_before' => '', 'link_after' => '', 'walker' => '',
        );
 
        $r = wp_parse_args( $args, $defaults );
@@ -751,8 +746,9 @@ function wp_list_pages($args = '') {
        // sanitize, mostly to keep spaces out
        $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
 
-       // Allow plugins to filter an array of excluded pages
-       $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
+       // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
+       $exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();
+       $r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );
 
        // Query pages.
        $r['hierarchical'] = 0;
@@ -771,7 +767,7 @@ function wp_list_pages($args = '') {
                        $output .= '</ul></li>';
        }
 
-       $output = apply_filters('wp_list_pages', $output);
+       $output = apply_filters('wp_list_pages', $output, $r);
 
        if ( $r['echo'] )
                echo $output;
@@ -805,7 +801,7 @@ function wp_list_pages($args = '') {
  * @param array|string $args
  */
 function wp_page_menu( $args = array() ) {
-       $defaults = array('sort_column' => 'post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
+       $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
        $args = wp_parse_args( $args, $defaults );
        $args = apply_filters( 'wp_page_menu_args', $args );
 
@@ -822,7 +818,7 @@ function wp_page_menu( $args = array() ) {
                $class = '';
                if ( is_front_page() && !is_paged() )
                        $class = 'class="current_page_item"';
-               $menu .= '<li ' . $class . '><a href="' . get_option('home') . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
+               $menu .= '<li ' . $class . '><a href="' . get_option('home') . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
                // If the front page is a page, add it to the exclude list
                if (get_option('show_on_front') == 'page') {
                        if ( !empty( $list_args['exclude'] ) ) {
@@ -841,7 +837,7 @@ function wp_page_menu( $args = array() ) {
        if ( $menu )
                $menu = '<ul>' . $menu . '</ul>';
 
-       $menu = '<div class="' . $args['menu_class'] . '">' . $menu . "</div>\n";
+       $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
        $menu = apply_filters( 'wp_page_menu', $menu, $args );
        if ( $args['echo'] )
                echo $menu;