';
// If the front page is a page, add it to the exclude list
if (get_option('show_on_front') == 'page') {
if ( !empty( $list_args['exclude'] ) ) {
@@ -930,6 +1162,17 @@ function wp_page_menu( $args = array() ) {
$menu = '
' . $menu . '
';
$menu = '
' . $menu . "
\n";
+
+ /**
+ * Filter the HTML output of a page-based menu.
+ *
+ * @since 2.7.0
+ *
+ * @see wp_page_menu()
+ *
+ * @param string $menu The HTML output.
+ * @param array $args An array of arguments.
+ */
$menu = apply_filters( 'wp_page_menu', $menu, $args );
if ( $args['echo'] )
echo $menu;
@@ -954,6 +1197,11 @@ function walk_page_tree($pages, $depth, $current_page, $r) {
else
$walker = $r['walker'];
+ foreach ( (array) $pages as $page ) {
+ if ( $page->post_parent )
+ $r['pages_with_children'][ $page->post_parent ] = true;
+ }
+
$args = array($pages, $depth, $r, $current_page);
return call_user_func_array(array($walker, 'walk'), $args);
}
@@ -978,7 +1226,6 @@ function walk_page_dropdown_tree() {
/**
* Create HTML list of pages.
*
- * @package WordPress
* @since 2.1.0
* @uses Walker
*/
@@ -988,7 +1235,7 @@ class Walker_Page extends Walker {
* @since 2.1.0
* @var string
*/
- var $tree_type = 'page';
+ public $tree_type = 'page';
/**
* @see Walker::$db_fields
@@ -996,7 +1243,7 @@ class Walker_Page extends Walker {
* @todo Decouple this.
* @var array
*/
- var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
+ public $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
/**
* @see Walker::start_lvl()
@@ -1006,7 +1253,7 @@ class Walker_Page extends Walker {
* @param int $depth Depth of page. Used for padding.
* @param array $args
*/
- function start_lvl( &$output, $depth = 0, $args = array() ) {
+ public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent
\n";
}
@@ -1019,7 +1266,7 @@ class Walker_Page extends Walker {
* @param int $depth Depth of page. Used for padding.
* @param array $args
*/
- function end_lvl( &$output, $depth = 0, $args = array() ) {
+ public function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent
\n";
}
@@ -1034,40 +1281,75 @@ class Walker_Page extends Walker {
* @param int $current_page Page ID.
* @param array $args
*/
- function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
- if ( $depth )
- $indent = str_repeat("\t", $depth);
- else
+ public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
+ if ( $depth ) {
+ $indent = str_repeat( "\t", $depth );
+ } else {
$indent = '';
+ }
+
+ $css_class = array( 'page_item', 'page-item-' . $page->ID );
- extract($args, EXTR_SKIP);
- $css_class = array('page_item', 'page-item-'.$page->ID);
- if ( !empty($current_page) ) {
+ if ( isset( $args['pages_with_children'][ $page->ID ] ) ) {
+ $css_class[] = 'page_item_has_children';
+ }
+
+ if ( ! empty( $current_page ) ) {
$_current_page = get_post( $current_page );
- if ( in_array( $page->ID, $_current_page->ancestors ) )
+ if ( in_array( $page->ID, $_current_page->ancestors ) ) {
$css_class[] = 'current_page_ancestor';
- if ( $page->ID == $current_page )
+ }
+ if ( $page->ID == $current_page ) {
$css_class[] = 'current_page_item';
- elseif ( $_current_page && $page->ID == $_current_page->post_parent )
+ } elseif ( $_current_page && $page->ID == $_current_page->post_parent ) {
$css_class[] = 'current_page_parent';
+ }
} elseif ( $page->ID == get_option('page_for_posts') ) {
$css_class[] = 'current_page_parent';
}
- $css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
-
- if ( '' === $page->post_title )
+ /**
+ * Filter the list of CSS classes to include with each page item in the list.
+ *
+ * @since 2.8.0
+ *
+ * @see wp_list_pages()
+ *
+ * @param array $css_class An array of CSS classes to be applied
+ * to each list item.
+ * @param WP_Post $page Page data object.
+ * @param int $depth Depth of page, used for padding.
+ * @param array $args An array of arguments.
+ * @param int $current_page ID of the current page.
+ */
+ $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
+
+ if ( '' === $page->post_title ) {
$page->post_title = sprintf( __( '#%d (no title)' ), $page->ID );
+ }
- $output .= $indent . '
\n";
}
@@ -1089,7 +1371,6 @@ class Walker_Page extends Walker {
/**
* Create HTML dropdown list of pages.
*
- * @package WordPress
* @since 2.1.0
* @uses Walker
*/
@@ -1099,7 +1380,7 @@ class Walker_PageDropdown extends Walker {
* @since 2.1.0
* @var string
*/
- var $tree_type = 'page';
+ public $tree_type = 'page';
/**
* @see Walker::$db_fields
@@ -1107,7 +1388,7 @@ class Walker_PageDropdown extends Walker {
* @todo Decouple this
* @var array
*/
- var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
+ public $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
/**
* @see Walker::start_el()
@@ -1119,14 +1400,28 @@ class Walker_PageDropdown extends Walker {
* @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.
* @param int $id
*/
- function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
+ public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
$pad = str_repeat(' ', $depth * 3);
$output .= "\t\n";
}
@@ -1141,7 +1436,7 @@ class Walker_PageDropdown extends Walker {
*
* @since 2.0.0
*
- * @param int $id Optional. Post ID.
+ * @param int|WP_Post $id Optional. Post ID or post object.
* @param bool $fullsize Optional, default is false. Whether to use full size.
* @param bool $deprecated Deprecated. Not used.
* @param bool $permalink Optional, default is false. Whether to include permalink.
@@ -1162,7 +1457,7 @@ function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $
* @since 2.5.0
* @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
*
- * @param int $id Optional. Post ID.
+ * @param int|WP_Post $id Optional. Post ID or post object.
* @param string $size Optional, default is 'thumbnail'. Size of image, either array or string.
* @param bool $permalink Optional, default is false. Whether to add permalink to image.
* @param bool $icon Optional, default is false. Whether to include icon.
@@ -1179,8 +1474,6 @@ function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = fals
if ( $permalink )
$url = get_attachment_link( $_post->ID );
- $post_title = esc_attr( $_post->post_title );
-
if ( $text )
$link_text = $text;
elseif ( $size && 'none' != $size )
@@ -1191,14 +1484,25 @@ function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = fals
if ( trim( $link_text ) == '' )
$link_text = $_post->post_title;
- return apply_filters( 'wp_get_attachment_link', "$link_text", $id, $size, $permalink, $icon, $text );
+ /**
+ * Filter a retrieved attachment page link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $link_html The page link HTML output.
+ * @param int $id Post ID.
+ * @param string $size Image size. Default 'thumbnail'.
+ * @param bool $permalink Whether to add permalink to image. Default false.
+ * @param bool $icon Whether to include an icon. Default false.
+ * @param string|bool $text If string, will be link text. Default false.
+ */
+ return apply_filters( 'wp_get_attachment_link', "$link_text", $id, $size, $permalink, $icon, $text );
}
/**
* Wrap attachment in <
> element before content.
*
* @since 2.0.0
- * @uses apply_filters() Calls 'prepend_attachment' hook on HTML content.
*
* @param string $content
* @return string
@@ -1209,11 +1513,36 @@ function prepend_attachment($content) {
if ( empty($post->post_type) || $post->post_type != 'attachment' )
return $content;
- $p = '
';
- // show the medium sized image representation of the attachment if available, and link to the raw file
- $p .= wp_get_attachment_link(0, 'medium', false);
- $p .= '
';
+ // show the medium sized image representation of the attachment if available, and link to the raw file
+ $p .= wp_get_attachment_link(0, 'medium', false);
+ $p .= '
';
+ }
+
+ /**
+ * Filter the attachment markup to be prepended to the post content.
+ *
+ * @since 2.0.0
+ *
+ * @see prepend_attachment()
+ *
+ * @param string $p The attachment HTML output.
+ */
+ $p = apply_filters( 'prepend_attachment', $p );
return "$p\n$content";
}
@@ -1226,19 +1555,30 @@ function prepend_attachment($content) {
* Retrieve protected post password form content.
*
* @since 1.0.0
- * @uses apply_filters() Calls 'the_password_form' filter on output.
- * @param int|WP_Post $post Optional. A post id or post object. Defaults to the current post when in The Loop, undefined otherwise.
+ *
+ * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
* @return string HTML content for password form for password protected post.
*/
function get_the_password_form( $post = 0 ) {
$post = get_post( $post );
$label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
- $output = '
+ $output = '
';
- return apply_filters('the_password_form', $output);
+
+ /**
+ * Filter the HTML output for the protected post password form.
+ *
+ * If modifying the password field, please note that the core database schema
+ * limits the password field to 20 characters regardless of the value of the
+ * size attribute in the form input.
+ *
+ * @since 2.7.0
+ *
+ * @param string $output The password form HTML output.
+ */
+ return apply_filters( 'the_password_form', $output );
}
/**
@@ -1294,8 +1634,6 @@ function get_page_template_slug( $post_id = null ) {
/**
* Retrieve formatted date timestamp of a revision (linked to that revisions's page).
*
- * @package WordPress
- * @subpackage Post_Revisions
* @since 2.6.0
*
* @uses date_i18n()
@@ -1333,8 +1671,6 @@ function wp_post_revision_title( $revision, $link = true ) {
/**
* Retrieve formatted date timestamp of a revision (linked to that revisions's page).
*
- * @package WordPress
- * @subpackage Post_Revisions
* @since 3.6.0
*
* @uses date_i18n()
@@ -1386,8 +1722,6 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
* Can output either a UL with edit links or a TABLE with diff interface, and
* restore action links.
*
- * @package WordPress
- * @subpackage Post_Revisions
* @since 2.6.0
*
* @uses wp_get_post_revisions()
@@ -1395,7 +1729,7 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
* @uses get_edit_post_link()
* @uses get_the_author_meta()
*
- * @param int|object $post_id Post ID or post object.
+ * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
* @param string $type 'all' (default), 'revision' or 'autosave'
* @return null
*/
@@ -1428,31 +1762,5 @@ function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
echo "
\n";
echo $rows;
-
- // if the post was previously restored from a revision
- // show the restore event details
- if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) {
- $author = get_user_by( 'id', $restored_from_meta[ 'restored_by_user' ] );
- /* translators: revision date format, see http://php.net/date */
- $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
- $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) );
- $time_diff = human_time_diff( $restored_from_meta[ 'restored_time' ] ) ;
- ?>
-
-