Changeset 24034 for trunk/wp-includes/post-formats.php
- Timestamp:
- 04/18/2013 06:07:58 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/post-formats.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post-formats.php
r24021 r24034 400 400 401 401 case 'quote': 402 if ( ! empty( $meta['quote'] ) && ! stristr( $content, $meta['quote'] ) ) { 403 $quote = sprintf( '<blockquote>%s</blockquote>', wpautop( $meta['quote'] ) ); 404 if ( ! empty( $meta['quote_source_name'] ) ) { 405 $source = ( empty( $meta['quote_source_url'] ) ) ? $meta['quote_source_name'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['quote_source_url'] ), $meta['quote_source_name'] ); 406 $quote .= sprintf( '<figcaption class="quote-caption">%s</figcaption>', $source ); 407 } 408 $format_output .= sprintf( '<figure class="quote">%s</figure>', $quote ); 409 } 402 $quote = get_the_post_format_quote( $post ); 403 404 // Replace the existing quote in-place. 405 if ( ! empty( $quote ) ) 406 get_content_quote( $content, true, $quote ); 410 407 break; 411 408 … … 681 678 682 679 /** 680 * Get the first <blockquote> from the $content string passed by reference. 681 * 682 * If $content does not have a blockquote, assume the whole string 683 * is the quote. 684 * 685 * @since 3.6.0 686 * 687 * @param string $content A string which might contain chat data, passed by reference. 688 * @param bool $remove (optional) Whether to remove the quote from the content. 689 * @param string $replace (optional) Content to replace the quote content with if $remove is set to true. 690 * @return string The quote content. 691 */ 692 function get_content_quote( &$content, $remove = false, $replace = '' ) { 693 if ( empty( $content ) ) 694 return ''; 695 696 $matches = array(); 697 if ( ! preg_match( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', $content, $matches ) ) { 698 $quote = $content; 699 if ( $remove || ! empty( $replace ) ) 700 $content = $replace; 701 return $quote; 702 } 703 704 if ( $remove || ! empty( $replace ) ) 705 $content = preg_replace( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', addcslashes( $replace, '\\$' ), $content, 1 ); 706 707 return $matches[1]; 708 } 709 710 /** 711 * Get a quote from the post content and set split_content for future use. 712 * 713 * @since 3.6.0 714 * 715 * @uses get_content_quote() 716 * 717 * @param object $post (optional) A reference to the post object, falls back to get_post(). 718 * @return string The quote html. 719 */ 720 function get_the_post_format_quote( &$post = null ) { 721 if ( empty( $post ) ) 722 $post = get_post(); 723 724 if ( empty( $post ) ) 725 return ''; 726 727 $content = $post->post_content; 728 $quote = get_content_quote( $content, true ); 729 $post->split_content = $content; 730 731 if ( ! empty( $quote ) ) 732 $quote = sprintf( '<blockquote>%s</blockquote>', wpautop( $quote ) ); 733 734 $meta = get_post_format_meta( $post->ID ); 735 736 if ( ! empty( $meta['quote_source_name'] ) ) { 737 $source = ( empty( $meta['quote_source_url'] ) ) ? $meta['quote_source_name'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['quote_source_url'] ), $meta['quote_source_name'] ); 738 $quote .= sprintf( '<figcaption class="quote-caption">%s</figcaption>', $source ); 739 } 740 741 if ( ! empty( $quote ) ) 742 $quote = sprintf( '<figure class="quote">%s</figure>', $quote ); 743 744 return $quote; 745 } 746 747 /** 748 * Outputs the post format quote. 749 * 750 * @since 3.6.0 751 */ 752 function the_post_format_quote() { 753 echo get_the_post_format_quote(); 754 } 755 756 /** 683 757 * Extract a URL from passed content, if possible 684 758 * Checks for a URL on the first line of the content or the first encountered href attribute.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)