Make WordPress Core

Ticket #23254: post-template.php.patch

File post-template.php.patch, 46.5 KB (added by cais, 12 years ago)
  • wp-includes/post-template.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
    <+><?php\n/**\n * WordPress Post Template Functions.\n *\n * Gets content for the current post in the loop.\n *\n * @package WordPress\n * @subpackage Template\n */\n\n/**\n * Display the ID of the current item in the WordPress Loop.\n *\n * @since 0.71\n */\nfunction the_ID() {\n\techo get_the_ID();\n}\n\n/**\n * Retrieve the ID of the current item in the WordPress Loop.\n *\n * @since 2.1.0\n * @uses $post\n *\n * @return int\n */\nfunction get_the_ID() {\n\treturn get_post()->ID;\n}\n\n/**\n * Display or retrieve the current post title with optional content.\n *\n * @since 0.71\n *\n * @param string $before Optional. Content to prepend to the title.\n * @param string $after Optional. Content to append to the title.\n * @param bool $echo Optional, default to true.Whether to display or return.\n * @return null|string Null on no title. String if $echo parameter is false.\n */\nfunction the_title($before = '', $after = '', $echo = true) {\n\t$title = get_the_title();\n\n\tif ( strlen($title) == 0 )\n\t\treturn;\n\n\t$title = $before . $title . $after;\n\n\tif ( $echo )\n\t\techo $title;\n\telse\n\t\treturn $title;\n}\n\n/**\n * Sanitize the current title when retrieving or displaying.\n *\n * Works like {@link the_title()}, except the parameters can be in a string or\n * an array. See the function for what can be override in the $args parameter.\n *\n * The title before it is displayed will have the tags stripped and {@link\n * esc_attr()} before it is passed to the user or displayed. The default\n * as with {@link the_title()}, is to display the title.\n *\n * @since 2.3.0\n *\n * @param string|array $args Optional. Override the defaults.\n * @return string|null Null on failure or display. String when echo is false.\n */\nfunction the_title_attribute( $args = '' ) {\n\t$title = get_the_title();\n\n\tif ( strlen($title) == 0 )\n\t\treturn;\n\n\t$defaults = array('before' => '', 'after' =>  '', 'echo' => true);\n\t$r = wp_parse_args($args, $defaults);\n\textract( $r, EXTR_SKIP );\n\n\t$title = $before . $title . $after;\n\t$title = esc_attr(strip_tags($title));\n\n\tif ( $echo )\n\t\techo $title;\n\telse\n\t\treturn $title;\n}\n\n/**\n * Retrieve post title.\n *\n * If the post is protected and the visitor is not an admin, then \"Protected\"\n * will be displayed before the post title. If the post is private, then\n * \"Private\" will be located before the post title.\n *\n * @since 0.71\n *\n * @param mixed $post Optional. Post ID or object.\n * @return string\n */\nfunction get_the_title( $post = 0 ) {\n\t$post = get_post( $post );\n\n\t$title = isset( $post->post_title ) ? $post->post_title : '';\n\t$id = isset( $post->ID ) ? $post->ID : 0;\n\n\tif ( ! is_admin() ) {\n\t\tif ( ! empty( $post->post_password ) ) {\n\t\t\t$protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) );\n\t\t\t$title = sprintf( $protected_title_format, $title );\n\t\t} else if ( isset( $post->post_status ) && 'private' == $post->post_status ) {\n\t\t\t$private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) );\n\t\t\t$title = sprintf( $private_title_format, $title );\n\t\t}\n\t}\n\n\treturn apply_filters( 'the_title', $title, $id );\n}\n\n/**\n * Display the Post Global Unique Identifier (guid).\n *\n * The guid will appear to be a link, but should not be used as an link to the\n * post. The reason you should not use it as a link, is because of moving the\n * blog across domains.\n *\n * Url is escaped to make it xml safe\n *\n * @since 1.5.0\n *\n * @param int $id Optional. Post ID.\n */\nfunction the_guid( $id = 0 ) {\n\techo esc_url( get_the_guid( $id ) );\n}\n\n/**\n * Retrieve the Post Global Unique Identifier (guid).\n *\n * The guid will appear to be a link, but should not be used as an link to the\n * post. The reason you should not use it as a link, is because of moving the\n * blog across domains.\n *\n * @since 1.5.0\n *\n * @param int $id Optional. Post ID.\n * @return string\n */\nfunction get_the_guid( $id = 0 ) {\n\t$post = get_post($id);\n\n\treturn apply_filters('get_the_guid', $post->guid);\n}\n\n/**\n * Display the post content.\n *\n * @since 0.71\n *\n * @param string $more_link_text Optional. Content for when there is more text.\n * @param bool $stripteaser Optional. Strip teaser content before the more text. Default is false.\n */\nfunction the_content($more_link_text = null, $stripteaser = false) {\n\t$content = get_the_content($more_link_text, $stripteaser);\n\t$content = apply_filters('the_content', $content);\n\t$content = str_replace(']]>', ']]&gt;', $content);\n\techo $content;\n}\n\n/**\n * Retrieve the post content.\n *\n * @since 0.71\n *\n * @param string $more_link_text Optional. Content for when there is more text.\n * @param bool $stripteaser Optional. Strip teaser content before the more text. Default is false.\n * @return string\n */\nfunction get_the_content( $more_link_text = null, $stripteaser = false ) {\n\tglobal $more, $page, $pages, $multipage, $preview;\n\n\t$post = get_post();\n\n\tif ( null === $more_link_text )\n\t\t$more_link_text = __( '(more...)' );\n\n\t$output = '';\n\t$hasTeaser = false;\n\n\t// If post password required and it doesn't match the cookie.\n\tif ( post_password_required() )\n\t\treturn get_the_password_form();\n\n\tif ( $page > count($pages) ) // if the requested page doesn't exist\n\t\t$page = count($pages); // give them the highest numbered page that DOES exist\n\n\t$content = $pages[$page-1];\n\tif ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) {\n\t\t$content = explode($matches[0], $content, 2);\n\t\tif ( !empty($matches[1]) && !empty($more_link_text) )\n\t\t\t$more_link_text = strip_tags(wp_kses_no_null(trim($matches[1])));\n\n\t\t$hasTeaser = true;\n\t} else {\n\t\t$content = array($content);\n\t}\n\tif ( (false !== strpos($post->post_content, '<!--noteaser-->') && ((!$multipage) || ($page==1))) )\n\t\t$stripteaser = true;\n\t$teaser = $content[0];\n\tif ( $more && $stripteaser && $hasTeaser )\n\t\t$teaser = '';\n\t$output .= $teaser;\n\tif ( count($content) > 1 ) {\n\t\tif ( $more ) {\n\t\t\t$output .= '<span id=\"more-' . $post->ID . '\"></span>' . $content[1];\n\t\t} else {\n\t\t\tif ( ! empty($more_link_text) )\n\t\t\t\t$output .= apply_filters( 'the_content_more_link', ' <a href=\"' . get_permalink() . \"#more-{$post->ID}\\\" class=\\\"more-link\\\">$more_link_text</a>\", $more_link_text );\n\t\t\t$output = force_balance_tags($output);\n\t\t}\n\n\t}\n\tif ( $preview ) // preview fix for javascript bug with foreign languages\n\t\t$output =\tpreg_replace_callback('/\\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output);\n\n\treturn $output;\n}\n\n/**\n * Preview fix for javascript bug with foreign languages\n *\n * @since 3.1.0\n * @access private\n * @param array $match Match array from preg_replace_callback\n * @return string\n */\nfunction _convert_urlencoded_to_entities( $match ) {\n\treturn '&#' . base_convert( $match[1], 16, 10 ) . ';';\n}\n\n/**\n * Display the post excerpt.\n *\n * @since 0.71\n * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt.\n */\nfunction the_excerpt() {\n\techo apply_filters('the_excerpt', get_the_excerpt());\n}\n\n/**\n * Retrieve the post excerpt.\n *\n * @since 0.71\n *\n * @param mixed $deprecated Not used.\n * @return string\n */\nfunction get_the_excerpt( $deprecated = '' ) {\n\tif ( !empty( $deprecated ) )\n\t\t_deprecated_argument( __FUNCTION__, '2.3' );\n\n\t$post = get_post();\n\n\tif ( post_password_required() ) {\n\t\treturn __( 'There is no excerpt because this is a protected post.' );\n\t}\n\n\treturn apply_filters( 'get_the_excerpt', $post->post_excerpt );\n}\n\n/**\n * Whether post has excerpt.\n *\n * @since 2.3.0\n *\n * @param int $id Optional. Post ID.\n * @return bool\n */\nfunction has_excerpt( $id = 0 ) {\n\t$post = get_post( $id );\n\treturn ( !empty( $post->post_excerpt ) );\n}\n\n/**\n * Display the classes for the post div.\n *\n * @since 2.7.0\n *\n * @param string|array $class One or more classes to add to the class list.\n * @param int $post_id An optional post ID.\n */\nfunction post_class( $class = '', $post_id = null ) {\n\t// Separates classes with a single space, collates classes for post DIV\n\techo 'class=\"' . join( ' ', get_post_class( $class, $post_id ) ) . '\"';\n}\n\n/**\n * Retrieve the classes for the post div as an array.\n *\n * The class names are add are many. If the post is a sticky, then the 'sticky'\n * class name. The class 'hentry' is always added to each post. For each\n * category, the class will be added with 'category-' with category slug is\n * added. The tags are the same way as the categories with 'tag-' before the tag\n * slug. All classes are passed through the filter, 'post_class' with the list\n * of classes, followed by $class parameter value, with the post ID as the last\n * parameter.\n *\n * @since 2.7.0\n *\n * @param string|array $class One or more classes to add to the class list.\n * @param int $post_id An optional post ID.\n * @return array Array of classes.\n */\nfunction get_post_class( $class = '', $post_id = null ) {\n\t$post = get_post($post_id);\n\n\t$classes = array();\n\n\tif ( empty($post) )\n\t\treturn $classes;\n\n\t$classes[] = 'post-' . $post->ID;\n\tif ( ! is_admin() )\n\t\t$classes[] = $post->post_type;\n\t$classes[] = 'type-' . $post->post_type;\n\t$classes[] = 'status-' . $post->post_status;\n\n\t// Post Format\n\tif ( post_type_supports( $post->post_type, 'post-formats' ) ) {\n\t\t$post_format = get_post_format( $post->ID );\n\n\t\tif ( $post_format && !is_wp_error($post_format) )\n\t\t\t$classes[] = 'format-' . sanitize_html_class( $post_format );\n\t\telse\n\t\t\t$classes[] = 'format-standard';\n\t}\n\n\t// post requires password\n\tif ( post_password_required($post->ID) )\n\t\t$classes[] = 'post-password-required';\n\n\t// sticky for Sticky Posts\n\tif ( is_sticky($post->ID) && is_home() && !is_paged() )\n\t\t$classes[] = 'sticky';\n\n\t// hentry for hAtom compliance\n\t$classes[] = 'hentry';\n\n\t// Categories\n\tif ( is_object_in_taxonomy( $post->post_type, 'category' ) ) {\n\t\tforeach ( (array) get_the_category($post->ID) as $cat ) {\n\t\t\tif ( empty($cat->slug ) )\n\t\t\t\tcontinue;\n\t\t\t$classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->term_id);\n\t\t}\n\t}\n\n\t// Tags\n\tif ( is_object_in_taxonomy( $post->post_type, 'post_tag' ) ) {\n\t\tforeach ( (array) get_the_tags($post->ID) as $tag ) {\n\t\t\tif ( empty($tag->slug ) )\n\t\t\t\tcontinue;\n\t\t\t$classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id);\n\t\t}\n\t}\n\n\tif ( !empty($class) ) {\n\t\tif ( !is_array( $class ) )\n\t\t\t$class = preg_split('#\\s+#', $class);\n\t\t$classes = array_merge($classes, $class);\n\t}\n\n\t$classes = array_map('esc_attr', $classes);\n\n\treturn apply_filters('post_class', $classes, $class, $post->ID);\n}\n\n/**\n * Display the classes for the body element.\n *\n * @since 2.8.0\n *\n * @param string|array $class One or more classes to add to the class list.\n */\nfunction body_class( $class = '' ) {\n\t// Separates classes with a single space, collates classes for body element\n\techo 'class=\"' . join( ' ', get_body_class( $class ) ) . '\"';\n}\n\n/**\n * Retrieve the classes for the body element as an array.\n *\n * @since 2.8.0\n *\n * @param string|array $class One or more classes to add to the class list.\n * @return array Array of classes.\n */\nfunction get_body_class( $class = '' ) {\n\tglobal $wp_query, $wpdb;\n\n\t$classes = array();\n\n\tif ( is_rtl() )\n\t\t$classes[] = 'rtl';\n\n\tif ( is_front_page() )\n\t\t$classes[] = 'home';\n\tif ( is_home() )\n\t\t$classes[] = 'blog';\n\tif ( is_archive() )\n\t\t$classes[] = 'archive';\n\tif ( is_date() )\n\t\t$classes[] = 'date';\n\tif ( is_search() ) {\n\t\t$classes[] = 'search';\n\t\t$classes[] = $wp_query->posts ? 'search-results' : 'search-no-results';\n\t}\n\tif ( is_paged() )\n\t\t$classes[] = 'paged';\n\tif ( is_attachment() )\n\t\t$classes[] = 'attachment';\n\tif ( is_404() )\n\t\t$classes[] = 'error404';\n\n\tif ( is_single() ) {\n\t\t$post_id = $wp_query->get_queried_object_id();\n\t\t$post = $wp_query->get_queried_object();\n\n\t\t$classes[] = 'single';\n\t\tif ( isset( $post->post_type ) ) {\n\t\t\t$classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id);\n\t\t\t$classes[] = 'postid-' . $post_id;\n\n\t\t\t// Post Format\n\t\t\tif ( post_type_supports( $post->post_type, 'post-formats' ) ) {\n\t\t\t\t$post_format = get_post_format( $post->ID );\n\n\t\t\t\tif ( $post_format && !is_wp_error($post_format) )\n\t\t\t\t\t$classes[] = 'single-format-' . sanitize_html_class( $post_format );\n\t\t\t\telse\n\t\t\t\t\t$classes[] = 'single-format-standard';\n\t\t\t}\n\t\t}\n\n\t\tif ( is_attachment() ) {\n\t\t\t$mime_type = get_post_mime_type($post_id);\n\t\t\t$mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );\n\t\t\t$classes[] = 'attachmentid-' . $post_id;\n\t\t\t$classes[] = 'attachment-' . str_replace( $mime_prefix, '', $mime_type );\n\t\t}\n\t} elseif ( is_archive() ) {\n\t\tif ( is_post_type_archive() ) {\n\t\t\t$classes[] = 'post-type-archive';\n\t\t\t$classes[] = 'post-type-archive-' . sanitize_html_class( get_query_var( 'post_type' ) );\n\t\t} else if ( is_author() ) {\n\t\t\t$author = $wp_query->get_queried_object();\n\t\t\t$classes[] = 'author';\n\t\t\tif ( isset( $author->user_nicename ) ) {\n\t\t\t\t$classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID );\n\t\t\t\t$classes[] = 'author-' . $author->ID;\n\t\t\t}\n\t\t} elseif ( is_category() ) {\n\t\t\t$cat = $wp_query->get_queried_object();\n\t\t\t$classes[] = 'category';\n\t\t\tif ( isset( $cat->term_id ) ) {\n\t\t\t\t$classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->term_id );\n\t\t\t\t$classes[] = 'category-' . $cat->term_id;\n\t\t\t}\n\t\t} elseif ( is_tag() ) {\n\t\t\t$tags = $wp_query->get_queried_object();\n\t\t\t$classes[] = 'tag';\n\t\t\tif ( isset( $tags->term_id ) ) {\n\t\t\t\t$classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id );\n\t\t\t\t$classes[] = 'tag-' . $tags->term_id;\n\t\t\t}\n\t\t} elseif ( is_tax() ) {\n\t\t\t$term = $wp_query->get_queried_object();\n\t\t\tif ( isset( $term->term_id ) ) {\n\t\t\t\t$classes[] = 'tax-' . sanitize_html_class( $term->taxonomy );\n\t\t\t\t$classes[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id );\n\t\t\t\t$classes[] = 'term-' . $term->term_id;\n\t\t\t}\n\t\t}\n\t} elseif ( is_page() ) {\n\t\t$classes[] = 'page';\n\n\t\t$page_id = $wp_query->get_queried_object_id();\n\n\t\t$post = get_post($page_id);\n\n\t\t$classes[] = 'page-id-' . $page_id;\n\n\t\tif ( $wpdb->get_var( $wpdb->prepare(\"SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status = 'publish' LIMIT 1\", $page_id) ) )\n\t\t\t$classes[] = 'page-parent';\n\n\t\tif ( $post->post_parent ) {\n\t\t\t$classes[] = 'page-child';\n\t\t\t$classes[] = 'parent-pageid-' . $post->post_parent;\n\t\t}\n\t\tif ( is_page_template() ) {\n\t\t\t$classes[] = 'page-template';\n\t\t\t$classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_page_template_slug( $page_id ) ) );\n\t\t} else {\n\t\t\t$classes[] = 'page-template-default';\n\t\t}\n\t}\n\n\tif ( is_user_logged_in() )\n\t\t$classes[] = 'logged-in';\n\n\tif ( is_admin_bar_showing() ) {\n\t\t$classes[] = 'admin-bar';\n\t\t$classes[] = 'no-customize-support';\n\t}\n\n\tif ( get_theme_mod( 'background_color' ) || get_background_image() )\n\t\t$classes[] = 'custom-background';\n\n\t$page = $wp_query->get( 'page' );\n\n\tif ( !$page || $page < 2)\n\t\t$page = $wp_query->get( 'paged' );\n\n\tif ( $page && $page > 1 ) {\n\t\t$classes[] = 'paged-' . $page;\n\n\t\tif ( is_single() )\n\t\t\t$classes[] = 'single-paged-' . $page;\n\t\telseif ( is_page() )\n\t\t\t$classes[] = 'page-paged-' . $page;\n\t\telseif ( is_category() )\n\t\t\t$classes[] = 'category-paged-' . $page;\n\t\telseif ( is_tag() )\n\t\t\t$classes[] = 'tag-paged-' . $page;\n\t\telseif ( is_date() )\n\t\t\t$classes[] = 'date-paged-' . $page;\n\t\telseif ( is_author() )\n\t\t\t$classes[] = 'author-paged-' . $page;\n\t\telseif ( is_search() )\n\t\t\t$classes[] = 'search-paged-' . $page;\n\t\telseif ( is_post_type_archive() )\n\t\t\t$classes[] = 'post-type-paged-' . $page;\n\t}\n\n\tif ( ! empty( $class ) ) {\n\t\tif ( !is_array( $class ) )\n\t\t\t$class = preg_split( '#\\s+#', $class );\n\t\t$classes = array_merge( $classes, $class );\n\t} else {\n\t\t// Ensure that we always coerce class to being an array.\n\t\t$class = array();\n\t}\n\n\t$classes = array_map( 'esc_attr', $classes );\n\n\treturn apply_filters( 'body_class', $classes, $class );\n}\n\n/**\n * Whether post requires password and correct password has been provided.\n *\n * @since 2.7.0\n *\n * @param int|object $post An optional post. Global $post used if not provided.\n * @return bool false if a password is not required or the correct password cookie is present, true otherwise.\n */\nfunction post_password_required( $post = null ) {\n\tglobal $wp_hasher;\n\n\t$post = get_post($post);\n\n\tif ( empty( $post->post_password ) )\n\t\treturn false;\n\n\tif ( ! isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )\n\t\treturn true;\n\n\tif ( empty( $wp_hasher ) ) {\n\t\trequire_once( ABSPATH . 'wp-includes/class-phpass.php');\n\t\t// By default, use the portable hash from phpass\n\t\t$wp_hasher = new PasswordHash(8, true);\n\t}\n\n\t$hash = stripslashes( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );\n\n\treturn ! $wp_hasher->CheckPassword( $post->post_password, $hash );\n}\n\n/**\n * Page Template Functions for usage in Themes\n *\n * @package WordPress\n * @subpackage Template\n */\n\n/**\n * The formatted output of a list of pages.\n *\n * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.\n * Quicktag one or more times). This tag must be within The Loop.\n *\n * The defaults for overwriting are:\n * 'next_or_number' - Default is 'number' (string). Indicates whether page\n *      numbers should be used. Valid values are number and next.\n * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page.\n *      of the bookmark.\n * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to\n *      previous page, if available.\n * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in\n *      the parameter string will be replaced with the page number, so Page %\n *      generates \"Page 1\", \"Page 2\", etc. Defaults to %, just the page number.\n * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to\n *      each bookmarks.\n * 'after' - Default is '</p>' (string). The html or text to append to each\n *      bookmarks.\n * 'link_before' - Default is '' (string). The html or text to prepend to each\n *      Pages link inside the <a> tag. Also prepended to the current item, which\n *      is not linked.\n * 'link_after' - Default is '' (string). The html or text to append to each\n *      Pages link inside the <a> tag. Also appended to the current item, which\n *      is not linked.\n *\n * @since 1.2.0\n * @access private\n *\n * @param string|array $args Optional. Overwrite the defaults.\n * @return string Formatted output in HTML.\n */\nfunction wp_link_pages($args = '') {\n\t$defaults = array(\n\t\t'before' => '<p>' . __('Pages:'), 'after' => '</p>',\n\t\t'link_before' => '', 'link_after' => '',\n\t\t'next_or_number' => 'number', 'nextpagelink' => __('Next page'),\n\t\t'previouspagelink' => __('Previous page'), 'pagelink' => '%',\n\t\t'echo' => 1\n\t);\n\n\t$r = wp_parse_args( $args, $defaults );\n\t$r = apply_filters( 'wp_link_pages_args', $r );\n\textract( $r, EXTR_SKIP );\n\n\tglobal $page, $numpages, $multipage, $more, $pagenow;\n\n\t$output = '';\n\tif ( $multipage ) {\n\t\tif ( 'number' == $next_or_number ) {\n\t\t\t$output .= $before;\n\t\t\tfor ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {\n\t\t\t\t$j = str_replace('%',$i,$pagelink);\n\t\t\t\t$output .= ' ';\n\t\t\t\tif ( ($i != $page) || ((!$more) && ($page==1)) ) {\n\t\t\t\t\t$output .= _wp_link_page($i);\n\t\t\t\t}\n\t\t\t\t$output .= $link_before . $j . $link_after;\n\t\t\t\tif ( ($i != $page) || ((!$more) && ($page==1)) )\n\t\t\t\t\t$output .= '</a>';\n\t\t\t}\n\t\t\t$output .= $after;\n\t\t} else {\n\t\t\tif ( $more ) {\n\t\t\t\t$output .= $before;\n\t\t\t\t$i = $page - 1;\n\t\t\t\tif ( $i && $more ) {\n\t\t\t\t\t$output .= _wp_link_page($i);\n\t\t\t\t\t$output .= $link_before. $previouspagelink . $link_after . '</a>';\n\t\t\t\t}\n\t\t\t\t$i = $page + 1;\n\t\t\t\tif ( $i <= $numpages && $more ) {\n\t\t\t\t\t$output .= _wp_link_page($i);\n\t\t\t\t\t$output .= $link_before. $nextpagelink . $link_after . '</a>';\n\t\t\t\t}\n\t\t\t\t$output .= $after;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( $echo )\n\t\techo $output;\n\n\treturn $output;\n}\n\n/**\n * Helper function for wp_link_pages().\n *\n * @since 3.1.0\n * @access private\n *\n * @param int $i Page number.\n * @return string Link.\n */\nfunction _wp_link_page( $i ) {\n\tglobal $wp_rewrite;\n\t$post = get_post();\n\n\tif ( 1 == $i ) {\n\t\t$url = get_permalink();\n\t} else {\n\t\tif ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )\n\t\t\t$url = add_query_arg( 'page', $i, get_permalink() );\n\t\telseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )\n\t\t\t$url = trailingslashit(get_permalink()) . user_trailingslashit(\"$wp_rewrite->pagination_base/\" . $i, 'single_paged');\n\t\telse\n\t\t\t$url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');\n\t}\n\n\treturn '<a href=\"' . esc_url( $url ) . '\">';\n}\n\n//\n// Post-meta: Custom per-post fields.\n//\n\n/**\n * Retrieve post custom meta data field.\n *\n * @since 1.5.0\n *\n * @param string $key Meta data key name.\n * @return bool|string|array Array of values or single value, if only one element exists. False will be returned if key does not exist.\n */\nfunction post_custom( $key = '' ) {\n\t$custom = get_post_custom();\n\n\tif ( !isset( $custom[$key] ) )\n\t\treturn false;\n\telseif ( 1 == count($custom[$key]) )\n\t\treturn $custom[$key][0];\n\telse\n\t\treturn $custom[$key];\n}\n\n/**\n * Display list of post custom fields.\n *\n * @internal This will probably change at some point...\n * @since 1.2.0\n * @uses apply_filters() Calls 'the_meta_key' on list item HTML content, with key and value as separate parameters.\n */\nfunction the_meta() {\n\tif ( $keys = get_post_custom_keys() ) {\n\t\techo \"<ul class='post-meta'>\\n\";\n\t\tforeach ( (array) $keys as $key ) {\n\t\t\t$keyt = trim($key);\n\t\t\tif ( is_protected_meta( $keyt, 'post' ) )\n\t\t\t\tcontinue;\n\t\t\t$values = array_map('trim', get_post_custom_values($key));\n\t\t\t$value = implode($values,', ');\n\t\t\techo apply_filters('the_meta_key', \"<li><span class='post-meta-key'>$key:</span> $value</li>\\n\", $key, $value);\n\t\t}\n\t\techo \"</ul>\\n\";\n\t}\n}\n\n//\n// Pages\n//\n\n/**\n * Retrieve or display list of pages as a dropdown (select list).\n *\n * @since 2.1.0\n *\n * @param array|string $args Optional. Override default arguments.\n * @return string HTML content, if not displaying.\n */\nfunction wp_dropdown_pages($args = '') {\n\t$defaults = array(\n\t\t'depth' => 0, 'child_of' => 0,\n\t\t'selected' => 0, 'echo' => 1,\n\t\t'name' => 'page_id', 'id' => '',\n\t\t'show_option_none' => '', 'show_option_no_change' => '',\n\t\t'option_none_value' => ''\n\t);\n\n\t$r = wp_parse_args( $args, $defaults );\n\textract( $r, EXTR_SKIP );\n\n\t$pages = get_pages($r);\n\t$output = '';\n\t// Back-compat with old system where both id and name were based on $name argument\n\tif ( empty($id) )\n\t\t$id = $name;\n\n\tif ( ! empty($pages) ) {\n\t\t$output = \"<select name='\" . esc_attr( $name ) . \"' id='\" . esc_attr( $id ) . \"'>\\n\";\n\t\tif ( $show_option_no_change )\n\t\t\t$output .= \"\\t<option value=\\\"-1\\\">$show_option_no_change</option>\";\n\t\tif ( $show_option_none )\n\t\t\t$output .= \"\\t<option value=\\\"\" . esc_attr($option_none_value) . \"\\\">$show_option_none</option>\\n\";\n\t\t$output .= walk_page_dropdown_tree($pages, $depth, $r);\n\t\t$output .= \"</select>\\n\";\n\t}\n\n\t$output = apply_filters('wp_dropdown_pages', $output);\n\n\tif ( $echo )\n\t\techo $output;\n\n\treturn $output;\n}\n\n/**\n * Retrieve or display list of pages in list (li) format.\n *\n * @since 1.5.0\n *\n * @param array|string $args Optional. Override default arguments.\n * @return string HTML content, if not displaying.\n */\nfunction wp_list_pages($args = '') {\n\t$defaults = array(\n\t\t'depth' => 0, 'show_date' => '',\n\t\t'date_format' => get_option('date_format'),\n\t\t'child_of' => 0, 'exclude' => '',\n\t\t'title_li' => __('Pages'), 'echo' => 1,\n\t\t'authors' => '', 'sort_column' => 'menu_order, post_title',\n\t\t'link_before' => '', 'link_after' => '', 'walker' => '',\n\t);\n\n\t$r = wp_parse_args( $args, $defaults );\n\textract( $r, EXTR_SKIP );\n\n\t$output = '';\n\t$current_page = 0;\n\n\t// sanitize, mostly to keep spaces out\n\t$r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);\n\n\t// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)\n\t$exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();\n\t$r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );\n\n\t// Query pages.\n\t$r['hierarchical'] = 0;\n\t$pages = get_pages($r);\n\n\tif ( !empty($pages) ) {\n\t\tif ( $r['title_li'] )\n\t\t\t$output .= '<li class=\"pagenav\">' . $r['title_li'] . '<ul>';\n\n\t\tglobal $wp_query;\n\t\tif ( is_page() || is_attachment() || $wp_query->is_posts_page )\n\t\t\t$current_page = $wp_query->get_queried_object_id();\n\t\t$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);\n\n\t\tif ( $r['title_li'] )\n\t\t\t$output .= '</ul></li>';\n\t}\n\n\t$output = apply_filters('wp_list_pages', $output, $r);\n\n\tif ( $r['echo'] )\n\t\techo $output;\n\telse\n\t\treturn $output;\n}\n\n/**\n * Display or retrieve list of pages with optional home link.\n *\n * The arguments are listed below and part of the arguments are for {@link\n * wp_list_pages()} function. Check that function for more info on those\n * arguments.\n *\n * <ul>\n * <li><strong>sort_column</strong> - How to sort the list of pages. Defaults\n * to page title. Use column for posts table.</li>\n * <li><strong>menu_class</strong> - Class to use for the div ID which contains\n * the page list. Defaults to 'menu'.</li>\n * <li><strong>echo</strong> - Whether to echo list or return it. Defaults to\n * echo.</li>\n * <li><strong>link_before</strong> - Text before show_home argument text.</li>\n * <li><strong>link_after</strong> - Text after show_home argument text.</li>\n * <li><strong>show_home</strong> - If you set this argument, then it will\n * display the link to the home page. The show_home argument really just needs\n * to be set to the value of the text of the link.</li>\n * </ul>\n *\n * @since 2.7.0\n *\n * @param array|string $args\n * @return string html menu\n */\nfunction wp_page_menu( $args = array() ) {\n\t$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');\n\t$args = wp_parse_args( $args, $defaults );\n\t$args = apply_filters( 'wp_page_menu_args', $args );\n\n\t$menu = '';\n\n\t$list_args = $args;\n\n\t// Show Home in the menu\n\tif ( ! empty($args['show_home']) ) {\n\t\tif ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )\n\t\t\t$text = __('Home');\n\t\telse\n\t\t\t$text = $args['show_home'];\n\t\t$class = '';\n\t\tif ( is_front_page() && !is_paged() )\n\t\t\t$class = 'class=\"current_page_item\"';\n\t\t$menu .= '<li ' . $class . '><a href=\"' . home_url( '/' ) . '\" title=\"' . esc_attr($text) . '\">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';\n\t\t// If the front page is a page, add it to the exclude list\n\t\tif (get_option('show_on_front') == 'page') {\n\t\t\tif ( !empty( $list_args['exclude'] ) ) {\n\t\t\t\t$list_args['exclude'] .= ',';\n\t\t\t} else {\n\t\t\t\t$list_args['exclude'] = '';\n\t\t\t}\n\t\t\t$list_args['exclude'] .= get_option('page_on_front');\n\t\t}\n\t}\n\n\t$list_args['echo'] = false;\n\t$list_args['title_li'] = '';\n\t$menu .= str_replace( array( \"\\r\", \"\\n\", \"\\t\" ), '', wp_list_pages($list_args) );\n\n\tif ( $menu )\n\t\t$menu = '<ul>' . $menu . '</ul>';\n\n\t$menu = '<div class=\"' . esc_attr($args['menu_class']) . '\">' . $menu . \"</div>\\n\";\n\t$menu = apply_filters( 'wp_page_menu', $menu, $args );\n\tif ( $args['echo'] )\n\t\techo $menu;\n\telse\n\t\treturn $menu;\n}\n\n//\n// Page helpers\n//\n\n/**\n * Retrieve HTML list content for page list.\n *\n * @uses Walker_Page to create HTML list content.\n * @since 2.1.0\n * @see Walker_Page::walk() for parameters and return description.\n */\nfunction walk_page_tree($pages, $depth, $current_page, $r) {\n\tif ( empty($r['walker']) )\n\t\t$walker = new Walker_Page;\n\telse\n\t\t$walker = $r['walker'];\n\n\t$args = array($pages, $depth, $r, $current_page);\n\treturn call_user_func_array(array($walker, 'walk'), $args);\n}\n\n/**\n * Retrieve HTML dropdown (select) content for page list.\n *\n * @uses Walker_PageDropdown to create HTML dropdown content.\n * @since 2.1.0\n * @see Walker_PageDropdown::walk() for parameters and return description.\n */\nfunction walk_page_dropdown_tree() {\n\t$args = func_get_args();\n\tif ( empty($args[2]['walker']) ) // the user's options are the third parameter\n\t\t$walker = new Walker_PageDropdown;\n\telse\n\t\t$walker = $args[2]['walker'];\n\n\treturn call_user_func_array(array($walker, 'walk'), $args);\n}\n\n/**\n * Create HTML list of pages.\n *\n * @package WordPress\n * @since 2.1.0\n * @uses Walker\n */\nclass Walker_Page extends Walker {\n\t/**\n\t * @see Walker::$tree_type\n\t * @since 2.1.0\n\t * @var string\n\t */\n\tvar $tree_type = 'page';\n\n\t/**\n\t * @see Walker::$db_fields\n\t * @since 2.1.0\n\t * @todo Decouple this.\n\t * @var array\n\t */\n\tvar $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');\n\n\t/**\n\t * @see Walker::start_lvl()\n\t * @since 2.1.0\n\t *\n\t * @param string $output Passed by reference. Used to append additional content.\n\t * @param int $depth Depth of page. Used for padding.\n\t * @param array $args\n\t */\n\tfunction start_lvl( &$output, $depth = 0, $args = array() ) {\n\t\t$indent = str_repeat(\"\\t\", $depth);\n\t\t$output .= \"\\n$indent<ul class='children'>\\n\";\n\t}\n\n\t/**\n\t * @see Walker::end_lvl()\n\t * @since 2.1.0\n\t *\n\t * @param string $output Passed by reference. Used to append additional content.\n\t * @param int $depth Depth of page. Used for padding.\n\t * @param array $args\n\t */\n\tfunction end_lvl( &$output, $depth = 0, $args = array() ) {\n\t\t$indent = str_repeat(\"\\t\", $depth);\n\t\t$output .= \"$indent</ul>\\n\";\n\t}\n\n\t/**\n\t * @see Walker::start_el()\n\t * @since 2.1.0\n\t *\n\t * @param string $output Passed by reference. Used to append additional content.\n\t * @param object $page Page data object.\n\t * @param int $depth Depth of page. Used for padding.\n\t * @param int $current_page Page ID.\n\t * @param array $args\n\t */\n\tfunction start_el( &$output, $page, $depth, $args, $current_page = 0 ) {\n\t\tif ( $depth )\n\t\t\t$indent = str_repeat(\"\\t\", $depth);\n\t\telse\n\t\t\t$indent = '';\n\n\t\textract($args, EXTR_SKIP);\n\t\t$css_class = array('page_item', 'page-item-'.$page->ID);\n\t\tif ( !empty($current_page) ) {\n\t\t\t$_current_page = get_post( $current_page );\n\t\t\tif ( in_array( $page->ID, $_current_page->ancestors ) )\n\t\t\t\t$css_class[] = 'current_page_ancestor';\n\t\t\tif ( $page->ID == $current_page )\n\t\t\t\t$css_class[] = 'current_page_item';\n\t\t\telseif ( $_current_page && $page->ID == $_current_page->post_parent )\n\t\t\t\t$css_class[] = 'current_page_parent';\n\t\t} elseif ( $page->ID == get_option('page_for_posts') ) {\n\t\t\t$css_class[] = 'current_page_parent';\n\t\t}\n\n\t\t$css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );\n\n\t\t$output .= $indent . '<li class=\"' . $css_class . '\"><a href=\"' . get_permalink($page->ID) . '\">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>';\n\n\t\tif ( !empty($show_date) ) {\n\t\t\tif ( 'modified' == $show_date )\n\t\t\t\t$time = $page->post_modified;\n\t\t\telse\n\t\t\t\t$time = $page->post_date;\n\n\t\t\t$output .= \" \" . mysql2date($date_format, $time);\n\t\t}\n\t}\n\n\t/**\n\t * @see Walker::end_el()\n\t * @since 2.1.0\n\t *\n\t * @param string $output Passed by reference. Used to append additional content.\n\t * @param object $page Page data object. Not used.\n\t * @param int $depth Depth of page. Not Used.\n\t * @param array $args\n\t */\n\tfunction end_el( &$output, $page, $depth = 0, $args = array() ) {\n\t\t$output .= \"</li>\\n\";\n\t}\n\n}\n\n/**\n * Create HTML dropdown list of pages.\n *\n * @package WordPress\n * @since 2.1.0\n * @uses Walker\n */\nclass Walker_PageDropdown extends Walker {\n\t/**\n\t * @see Walker::$tree_type\n\t * @since 2.1.0\n\t * @var string\n\t */\n\tvar $tree_type = 'page';\n\n\t/**\n\t * @see Walker::$db_fields\n\t * @since 2.1.0\n\t * @todo Decouple this\n\t * @var array\n\t */\n\tvar $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');\n\n\t/**\n\t * @see Walker::start_el()\n\t * @since 2.1.0\n\t *\n\t * @param string $output Passed by reference. Used to append additional content.\n\t * @param object $page Page data object.\n\t * @param int $depth Depth of page in reference to parent pages. Used for padding.\n\t * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.\n\t * @param int $id\n\t */\n\tfunction start_el(&$output, $page, $depth, $args, $id = 0) {\n\t\t$pad = str_repeat('&nbsp;', $depth * 3);\n\n\t\t$output .= \"\\t<option class=\\\"level-$depth\\\" value=\\\"$page->ID\\\"\";\n\t\tif ( $page->ID == $args['selected'] )\n\t\t\t$output .= ' selected=\"selected\"';\n\t\t$output .= '>';\n\t\t$title = apply_filters( 'list_pages', $page->post_title, $page );\n\t\t$output .= $pad . esc_html( $title );\n\t\t$output .= \"</option>\\n\";\n\t}\n}\n\n//\n// Attachments\n//\n\n/**\n * Display an attachment page link using an image or icon.\n *\n * @since 2.0.0\n *\n * @param int $id Optional. Post ID.\n * @param bool $fullsize Optional, default is false. Whether to use full size.\n * @param bool $deprecated Deprecated. Not used.\n * @param bool $permalink Optional, default is false. Whether to include permalink.\n */\nfunction the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {\n\tif ( !empty( $deprecated ) )\n\t\t_deprecated_argument( __FUNCTION__, '2.5' );\n\n\tif ( $fullsize )\n\t\techo wp_get_attachment_link($id, 'full', $permalink);\n\telse\n\t\techo wp_get_attachment_link($id, 'thumbnail', $permalink);\n}\n\n/**\n * Retrieve an attachment page link using an image or icon, if possible.\n *\n * @since 2.5.0\n * @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.\n *\n * @param int $id Optional. Post ID.\n * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string.\n * @param bool $permalink Optional, default is false. Whether to add permalink to image.\n * @param bool $icon Optional, default is false. Whether to include icon.\n * @param string|bool $text Optional, default is false. If string, then will be link text.\n * @return string HTML content.\n */\nfunction wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {\n\t$id = intval( $id );\n\t$_post = get_post( $id );\n\n\tif ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )\n\t\treturn __( 'Missing Attachment' );\n\n\tif ( $permalink )\n\t\t$url = get_attachment_link( $_post->ID );\n\n\t$post_title = esc_attr( $_post->post_title );\n\n\tif ( $text )\n\t\t$link_text = $text;\n\telseif ( $size && 'none' != $size )\n\t\t$link_text = wp_get_attachment_image( $id, $size, $icon );\n\telse\n\t\t$link_text = '';\n\n\tif ( trim( $link_text ) == '' )\n\t\t$link_text = $_post->post_title;\n\n\treturn apply_filters( 'wp_get_attachment_link', \"<a href='$url' title='$post_title'>$link_text</a>\", $id, $size, $permalink, $icon, $text );\n}\n\n/**\n * Wrap attachment in <<p>> element before content.\n *\n * @since 2.0.0\n * @uses apply_filters() Calls 'prepend_attachment' hook on HTML content.\n *\n * @param string $content\n * @return string\n */\nfunction prepend_attachment($content) {\n\t$post = get_post();\n\n\tif ( empty($post->post_type) || $post->post_type != 'attachment' )\n\t\treturn $content;\n\n\t$p = '<p class=\"attachment\">';\n\t// show the medium sized image representation of the attachment if available, and link to the raw file\n\t$p .= wp_get_attachment_link(0, 'medium', false);\n\t$p .= '</p>';\n\t$p = apply_filters('prepend_attachment', $p);\n\n\treturn \"$p\\n$content\";\n}\n\n//\n// Misc\n//\n\n/**\n * Retrieve protected post password form content.\n *\n * @since 1.0.0\n * @uses apply_filters() Calls 'the_password_form' filter on output.\n *\n * @return string HTML content for password form for password protected post.\n */\nfunction get_the_password_form() {\n\t$post = get_post();\n\t$label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );\n\t$output = '<form action=\"' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '\" method=\"post\">\n\t<p>' . __(\"This post is password protected. To view it please enter your password below:\") . '</p>\n\t<p><label for=\"' . $label . '\">' . __(\"Password:\") . ' <input name=\"post_password\" id=\"' . $label . '\" type=\"password\" size=\"20\" /></label> <input type=\"submit\" name=\"Submit\" value=\"' . esc_attr__(\"Submit\") . '\" /></p>\n</form>\n\t';\n\treturn apply_filters('the_password_form', $output);\n}\n\n/**\n * Whether currently in a page template.\n *\n * This template tag allows you to determine if you are in a page template.\n * You can optionally provide a template name and then the check will be\n * specific to that template.\n *\n * @since 2.5.0\n * @uses $wp_query\n *\n * @param string $template The specific template name if specific matching is required.\n * @return bool False on failure, true if success.\n */\nfunction is_page_template( $template = '' ) {\n\tif ( ! is_page() )\n\t\treturn false;\n\n\t$page_template = get_page_template_slug( get_queried_object_id() );\n\n\tif ( empty( $template ) )\n\t\treturn (bool) $page_template;\n\n\tif ( $template == $page_template )\n\t\treturn true;\n\n\tif ( 'default' == $template && ! $page_template )\n\t\treturn true;\n\n\treturn false;\n}\n\n/**\n * Get the specific template name for a page.\n *\n * @since 3.4.0\n *\n * @param int $post_id The page ID to check. Defaults to the current post, when used in the loop.\n * @return string|bool Page template filename. Returns an empty string when the default page template\n * \tis in use. Returns false if the post is not a page.\n */\nfunction get_page_template_slug( $post_id = null ) {\n\t$post = get_post( $post_id );\n\tif ( 'page' != $post->post_type )\n\t\treturn false;\n\t$template = get_post_meta( $post->ID, '_wp_page_template', true );\n\tif ( ! $template || 'default' == $template )\n\t\treturn '';\n\treturn $template;\n}\n\n/**\n * Retrieve formatted date timestamp of a revision (linked to that revisions's page).\n *\n * @package WordPress\n * @subpackage Post_Revisions\n * @since 2.6.0\n *\n * @uses date_i18n()\n *\n * @param int|object $revision Revision ID or revision object.\n * @param bool $link Optional, default is true. Link to revisions's page?\n * @return string i18n formatted datetimestamp or localized 'Current Revision'.\n */\nfunction wp_post_revision_title( $revision, $link = true ) {\n\tif ( !$revision = get_post( $revision ) )\n\t\treturn $revision;\n\n\tif ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )\n\t\treturn false;\n\n\t/* translators: revision date format, see http://php.net/date */\n\t$datef = _x( 'j F, Y @ G:i', 'revision date format');\n\t/* translators: 1: date */\n\t$autosavef = __( '%1$s [Autosave]' );\n\t/* translators: 1: date */\n\t$currentf  = __( '%1$s [Current Revision]' );\n\n\t$date = date_i18n( $datef, strtotime( $revision->post_modified ) );\n\tif ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )\n\t\t$date = \"<a href='$link'>$date</a>\";\n\n\tif ( !wp_is_post_revision( $revision ) )\n\t\t$date = sprintf( $currentf, $date );\n\telseif ( wp_is_post_autosave( $revision ) )\n\t\t$date = sprintf( $autosavef, $date );\n\n\treturn $date;\n}\n\n/**\n * Display list of a post's revisions.\n *\n * Can output either a UL with edit links or a TABLE with diff interface, and\n * restore action links.\n *\n * Second argument controls parameters:\n *   (bool)   parent : include the parent (the \"Current Revision\") in the list.\n *   (string) format : 'list' or 'form-table'. 'list' outputs UL, 'form-table'\n *                     outputs TABLE with UI.\n *   (int)    right  : what revision is currently being viewed - used in\n *                     form-table format.\n *   (int)    left   : what revision is currently being diffed against right -\n *                     used in form-table format.\n *\n * @package WordPress\n * @subpackage Post_Revisions\n * @since 2.6.0\n *\n * @uses wp_get_post_revisions()\n * @uses wp_post_revision_title()\n * @uses get_edit_post_link()\n * @uses get_the_author_meta()\n *\n * @todo split into two functions (list, form-table) ?\n *\n * @param int|object $post_id Post ID or post object.\n * @param string|array $args See description {@link wp_parse_args()}.\n * @return null\n */\nfunction wp_list_post_revisions( $post_id = 0, $args = null ) {\n\tif ( !$post = get_post( $post_id ) )\n\t\treturn;\n\n\t$defaults = array( 'parent' => false, 'right' => false, 'left' => false, 'format' => 'list', 'type' => 'all' );\n\textract( wp_parse_args( $args, $defaults ), EXTR_SKIP );\n\n\tswitch ( $type ) {\n\t\tcase 'autosave' :\n\t\t\tif ( !$autosave = wp_get_post_autosave( $post->ID ) )\n\t\t\t\treturn;\n\t\t\t$revisions = array( $autosave );\n\t\t\tbreak;\n\t\tcase 'revision' : // just revisions - remove autosave later\n\t\tcase 'all' :\n\t\tdefault :\n\t\t\tif ( !$revisions = wp_get_post_revisions( $post->ID ) )\n\t\t\t\treturn;\n\t\t\tbreak;\n\t}\n\n\t/* translators: post revision: 1: when, 2: author name */\n\t$titlef = _x( '%1$s by %2$s', 'post revision' );\n\n\tif ( $parent )\n\t\tarray_unshift( $revisions, $post );\n\n\t$rows = $right_checked = '';\n\t$class = false;\n\t$can_edit_post = current_user_can( 'edit_post', $post->ID );\n\tforeach ( $revisions as $revision ) {\n\t\tif ( !current_user_can( 'read_post', $revision->ID ) )\n\t\t\tcontinue;\n\t\tif ( 'revision' === $type && wp_is_post_autosave( $revision ) )\n\t\t\tcontinue;\n\n\t\t$date = wp_post_revision_title( $revision );\n\t\t$name = get_the_author_meta( 'display_name', $revision->post_author );\n\n\t\tif ( 'form-table' == $format ) {\n\t\t\tif ( $left )\n\t\t\t\t$left_checked = $left == $revision->ID ? ' checked=\"checked\"' : '';\n\t\t\telse\n\t\t\t\t$left_checked = $right_checked ? ' checked=\"checked\"' : ''; // [sic] (the next one)\n\t\t\t$right_checked = $right == $revision->ID ? ' checked=\"checked\"' : '';\n\n\t\t\t$class = $class ? '' : \" class='alternate'\";\n\n\t\t\tif ( $post->ID != $revision->ID && $can_edit_post )\n\t\t\t\t$actions = '<a href=\"' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'action' => 'restore' ) ), \"restore-post_$post->ID|$revision->ID\" ) . '\">' . __( 'Restore' ) . '</a>';\n\t\t\telse\n\t\t\t\t$actions = '';\n\n\t\t\t$rows .= \"<tr$class>\\n\";\n\t\t\t$rows .= \"\\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /></th>\\n\";\n\t\t\t$rows .= \"\\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\\n\";\n\t\t\t$rows .= \"\\t<td>$date</td>\\n\";\n\t\t\t$rows .= \"\\t<td>$name</td>\\n\";\n\t\t\t$rows .= \"\\t<td class='action-links'>$actions</td>\\n\";\n\t\t\t$rows .= \"</tr>\\n\";\n\t\t} else {\n\t\t\t$title = sprintf( $titlef, $date, $name );\n\t\t\t$rows .= \"\\t<li>$title</li>\\n\";\n\t\t}\n\t}\n\n\tif ( 'form-table' == $format ) : ?>\n\n<form action=\"revision.php\" method=\"get\">\n\n<div class=\"tablenav\">\n\t<div class=\"alignleft\">\n\t\t<input type=\"submit\" class=\"button-secondary\" value=\"<?php esc_attr_e( 'Compare Revisions' ); ?>\" />\n\t\t<input type=\"hidden\" name=\"action\" value=\"diff\" />\n\t\t<input type=\"hidden\" name=\"post_type\" value=\"<?php echo esc_attr($post->post_type); ?>\" />\n\t</div>\n</div>\n\n<br class=\"clear\" />\n\n<table class=\"widefat post-revisions\" cellspacing=\"0\" id=\"post-revisions\">\n\t<col />\n\t<col />\n\t<col style=\"width: 33%\" />\n\t<col style=\"width: 33%\" />\n\t<col style=\"width: 33%\" />\n<thead>\n<tr>\n\t<th scope=\"col\"><?php /* translators: column name in revisions */ _ex( 'Old', 'revisions column name' ); ?></th>\n\t<th scope=\"col\"><?php /* translators: column name in revisions */ _ex( 'New', 'revisions column name' ); ?></th>\n\t<th scope=\"col\"><?php /* translators: column name in revisions */ _ex( 'Date Created', 'revisions column name' ); ?></th>\n\t<th scope=\"col\"><?php _e( 'Author' ); ?></th>\n\t<th scope=\"col\" class=\"action-links\"><?php _e( 'Actions' ); ?></th>\n</tr>\n</thead>\n<tbody>\n\n<?php echo $rows; ?>\n\n</tbody>\n</table>\n\n</form>\n\n<?php\n\telse :\n\t\techo \"<ul class='post-revisions'>\\n\";\n\t\techo $rows;\n\t\techo \"</ul>\";\n\tendif;\n\n}\n
     
    10481048
    10491049                $css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
    10501050
    1051                 $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>';
     1051        /** Check if there is an actual Page Title otherwise use the Page ID as the menu item */
     1052        if ( ! empty( $page->post_title ) ) {
     1053            $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>';
     1054        } else {
     1055            $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters( 'the_title', 'Page-' . $page->ID, $page->ID ) . $link_after . '</a>';
     1056        }
    10521057
    10531058                if ( !empty($show_date) ) {
    10541059                        if ( 'modified' == $show_date )