It’s easier to remove specific shortcodes than it is to remove_all_shortcodes()
and enable specific shortcodes.
To disable specific shortcodes from display everywhere, you would use the following:
<?php
add_filter( 'the_content', 'oxo_remove_shortcodes', 0 );
function oxo_remove_shortcodes( $content ) {
/* Add the shortcodes that you would like to remove to the array below. */
$shortcode_tags = array(
'shortcode_1',
'shortcode_2',
'shortcode_3'
);
/* Remove each of the shortcodes listed above. */
foreach ( $shortcode_tags as $shortcode_tag )
remove_shortcode( $shortcode_tag );
/* Return the post content without the shortcodes listed above. */
return $content;
}
ALTERNATIVE
Depending on why you only want to enable a few shortcodes, you may be able to get away with creating a filter that checks if the content has_shortcode()
from an array, and then strip_shortcodes() from the content, if it does not.
NOTE: a filter like that would be server intensive, and time consuming in terms of site performance.