Revert [23450]. Removes post format compat.

see #23347, #24452. closes #24454.

git-svn-id: http://core.svn.wordpress.org/trunk@24387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Mark Jaquith 2013-05-30 17:55:22 +00:00
parent c10737d0f6
commit c5530f9fc6
2 changed files with 6 additions and 187 deletions

View File

@ -136,13 +136,12 @@ add_filter( 'the_title', 'convert_chars' );
add_filter( 'the_title', 'trim' );
add_filter( 'the_title', '_post_formats_title', 10, 2 );
add_filter( 'the_content', 'post_formats_compat', 7, 2 );
add_filter( 'the_content', 'wptexturize' );
add_filter( 'the_content', 'convert_smilies' );
add_filter( 'the_content', 'convert_chars' );
add_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'shortcode_unautop' );
add_filter( 'the_content', 'prepend_attachment' );
add_filter( 'the_content', 'wptexturize' );
add_filter( 'the_content', 'convert_smilies' );
add_filter( 'the_content', 'convert_chars' );
add_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'shortcode_unautop' );
add_filter( 'the_content', 'prepend_attachment' );
add_filter( 'the_excerpt', 'wptexturize' );
add_filter( 'the_excerpt', 'convert_smilies' );

View File

@ -285,186 +285,6 @@ function _post_format_wp_get_object_terms( $terms ) {
}
add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
/**
* Return the class for a post format content wrapper
*
* @since 3.6.0
*
* @param string $format The post format slug, such as status, quote, image, gallery, etc.
* @return string Filtered post format content class.
*/
function get_post_format_content_class( $format ) {
return apply_filters( 'post_format_content_class', 'post-format-content', $format );
}
/**
* Output the class for a post format content wrapper
*
* @since 3.6.0
*
* @param string $format The post format slug, such as status, quote, image, gallery, etc.
*/
function post_format_content_class( $format ) {
echo get_post_format_content_class( $format );
}
/**
* Provide fallback behavior for Posts that have associated post format
*
* @since 3.6.0
*
* @uses get_post_format_meta()
*
* @param string $content The post content.
* @param int $post_id (optional) The post ID.
* @return string Formatted output based on associated post format.
*/
function post_formats_compat( $content, $post_id = 0 ) {
if ( ! $post = get_post( $post_id ) )
return $content;
$format = get_post_format( $post );
if ( empty( $format ) || in_array( $format, array( 'status', 'aside', 'chat', 'gallery' ) ) )
return $content;
if ( current_theme_supports( 'structured-post-formats', $format ) )
return $content;
$defaults = array(
'position' => 'after',
'tag' => 'div',
'class' => get_post_format_content_class( $format ),
'link_class' => '',
);
$args = apply_filters( 'post_format_compat', array() );
$compat = wp_parse_args( $args, $defaults );
$show_content = true;
$format_output = '';
$meta = get_post_format_meta( $post->ID );
switch ( $format ) {
case 'link':
if ( ! empty( $meta['link_url'] ) ) {
$esc_url = preg_quote( $meta['link_url'], '#' );
// Make sure the same URL isn't in the post (modified/extended versions allowed)
if ( ! preg_match( '#' . $esc_url . '[^/&\?]?#', $content ) ) {
$url = $meta['link_url'];
} else {
$url = get_content_url( $content, true );
}
} else {
$content_before = $content;
$url = get_content_url( $content, true );
if ( $content_before == $content )
$url = '';
}
if ( ! empty( $url ) ) {
$format_output .= sprintf(
'<a %shref="%s">%s</a>',
empty( $compat['link_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['link_class'] ) ),
esc_url( $url ),
empty( $post->post_title ) ? esc_url( $url ) : apply_filters( 'the_title', $post->post_title, $post->ID )
);
}
break;
case 'image':
if ( ! empty( $meta['image'] ) ) {
if ( has_shortcode( $meta['image'], 'caption' ) ) {
// wrap <img> in <a>
if ( ! empty( $meta['url'] ) && false === strpos( $meta['image'], '<a ' ) ) {
$meta['image'] = preg_replace(
'#(<img[^>]+>)#',
sprintf( '<a href="%s">$1</a>', esc_url( $meta['url'] ) ),
$meta['image']
);
}
$format_output .= do_shortcode( $meta['image'] );
} else {
if ( is_numeric( $meta['image'] ) ) {
$image = wp_get_attachment_image( absint( $meta['image'] ), 'full' );
} elseif ( ! preg_match( '#<[^>]+>#', $meta['image'] ) ) {
// not HTML, assume URL
$image = sprintf(
'<img %ssrc="%s" alt="" />',
empty( $compat['image_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['image_class'] ) ),
esc_url( $meta['image'] )
);
} else {
// assume HTML
$image = $meta['image'];
}
if ( ! empty( $meta['url'] ) && false === strpos( $image, '<a ' ) ) {
$format_output .= sprintf(
'<a href="%s">%s</a>',
esc_url( $meta['url'] ),
$image
);
} else {
$format_output .= $image;
}
}
}
break;
case 'quote':
$quote = get_the_post_format_quote( $post );
// Replace the existing quote in-place.
if ( ! empty( $quote ) )
get_content_quote( $content, true, $quote );
break;
case 'video':
case 'audio':
if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta[$format . '_embed'] ) ) {
$value = $meta[$format . '_embed'];
// the metadata is an attachment ID
if ( is_numeric( $value ) ) {
$url = wp_get_attachment_url( $value );
$format_output .= sprintf( '[%s src="%s"]', $format, $url );
// the metadata is a shortcode or an embed code
} elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $value ) || preg_match( '#<[^>]+>#', $value ) ) {
$format_output .= $value;
} elseif ( ! stristr( $content, $value ) ) {
// attempt to embed the URL
$format_output .= sprintf( '[embed]%s[/embed]', $value );
}
}
break;
default:
return $content;
break;
}
if ( empty( $format_output ) )
return $content;
$output = '';
if ( ! empty( $content ) && $show_content && 'before' !== $compat['position'] )
$output .= $content . "\n\n";
if ( ! empty( $compat['tag'] ) )
$output .= sprintf( '<%s class="%s">', tag_escape( $compat['tag'] ), esc_attr( $compat['class'] ) );
$output .= "\n\n" . $format_output;
if ( ! empty( $compat['tag'] ) )
$output .= sprintf( '</%s>', tag_escape( $compat['tag'] ) );
if ( ! empty( $content ) && $show_content && 'before' === $compat['position'] )
$output .= "\n\n" . $content;
return $output;
}
/**
* Add chat detection support to the `get_content_chat()` chat parser.
*