Created
September 27, 2011 23:04
-
-
Save billerickson/1246507 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'save_post', 'be_div_shortcode_filter', 10, 2 ); | |
function be_div_shortcode_filter( $post_ID, $post ) { | |
// Make sure we're on the actual post, not a revision | |
if( wp_is_post_revision( $post ) ) | |
return; | |
// Filter the content through the dean_is_awesome function that converts | |
// [div class="foo" id="bar"] to <div class="foo" id="bar"> | |
$content = dean_is_awesome( $post->post_content ); | |
// If there's no change (no shortcodes), return | |
if( $post->post_content === $content ) | |
return; | |
// Update be_div_shortcode custom field | |
update_post_meta( $post_ID, 'be_div_shortcode', $content ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment