Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run PMPro shortcodes later to avoid issues with the_content filters/etc
/*
Run PMPro shortcodes later to avoid issues with the_content filters/etc
Add this code to your active theme's functions.php or a custom plugin.
You may need to change the priority of the add_filter calls below to get the desired result.
*/
//this function removes the shortcodes to keep them from being messed with
function pmpro_shortcodes_later_prep($content) {
$shortcodes = array('pmpro_account', 'pmpro_billing', 'pmpro_cancel', 'pmpro_checkout', 'pmpro_confirmation', 'pmpro_invoice', 'pmpro_levels');
foreach($shortcodes as $shortcode) {
$content = str_replace("[" . $shortcode . "]", "<!-- PMPROSHORTCODEREPLACE " . $shortcode . " PMPROSHORTCODEREPLACE -->", $content);
}
return $content;
}
add_filter('the_content', 'pmpro_shortcodes_later_prep', 1);
//this function adds the shortcodes back in later
function pmpro_shortcodes_later_restore($content) {
$shortcodes = array('pmpro_account', 'pmpro_billing', 'pmpro_cancel', 'pmpro_checkout', 'pmpro_confirmation', 'pmpro_invoice', 'pmpro_levels');
foreach($shortcodes as $shortcode) {
$content = str_replace("<!-- PMPROSHORTCODEREPLACE " . $shortcode . " PMPROSHORTCODEREPLACE -->", do_shortcode("[" . $shortcode . "]"), $content);
}
return $content;
}
add_filter('the_content', 'pmpro_shortcodes_later_restore', 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.