*
* @since 0.71
*
- * @param int|object $post Optional. Post ID or object.
+ * @param int|WP_Post $post Optional. Post ID or post object.
* @return string
*/
function get_the_title( $post = 0 ) {
if ( ! is_admin() ) {
if ( ! empty( $post->post_password ) ) {
+
+ /**
+ * Filter the text prepended to the post title for protected posts.
+ *
+ * The filter is only applied on the front end.
+ *
+ * @since 2.8.0
+ *
+ * @param string $prepend Text displayed before the post title.
+ * Default 'Protected: %s'.
+ */
$protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) );
$title = sprintf( $protected_title_format, $title );
} else if ( isset( $post->post_status ) && 'private' == $post->post_status ) {
+
+ /**
+ * Filter the text prepended to the post title of private posts.
+ *
+ * The filter is only applied on the front end.
+ *
+ * @since 2.8.0
+ *
+ * @param string $prepend Text displayed before the post title.
+ * Default 'Private: %s'.
+ */
$private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) );
$title = sprintf( $private_title_format, $title );
}
}
+ /**
+ * Filter the post title.
+ *
+ * @since 0.71
+ *
+ * @param string $title The post title.
+ * @param int $id The post ID.
+ */
return apply_filters( 'the_title', $title, $id );
}
*
* @since 1.5.0
*
- * @param int $id Optional. Post ID.
+ * @param int|WP_Post $id Optional. Post ID or post object.
*/
function the_guid( $id = 0 ) {
echo esc_url( get_the_guid( $id ) );
*
* @since 1.5.0
*
- * @param int $id Optional. Post ID.
+ * @param int|WP_Post $id Optional. Post ID or post object.
* @return string
*/
function get_the_guid( $id = 0 ) {
$post = get_post($id);
- return apply_filters('get_the_guid', $post->guid);
+ /**
+ * Filter the Global Unique Identifier (guid) of the post.
+ *
+ * @since 1.5.0
+ *
+ * @param string $post_guid Global Unique Identifier (guid) of the post.
+ */
+ return apply_filters( 'get_the_guid', $post->guid );
}
/**
*/
function the_content( $more_link_text = null, $strip_teaser = false) {
$content = get_the_content( $more_link_text, $strip_teaser );
+
+ /**
+ * Filter the post content.
+ *
+ * @since 0.71
+ *
+ * @param string $content Content of the current post.
+ */
$content = apply_filters( 'the_content', $content );
$content = str_replace( ']]>', ']]>', $content );
echo $content;
$output .= '<span id="more-' . $post->ID . '"></span>' . $content[1];
} else {
if ( ! empty( $more_link_text ) )
+
+ /**
+ * Filter the Read More link text.
+ *
+ * @since 2.8.0
+ *
+ * @param string $more_link_element Read More link element.
+ * @param string $more_link_text Read More text.
+ */
$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
$output = force_balance_tags( $output );
}
* Display the post excerpt.
*
* @since 0.71
- * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt.
*/
function the_excerpt() {
- echo apply_filters('the_excerpt', get_the_excerpt());
+
+ /**
+ * Filter the displayed post excerpt.
+ *
+ * @since 0.71
+ *
+ * @see get_the_excerpt()
+ *
+ * @param string $post_excerpt The post excerpt.
+ */
+ echo apply_filters( 'the_excerpt', get_the_excerpt() );
}
/**
return __( 'There is no excerpt because this is a protected post.' );
}
+ /**
+ * Filter the retrieved post excerpt.
+ *
+ * @since 1.2.0
+ *
+ * @param string $post_excerpt The post excerpt.
+ */
return apply_filters( 'get_the_excerpt', $post->post_excerpt );
}
*
* @since 2.3.0
*
- * @param int $id Optional. Post ID.
+ * @param int|WP_Post $id Optional. Post ID or post object.
* @return bool
*/
function has_excerpt( $id = 0 ) {
* @since 2.7.0
*
* @param string|array $class One or more classes to add to the class list.
- * @param int $post_id An optional post ID.
+ * @param int|WP_Post $post_id Optional. Post ID or post object.
*/
function post_class( $class = '', $post_id = null ) {
// Separates classes with a single space, collates classes for post DIV
/**
* Retrieve the classes for the post div as an array.
*
- * The class names are add are many. If the post is a sticky, then the 'sticky'
- * class name. The class 'hentry' is always added to each post. For each
+ * The class names are many. If the post is a sticky, then the 'sticky'
+ * class name. The class 'hentry' is always added to each post. If the post has a
+ * post thumbnail, 'has-post-thumbnail' is added as a class. For each
* category, the class will be added with 'category-' with category slug is
* added. The tags are the same way as the categories with 'tag-' before the tag
* slug. All classes are passed through the filter, 'post_class' with the list
* @since 2.7.0
*
* @param string|array $class One or more classes to add to the class list.
- * @param int $post_id An optional post ID.
+ * @param int|WP_Post $post_id Optional. Post ID or post object.
* @return array Array of classes.
*/
function get_post_class( $class = '', $post_id = null ) {
$classes[] = 'format-standard';
}
- // post requires password
- if ( post_password_required($post->ID) )
+ // Post requires password
+ if ( post_password_required( $post->ID ) ) {
$classes[] = 'post-password-required';
+ // Post thumbnails
+ } elseif ( ! is_attachment( $post ) && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) {
+ $classes[] = 'has-post-thumbnail';
+ }
// sticky for Sticky Posts
if ( is_sticky($post->ID) && is_home() && !is_paged() )
$classes = array_map('esc_attr', $classes);
- return apply_filters('post_class', $classes, $class, $post->ID);
+ /**
+ * Filter the list of CSS classes for the current post.
+ *
+ * @since 2.7.0
+ *
+ * @param array $classes An array of post classes.
+ * @param string $class A comma-separated list of additional classes added to the post.
+ * @param int $post_id The post ID.
+ */
+ return apply_filters( 'post_class', $classes, $class, $post->ID );
}
/**
$classes = array_map( 'esc_attr', $classes );
+ /**
+ * Filter the list of CSS body classes for the current post or page.
+ *
+ * @since 2.8.0
+ *
+ * @param array $classes An array of body classes.
+ * @param string $class A comma-separated list of additional classes added to the body.
+ */
return apply_filters( 'body_class', $classes, $class );
}
return ! $hasher->CheckPassword( $post->post_password, $hash );
}
-/**
- * Page Template Functions for usage in Themes
- *
- * @package WordPress
- * @subpackage Template
- */
+//
+// Page Template Functions for usage in Themes
+//
/**
* The formatted output of a list of pages.
);
$r = wp_parse_args( $args, $defaults );
+
+ /**
+ * Filter the arguments used in retrieving page links for paginated posts.
+ *
+ * @since 3.0.0
+ *
+ * @param array $r An array of arguments for page links for paginated posts.
+ */
$r = apply_filters( 'wp_link_pages_args', $r );
extract( $r, EXTR_SKIP );
$link = $link_before . str_replace( '%', $i, $pagelink ) . $link_after;
if ( $i != $page || ! $more && 1 == $page )
$link = _wp_link_page( $i ) . $link . '</a>';
+
+ /**
+ * Filter the HTML output of individual page number links.
+ *
+ * @since 3.6.0
+ *
+ * @param string $link The page number HTML output.
+ * @param int $i Page number for paginated posts' page links.
+ */
$link = apply_filters( 'wp_link_pages_link', $link, $i );
$output .= $separator . $link;
}
$i = $page - 1;
if ( $i ) {
$link = _wp_link_page( $i ) . $link_before . $previouspagelink . $link_after . '</a>';
+
+ /** This filter is documented in wp-includes/post-template.php */
$link = apply_filters( 'wp_link_pages_link', $link, $i );
$output .= $separator . $link;
}
$i = $page + 1;
if ( $i <= $numpages ) {
$link = _wp_link_page( $i ) . $link_before . $nextpagelink . $link_after . '</a>';
+
+ /** This filter is documented in wp-includes/post-template.php */
$link = apply_filters( 'wp_link_pages_link', $link, $i );
$output .= $separator . $link;
}
}
}
+ /**
+ * Filter the HTML output of page links for paginated posts.
+ *
+ * @since 3.6.0
+ *
+ * @param string $output HTML output of paginated posts' page links.
+ * @param array $args An array of arguments.
+ */
$output = apply_filters( 'wp_link_pages', $output, $args );
if ( $echo )
$url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
}
+ if ( is_preview() ) {
+ $url = add_query_arg( array(
+ 'preview' => 'true'
+ ), $url );
+
+ if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
+ $url = add_query_arg( array(
+ 'preview_id' => wp_unslash( $_GET['preview_id'] ),
+ 'preview_nonce' => wp_unslash( $_GET['preview_nonce'] )
+ ), $url );
+ }
+ }
+
return '<a href="' . esc_url( $url ) . '">';
}
continue;
$values = array_map('trim', get_post_custom_values($key));
$value = implode($values,', ');
- echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value);
+
+ /**
+ * Filter the HTML output of the li element in the post custom fields list.
+ *
+ * @since 2.2.0
+ *
+ * @param string $html The HTML output for the li element.
+ * @param string $key Meta key.
+ * @param string $value Meta value.
+ */
+ echo apply_filters( 'the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value );
}
echo "</ul>\n";
}
$output .= "</select>\n";
}
- $output = apply_filters('wp_dropdown_pages', $output);
+ /**
+ * Filter the HTML output of a list of pages as a drop down.
+ *
+ * @since 2.1.0
+ *
+ * @param string $output HTML output for drop down list of pages.
+ */
+ $output = apply_filters( 'wp_dropdown_pages', $output );
if ( $echo )
echo $output;
// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
$exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();
- $r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );
+
+ /**
+ * Filter the array of pages to exclude from the pages list.
+ *
+ * @since 2.1.0
+ *
+ * @param array $exclude_array An array of page IDs to exclude.
+ */
+ $r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) );
// Query pages.
$r['hierarchical'] = 0;
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
global $wp_query;
- if ( is_page() || is_attachment() || $wp_query->is_posts_page )
- $current_page = $wp_query->get_queried_object_id();
+ if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
+ $current_page = get_queried_object_id();
+ } elseif ( is_singular() ) {
+ $queried_object = get_queried_object();
+ if ( is_post_type_hierarchical( $queried_object->post_type ) ) {
+ $current_page = $queried_object->ID;
+ }
+ }
+
$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
if ( $r['title_li'] )
$output .= '</ul></li>';
}
- $output = apply_filters('wp_list_pages', $output, $r);
+ /**
+ * Filter the HTML output of the pages to list.
+ *
+ * @since 1.5.1
+ *
+ * @see wp_list_pages()
+ *
+ * @param string $output HTML output of the pages list.
+ * @param array $r An array of page-listing arguments.
+ */
+ $output = apply_filters( 'wp_list_pages', $output, $r );
if ( $r['echo'] )
echo $output;
function wp_page_menu( $args = array() ) {
$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
$args = wp_parse_args( $args, $defaults );
+
+ /**
+ * Filter the arguments used to generate a page-based menu.
+ *
+ * @since 2.7.0
+ *
+ * @see wp_page_menu()
+ *
+ * @param array $args An array of page menu arguments.
+ */
$args = apply_filters( 'wp_page_menu_args', $args );
$menu = '';
$menu = '<ul>' . $menu . '</ul>';
$menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\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;
/**
* Create HTML list of pages.
*
- * @package WordPress
* @since 2.1.0
* @uses Walker
*/
$css_class[] = 'current_page_parent';
}
+ /**
+ * 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_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
if ( '' === $page->post_title )
/**
* Create HTML dropdown list of pages.
*
- * @package WordPress
* @since 2.1.0
* @uses Walker
*/
if ( $page->ID == $args['selected'] )
$output .= ' selected="selected"';
$output .= '>';
- $title = apply_filters( 'list_pages', $page->post_title, $page );
+
+ $title = $page->post_title;
+ if ( '' === $title ) {
+ $title = sprintf( __( '#%d (no title)' ), $page->ID );
+ }
+
+ /**
+ * Filter the page title when creating an HTML drop-down list of pages.
+ *
+ * @since 3.1.0
+ *
+ * @param string $title Page title.
+ * @param object $page Page data object.
+ */
+ $title = apply_filters( 'list_pages', $title, $page );
$output .= $pad . esc_html( $title );
$output .= "</option>\n";
}
*
* @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.
* @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.
if ( trim( $link_text ) == '' )
$link_text = $_post->post_title;
+ /**
+ * 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', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text );
}
* Wrap attachment in <<p>> element before content.
*
* @since 2.0.0
- * @uses apply_filters() Calls 'prepend_attachment' hook on HTML content.
*
* @param string $content
* @return string
if ( empty($post->post_type) || $post->post_type != 'attachment' )
return $content;
- $p = '<p class="attachment">';
- // 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 .= '</p>';
- $p = apply_filters('prepend_attachment', $p);
+ if ( 0 === strpos( $post->post_mime_type, 'video' ) ) {
+ $meta = wp_get_attachment_metadata( get_the_ID() );
+ $atts = array( 'src' => wp_get_attachment_url() );
+ if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
+ $atts['width'] = (int) $meta['width'];
+ $atts['height'] = (int) $meta['height'];
+ }
+ $p = wp_video_shortcode( $atts );
+ } elseif ( 0 === strpos( $post->post_mime_type, 'audio' ) ) {
+ $p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) );
+ } else {
+ $p = '<p class="attachment">';
+ // 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 .= '</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";
}
*
* @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. A post ID or post object.
* @return string HTML content for password form for password protected post.
*/
function get_the_password_form( $post = 0 ) {
$label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
<p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
- <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>
+ <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>
';
+
+ /**
+ * 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 );
}
/**
* 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()
/**
* 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()
* 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()
* @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 post object.
* @param string $type 'all' (default), 'revision' or 'autosave'
* @return null
*/