wp/wp-includes/post-template.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    19 
    19 
    20 /**
    20 /**
    21  * Retrieve the ID of the current item in the WordPress Loop.
    21  * Retrieve the ID of the current item in the WordPress Loop.
    22  *
    22  *
    23  * @since 2.1.0
    23  * @since 2.1.0
    24  * @uses $post
    24  *
    25  *
    25  * @return int|bool The ID of the current item in the WordPress Loop. False if $post is not set.
    26  * @return int
       
    27  */
    26  */
    28 function get_the_ID() {
    27 function get_the_ID() {
    29 	return get_post()->ID;
    28 	$post = get_post();
       
    29 	return ! empty( $post ) ? $post->ID : false;
    30 }
    30 }
    31 
    31 
    32 /**
    32 /**
    33  * Display or retrieve the current post title with optional content.
    33  * Display or retrieve the current post title with optional content.
    34  *
    34  *
    63  * esc_attr()} before it is passed to the user or displayed. The default
    63  * esc_attr()} before it is passed to the user or displayed. The default
    64  * as with {@link the_title()}, is to display the title.
    64  * as with {@link the_title()}, is to display the title.
    65  *
    65  *
    66  * @since 2.3.0
    66  * @since 2.3.0
    67  *
    67  *
    68  * @param string|array $args Optional. Override the defaults.
    68  * @param string|array $args {
       
    69  *     Title attribute arguments. Optional.
       
    70  *
       
    71  *     @type string  $before Markup to prepend to the title. Default empty.
       
    72  *     @type string  $after  Markup to append to the title. Default empty.
       
    73  *     @type bool    $echo   Whether to echo or return the title. Default true for echo.
       
    74  *     @type WP_Post $post   Current post object to retrieve the title for.
       
    75  * }
    69  * @return string|null Null on failure or display. String when echo is false.
    76  * @return string|null Null on failure or display. String when echo is false.
    70  */
    77  */
    71 function the_title_attribute( $args = '' ) {
    78 function the_title_attribute( $args = '' ) {
    72 	$defaults = array('before' => '', 'after' =>  '', 'echo' => true, 'post' => get_post() );
    79 	$defaults = array( 'before' => '', 'after' =>  '', 'echo' => true, 'post' => get_post() );
    73 	$r = wp_parse_args($args, $defaults);
    80 	$r = wp_parse_args( $args, $defaults );
    74 	extract( $r, EXTR_SKIP );
    81 
    75 
    82 	$title = get_the_title( $r['post'] );
    76 	$title = get_the_title( $post );
    83 
    77 
    84 	if ( strlen( $title ) == 0 ) {
    78 	if ( strlen($title) == 0 )
       
    79 		return;
    85 		return;
    80 
    86 	}
    81 	$title = $before . $title . $after;
    87 
    82 	$title = esc_attr(strip_tags($title));
    88 	$title = $r['before'] . $title . $r['after'];
    83 
    89 	$title = esc_attr( strip_tags( $title ) );
    84 	if ( $echo )
    90 
       
    91 	if ( $r['echo'] ) {
    85 		echo $title;
    92 		echo $title;
    86 	else
    93 	} else {
    87 		return $title;
    94 		return $title;
       
    95 	}
    88 }
    96 }
    89 
    97 
    90 /**
    98 /**
    91  * Retrieve post title.
    99  * Retrieve post title.
    92  *
   100  *
    94  * will be displayed before the post title. If the post is private, then
   102  * will be displayed before the post title. If the post is private, then
    95  * "Private" will be located before the post title.
   103  * "Private" will be located before the post title.
    96  *
   104  *
    97  * @since 0.71
   105  * @since 0.71
    98  *
   106  *
    99  * @param int|object $post Optional. Post ID or object.
   107  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
   100  * @return string
   108  * @return string
   101  */
   109  */
   102 function get_the_title( $post = 0 ) {
   110 function get_the_title( $post = 0 ) {
   103 	$post = get_post( $post );
   111 	$post = get_post( $post );
   104 
   112 
   105 	$title = isset( $post->post_title ) ? $post->post_title : '';
   113 	$title = isset( $post->post_title ) ? $post->post_title : '';
   106 	$id = isset( $post->ID ) ? $post->ID : 0;
   114 	$id = isset( $post->ID ) ? $post->ID : 0;
   107 
   115 
   108 	if ( ! is_admin() ) {
   116 	if ( ! is_admin() ) {
   109 		if ( ! empty( $post->post_password ) ) {
   117 		if ( ! empty( $post->post_password ) ) {
   110 			$protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) );
   118 
       
   119 			/**
       
   120 			 * Filter the text prepended to the post title for protected posts.
       
   121 			 *
       
   122 			 * The filter is only applied on the front end.
       
   123 			 *
       
   124 			 * @since 2.8.0
       
   125 			 *
       
   126 			 * @param string  $prepend Text displayed before the post title.
       
   127 			 *                         Default 'Protected: %s'.
       
   128 			 * @param WP_Post $post    Current post object.
       
   129 			 */
       
   130 			$protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ), $post );
   111 			$title = sprintf( $protected_title_format, $title );
   131 			$title = sprintf( $protected_title_format, $title );
   112 		} else if ( isset( $post->post_status ) && 'private' == $post->post_status ) {
   132 		} elseif ( isset( $post->post_status ) && 'private' == $post->post_status ) {
   113 			$private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) );
   133 
       
   134 			/**
       
   135 			 * Filter the text prepended to the post title of private posts.
       
   136 			 *
       
   137 			 * The filter is only applied on the front end.
       
   138 			 *
       
   139 			 * @since 2.8.0
       
   140 			 *
       
   141 			 * @param string  $prepend Text displayed before the post title.
       
   142 			 *                         Default 'Private: %s'.
       
   143 			 * @param WP_Post $post    Current post object.
       
   144 			 */
       
   145 			$private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ), $post );
   114 			$title = sprintf( $private_title_format, $title );
   146 			$title = sprintf( $private_title_format, $title );
   115 		}
   147 		}
   116 	}
   148 	}
   117 
   149 
       
   150 	/**
       
   151 	 * Filter the post title.
       
   152 	 *
       
   153 	 * @since 0.71
       
   154 	 *
       
   155 	 * @param string $title The post title.
       
   156 	 * @param int    $id    The post ID.
       
   157 	 */
   118 	return apply_filters( 'the_title', $title, $id );
   158 	return apply_filters( 'the_title', $title, $id );
   119 }
   159 }
   120 
   160 
   121 /**
   161 /**
   122  * Display the Post Global Unique Identifier (guid).
   162  * Display the Post Global Unique Identifier (guid).
   127  *
   167  *
   128  * Url is escaped to make it xml safe
   168  * Url is escaped to make it xml safe
   129  *
   169  *
   130  * @since 1.5.0
   170  * @since 1.5.0
   131  *
   171  *
   132  * @param int $id Optional. Post ID.
   172  * @param int|WP_Post $id Optional. Post ID or post object.
   133  */
   173  */
   134 function the_guid( $id = 0 ) {
   174 function the_guid( $id = 0 ) {
   135 	echo esc_url( get_the_guid( $id ) );
   175 	/**
       
   176 	 * Filter the escaped Global Unique Identifier (guid) of the post.
       
   177 	 *
       
   178 	 * @since 4.2.0
       
   179 	 *
       
   180 	 * @see get_the_guid()
       
   181 	 *
       
   182 	 * @param string $post_guid Escaped Global Unique Identifier (guid) of the post.
       
   183 	 */
       
   184 	echo apply_filters( 'the_guid', get_the_guid( $id ) );
   136 }
   185 }
   137 
   186 
   138 /**
   187 /**
   139  * Retrieve the Post Global Unique Identifier (guid).
   188  * Retrieve the Post Global Unique Identifier (guid).
   140  *
   189  *
   142  * post. The reason you should not use it as a link, is because of moving the
   191  * post. The reason you should not use it as a link, is because of moving the
   143  * blog across domains.
   192  * blog across domains.
   144  *
   193  *
   145  * @since 1.5.0
   194  * @since 1.5.0
   146  *
   195  *
   147  * @param int $id Optional. Post ID.
   196  * @param int|WP_Post $id Optional. Post ID or post object.
   148  * @return string
   197  * @return string
   149  */
   198  */
   150 function get_the_guid( $id = 0 ) {
   199 function get_the_guid( $id = 0 ) {
   151 	$post = get_post($id);
   200 	$post = get_post($id);
   152 
   201 
   153 	return apply_filters('get_the_guid', $post->guid);
   202 	/**
       
   203 	 * Filter the Global Unique Identifier (guid) of the post.
       
   204 	 *
       
   205 	 * @since 1.5.0
       
   206 	 *
       
   207 	 * @param string $post_guid Global Unique Identifier (guid) of the post.
       
   208 	 */
       
   209 	return apply_filters( 'get_the_guid', $post->guid );
   154 }
   210 }
   155 
   211 
   156 /**
   212 /**
   157  * Display the post content.
   213  * Display the post content.
   158  *
   214  *
   159  * @since 0.71
   215  * @since 0.71
   160  *
   216  *
   161  * @param string $more_link_text Optional. Content for when there is more text.
   217  * @param string $more_link_text Optional. Content for when there is more text.
   162  * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false.
   218  * @param bool   $strip_teaser   Optional. Strip teaser content before the more text. Default is false.
   163  */
   219  */
   164 function the_content( $more_link_text = null, $strip_teaser = false) {
   220 function the_content( $more_link_text = null, $strip_teaser = false) {
   165 	$content = get_the_content( $more_link_text, $strip_teaser );
   221 	$content = get_the_content( $more_link_text, $strip_teaser );
       
   222 
       
   223 	/**
       
   224 	 * Filter the post content.
       
   225 	 *
       
   226 	 * @since 0.71
       
   227 	 *
       
   228 	 * @param string $content Content of the current post.
       
   229 	 */
   166 	$content = apply_filters( 'the_content', $content );
   230 	$content = apply_filters( 'the_content', $content );
   167 	$content = str_replace( ']]>', ']]>', $content );
   231 	$content = str_replace( ']]>', ']]>', $content );
   168 	echo $content;
   232 	echo $content;
   169 }
   233 }
   170 
   234 
   172  * Retrieve the post content.
   236  * Retrieve the post content.
   173  *
   237  *
   174  * @since 0.71
   238  * @since 0.71
   175  *
   239  *
   176  * @param string $more_link_text Optional. Content for when there is more text.
   240  * @param string $more_link_text Optional. Content for when there is more text.
   177  * @param bool $stripteaser Optional. Strip teaser content before the more text. Default is false.
   241  * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false.
   178  * @return string
   242  * @return string
   179  */
   243  */
   180 function get_the_content( $more_link_text = null, $strip_teaser = false ) {
   244 function get_the_content( $more_link_text = null, $strip_teaser = false ) {
   181 	global $page, $more, $preview, $pages, $multipage;
   245 	global $page, $more, $preview, $pages, $multipage;
   182 
   246 
   219 	if ( count( $content ) > 1 ) {
   283 	if ( count( $content ) > 1 ) {
   220 		if ( $more ) {
   284 		if ( $more ) {
   221 			$output .= '<span id="more-' . $post->ID . '"></span>' . $content[1];
   285 			$output .= '<span id="more-' . $post->ID . '"></span>' . $content[1];
   222 		} else {
   286 		} else {
   223 			if ( ! empty( $more_link_text ) )
   287 			if ( ! empty( $more_link_text ) )
       
   288 
       
   289 				/**
       
   290 				 * Filter the Read More link text.
       
   291 				 *
       
   292 				 * @since 2.8.0
       
   293 				 *
       
   294 				 * @param string $more_link_element Read More link element.
       
   295 				 * @param string $more_link_text    Read More text.
       
   296 				 */
   224 				$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
   297 				$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
   225 			$output = force_balance_tags( $output );
   298 			$output = force_balance_tags( $output );
   226 		}
   299 		}
   227 	}
   300 	}
   228 
   301 
   229 	if ( $preview ) // preview fix for javascript bug with foreign languages
   302 	if ( $preview ) // Preview fix for JavaScript bug with foreign languages.
   230 		$output =	preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output );
   303 		$output =	preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output );
   231 
   304 
   232 	return $output;
   305 	return $output;
   233 }
   306 }
   234 
   307 
   235 /**
   308 /**
   236  * Preview fix for javascript bug with foreign languages
   309  * Preview fix for JavaScript bug with foreign languages.
   237  *
   310  *
   238  * @since 3.1.0
   311  * @since 3.1.0
   239  * @access private
   312  * @access private
   240  * @param array $match Match array from preg_replace_callback
   313  * @param array $match Match array from preg_replace_callback
   241  * @return string
   314  * @return string
   246 
   319 
   247 /**
   320 /**
   248  * Display the post excerpt.
   321  * Display the post excerpt.
   249  *
   322  *
   250  * @since 0.71
   323  * @since 0.71
   251  * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt.
       
   252  */
   324  */
   253 function the_excerpt() {
   325 function the_excerpt() {
   254 	echo apply_filters('the_excerpt', get_the_excerpt());
   326 
       
   327 	/**
       
   328 	 * Filter the displayed post excerpt.
       
   329 	 *
       
   330 	 * @since 0.71
       
   331 	 *
       
   332 	 * @see get_the_excerpt()
       
   333 	 *
       
   334 	 * @param string $post_excerpt The post excerpt.
       
   335 	 */
       
   336 	echo apply_filters( 'the_excerpt', get_the_excerpt() );
   255 }
   337 }
   256 
   338 
   257 /**
   339 /**
   258  * Retrieve the post excerpt.
   340  * Retrieve the post excerpt.
   259  *
   341  *
   265 function get_the_excerpt( $deprecated = '' ) {
   347 function get_the_excerpt( $deprecated = '' ) {
   266 	if ( !empty( $deprecated ) )
   348 	if ( !empty( $deprecated ) )
   267 		_deprecated_argument( __FUNCTION__, '2.3' );
   349 		_deprecated_argument( __FUNCTION__, '2.3' );
   268 
   350 
   269 	$post = get_post();
   351 	$post = get_post();
       
   352 	if ( empty( $post ) ) {
       
   353 		return '';
       
   354 	}
   270 
   355 
   271 	if ( post_password_required() ) {
   356 	if ( post_password_required() ) {
   272 		return __( 'There is no excerpt because this is a protected post.' );
   357 		return __( 'There is no excerpt because this is a protected post.' );
   273 	}
   358 	}
   274 
   359 
       
   360 	/**
       
   361 	 * Filter the retrieved post excerpt.
       
   362 	 *
       
   363 	 * @since 1.2.0
       
   364 	 *
       
   365 	 * @param string $post_excerpt The post excerpt.
       
   366 	 */
   275 	return apply_filters( 'get_the_excerpt', $post->post_excerpt );
   367 	return apply_filters( 'get_the_excerpt', $post->post_excerpt );
   276 }
   368 }
   277 
   369 
   278 /**
   370 /**
   279  * Whether post has excerpt.
   371  * Whether post has excerpt.
   280  *
   372  *
   281  * @since 2.3.0
   373  * @since 2.3.0
   282  *
   374  *
   283  * @param int $id Optional. Post ID.
   375  * @param int|WP_Post $id Optional. Post ID or post object.
   284  * @return bool
   376  * @return bool
   285  */
   377  */
   286 function has_excerpt( $id = 0 ) {
   378 function has_excerpt( $id = 0 ) {
   287 	$post = get_post( $id );
   379 	$post = get_post( $id );
   288 	return ( !empty( $post->post_excerpt ) );
   380 	return ( !empty( $post->post_excerpt ) );
   292  * Display the classes for the post div.
   384  * Display the classes for the post div.
   293  *
   385  *
   294  * @since 2.7.0
   386  * @since 2.7.0
   295  *
   387  *
   296  * @param string|array $class One or more classes to add to the class list.
   388  * @param string|array $class One or more classes to add to the class list.
   297  * @param int $post_id An optional post ID.
   389  * @param int|WP_Post $post_id Optional. Post ID or post object.
   298  */
   390  */
   299 function post_class( $class = '', $post_id = null ) {
   391 function post_class( $class = '', $post_id = null ) {
   300 	// Separates classes with a single space, collates classes for post DIV
   392 	// Separates classes with a single space, collates classes for post DIV
   301 	echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"';
   393 	echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"';
   302 }
   394 }
   303 
   395 
   304 /**
   396 /**
   305  * Retrieve the classes for the post div as an array.
   397  * Retrieve the classes for the post div as an array.
   306  *
   398  *
   307  * The class names are add are many. If the post is a sticky, then the 'sticky'
   399  * The class names are many. If the post is a sticky, then the 'sticky'
   308  * class name. The class 'hentry' is always added to each post. For each
   400  * class name. The class 'hentry' is always added to each post. If the post has a
   309  * category, the class will be added with 'category-' with category slug is
   401  * post thumbnail, 'has-post-thumbnail' is added as a class. For each taxonomy that
   310  * added. The tags are the same way as the categories with 'tag-' before the tag
   402  * the post belongs to, a class will be added of the format '{$taxonomy}-{$slug}' -
   311  * slug. All classes are passed through the filter, 'post_class' with the list
   403  * eg 'category-foo' or 'my_custom_taxonomy-bar'. The 'post_tag' taxonomy is a special
   312  * of classes, followed by $class parameter value, with the post ID as the last
   404  * case; the class has the 'tag-' prefix instead of 'post_tag-'. All classes are
   313  * parameter.
   405  * passed through the filter, 'post_class' with the list of classes, followed by
       
   406  * $class parameter value, with the post ID as the last parameter.
   314  *
   407  *
   315  * @since 2.7.0
   408  * @since 2.7.0
   316  *
   409  * @since 4.2.0 Custom taxonomy classes were added.
   317  * @param string|array $class One or more classes to add to the class list.
   410  *
   318  * @param int $post_id An optional post ID.
   411  * @param string|array $class   One or more classes to add to the class list.
       
   412  * @param int|WP_Post  $post_id Optional. Post ID or post object.
   319  * @return array Array of classes.
   413  * @return array Array of classes.
   320  */
   414  */
   321 function get_post_class( $class = '', $post_id = null ) {
   415 function get_post_class( $class = '', $post_id = null ) {
   322 	$post = get_post($post_id);
   416 	$post = get_post( $post_id );
   323 
   417 
   324 	$classes = array();
   418 	$classes = array();
   325 
   419 
   326 	if ( empty($post) )
   420 	if ( $class ) {
       
   421 		if ( ! is_array( $class ) ) {
       
   422 			$class = preg_split( '#\s+#', $class );
       
   423 		}
       
   424 		$classes = array_map( 'esc_attr', $class );
       
   425 	}
       
   426 
       
   427 	if ( ! $post ) {
   327 		return $classes;
   428 		return $classes;
       
   429 	}
   328 
   430 
   329 	$classes[] = 'post-' . $post->ID;
   431 	$classes[] = 'post-' . $post->ID;
   330 	if ( ! is_admin() )
   432 	if ( ! is_admin() )
   331 		$classes[] = $post->post_type;
   433 		$classes[] = $post->post_type;
   332 	$classes[] = 'type-' . $post->post_type;
   434 	$classes[] = 'type-' . $post->post_type;
   340 			$classes[] = 'format-' . sanitize_html_class( $post_format );
   442 			$classes[] = 'format-' . sanitize_html_class( $post_format );
   341 		else
   443 		else
   342 			$classes[] = 'format-standard';
   444 			$classes[] = 'format-standard';
   343 	}
   445 	}
   344 
   446 
   345 	// post requires password
   447 	// Post requires password
   346 	if ( post_password_required($post->ID) )
   448 	if ( post_password_required( $post->ID ) ) {
   347 		$classes[] = 'post-password-required';
   449 		$classes[] = 'post-password-required';
       
   450 	// Post thumbnails
       
   451 	} elseif ( ! is_attachment( $post ) && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) {
       
   452 		$classes[] = 'has-post-thumbnail';
       
   453 	}
   348 
   454 
   349 	// sticky for Sticky Posts
   455 	// sticky for Sticky Posts
   350 	if ( is_sticky($post->ID) && is_home() && !is_paged() )
   456 	if ( is_sticky( $post->ID ) ) {
   351 		$classes[] = 'sticky';
   457 		if ( is_home() && ! is_paged() ) {
       
   458 			$classes[] = 'sticky';
       
   459 		} elseif ( is_admin() ) {
       
   460 			$classes[] = 'status-sticky';
       
   461 		}
       
   462 	}
   352 
   463 
   353 	// hentry for hAtom compliance
   464 	// hentry for hAtom compliance
   354 	$classes[] = 'hentry';
   465 	$classes[] = 'hentry';
   355 
   466 
   356 	// Categories
   467 	// All public taxonomies
   357 	if ( is_object_in_taxonomy( $post->post_type, 'category' ) ) {
   468 	$taxonomies = get_taxonomies( array( 'public' => true ) );
   358 		foreach ( (array) get_the_category($post->ID) as $cat ) {
   469 	foreach ( (array) $taxonomies as $taxonomy ) {
   359 			if ( empty($cat->slug ) )
   470 		if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
   360 				continue;
   471 			foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) {
   361 			$classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->term_id);
   472 				if ( empty( $term->slug ) ) {
   362 		}
   473 					continue;
   363 	}
   474 				}
   364 
   475 
   365 	// Tags
   476 				$term_class = sanitize_html_class( $term->slug, $term->term_id );
   366 	if ( is_object_in_taxonomy( $post->post_type, 'post_tag' ) ) {
   477 				if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) {
   367 		foreach ( (array) get_the_tags($post->ID) as $tag ) {
   478 					$term_class = $term->term_id;
   368 			if ( empty($tag->slug ) )
   479 				}
   369 				continue;
   480 
   370 			$classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id);
   481 				// 'post_tag' uses the 'tag' prefix for backward compatibility.
   371 		}
   482 				if ( 'post_tag' == $taxonomy ) {
   372 	}
   483 					$classes[] = 'tag-' . $term_class;
   373 
   484 				} else {
   374 	if ( !empty($class) ) {
   485 					$classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id );
   375 		if ( !is_array( $class ) )
   486 				}
   376 			$class = preg_split('#\s+#', $class);
   487 			}
   377 		$classes = array_merge($classes, $class);
   488 		}
   378 	}
   489 	}
   379 
   490 
   380 	$classes = array_map('esc_attr', $classes);
   491 	$classes = array_map( 'esc_attr', $classes );
   381 
   492 
   382 	return apply_filters('post_class', $classes, $class, $post->ID);
   493 	/**
       
   494 	 * Filter the list of CSS classes for the current post.
       
   495 	 *
       
   496 	 * @since 2.7.0
       
   497 	 *
       
   498 	 * @param array  $classes An array of post classes.
       
   499 	 * @param string $class   A comma-separated list of additional classes added to the post.
       
   500 	 * @param int    $post_id The post ID.
       
   501 	 */
       
   502 	$classes = apply_filters( 'post_class', $classes, $class, $post->ID );
       
   503 
       
   504 	return array_unique( $classes );
   383 }
   505 }
   384 
   506 
   385 /**
   507 /**
   386  * Display the classes for the body element.
   508  * Display the classes for the body element.
   387  *
   509  *
   460 			$classes[] = 'post-type-archive';
   582 			$classes[] = 'post-type-archive';
   461 			$post_type = get_query_var( 'post_type' );
   583 			$post_type = get_query_var( 'post_type' );
   462 			if ( is_array( $post_type ) )
   584 			if ( is_array( $post_type ) )
   463 				$post_type = reset( $post_type );
   585 				$post_type = reset( $post_type );
   464 			$classes[] = 'post-type-archive-' . sanitize_html_class( $post_type );
   586 			$classes[] = 'post-type-archive-' . sanitize_html_class( $post_type );
   465 		} else if ( is_author() ) {
   587 		} elseif ( is_author() ) {
   466 			$author = $wp_query->get_queried_object();
   588 			$author = $wp_query->get_queried_object();
   467 			$classes[] = 'author';
   589 			$classes[] = 'author';
   468 			if ( isset( $author->user_nicename ) ) {
   590 			if ( isset( $author->user_nicename ) ) {
   469 				$classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID );
   591 				$classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID );
   470 				$classes[] = 'author-' . $author->ID;
   592 				$classes[] = 'author-' . $author->ID;
   471 			}
   593 			}
   472 		} elseif ( is_category() ) {
   594 		} elseif ( is_category() ) {
   473 			$cat = $wp_query->get_queried_object();
   595 			$cat = $wp_query->get_queried_object();
   474 			$classes[] = 'category';
   596 			$classes[] = 'category';
   475 			if ( isset( $cat->term_id ) ) {
   597 			if ( isset( $cat->term_id ) ) {
   476 				$classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->term_id );
   598 				$cat_class = sanitize_html_class( $cat->slug, $cat->term_id );
       
   599 				if ( is_numeric( $cat_class ) || ! trim( $cat_class, '-' ) ) {
       
   600 					$cat_class = $cat->term_id;
       
   601 				}
       
   602 
       
   603 				$classes[] = 'category-' . $cat_class;
   477 				$classes[] = 'category-' . $cat->term_id;
   604 				$classes[] = 'category-' . $cat->term_id;
   478 			}
   605 			}
   479 		} elseif ( is_tag() ) {
   606 		} elseif ( is_tag() ) {
   480 			$tags = $wp_query->get_queried_object();
   607 			$tag = $wp_query->get_queried_object();
   481 			$classes[] = 'tag';
   608 			$classes[] = 'tag';
   482 			if ( isset( $tags->term_id ) ) {
   609 			if ( isset( $tag->term_id ) ) {
   483 				$classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id );
   610 				$tag_class = sanitize_html_class( $tag->slug, $tag->term_id );
   484 				$classes[] = 'tag-' . $tags->term_id;
   611 				if ( is_numeric( $tag_class ) || ! trim( $tag_class, '-' ) ) {
       
   612 					$tag_class = $tag->term_id;
       
   613 				}
       
   614 
       
   615 				$classes[] = 'tag-' . $tag_class;
       
   616 				$classes[] = 'tag-' . $tag->term_id;
   485 			}
   617 			}
   486 		} elseif ( is_tax() ) {
   618 		} elseif ( is_tax() ) {
   487 			$term = $wp_query->get_queried_object();
   619 			$term = $wp_query->get_queried_object();
   488 			if ( isset( $term->term_id ) ) {
   620 			if ( isset( $term->term_id ) ) {
       
   621 				$term_class = sanitize_html_class( $term->slug, $term->term_id );
       
   622 				if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) {
       
   623 					$term_class = $term->term_id;
       
   624 				}
       
   625 
   489 				$classes[] = 'tax-' . sanitize_html_class( $term->taxonomy );
   626 				$classes[] = 'tax-' . sanitize_html_class( $term->taxonomy );
   490 				$classes[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id );
   627 				$classes[] = 'term-' . $term_class;
   491 				$classes[] = 'term-' . $term->term_id;
   628 				$classes[] = 'term-' . $term->term_id;
   492 			}
   629 			}
   493 		}
   630 		}
   494 	} elseif ( is_page() ) {
   631 	} elseif ( is_page() ) {
   495 		$classes[] = 'page';
   632 		$classes[] = 'page';
   498 
   635 
   499 		$post = get_post($page_id);
   636 		$post = get_post($page_id);
   500 
   637 
   501 		$classes[] = 'page-id-' . $page_id;
   638 		$classes[] = 'page-id-' . $page_id;
   502 
   639 
   503 		if ( $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) ) )
   640 		if ( get_pages( array( 'parent' => $page_id, 'number' => 1 ) ) ) {
   504 			$classes[] = 'page-parent';
   641 			$classes[] = 'page-parent';
       
   642 		}
   505 
   643 
   506 		if ( $post->post_parent ) {
   644 		if ( $post->post_parent ) {
   507 			$classes[] = 'page-child';
   645 			$classes[] = 'page-child';
   508 			$classes[] = 'parent-pageid-' . $post->post_parent;
   646 			$classes[] = 'parent-pageid-' . $post->post_parent;
   509 		}
   647 		}
   510 		if ( is_page_template() ) {
   648 		if ( is_page_template() ) {
   511 			$classes[] = 'page-template';
   649 			$classes[] = 'page-template';
   512 			$classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_page_template_slug( $page_id ) ) );
   650 
       
   651 			$template_slug  = get_page_template_slug( $page_id );
       
   652 			$template_parts = explode( '/', $template_slug );
       
   653 
       
   654 			foreach ( $template_parts as $part ) {
       
   655 				$classes[] = 'page-template-' . sanitize_html_class( str_replace( array( '.', '/' ), '-', basename( $part, '.php' ) ) );
       
   656 			}
       
   657 			$classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', $template_slug ) );
   513 		} else {
   658 		} else {
   514 			$classes[] = 'page-template-default';
   659 			$classes[] = 'page-template-default';
   515 		}
   660 		}
   516 	}
   661 	}
   517 
   662 
   521 	if ( is_admin_bar_showing() ) {
   666 	if ( is_admin_bar_showing() ) {
   522 		$classes[] = 'admin-bar';
   667 		$classes[] = 'admin-bar';
   523 		$classes[] = 'no-customize-support';
   668 		$classes[] = 'no-customize-support';
   524 	}
   669 	}
   525 
   670 
   526 	if ( get_theme_mod( 'background_color' ) || get_background_image() )
   671 	if ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() )
   527 		$classes[] = 'custom-background';
   672 		$classes[] = 'custom-background';
   528 
   673 
   529 	$page = $wp_query->get( 'page' );
   674 	$page = $wp_query->get( 'page' );
   530 
   675 
   531 	if ( !$page || $page < 2)
   676 	if ( ! $page || $page < 2 )
   532 		$page = $wp_query->get( 'paged' );
   677 		$page = $wp_query->get( 'paged' );
   533 
   678 
   534 	if ( $page && $page > 1 ) {
   679 	if ( $page && $page > 1 && ! is_404() ) {
   535 		$classes[] = 'paged-' . $page;
   680 		$classes[] = 'paged-' . $page;
   536 
   681 
   537 		if ( is_single() )
   682 		if ( is_single() )
   538 			$classes[] = 'single-paged-' . $page;
   683 			$classes[] = 'single-paged-' . $page;
   539 		elseif ( is_page() )
   684 		elseif ( is_page() )
   561 		$class = array();
   706 		$class = array();
   562 	}
   707 	}
   563 
   708 
   564 	$classes = array_map( 'esc_attr', $classes );
   709 	$classes = array_map( 'esc_attr', $classes );
   565 
   710 
   566 	return apply_filters( 'body_class', $classes, $class );
   711 	/**
       
   712 	 * Filter the list of CSS body classes for the current post or page.
       
   713 	 *
       
   714 	 * @since 2.8.0
       
   715 	 *
       
   716 	 * @param array  $classes An array of body classes.
       
   717 	 * @param string $class   A comma-separated list of additional classes added to the body.
       
   718 	 */
       
   719 	$classes = apply_filters( 'body_class', $classes, $class );
       
   720 
       
   721 	return array_unique( $classes );
   567 }
   722 }
   568 
   723 
   569 /**
   724 /**
   570  * Whether post requires password and correct password has been provided.
   725  * Whether post requires password and correct password has been provided.
   571  *
   726  *
   581 		return false;
   736 		return false;
   582 
   737 
   583 	if ( ! isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
   738 	if ( ! isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
   584 		return true;
   739 		return true;
   585 
   740 
   586 	require_once ABSPATH . 'wp-includes/class-phpass.php';
   741 	require_once ABSPATH . WPINC . '/class-phpass.php';
   587 	$hasher = new PasswordHash( 8, true );
   742 	$hasher = new PasswordHash( 8, true );
   588 
   743 
   589 	$hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
   744 	$hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
   590 	if ( 0 !== strpos( $hash, '$P$B' ) )
   745 	if ( 0 !== strpos( $hash, '$P$B' ) )
   591 		return true;
   746 		return true;
   592 
   747 
   593 	return ! $hasher->CheckPassword( $post->post_password, $hash );
   748 	return ! $hasher->CheckPassword( $post->post_password, $hash );
   594 }
   749 }
   595 
   750 
   596 /**
   751 //
   597  * Page Template Functions for usage in Themes
   752 // Page Template Functions for usage in Themes
   598  *
   753 //
   599  * @package WordPress
       
   600  * @subpackage Template
       
   601  */
       
   602 
   754 
   603 /**
   755 /**
   604  * The formatted output of a list of pages.
   756  * The formatted output of a list of pages.
   605  *
   757  *
   606  * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
   758  * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
   607  * Quicktag one or more times). This tag must be within The Loop.
   759  * Quicktag one or more times). This tag must be within The Loop.
   608  *
   760  *
   609  * The defaults for overwriting are:
       
   610  * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to
       
   611  *      each bookmarks.
       
   612  * 'after' - Default is '</p>' (string). The html or text to append to each
       
   613  *      bookmarks.
       
   614  * 'link_before' - Default is '' (string). The html or text to prepend to each
       
   615  *      Pages link inside the <a> tag. Also prepended to the current item, which
       
   616  *      is not linked.
       
   617  * 'link_after' - Default is '' (string). The html or text to append to each
       
   618  *      Pages link inside the <a> tag. Also appended to the current item, which
       
   619  *      is not linked.
       
   620  * 'next_or_number' - Default is 'number' (string). Indicates whether page
       
   621  *      numbers should be used. Valid values are number and next.
       
   622  * 'separator' - Default is ' ' (string). Text used between pagination links.
       
   623  * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page.
       
   624  *      of the bookmark.
       
   625  * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to
       
   626  *      previous page, if available.
       
   627  * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in
       
   628  *      the parameter string will be replaced with the page number, so Page %
       
   629  *      generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
       
   630  * 'echo' - Default is 1 (integer). When not 0, this triggers the HTML to be
       
   631  *      echoed and then returned.
       
   632  *
       
   633  * @since 1.2.0
   761  * @since 1.2.0
   634  *
   762  *
   635  * @param string|array $args Optional. Overwrite the defaults.
   763  * @param string|array $args {
       
   764  *     Optional. Array or string of default arguments.
       
   765  *
       
   766  *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
       
   767  *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
       
   768  *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
       
   769  *                                          Also prepended to the current item, which is not linked. Default empty.
       
   770  *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
       
   771  *                                          Also appended to the current item, which is not linked. Default empty.
       
   772  *     @type string       $next_or_number   Indicates whether page numbers should be used. Valid values are number
       
   773  *                                          and next. Default is 'number'.
       
   774  *     @type string       $separator        Text between pagination links. Default is ' '.
       
   775  *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
       
   776  *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
       
   777  *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
       
   778  *                                          replaced with the page number, so 'Page %' generates "Page 1", "Page 2", etc.
       
   779  *                                          Defaults to '%', just the page number.
       
   780  *     @type int|bool     $echo             Whether to echo or not. Accepts 1|true or 0|false. Default 1|true.
       
   781  * }
   636  * @return string Formatted output in HTML.
   782  * @return string Formatted output in HTML.
   637  */
   783  */
   638 function wp_link_pages( $args = '' ) {
   784 function wp_link_pages( $args = '' ) {
   639 	$defaults = array(
   785 	$defaults = array(
   640 		'before'           => '<p>' . __( 'Pages:' ),
   786 		'before'           => '<p>' . __( 'Pages:' ),
   647 		'previouspagelink' => __( 'Previous page' ),
   793 		'previouspagelink' => __( 'Previous page' ),
   648 		'pagelink'         => '%',
   794 		'pagelink'         => '%',
   649 		'echo'             => 1
   795 		'echo'             => 1
   650 	);
   796 	);
   651 
   797 
   652 	$r = wp_parse_args( $args, $defaults );
   798 	$params = wp_parse_args( $args, $defaults );
   653 	$r = apply_filters( 'wp_link_pages_args', $r );
   799 
   654 	extract( $r, EXTR_SKIP );
   800 	/**
       
   801 	 * Filter the arguments used in retrieving page links for paginated posts.
       
   802 	 *
       
   803 	 * @since 3.0.0
       
   804 	 *
       
   805 	 * @param array $params An array of arguments for page links for paginated posts.
       
   806 	 */
       
   807 	$r = apply_filters( 'wp_link_pages_args', $params );
   655 
   808 
   656 	global $page, $numpages, $multipage, $more;
   809 	global $page, $numpages, $multipage, $more;
   657 
   810 
   658 	$output = '';
   811 	$output = '';
   659 	if ( $multipage ) {
   812 	if ( $multipage ) {
   660 		if ( 'number' == $next_or_number ) {
   813 		if ( 'number' == $r['next_or_number'] ) {
   661 			$output .= $before;
   814 			$output .= $r['before'];
   662 			for ( $i = 1; $i <= $numpages; $i++ ) {
   815 			for ( $i = 1; $i <= $numpages; $i++ ) {
   663 				$link = $link_before . str_replace( '%', $i, $pagelink ) . $link_after;
   816 				$link = $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after'];
   664 				if ( $i != $page || ! $more && 1 == $page )
   817 				if ( $i != $page || ! $more && 1 == $page ) {
   665 					$link = _wp_link_page( $i ) . $link . '</a>';
   818 					$link = _wp_link_page( $i ) . $link . '</a>';
       
   819 				}
       
   820 				/**
       
   821 				 * Filter the HTML output of individual page number links.
       
   822 				 *
       
   823 				 * @since 3.6.0
       
   824 				 *
       
   825 				 * @param string $link The page number HTML output.
       
   826 				 * @param int    $i    Page number for paginated posts' page links.
       
   827 				 */
   666 				$link = apply_filters( 'wp_link_pages_link', $link, $i );
   828 				$link = apply_filters( 'wp_link_pages_link', $link, $i );
   667 				$output .= $separator . $link;
   829 
       
   830 				// Use the custom links separator beginning with the second link.
       
   831 				$output .= ( 1 === $i ) ? ' ' : $r['separator'];
       
   832 				$output .= $link;
   668 			}
   833 			}
   669 			$output .= $after;
   834 			$output .= $r['after'];
   670 		} elseif ( $more ) {
   835 		} elseif ( $more ) {
   671 			$output .= $before;
   836 			$output .= $r['before'];
   672 			$i = $page - 1;
   837 			$prev = $page - 1;
   673 			if ( $i ) {
   838 			if ( $prev ) {
   674 				$link = _wp_link_page( $i ) . $link_before . $previouspagelink . $link_after . '</a>';
   839 				$link = _wp_link_page( $prev ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
   675 				$link = apply_filters( 'wp_link_pages_link', $link, $i );
   840 
   676 				$output .= $separator . $link;
   841 				/** This filter is documented in wp-includes/post-template.php */
       
   842 				$output .= apply_filters( 'wp_link_pages_link', $link, $prev );
   677 			}
   843 			}
   678 			$i = $page + 1;
   844 			$next = $page + 1;
   679 			if ( $i <= $numpages ) {
   845 			if ( $next <= $numpages ) {
   680 				$link = _wp_link_page( $i ) . $link_before . $nextpagelink . $link_after . '</a>';
   846 				if ( $prev ) {
   681 				$link = apply_filters( 'wp_link_pages_link', $link, $i );
   847 					$output .= $r['separator'];
   682 				$output .= $separator . $link;
   848 				}
       
   849 				$link = _wp_link_page( $next ) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
       
   850 
       
   851 				/** This filter is documented in wp-includes/post-template.php */
       
   852 				$output .= apply_filters( 'wp_link_pages_link', $link, $next );
   683 			}
   853 			}
   684 			$output .= $after;
   854 			$output .= $r['after'];
   685 		}
   855 		}
   686 	}
   856 	}
   687 
   857 
   688 	$output = apply_filters( 'wp_link_pages', $output, $args );
   858 	/**
   689 
   859 	 * Filter the HTML output of page links for paginated posts.
   690 	if ( $echo )
   860 	 *
   691 		echo $output;
   861 	 * @since 3.6.0
   692 
   862 	 *
   693 	return $output;
   863 	 * @param string $output HTML output of paginated posts' page links.
       
   864 	 * @param array  $args   An array of arguments.
       
   865 	 */
       
   866 	$html = apply_filters( 'wp_link_pages', $output, $args );
       
   867 
       
   868 	if ( $r['echo'] ) {
       
   869 		echo $html;
       
   870 	}
       
   871 	return $html;
   694 }
   872 }
   695 
   873 
   696 /**
   874 /**
   697  * Helper function for wp_link_pages().
   875  * Helper function for wp_link_pages().
   698  *
   876  *
   715 			$url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
   893 			$url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
   716 		else
   894 		else
   717 			$url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
   895 			$url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
   718 	}
   896 	}
   719 
   897 
       
   898 	if ( is_preview() ) {
       
   899 		$url = add_query_arg( array(
       
   900 			'preview' => 'true'
       
   901 		), $url );
       
   902 
       
   903 		if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
       
   904 			$url = add_query_arg( array(
       
   905 				'preview_id'    => wp_unslash( $_GET['preview_id'] ),
       
   906 				'preview_nonce' => wp_unslash( $_GET['preview_nonce'] )
       
   907 			), $url );
       
   908 		}
       
   909 	}
       
   910 
   720 	return '<a href="' . esc_url( $url ) . '">';
   911 	return '<a href="' . esc_url( $url ) . '">';
   721 }
   912 }
   722 
   913 
   723 //
   914 //
   724 // Post-meta: Custom per-post fields.
   915 // Post-meta: Custom per-post fields.
   746 /**
   937 /**
   747  * Display list of post custom fields.
   938  * Display list of post custom fields.
   748  *
   939  *
   749  * @internal This will probably change at some point...
   940  * @internal This will probably change at some point...
   750  * @since 1.2.0
   941  * @since 1.2.0
   751  * @uses apply_filters() Calls 'the_meta_key' on list item HTML content, with key and value as separate parameters.
       
   752  */
   942  */
   753 function the_meta() {
   943 function the_meta() {
   754 	if ( $keys = get_post_custom_keys() ) {
   944 	if ( $keys = get_post_custom_keys() ) {
   755 		echo "<ul class='post-meta'>\n";
   945 		echo "<ul class='post-meta'>\n";
   756 		foreach ( (array) $keys as $key ) {
   946 		foreach ( (array) $keys as $key ) {
   757 			$keyt = trim($key);
   947 			$keyt = trim($key);
   758 			if ( is_protected_meta( $keyt, 'post' ) )
   948 			if ( is_protected_meta( $keyt, 'post' ) )
   759 				continue;
   949 				continue;
   760 			$values = array_map('trim', get_post_custom_values($key));
   950 			$values = array_map('trim', get_post_custom_values($key));
   761 			$value = implode($values,', ');
   951 			$value = implode($values,', ');
   762 			echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value);
   952 
       
   953 			/**
       
   954 			 * Filter the HTML output of the li element in the post custom fields list.
       
   955 			 *
       
   956 			 * @since 2.2.0
       
   957 			 *
       
   958 			 * @param string $html  The HTML output for the li element.
       
   959 			 * @param string $key   Meta key.
       
   960 			 * @param string $value Meta value.
       
   961 			 */
       
   962 			echo apply_filters( 'the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value );
   763 		}
   963 		}
   764 		echo "</ul>\n";
   964 		echo "</ul>\n";
   765 	}
   965 	}
   766 }
   966 }
   767 
   967 
   771 
   971 
   772 /**
   972 /**
   773  * Retrieve or display list of pages as a dropdown (select list).
   973  * Retrieve or display list of pages as a dropdown (select list).
   774  *
   974  *
   775  * @since 2.1.0
   975  * @since 2.1.0
   776  *
   976  * @since 4.2.0 The `$value_field` argument was added.
   777  * @param array|string $args Optional. Override default arguments.
   977  *
       
   978  * @param array|string $args {
       
   979  *     Optional. Array or string of arguments to generate a pages drop-down element.
       
   980  *
       
   981  *     @type int          $depth                 Maximum depth. Default 0.
       
   982  *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
       
   983  *     @type int|string   $selected              Value of the option that should be selected. Default 0.
       
   984  *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
       
   985  *                                               or their bool equivalents. Default 1.
       
   986  *     @type string       $name                  Value for the 'name' attribute of the select element.
       
   987  *                                               Default 'page_id'.
       
   988  *     @type string       $id                    Value for the 'id' attribute of the select element.
       
   989  *                                               Defaults to the value of `$name`.
       
   990  *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
       
   991  *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
       
   992  *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
       
   993  *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
       
   994  *                                               elements. Accepts any valid post field. Default 'ID'.
       
   995  * }
   778  * @return string HTML content, if not displaying.
   996  * @return string HTML content, if not displaying.
   779  */
   997  */
   780 function wp_dropdown_pages($args = '') {
   998 function wp_dropdown_pages( $args = '' ) {
   781 	$defaults = array(
   999 	$defaults = array(
   782 		'depth' => 0, 'child_of' => 0,
  1000 		'depth' => 0, 'child_of' => 0,
   783 		'selected' => 0, 'echo' => 1,
  1001 		'selected' => 0, 'echo' => 1,
   784 		'name' => 'page_id', 'id' => '',
  1002 		'name' => 'page_id', 'id' => '',
   785 		'show_option_none' => '', 'show_option_no_change' => '',
  1003 		'show_option_none' => '', 'show_option_no_change' => '',
   786 		'option_none_value' => ''
  1004 		'option_none_value' => '',
       
  1005 		'value_field' => 'ID',
   787 	);
  1006 	);
   788 
  1007 
   789 	$r = wp_parse_args( $args, $defaults );
  1008 	$r = wp_parse_args( $args, $defaults );
   790 	extract( $r, EXTR_SKIP );
  1009 
   791 
  1010 	$pages = get_pages( $r );
   792 	$pages = get_pages($r);
       
   793 	$output = '';
  1011 	$output = '';
   794 	// Back-compat with old system where both id and name were based on $name argument
  1012 	// Back-compat with old system where both id and name were based on $name argument
   795 	if ( empty($id) )
  1013 	if ( empty( $r['id'] ) ) {
   796 		$id = $name;
  1014 		$r['id'] = $r['name'];
   797 
  1015 	}
   798 	if ( ! empty($pages) ) {
  1016 
   799 		$output = "<select name='" . esc_attr( $name ) . "' id='" . esc_attr( $id ) . "'>\n";
  1017 	if ( ! empty( $pages ) ) {
   800 		if ( $show_option_no_change )
  1018 		$output = "<select name='" . esc_attr( $r['name'] ) . "' id='" . esc_attr( $r['id'] ) . "'>\n";
   801 			$output .= "\t<option value=\"-1\">$show_option_no_change</option>";
  1019 		if ( $r['show_option_no_change'] ) {
   802 		if ( $show_option_none )
  1020 			$output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
   803 			$output .= "\t<option value=\"" . esc_attr($option_none_value) . "\">$show_option_none</option>\n";
  1021 		}
   804 		$output .= walk_page_dropdown_tree($pages, $depth, $r);
  1022 		if ( $r['show_option_none'] ) {
       
  1023 			$output .= "\t<option value=\"" . esc_attr( $r['option_none_value'] ) . '">' . $r['show_option_none'] . "</option>\n";
       
  1024 		}
       
  1025 		$output .= walk_page_dropdown_tree( $pages, $r['depth'], $r );
   805 		$output .= "</select>\n";
  1026 		$output .= "</select>\n";
   806 	}
  1027 	}
   807 
  1028 
   808 	$output = apply_filters('wp_dropdown_pages', $output);
  1029 	/**
   809 
  1030 	 * Filter the HTML output of a list of pages as a drop down.
   810 	if ( $echo )
  1031 	 *
   811 		echo $output;
  1032 	 * @since 2.1.0
   812 
  1033 	 *
   813 	return $output;
  1034 	 * @param string $output HTML output for drop down list of pages.
       
  1035 	 */
       
  1036 	$html = apply_filters( 'wp_dropdown_pages', $output );
       
  1037 
       
  1038 	if ( $r['echo'] ) {
       
  1039 		echo $html;
       
  1040 	}
       
  1041 	return $html;
   814 }
  1042 }
   815 
  1043 
   816 /**
  1044 /**
   817  * Retrieve or display list of pages in list (li) format.
  1045  * Retrieve or display list of pages in list (li) format.
   818  *
  1046  *
   819  * @since 1.5.0
  1047  * @since 1.5.0
   820  *
  1048  *
   821  * @param array|string $args Optional. Override default arguments.
  1049  * @see get_pages()
   822  * @return string HTML content, if not displaying.
  1050  *
   823  */
  1051  * @param array|string $args {
   824 function wp_list_pages($args = '') {
  1052  *     Array or string of arguments. Optional.
       
  1053  *
       
  1054  *     @type int    $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
       
  1055  *     @type string $authors      Comma-separated list of author IDs. Default empty (all authors).
       
  1056  *     @type string $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
       
  1057  *                                Default is the value of 'date_format' option.
       
  1058  *     @type int    $depth        Number of levels in the hierarchy of pages to include in the generated list.
       
  1059  *                                Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
       
  1060  *                                the given n depth). Default 0.
       
  1061  *     @type bool   $echo         Whether or not to echo the list of pages. Default true.
       
  1062  *     @type string $exclude      Comma-separated list of page IDs to exclude. Default empty.
       
  1063  *     @type array  $include      Comma-separated list of page IDs to include. Default empty.
       
  1064  *     @type string $link_after   Text or HTML to follow the page link label. Default null.
       
  1065  *     @type string $link_before  Text or HTML to precede the page link label. Default null.
       
  1066  *     @type string $post_type    Post type to query for. Default 'page'.
       
  1067  *     @type string $post_status  Comma-separated list of post statuses to include. Default 'publish'.
       
  1068  *     @type string $show_date	  Whether to display the page publish or modified date for each page. Accepts
       
  1069  *                                'modified' or any other value. An empty value hides the date. Default empty.
       
  1070  *     @type string $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
       
  1071  *                                'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
       
  1072  *                                'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
       
  1073  *     @type string $title_li     List heading. Passing a null or empty value will result in no heading, and the list
       
  1074  *                                will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
       
  1075  *     @type Walker $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
       
  1076  * }
       
  1077  * @return string HTML list of pages.
       
  1078  */
       
  1079 function wp_list_pages( $args = '' ) {
   825 	$defaults = array(
  1080 	$defaults = array(
   826 		'depth' => 0, 'show_date' => '',
  1081 		'depth' => 0, 'show_date' => '',
   827 		'date_format' => get_option('date_format'),
  1082 		'date_format' => get_option( 'date_format' ),
   828 		'child_of' => 0, 'exclude' => '',
  1083 		'child_of' => 0, 'exclude' => '',
   829 		'title_li' => __('Pages'), 'echo' => 1,
  1084 		'title_li' => __( 'Pages' ), 'echo' => 1,
   830 		'authors' => '', 'sort_column' => 'menu_order, post_title',
  1085 		'authors' => '', 'sort_column' => 'menu_order, post_title',
   831 		'link_before' => '', 'link_after' => '', 'walker' => '',
  1086 		'link_before' => '', 'link_after' => '', 'walker' => '',
   832 	);
  1087 	);
   833 
  1088 
   834 	$r = wp_parse_args( $args, $defaults );
  1089 	$r = wp_parse_args( $args, $defaults );
   835 	extract( $r, EXTR_SKIP );
       
   836 
  1090 
   837 	$output = '';
  1091 	$output = '';
   838 	$current_page = 0;
  1092 	$current_page = 0;
   839 
  1093 
   840 	// sanitize, mostly to keep spaces out
  1094 	// sanitize, mostly to keep spaces out
   841 	$r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
  1095 	$r['exclude'] = preg_replace( '/[^0-9,]/', '', $r['exclude'] );
   842 
  1096 
   843 	// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
  1097 	// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
   844 	$exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();
  1098 	$exclude_array = ( $r['exclude'] ) ? explode( ',', $r['exclude'] ) : array();
   845 	$r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );
  1099 
       
  1100 	/**
       
  1101 	 * Filter the array of pages to exclude from the pages list.
       
  1102 	 *
       
  1103 	 * @since 2.1.0
       
  1104 	 *
       
  1105 	 * @param array $exclude_array An array of page IDs to exclude.
       
  1106 	 */
       
  1107 	$r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) );
   846 
  1108 
   847 	// Query pages.
  1109 	// Query pages.
   848 	$r['hierarchical'] = 0;
  1110 	$r['hierarchical'] = 0;
   849 	$pages = get_pages($r);
  1111 	$pages = get_pages( $r );
   850 
  1112 
   851 	if ( !empty($pages) ) {
  1113 	if ( ! empty( $pages ) ) {
   852 		if ( $r['title_li'] )
  1114 		if ( $r['title_li'] ) {
   853 			$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
  1115 			$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
   854 
  1116 		}
   855 		global $wp_query;
  1117 		global $wp_query;
   856 		if ( is_page() || is_attachment() || $wp_query->is_posts_page )
  1118 		if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
   857 			$current_page = $wp_query->get_queried_object_id();
  1119 			$current_page = get_queried_object_id();
   858 		$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
  1120 		} elseif ( is_singular() ) {
   859 
  1121 			$queried_object = get_queried_object();
   860 		if ( $r['title_li'] )
  1122 			if ( is_post_type_hierarchical( $queried_object->post_type ) ) {
       
  1123 				$current_page = $queried_object->ID;
       
  1124 			}
       
  1125 		}
       
  1126 
       
  1127 		$output .= walk_page_tree( $pages, $r['depth'], $current_page, $r );
       
  1128 
       
  1129 		if ( $r['title_li'] ) {
   861 			$output .= '</ul></li>';
  1130 			$output .= '</ul></li>';
   862 	}
  1131 		}
   863 
  1132 	}
   864 	$output = apply_filters('wp_list_pages', $output, $r);
  1133 
   865 
  1134 	/**
   866 	if ( $r['echo'] )
  1135 	 * Filter the HTML output of the pages to list.
   867 		echo $output;
  1136 	 *
   868 	else
  1137 	 * @since 1.5.1
   869 		return $output;
  1138 	 *
       
  1139 	 * @see wp_list_pages()
       
  1140 	 *
       
  1141 	 * @param string $output HTML output of the pages list.
       
  1142 	 * @param array  $r      An array of page-listing arguments.
       
  1143 	 */
       
  1144 	$html = apply_filters( 'wp_list_pages', $output, $r );
       
  1145 
       
  1146 	if ( $r['echo'] ) {
       
  1147 		echo $html;
       
  1148 	} else {
       
  1149 		return $html;
       
  1150 	}
   870 }
  1151 }
   871 
  1152 
   872 /**
  1153 /**
   873  * Display or retrieve list of pages with optional home link.
  1154  * Display or retrieve list of pages with optional home link.
   874  *
  1155  *
   875  * The arguments are listed below and part of the arguments are for {@link
  1156  * The arguments are listed below and part of the arguments are for {@link
   876  * wp_list_pages()} function. Check that function for more info on those
  1157  * wp_list_pages()} function. Check that function for more info on those
   877  * arguments.
  1158  * arguments.
   878  *
  1159  *
   879  * <ul>
       
   880  * <li><strong>sort_column</strong> - How to sort the list of pages. Defaults
       
   881  * to 'menu_order, post_title'. Use column for posts table.</li>
       
   882  * <li><strong>menu_class</strong> - Class to use for the div ID which contains
       
   883  * the page list. Defaults to 'menu'.</li>
       
   884  * <li><strong>echo</strong> - Whether to echo list or return it. Defaults to
       
   885  * echo.</li>
       
   886  * <li><strong>link_before</strong> - Text before show_home argument text.</li>
       
   887  * <li><strong>link_after</strong> - Text after show_home argument text.</li>
       
   888  * <li><strong>show_home</strong> - If you set this argument, then it will
       
   889  * display the link to the home page. The show_home argument really just needs
       
   890  * to be set to the value of the text of the link.</li>
       
   891  * </ul>
       
   892  *
       
   893  * @since 2.7.0
  1160  * @since 2.7.0
   894  *
  1161  *
   895  * @param array|string $args
  1162  * @param array|string $args {
       
  1163  *     Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
       
  1164  *
       
  1165  *     @type string          $sort_column How to short the list of pages. Accepts post column names.
       
  1166  *                                        Default 'menu_order, post_title'.
       
  1167  *     @type string          $menu_class  Class to use for the div ID containing the page list. Default 'menu'.
       
  1168  *     @type bool            $echo        Whether to echo the list or return it. Accepts true (echo) or false (return).
       
  1169  *                                        Default true.
       
  1170  *     @type string          $link_before The HTML or text to prepend to $show_home text. Default empty.
       
  1171  *     @type string          $link_after  The HTML or text to append to $show_home text. Default empty.
       
  1172  *     @type int|bool|string $show_home   Whether to display the link to the home page. Can just enter the text
       
  1173  *                                        you'd like shown for the home link. 1|true defaults to 'Home'.
       
  1174  * }
   896  * @return string html menu
  1175  * @return string html menu
   897  */
  1176  */
   898 function wp_page_menu( $args = array() ) {
  1177 function wp_page_menu( $args = array() ) {
   899 	$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
  1178 	$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
   900 	$args = wp_parse_args( $args, $defaults );
  1179 	$args = wp_parse_args( $args, $defaults );
       
  1180 
       
  1181 	/**
       
  1182 	 * Filter the arguments used to generate a page-based menu.
       
  1183 	 *
       
  1184 	 * @since 2.7.0
       
  1185 	 *
       
  1186 	 * @see wp_page_menu()
       
  1187 	 *
       
  1188 	 * @param array $args An array of page menu arguments.
       
  1189 	 */
   901 	$args = apply_filters( 'wp_page_menu_args', $args );
  1190 	$args = apply_filters( 'wp_page_menu_args', $args );
   902 
  1191 
   903 	$menu = '';
  1192 	$menu = '';
   904 
  1193 
   905 	$list_args = $args;
  1194 	$list_args = $args;
   931 
  1220 
   932 	if ( $menu )
  1221 	if ( $menu )
   933 		$menu = '<ul>' . $menu . '</ul>';
  1222 		$menu = '<ul>' . $menu . '</ul>';
   934 
  1223 
   935 	$menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
  1224 	$menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
       
  1225 
       
  1226 	/**
       
  1227 	 * Filter the HTML output of a page-based menu.
       
  1228 	 *
       
  1229 	 * @since 2.7.0
       
  1230 	 *
       
  1231 	 * @see wp_page_menu()
       
  1232 	 *
       
  1233 	 * @param string $menu The HTML output.
       
  1234 	 * @param array  $args An array of arguments.
       
  1235 	 */
   936 	$menu = apply_filters( 'wp_page_menu', $menu, $args );
  1236 	$menu = apply_filters( 'wp_page_menu', $menu, $args );
   937 	if ( $args['echo'] )
  1237 	if ( $args['echo'] )
   938 		echo $menu;
  1238 		echo $menu;
   939 	else
  1239 	else
   940 		return $menu;
  1240 		return $menu;
   984 }
  1284 }
   985 
  1285 
   986 /**
  1286 /**
   987  * Create HTML list of pages.
  1287  * Create HTML list of pages.
   988  *
  1288  *
   989  * @package WordPress
       
   990  * @since 2.1.0
  1289  * @since 2.1.0
   991  * @uses Walker
  1290  * @uses Walker
   992  */
  1291  */
   993 class Walker_Page extends Walker {
  1292 class Walker_Page extends Walker {
   994 	/**
  1293 	/**
   995 	 * @see Walker::$tree_type
  1294 	 * @see Walker::$tree_type
   996 	 * @since 2.1.0
  1295 	 * @since 2.1.0
   997 	 * @var string
  1296 	 * @var string
   998 	 */
  1297 	 */
   999 	var $tree_type = 'page';
  1298 	public $tree_type = 'page';
  1000 
  1299 
  1001 	/**
  1300 	/**
  1002 	 * @see Walker::$db_fields
  1301 	 * @see Walker::$db_fields
  1003 	 * @since 2.1.0
  1302 	 * @since 2.1.0
  1004 	 * @todo Decouple this.
  1303 	 * @todo Decouple this.
  1005 	 * @var array
  1304 	 * @var array
  1006 	 */
  1305 	 */
  1007 	var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
  1306 	public $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
  1008 
  1307 
  1009 	/**
  1308 	/**
  1010 	 * @see Walker::start_lvl()
  1309 	 * @see Walker::start_lvl()
  1011 	 * @since 2.1.0
  1310 	 * @since 2.1.0
  1012 	 *
  1311 	 *
  1013 	 * @param string $output Passed by reference. Used to append additional content.
  1312 	 * @param string $output Passed by reference. Used to append additional content.
  1014 	 * @param int $depth Depth of page. Used for padding.
  1313 	 * @param int $depth Depth of page. Used for padding.
  1015 	 * @param array $args
  1314 	 * @param array $args
  1016 	 */
  1315 	 */
  1017 	function start_lvl( &$output, $depth = 0, $args = array() ) {
  1316 	public function start_lvl( &$output, $depth = 0, $args = array() ) {
  1018 		$indent = str_repeat("\t", $depth);
  1317 		$indent = str_repeat("\t", $depth);
  1019 		$output .= "\n$indent<ul class='children'>\n";
  1318 		$output .= "\n$indent<ul class='children'>\n";
  1020 	}
  1319 	}
  1021 
  1320 
  1022 	/**
  1321 	/**
  1025 	 *
  1324 	 *
  1026 	 * @param string $output Passed by reference. Used to append additional content.
  1325 	 * @param string $output Passed by reference. Used to append additional content.
  1027 	 * @param int $depth Depth of page. Used for padding.
  1326 	 * @param int $depth Depth of page. Used for padding.
  1028 	 * @param array $args
  1327 	 * @param array $args
  1029 	 */
  1328 	 */
  1030 	function end_lvl( &$output, $depth = 0, $args = array() ) {
  1329 	public function end_lvl( &$output, $depth = 0, $args = array() ) {
  1031 		$indent = str_repeat("\t", $depth);
  1330 		$indent = str_repeat("\t", $depth);
  1032 		$output .= "$indent</ul>\n";
  1331 		$output .= "$indent</ul>\n";
  1033 	}
  1332 	}
  1034 
  1333 
  1035 	/**
  1334 	/**
  1040 	 * @param object $page Page data object.
  1339 	 * @param object $page Page data object.
  1041 	 * @param int $depth Depth of page. Used for padding.
  1340 	 * @param int $depth Depth of page. Used for padding.
  1042 	 * @param int $current_page Page ID.
  1341 	 * @param int $current_page Page ID.
  1043 	 * @param array $args
  1342 	 * @param array $args
  1044 	 */
  1343 	 */
  1045 	function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
  1344 	public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
  1046 		if ( $depth )
  1345 		if ( $depth ) {
  1047 			$indent = str_repeat("\t", $depth);
  1346 			$indent = str_repeat( "\t", $depth );
  1048 		else
  1347 		} else {
  1049 			$indent = '';
  1348 			$indent = '';
  1050 
  1349 		}
  1051 		extract($args, EXTR_SKIP);
  1350 
  1052 		$css_class = array('page_item', 'page-item-'.$page->ID);
  1351 		$css_class = array( 'page_item', 'page-item-' . $page->ID );
  1053 
  1352 
  1054 		if( isset( $args['pages_with_children'][ $page->ID ] ) )
  1353 		if ( isset( $args['pages_with_children'][ $page->ID ] ) ) {
  1055 			$css_class[] = 'page_item_has_children';
  1354 			$css_class[] = 'page_item_has_children';
  1056 
  1355 		}
  1057 		if ( !empty($current_page) ) {
  1356 
       
  1357 		if ( ! empty( $current_page ) ) {
  1058 			$_current_page = get_post( $current_page );
  1358 			$_current_page = get_post( $current_page );
  1059 			if ( in_array( $page->ID, $_current_page->ancestors ) )
  1359 			if ( $_current_page && in_array( $page->ID, $_current_page->ancestors ) ) {
  1060 				$css_class[] = 'current_page_ancestor';
  1360 				$css_class[] = 'current_page_ancestor';
  1061 			if ( $page->ID == $current_page )
  1361 			}
       
  1362 			if ( $page->ID == $current_page ) {
  1062 				$css_class[] = 'current_page_item';
  1363 				$css_class[] = 'current_page_item';
  1063 			elseif ( $_current_page && $page->ID == $_current_page->post_parent )
  1364 			} elseif ( $_current_page && $page->ID == $_current_page->post_parent ) {
  1064 				$css_class[] = 'current_page_parent';
  1365 				$css_class[] = 'current_page_parent';
       
  1366 			}
  1065 		} elseif ( $page->ID == get_option('page_for_posts') ) {
  1367 		} elseif ( $page->ID == get_option('page_for_posts') ) {
  1066 			$css_class[] = 'current_page_parent';
  1368 			$css_class[] = 'current_page_parent';
  1067 		}
  1369 		}
  1068 
  1370 
  1069 		$css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
  1371 		/**
  1070 
  1372 		 * Filter the list of CSS classes to include with each page item in the list.
  1071 		if ( '' === $page->post_title )
  1373 		 *
       
  1374 		 * @since 2.8.0
       
  1375 		 *
       
  1376 		 * @see wp_list_pages()
       
  1377 		 *
       
  1378 		 * @param array   $css_class    An array of CSS classes to be applied
       
  1379 		 *                             to each list item.
       
  1380 		 * @param WP_Post $page         Page data object.
       
  1381 		 * @param int     $depth        Depth of page, used for padding.
       
  1382 		 * @param array   $args         An array of arguments.
       
  1383 		 * @param int     $current_page ID of the current page.
       
  1384 		 */
       
  1385 		$css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
       
  1386 
       
  1387 		if ( '' === $page->post_title ) {
  1072 			$page->post_title = sprintf( __( '#%d (no title)' ), $page->ID );
  1388 			$page->post_title = sprintf( __( '#%d (no title)' ), $page->ID );
       
  1389 		}
       
  1390 
       
  1391 		$args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before'];
       
  1392 		$args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after'];
  1073 
  1393 
  1074 		/** This filter is documented in wp-includes/post-template.php */
  1394 		/** This filter is documented in wp-includes/post-template.php */
  1075 		$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>';
  1395 		$output .= $indent . sprintf(
  1076 
  1396 			'<li class="%s"><a href="%s">%s%s%s</a>',
  1077 		if ( !empty($show_date) ) {
  1397 			$css_classes,
  1078 			if ( 'modified' == $show_date )
  1398 			get_permalink( $page->ID ),
       
  1399 			$args['link_before'],
       
  1400 			apply_filters( 'the_title', $page->post_title, $page->ID ),
       
  1401 			$args['link_after']
       
  1402 		);
       
  1403 
       
  1404 		if ( ! empty( $args['show_date'] ) ) {
       
  1405 			if ( 'modified' == $args['show_date'] ) {
  1079 				$time = $page->post_modified;
  1406 				$time = $page->post_modified;
  1080 			else
  1407 			} else {
  1081 				$time = $page->post_date;
  1408 				$time = $page->post_date;
  1082 
  1409 			}
  1083 			$output .= " " . mysql2date($date_format, $time);
  1410 
       
  1411 			$date_format = empty( $args['date_format'] ) ? '' : $args['date_format'];
       
  1412 			$output .= " " . mysql2date( $date_format, $time );
  1084 		}
  1413 		}
  1085 	}
  1414 	}
  1086 
  1415 
  1087 	/**
  1416 	/**
  1088 	 * @see Walker::end_el()
  1417 	 * @see Walker::end_el()
  1091 	 * @param string $output Passed by reference. Used to append additional content.
  1420 	 * @param string $output Passed by reference. Used to append additional content.
  1092 	 * @param object $page Page data object. Not used.
  1421 	 * @param object $page Page data object. Not used.
  1093 	 * @param int $depth Depth of page. Not Used.
  1422 	 * @param int $depth Depth of page. Not Used.
  1094 	 * @param array $args
  1423 	 * @param array $args
  1095 	 */
  1424 	 */
  1096 	function end_el( &$output, $page, $depth = 0, $args = array() ) {
  1425 	public function end_el( &$output, $page, $depth = 0, $args = array() ) {
  1097 		$output .= "</li>\n";
  1426 		$output .= "</li>\n";
  1098 	}
  1427 	}
  1099 
  1428 
  1100 }
  1429 }
  1101 
  1430 
  1102 /**
  1431 /**
  1103  * Create HTML dropdown list of pages.
  1432  * Create HTML dropdown list of pages.
  1104  *
  1433  *
  1105  * @package WordPress
       
  1106  * @since 2.1.0
  1434  * @since 2.1.0
  1107  * @uses Walker
  1435  * @uses Walker
  1108  */
  1436  */
  1109 class Walker_PageDropdown extends Walker {
  1437 class Walker_PageDropdown extends Walker {
  1110 	/**
  1438 	/**
  1111 	 * @see Walker::$tree_type
  1439 	 * @see Walker::$tree_type
  1112 	 * @since 2.1.0
  1440 	 * @since 2.1.0
  1113 	 * @var string
  1441 	 * @var string
  1114 	 */
  1442 	 */
  1115 	var $tree_type = 'page';
  1443 	public $tree_type = 'page';
  1116 
  1444 
  1117 	/**
  1445 	/**
  1118 	 * @see Walker::$db_fields
  1446 	 * @see Walker::$db_fields
  1119 	 * @since 2.1.0
  1447 	 * @since 2.1.0
  1120 	 * @todo Decouple this
  1448 	 * @todo Decouple this
  1121 	 * @var array
  1449 	 * @var array
  1122 	 */
  1450 	 */
  1123 	var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
  1451 	public $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
  1124 
  1452 
  1125 	/**
  1453 	/**
  1126 	 * @see Walker::start_el()
  1454 	 * @see Walker::start_el()
  1127 	 * @since 2.1.0
  1455 	 * @since 2.1.0
  1128 	 *
  1456 	 *
  1129 	 * @param string $output Passed by reference. Used to append additional content.
  1457 	 * @param string $output Passed by reference. Used to append additional content.
  1130 	 * @param object $page Page data object.
  1458 	 * @param object $page   Page data object.
  1131 	 * @param int $depth Depth of page in reference to parent pages. Used for padding.
  1459 	 * @param int    $depth  Depth of page in reference to parent pages. Used for padding.
  1132 	 * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.
  1460 	 * @param array  $args   Uses 'selected' argument for selected page to set selected HTML attribute for option
       
  1461 	 *              element. Uses 'value_field' argument to fill "value" attribute. See {@see wp_dropdown_pages()}.
  1133 	 * @param int $id
  1462 	 * @param int $id
  1134 	 */
  1463 	 */
  1135 	function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
  1464 	public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
  1136 		$pad = str_repeat('&nbsp;', $depth * 3);
  1465 		$pad = str_repeat('&nbsp;', $depth * 3);
  1137 
  1466 
  1138 		$output .= "\t<option class=\"level-$depth\" value=\"$page->ID\"";
  1467 		if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) {
       
  1468 			$args['value_field'] = 'ID';
       
  1469 		}
       
  1470 
       
  1471 		$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $page->{$args['value_field']} ) . "\"";
  1139 		if ( $page->ID == $args['selected'] )
  1472 		if ( $page->ID == $args['selected'] )
  1140 			$output .= ' selected="selected"';
  1473 			$output .= ' selected="selected"';
  1141 		$output .= '>';
  1474 		$output .= '>';
  1142 		$title = apply_filters( 'list_pages', $page->post_title, $page );
  1475 
       
  1476 		$title = $page->post_title;
       
  1477 		if ( '' === $title ) {
       
  1478 			$title = sprintf( __( '#%d (no title)' ), $page->ID );
       
  1479 		}
       
  1480 
       
  1481 		/**
       
  1482 		 * Filter the page title when creating an HTML drop-down list of pages.
       
  1483 		 *
       
  1484 		 * @since 3.1.0
       
  1485 		 *
       
  1486 		 * @param string $title Page title.
       
  1487 		 * @param object $page  Page data object.
       
  1488 		 */
       
  1489 		$title = apply_filters( 'list_pages', $title, $page );
  1143 		$output .= $pad . esc_html( $title );
  1490 		$output .= $pad . esc_html( $title );
  1144 		$output .= "</option>\n";
  1491 		$output .= "</option>\n";
  1145 	}
  1492 	}
  1146 }
  1493 }
  1147 
  1494 
  1152 /**
  1499 /**
  1153  * Display an attachment page link using an image or icon.
  1500  * Display an attachment page link using an image or icon.
  1154  *
  1501  *
  1155  * @since 2.0.0
  1502  * @since 2.0.0
  1156  *
  1503  *
  1157  * @param int $id Optional. Post ID.
  1504  * @param int|WP_Post $id Optional. Post ID or post object.
  1158  * @param bool $fullsize Optional, default is false. Whether to use full size.
  1505  * @param bool        $fullsize     Optional, default is false. Whether to use full size.
  1159  * @param bool $deprecated Deprecated. Not used.
  1506  * @param bool        $deprecated   Deprecated. Not used.
  1160  * @param bool $permalink Optional, default is false. Whether to include permalink.
  1507  * @param bool        $permalink    Optional, default is false. Whether to include permalink.
  1161  */
  1508  */
  1162 function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
  1509 function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
  1163 	if ( !empty( $deprecated ) )
  1510 	if ( !empty( $deprecated ) )
  1164 		_deprecated_argument( __FUNCTION__, '2.5' );
  1511 		_deprecated_argument( __FUNCTION__, '2.5' );
  1165 
  1512 
  1171 
  1518 
  1172 /**
  1519 /**
  1173  * Retrieve an attachment page link using an image or icon, if possible.
  1520  * Retrieve an attachment page link using an image or icon, if possible.
  1174  *
  1521  *
  1175  * @since 2.5.0
  1522  * @since 2.5.0
  1176  * @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
  1523  *
  1177  *
  1524  * @param int|WP_Post  $id        Optional. Post ID or post object.
  1178  * @param int $id Optional. Post ID.
  1525  * @param string       $size      Optional, default is 'thumbnail'. Size of image, either array or string.
  1179  * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string.
  1526  * @param bool         $permalink Optional, default is false. Whether to add permalink to image.
  1180  * @param bool $permalink Optional, default is false. Whether to add permalink to image.
  1527  * @param bool         $icon      Optional, default is false. Whether to include icon.
  1181  * @param bool $icon Optional, default is false. Whether to include icon.
  1528  * @param string|bool  $text      Optional, default is false. If string, then will be link text.
  1182  * @param string|bool $text Optional, default is false. If string, then will be link text.
  1529  * @param array|string $attr      Optional. Array or string of attributes.
  1183  * @return string HTML content.
  1530  * @return string HTML content.
  1184  */
  1531  */
  1185 function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {
  1532 function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
  1186 	$id = intval( $id );
  1533 	$id = intval( $id );
  1187 	$_post = get_post( $id );
  1534 	$_post = get_post( $id );
  1188 
  1535 
  1189 	if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
  1536 	if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
  1190 		return __( 'Missing Attachment' );
  1537 		return __( 'Missing Attachment' );
  1191 
  1538 
  1192 	if ( $permalink )
  1539 	if ( $permalink )
  1193 		$url = get_attachment_link( $_post->ID );
  1540 		$url = get_attachment_link( $_post->ID );
  1194 
  1541 
  1195 	$post_title = esc_attr( $_post->post_title );
  1542 	if ( $text ) {
  1196 
       
  1197 	if ( $text )
       
  1198 		$link_text = $text;
  1543 		$link_text = $text;
  1199 	elseif ( $size && 'none' != $size )
  1544 	} elseif ( $size && 'none' != $size ) {
  1200 		$link_text = wp_get_attachment_image( $id, $size, $icon );
  1545 		$link_text = wp_get_attachment_image( $id, $size, $icon, $attr );
  1201 	else
  1546 	} else {
  1202 		$link_text = '';
  1547 		$link_text = '';
       
  1548 	}
  1203 
  1549 
  1204 	if ( trim( $link_text ) == '' )
  1550 	if ( trim( $link_text ) == '' )
  1205 		$link_text = $_post->post_title;
  1551 		$link_text = $_post->post_title;
  1206 
  1552 
       
  1553 	/**
       
  1554 	 * Filter a retrieved attachment page link.
       
  1555 	 *
       
  1556 	 * @since 2.7.0
       
  1557 	 *
       
  1558 	 * @param string      $link_html The page link HTML output.
       
  1559 	 * @param int         $id        Post ID.
       
  1560 	 * @param string      $size      Image size. Default 'thumbnail'.
       
  1561 	 * @param bool        $permalink Whether to add permalink to image. Default false.
       
  1562 	 * @param bool        $icon      Whether to include an icon. Default false.
       
  1563 	 * @param string|bool $text      If string, will be link text. Default false.
       
  1564 	 */
  1207 	return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text );
  1565 	return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text );
  1208 }
  1566 }
  1209 
  1567 
  1210 /**
  1568 /**
  1211  * Wrap attachment in <<p>> element before content.
  1569  * Wrap attachment in paragraph tag before content.
  1212  *
  1570  *
  1213  * @since 2.0.0
  1571  * @since 2.0.0
  1214  * @uses apply_filters() Calls 'prepend_attachment' hook on HTML content.
       
  1215  *
  1572  *
  1216  * @param string $content
  1573  * @param string $content
  1217  * @return string
  1574  * @return string
  1218  */
  1575  */
  1219 function prepend_attachment($content) {
  1576 function prepend_attachment($content) {
  1220 	$post = get_post();
  1577 	$post = get_post();
  1221 
  1578 
  1222 	if ( empty($post->post_type) || $post->post_type != 'attachment' )
  1579 	if ( empty($post->post_type) || $post->post_type != 'attachment' )
  1223 		return $content;
  1580 		return $content;
  1224 
  1581 
  1225 	$p = '<p class="attachment">';
  1582 	if ( wp_attachment_is( 'video', $post ) ) {
  1226 	// show the medium sized image representation of the attachment if available, and link to the raw file
  1583 		$meta = wp_get_attachment_metadata( get_the_ID() );
  1227 	$p .= wp_get_attachment_link(0, 'medium', false);
  1584 		$atts = array( 'src' => wp_get_attachment_url() );
  1228 	$p .= '</p>';
  1585 		if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
  1229 	$p = apply_filters('prepend_attachment', $p);
  1586 			$atts['width'] = (int) $meta['width'];
       
  1587 			$atts['height'] = (int) $meta['height'];
       
  1588 		}
       
  1589 		if ( has_post_thumbnail() ) {
       
  1590 			$atts['poster'] = wp_get_attachment_url( get_post_thumbnail_id() );
       
  1591 		}
       
  1592 		$p = wp_video_shortcode( $atts );
       
  1593 	} elseif ( wp_attachment_is( 'audio', $post ) ) {
       
  1594 		$p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) );
       
  1595 	} else {
       
  1596 		$p = '<p class="attachment">';
       
  1597 		// show the medium sized image representation of the attachment if available, and link to the raw file
       
  1598 		$p .= wp_get_attachment_link(0, 'medium', false);
       
  1599 		$p .= '</p>';
       
  1600 	}
       
  1601 
       
  1602 	/**
       
  1603 	 * Filter the attachment markup to be prepended to the post content.
       
  1604 	 *
       
  1605 	 * @since 2.0.0
       
  1606 	 *
       
  1607 	 * @see prepend_attachment()
       
  1608 	 *
       
  1609 	 * @param string $p The attachment HTML output.
       
  1610 	 */
       
  1611 	$p = apply_filters( 'prepend_attachment', $p );
  1230 
  1612 
  1231 	return "$p\n$content";
  1613 	return "$p\n$content";
  1232 }
  1614 }
  1233 
  1615 
  1234 //
  1616 //
  1237 
  1619 
  1238 /**
  1620 /**
  1239  * Retrieve protected post password form content.
  1621  * Retrieve protected post password form content.
  1240  *
  1622  *
  1241  * @since 1.0.0
  1623  * @since 1.0.0
  1242  * @uses apply_filters() Calls 'the_password_form' filter on output.
  1624  *
  1243  * @param int|WP_Post $post Optional. A post id or post object. Defaults to the current post when in The Loop, undefined otherwise.
  1625  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
  1244  * @return string HTML content for password form for password protected post.
  1626  * @return string HTML content for password form for password protected post.
  1245  */
  1627  */
  1246 function get_the_password_form( $post = 0 ) {
  1628 function get_the_password_form( $post = 0 ) {
  1247 	$post = get_post( $post );
  1629 	$post = get_post( $post );
  1248 	$label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
  1630 	$label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
  1249 	$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
  1631 	$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
  1250 	<p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
  1632 	<p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
  1251 	<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>
  1633 	<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></form>
  1252 	</form>
       
  1253 	';
  1634 	';
       
  1635 
       
  1636 	/**
       
  1637 	 * Filter the HTML output for the protected post password form.
       
  1638 	 *
       
  1639 	 * If modifying the password field, please note that the core database schema
       
  1640 	 * limits the password field to 20 characters regardless of the value of the
       
  1641 	 * size attribute in the form input.
       
  1642 	 *
       
  1643 	 * @since 2.7.0
       
  1644 	 *
       
  1645 	 * @param string $output The password form HTML output.
       
  1646 	 */
  1254 	return apply_filters( 'the_password_form', $output );
  1647 	return apply_filters( 'the_password_form', $output );
  1255 }
  1648 }
  1256 
  1649 
  1257 /**
  1650 /**
  1258  * Whether currently in a page template.
  1651  * Whether currently in a page template.
  1259  *
  1652  *
  1260  * This template tag allows you to determine if you are in a page template.
  1653  * This template tag allows you to determine if you are in a page template.
  1261  * You can optionally provide a template name and then the check will be
  1654  * You can optionally provide a template name or array of template names
  1262  * specific to that template.
  1655  * and then the check will be specific to that template.
  1263  *
  1656  *
  1264  * @since 2.5.0
  1657  * @since 2.5.0
  1265  * @uses $wp_query
  1658  * @since 4.2.0 The `$template` parameter was changed to also accept an array of page templates.
  1266  *
  1659  *
  1267  * @param string $template The specific template name if specific matching is required.
  1660  * @param string|array $template The specific template name or array of templates to match.
  1268  * @return bool True on success, false on failure.
  1661  * @return bool True on success, false on failure.
  1269  */
  1662  */
  1270 function is_page_template( $template = '' ) {
  1663 function is_page_template( $template = '' ) {
  1271 	if ( ! is_page() )
  1664 	if ( ! is_page() )
  1272 		return false;
  1665 		return false;
  1276 	if ( empty( $template ) )
  1669 	if ( empty( $template ) )
  1277 		return (bool) $page_template;
  1670 		return (bool) $page_template;
  1278 
  1671 
  1279 	if ( $template == $page_template )
  1672 	if ( $template == $page_template )
  1280 		return true;
  1673 		return true;
       
  1674 
       
  1675 	if ( is_array( $template ) ) {
       
  1676 		if ( ( in_array( 'default', $template, true ) && ! $page_template )
       
  1677 			|| in_array( $page_template, $template, true )
       
  1678 		) {
       
  1679 			return true;
       
  1680 		}
       
  1681 	}
  1281 
  1682 
  1282 	if ( 'default' == $template && ! $page_template )
  1683 	if ( 'default' == $template && ! $page_template )
  1283 		return true;
  1684 		return true;
  1284 
  1685 
  1285 	return false;
  1686 	return false;
  1305 }
  1706 }
  1306 
  1707 
  1307 /**
  1708 /**
  1308  * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
  1709  * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
  1309  *
  1710  *
  1310  * @package WordPress
       
  1311  * @subpackage Post_Revisions
       
  1312  * @since 2.6.0
  1711  * @since 2.6.0
  1313  *
       
  1314  * @uses date_i18n()
       
  1315  *
  1712  *
  1316  * @param int|object $revision Revision ID or revision object.
  1713  * @param int|object $revision Revision ID or revision object.
  1317  * @param bool $link Optional, default is true. Link to revisions's page?
  1714  * @param bool $link Optional, default is true. Link to revisions's page?
  1318  * @return string i18n formatted datetimestamp or localized 'Current Revision'.
  1715  * @return string i18n formatted datetimestamp or localized 'Current Revision'.
  1319  */
  1716  */
  1323 
  1720 
  1324 	if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
  1721 	if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
  1325 		return false;
  1722 		return false;
  1326 
  1723 
  1327 	/* translators: revision date format, see http://php.net/date */
  1724 	/* translators: revision date format, see http://php.net/date */
  1328 	$datef = _x( 'j F, Y @ G:i', 'revision date format');
  1725 	$datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
  1329 	/* translators: 1: date */
  1726 	/* translators: 1: date */
  1330 	$autosavef = _x( '%1$s [Autosave]', 'post revision title extra' );
  1727 	$autosavef = _x( '%1$s [Autosave]', 'post revision title extra' );
  1331 	/* translators: 1: date */
  1728 	/* translators: 1: date */
  1332 	$currentf  = _x( '%1$s [Current Revision]', 'post revision title extra' );
  1729 	$currentf  = _x( '%1$s [Current Revision]', 'post revision title extra' );
  1333 
  1730 
  1344 }
  1741 }
  1345 
  1742 
  1346 /**
  1743 /**
  1347  * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
  1744  * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
  1348  *
  1745  *
  1349  * @package WordPress
       
  1350  * @subpackage Post_Revisions
       
  1351  * @since 3.6.0
  1746  * @since 3.6.0
  1352  *
       
  1353  * @uses date_i18n()
       
  1354  *
  1747  *
  1355  * @param int|object $revision Revision ID or revision object.
  1748  * @param int|object $revision Revision ID or revision object.
  1356  * @param bool $link Optional, default is true. Link to revisions's page?
  1749  * @param bool $link Optional, default is true. Link to revisions's page?
  1357  * @return string gravatar, user, i18n formatted datetimestamp or localized 'Current Revision'.
  1750  * @return string gravatar, user, i18n formatted datetimestamp or localized 'Current Revision'.
  1358  */
  1751  */
  1363 	if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
  1756 	if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
  1364 		return false;
  1757 		return false;
  1365 
  1758 
  1366 	$author = get_the_author_meta( 'display_name', $revision->post_author );
  1759 	$author = get_the_author_meta( 'display_name', $revision->post_author );
  1367 	/* translators: revision date format, see http://php.net/date */
  1760 	/* translators: revision date format, see http://php.net/date */
  1368 	$datef = _x( 'j F, Y @ G:i:s', 'revision date format');
  1761 	$datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
  1369 
  1762 
  1370 	$gravatar = get_avatar( $revision->post_author, 24 );
  1763 	$gravatar = get_avatar( $revision->post_author, 24 );
  1371 
  1764 
  1372 	$date = date_i18n( $datef, strtotime( $revision->post_modified ) );
  1765 	$date = date_i18n( $datef, strtotime( $revision->post_modified ) );
  1373 	if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
  1766 	if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
  1397  * Display list of a post's revisions.
  1790  * Display list of a post's revisions.
  1398  *
  1791  *
  1399  * Can output either a UL with edit links or a TABLE with diff interface, and
  1792  * Can output either a UL with edit links or a TABLE with diff interface, and
  1400  * restore action links.
  1793  * restore action links.
  1401  *
  1794  *
  1402  * @package WordPress
       
  1403  * @subpackage Post_Revisions
       
  1404  * @since 2.6.0
  1795  * @since 2.6.0
  1405  *
  1796  *
  1406  * @uses wp_get_post_revisions()
  1797  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
  1407  * @uses wp_post_revision_title_expanded()
  1798  * @param string      $type    'all' (default), 'revision' or 'autosave'
  1408  * @uses get_edit_post_link()
       
  1409  * @uses get_the_author_meta()
       
  1410  *
       
  1411  * @param int|object $post_id Post ID or post object.
       
  1412  * @param string $type 'all' (default), 'revision' or 'autosave'
       
  1413  * @return null
  1799  * @return null
  1414  */
  1800  */
  1415 function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
  1801 function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
  1416 	if ( ! $post = get_post( $post_id ) )
  1802 	if ( ! $post = get_post( $post_id ) )
  1417 		return;
  1803 		return;