X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..11be8dc178e77d0b46189bbd8e33a216a9b90942:/wp-includes/post-template.php
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index 40a56d99..2ff0e7db 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -1,21 +1,47 @@
guid);
}
-function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
+/**
+ * Display the post content.
+ *
+ * @since 0.71
+ *
+ * @param string $more_link_text Optional. Content for when there is more text.
+ * @param string $stripteaser Optional. Teaser content before the more text.
+ * @param string $more_file Optional. Not used.
+ */
+function the_content($more_link_text = null, $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
}
-
-function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
+/**
+ * Retrieve the post content.
+ *
+ * @since 0.71
+ *
+ * @param string $more_link_text Optional. Content for when there is more text.
+ * @param string $stripteaser Optional. Teaser content before the more text.
+ * @param string $more_file Optional. Not used.
+ * @return string
+ */
+function get_the_content($more_link_text = null, $stripteaser = 0, $more_file = '') {
global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow;
+ if ( null === $more_link_text )
+ $more_link_text = __( '(more...)' );
+
$output = '';
- if ( !empty($post->post_password) ) { // if there's a password
- if ( !isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) { // and it doesn't match the cookie
- $output = get_the_password_form();
- return $output;
- }
+ // If post password required and it doesn't match the cookie.
+ if ( post_password_required($post) ) {
+ $output = get_the_password_form();
+ return $output;
}
if ( $more_file != '' )
@@ -127,39 +223,202 @@ function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_
}
if ( $preview ) // preview fix for javascript bug with foreign languages
- $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "''.base_convert('\\1',16,10).';'", $output);
+ $output = preg_replace_callback('/\%u([0-9A-F]{4})/', create_function('$match', 'return "" . base_convert($match[1], 16, 10) . ";";'), $output);
return $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());
}
-
+/**
+ * Retrieve the post excerpt.
+ *
+ * @since 0.71
+ *
+ * @param mixed $deprecated Not used.
+ * @return string
+ */
function get_the_excerpt($deprecated = '') {
global $post;
$output = '';
$output = $post->post_excerpt;
- if ( !empty($post->post_password) ) { // if there's a password
- if ( !isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie
- $output = __('There is no excerpt because this is a protected post.');
- return $output;
- }
+ if ( post_password_required($post) ) {
+ $output = __('There is no excerpt because this is a protected post.');
+ return $output;
}
return apply_filters('get_the_excerpt', $output);
}
+/**
+ * Whether post has excerpt.
+ *
+ * @since 2.3.0
+ *
+ * @param int $id Optional. Post ID.
+ * @return bool
+ */
function has_excerpt( $id = 0 ) {
$post = &get_post( $id );
return ( !empty( $post->post_excerpt ) );
}
+/**
+ * Display the classes for the post div.
+ *
+ * @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.
+ */
+function post_class( $class = '', $post_id = null ) {
+ // Separates classes with a single space, collates classes for post DIV
+ echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"';
+}
+
+/**
+ * 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
+ * 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
+ * of classes, followed by $class parameter value, with the post ID as the last
+ * parameter.
+ *
+ * @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.
+ * @return array Array of classes.
+ */
+function get_post_class( $class = '', $post_id = null ) {
+ $post = get_post($post_id);
+
+ $classes = array();
+
+ $classes[] = $post->post_type;
+
+ // sticky for Sticky Posts
+ if ( is_sticky($post->ID) && is_home())
+ $classes[] = 'sticky';
+
+ // hentry for hAtom compliace
+ $classes[] = 'hentry';
+
+ // Categories
+ foreach ( (array) get_the_category($post->ID) as $cat ) {
+ if ( empty($cat->slug ) )
+ continue;
+ $classes[] = 'category-' . $cat->slug;
+ }
+
+ // Tags
+ foreach ( (array) get_the_tags($post->ID) as $tag ) {
+ if ( empty($tag->slug ) )
+ continue;
+ $classes[] = 'tag-' . $tag->slug;
+ }
+
+ if ( !empty($class) ) {
+ if ( !is_array( $class ) )
+ $class = preg_split('#\s+#', $class);
+ $classes = array_merge($classes, $class);
+ }
+
+ return apply_filters('post_class', $classes, $class, $post_id);
+}
+
+/**
+ * Whether post requires password and correct password has been provided.
+ *
+ * @since 2.7.0
+ *
+ * @param int|object $post An optional post. Global $post used if not provided.
+ * @return bool false if a password is not required or the correct password cookie is present, true otherwise.
+ */
+function post_password_required( $post = null ) {
+ $post = get_post($post);
+
+ if ( empty($post->post_password) )
+ return false;
+
+ if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) )
+ return true;
+
+ if ( $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password )
+ return true;
+
+ return false;
+}
+
+/**
+ * Display "sticky" CSS class, if a post is sticky.
+ *
+ * @since 2.7.0
+ *
+ * @param int $post_id An optional post ID.
+ */
+function sticky_class( $post_id = null ) {
+ if ( !is_sticky($post_id) )
+ return;
+
+ echo " sticky";
+}
+
+/**
+ * Page Template Functions for usage in Themes
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * The formatted output of a list of pages.
+ *
+ * Displays page links for paginated posts (i.e. includes the .
+ * Quicktag one or more times). This tag must be within The Loop.
+ *
+ * The defaults for overwriting are:
+ * 'next_or_number' - Default is 'number' (string). Indicates whether page
+ * numbers should be used. Valid values are number and next.
+ * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page.
+ * of the bookmark.
+ * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to
+ * previous page, if available.
+ * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in
+ * the parameter string will be replaced with the page number, so Page %
+ * generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
+ * 'before' - Default is '
Pages:' (string). The html or text to prepend to
+ * each bookmarks.
+ * 'after' - Default is '