Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created September 27, 2011 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/1246507 to your computer and use it in GitHub Desktop.
Save billerickson/1246507 to your computer and use it in GitHub Desktop.
<?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