web/wp-includes/post-template.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
   158  *
   158  *
   159  * @since 0.71
   159  * @since 0.71
   160  *
   160  *
   161  * @param string $more_link_text Optional. Content for when there is more text.
   161  * @param string $more_link_text Optional. Content for when there is more text.
   162  * @param string $stripteaser Optional. Teaser content before the more text.
   162  * @param string $stripteaser Optional. Teaser content before the more text.
   163  * @param string $more_file Optional. Not used.
   163  */
   164  */
   164 function the_content($more_link_text = null, $stripteaser = 0) {
   165 function the_content($more_link_text = null, $stripteaser = 0, $more_file = '') {
   165 	$content = get_the_content($more_link_text, $stripteaser);
   166 	$content = get_the_content($more_link_text, $stripteaser, $more_file);
       
   167 	$content = apply_filters('the_content', $content);
   166 	$content = apply_filters('the_content', $content);
   168 	$content = str_replace(']]>', ']]>', $content);
   167 	$content = str_replace(']]>', ']]>', $content);
   169 	echo $content;
   168 	echo $content;
   170 }
   169 }
   171 
   170 
   174  *
   173  *
   175  * @since 0.71
   174  * @since 0.71
   176  *
   175  *
   177  * @param string $more_link_text Optional. Content for when there is more text.
   176  * @param string $more_link_text Optional. Content for when there is more text.
   178  * @param string $stripteaser Optional. Teaser content before the more text.
   177  * @param string $stripteaser Optional. Teaser content before the more text.
   179  * @param string $more_file Optional. Not used.
       
   180  * @return string
   178  * @return string
   181  */
   179  */
   182 function get_the_content($more_link_text = null, $stripteaser = 0, $more_file = '') {
   180 function get_the_content($more_link_text = null, $stripteaser = 0) {
   183 	global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow;
   181 	global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow;
   184 
   182 
   185 	if ( null === $more_link_text )
   183 	if ( null === $more_link_text )
   186 		$more_link_text = __( '(more...)' );
   184 		$more_link_text = __( '(more...)' );
   187 
   185 
   191 	// If post password required and it doesn't match the cookie.
   189 	// If post password required and it doesn't match the cookie.
   192 	if ( post_password_required($post) ) {
   190 	if ( post_password_required($post) ) {
   193 		$output = get_the_password_form();
   191 		$output = get_the_password_form();
   194 		return $output;
   192 		return $output;
   195 	}
   193 	}
   196 
       
   197 	if ( $more_file != '' )
       
   198 		$file = $more_file;
       
   199 	else
       
   200 		$file = $pagenow; //$_SERVER['PHP_SELF'];
       
   201 
   194 
   202 	if ( $page > count($pages) ) // if the requested page doesn't exist
   195 	if ( $page > count($pages) ) // if the requested page doesn't exist
   203 		$page = count($pages); // give them the highest numbered page that DOES exist
   196 		$page = count($pages); // give them the highest numbered page that DOES exist
   204 
   197 
   205 	$content = $pages[$page-1];
   198 	$content = $pages[$page-1];
   252  * @param mixed $deprecated Not used.
   245  * @param mixed $deprecated Not used.
   253  * @return string
   246  * @return string
   254  */
   247  */
   255 function get_the_excerpt($deprecated = '') {
   248 function get_the_excerpt($deprecated = '') {
   256 	global $post;
   249 	global $post;
   257 	$output = '';
       
   258 	$output = $post->post_excerpt;
   250 	$output = $post->post_excerpt;
   259 	if ( post_password_required($post) ) {
   251 	if ( post_password_required($post) ) {
   260 		$output = __('There is no excerpt because this is a protected post.');
   252 		$output = __('There is no excerpt because this is a protected post.');
   261 		return $output;
   253 		return $output;
   262 	}
   254 	}
   309  */
   301  */
   310 function get_post_class( $class = '', $post_id = null ) {
   302 function get_post_class( $class = '', $post_id = null ) {
   311 	$post = get_post($post_id);
   303 	$post = get_post($post_id);
   312 
   304 
   313 	$classes = array();
   305 	$classes = array();
       
   306 
       
   307 	if ( empty($post) )
       
   308 		return $classes;
   314 
   309 
   315 	$classes[] = 'post-' . $post->ID;
   310 	$classes[] = 'post-' . $post->ID;
   316 	$classes[] = $post->post_type;
   311 	$classes[] = $post->post_type;
   317 
   312 
   318 	// sticky for Sticky Posts
   313 	// sticky for Sticky Posts
   407 		}
   402 		}
   408 	} elseif ( is_archive() ) {
   403 	} elseif ( is_archive() ) {
   409 		if ( is_author() ) {
   404 		if ( is_author() ) {
   410 			$author = $wp_query->get_queried_object();
   405 			$author = $wp_query->get_queried_object();
   411 			$classes[] = 'author';
   406 			$classes[] = 'author';
   412 			$classes[] = 'author-' . sanitize_html_class($author->user_nicename , $author->user_id);
   407 			$classes[] = 'author-' . sanitize_html_class($author->user_nicename , $author->ID);
   413 		} elseif ( is_category() ) {
   408 		} elseif ( is_category() ) {
   414 			$cat = $wp_query->get_queried_object();
   409 			$cat = $wp_query->get_queried_object();
   415 			$classes[] = 'category';
   410 			$classes[] = 'category';
   416 			$classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID);
   411 			$classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID);
   417 		} elseif ( is_tag() ) {
   412 		} elseif ( is_tag() ) {
   547  *      generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
   542  *      generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
   548  * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to
   543  * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to
   549  *      each bookmarks.
   544  *      each bookmarks.
   550  * 'after' - Default is '</p>' (string). The html or text to append to each
   545  * 'after' - Default is '</p>' (string). The html or text to append to each
   551  *      bookmarks.
   546  *      bookmarks.
   552  * 'more_file' - Default is '' (string) Page the links should point to. Defaults
       
   553  *      to the current page.
       
   554  * 'link_before' - Default is '' (string). The html or text to prepend to each
   547  * 'link_before' - Default is '' (string). The html or text to prepend to each
   555  *      Pages link inside the <a> tag.
   548  *      Pages link inside the <a> tag.
   556  * 'link_after' - Default is '' (string). The html or text to append to each
   549  * 'link_after' - Default is '' (string). The html or text to append to each
   557  *      Pages link inside the <a> tag.
   550  *      Pages link inside the <a> tag.
   558  *
   551  *
   566 	$defaults = array(
   559 	$defaults = array(
   567 		'before' => '<p>' . __('Pages:'), 'after' => '</p>',
   560 		'before' => '<p>' . __('Pages:'), 'after' => '</p>',
   568 		'link_before' => '', 'link_after' => '',
   561 		'link_before' => '', 'link_after' => '',
   569 		'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
   562 		'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
   570 		'previouspagelink' => __('Previous page'), 'pagelink' => '%',
   563 		'previouspagelink' => __('Previous page'), 'pagelink' => '%',
   571 		'more_file' => '', 'echo' => 1
   564 		'echo' => 1
   572 	);
   565 	);
   573 
   566 
   574 	$r = wp_parse_args( $args, $defaults );
   567 	$r = wp_parse_args( $args, $defaults );
   575 	extract( $r, EXTR_SKIP );
   568 	extract( $r, EXTR_SKIP );
   576 
   569 
   577 	global $post, $page, $numpages, $multipage, $more, $pagenow;
   570 	global $post, $page, $numpages, $multipage, $more, $pagenow;
   578 	if ( $more_file != '' )
       
   579 		$file = $more_file;
       
   580 	else
       
   581 		$file = $pagenow;
       
   582 
   571 
   583 	$output = '';
   572 	$output = '';
   584 	if ( $multipage ) {
   573 	if ( $multipage ) {
   585 		if ( 'number' == $next_or_number ) {
   574 		if ( 'number' == $next_or_number ) {
   586 			$output .= $before;
   575 			$output .= $before;
   743 		'depth' => 0, 'show_date' => '',
   732 		'depth' => 0, 'show_date' => '',
   744 		'date_format' => get_option('date_format'),
   733 		'date_format' => get_option('date_format'),
   745 		'child_of' => 0, 'exclude' => '',
   734 		'child_of' => 0, 'exclude' => '',
   746 		'title_li' => __('Pages'), 'echo' => 1,
   735 		'title_li' => __('Pages'), 'echo' => 1,
   747 		'authors' => '', 'sort_column' => 'menu_order, post_title',
   736 		'authors' => '', 'sort_column' => 'menu_order, post_title',
   748 		'link_before' => '', 'link_after' => ''
   737 		'link_before' => '', 'link_after' => '', 'walker' => '',
   749 	);
   738 	);
   750 
   739 
   751 	$r = wp_parse_args( $args, $defaults );
   740 	$r = wp_parse_args( $args, $defaults );
   752 	extract( $r, EXTR_SKIP );
   741 	extract( $r, EXTR_SKIP );
   753 
   742 
   755 	$current_page = 0;
   744 	$current_page = 0;
   756 
   745 
   757 	// sanitize, mostly to keep spaces out
   746 	// sanitize, mostly to keep spaces out
   758 	$r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
   747 	$r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
   759 
   748 
   760 	// Allow plugins to filter an array of excluded pages
   749 	// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
   761 	$r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
   750 	$exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();
       
   751 	$r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );
   762 
   752 
   763 	// Query pages.
   753 	// Query pages.
   764 	$r['hierarchical'] = 0;
   754 	$r['hierarchical'] = 0;
   765 	$pages = get_pages($r);
   755 	$pages = get_pages($r);
   766 
   756 
   775 
   765 
   776 		if ( $r['title_li'] )
   766 		if ( $r['title_li'] )
   777 			$output .= '</ul></li>';
   767 			$output .= '</ul></li>';
   778 	}
   768 	}
   779 
   769 
   780 	$output = apply_filters('wp_list_pages', $output);
   770 	$output = apply_filters('wp_list_pages', $output, $r);
   781 
   771 
   782 	if ( $r['echo'] )
   772 	if ( $r['echo'] )
   783 		echo $output;
   773 		echo $output;
   784 	else
   774 	else
   785 		return $output;
   775 		return $output;
   826 		else
   816 		else
   827 			$text = $args['show_home'];
   817 			$text = $args['show_home'];
   828 		$class = '';
   818 		$class = '';
   829 		if ( is_front_page() && !is_paged() )
   819 		if ( is_front_page() && !is_paged() )
   830 			$class = 'class="current_page_item"';
   820 			$class = 'class="current_page_item"';
   831 		$menu .= '<li ' . $class . '><a href="' . get_option('home') . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
   821 		$menu .= '<li ' . $class . '><a href="' . get_option('home') . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
   832 		// If the front page is a page, add it to the exclude list
   822 		// If the front page is a page, add it to the exclude list
   833 		if (get_option('show_on_front') == 'page') {
   823 		if (get_option('show_on_front') == 'page') {
   834 			if ( !empty( $list_args['exclude'] ) ) {
   824 			if ( !empty( $list_args['exclude'] ) ) {
   835 				$list_args['exclude'] .= ',';
   825 				$list_args['exclude'] .= ',';
   836 			} else {
   826 			} else {