Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
Filter the 'status' content
Browse files Browse the repository at this point in the history
Before, a post with the 'status' post format would be wrapper in a <div
class="note"> div and get an avatar inserted.

This works perfect for text statusses but not for embedded Tweets. Now
the theme only adds the wrapper in case there's no tweet embedded.
  • Loading branch information
jayj committed Aug 31, 2012
1 parent b8a28ba commit 692e949
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions functions.php
Expand Up @@ -183,6 +183,9 @@ function cakifo_theme_setup() {
/* Auto-add paragraphs to the chat text. */
add_filter( 'cakifo_post_format_chat_text', 'wpautop' );

/* Filter the content of status posts */
add_filter( 'the_content', 'cakifo_format_status_content' );

/**
* Custom header for logo upload
*/
Expand Down Expand Up @@ -1226,4 +1229,37 @@ function cakifo_format_chat_row_id( $chat_author ) {
return absint( array_search( $chat_author, $_post_format_chat_ids ) ) + 1;
}

/**
* This function filters the post content when viewing a post with the "status" post format. It formats the
* status with a .status-content wrapper and an avatar. In case the content of the status is a embedded
* Twitter status, it does nothing.
*
* @param string $content The content of the status.
* @return string $content The formatted content of the status.
* @since Cakifo 1.5
*/
function cakifo_format_status_content( $content ) {

/* Check if we're displaying a 'status' post. */
if ( has_post_format( 'status' ) ) :

/* Match any Twitter embeds (<blockquote class="twitter-tweet") elements. */
preg_match( '/<blockquote class=\"twitter.*?>/', $content, $matches );

/* Store the post content in the $output variable */
$output = $content;

/* If no <blockquote class="twitter-tweet"> elements were found, wrap the entire content in a div and insert an avatar. */
if ( empty( $matches ) ) {
$content = "\n\t\t\t\t" . '<div class="note status-content">';
$content .= "\n\t\t\t\t\t" . '<a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '">' . get_avatar( get_the_author_meta( 'ID' ), apply_atomic( 'status_avatar', '48' ) ) . '</a>';
$content .= "\n\t\t\t\t\t" . $output;
$content .= "\n\t\t\t\t" . '</div> <!-- .status-content -->';
}
endif;

return $content;
}


?>

1 comment on commit 692e949

@jayj
Copy link
Owner Author

@jayj jayj commented on 692e949 Sep 21, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted in 0ec026e

Please sign in to comment.