我会暂时删除一个短代码,制作一些东西并恢复它。。。有可能吗?
// override default wordpress "the_content" hook
remove_filter(\'the_content\', \'do_shortcode\', 11);
add_filter(\'the_content\', \'my_the_content\', 11);
function my_the_content($content) {
    remove_shortcode(\'some_shortcode\');
    $content = do_shortcode($content);
    // restore the shortcode
    add_shortcode(\'some_shortcode\', \'?????????????????????????????\');
    return $content;
}
 问题是如何正确还原它。。。
原始短代码位于类中,例如:
class foo {
    function __construct(){
        add_shortcode(\'some_shortcode\', array($this, \'get_some_shortcode\'));
    }
    public function get_some_shortcode(){
        return \'bar\';
    }
}
 
                    最合适的回答,由SO网友:Nathan Johnson 整理而成
                    另一个老问题没有答案。希望对将来的人有用。
WordPress在$shortcode_tags. 我会这样做的。
function my_the_content( $content ) {
  global $shortcode_tags;
  $tag= \'some_shortcode\';
  //* Make sure it\'s actually a valid shortcode
  if( ! isset( $shortcode_tags[ $tag ] ) ) {
    return $content;
  }
  $func = $shortcode_tags[ $tag ];
  remove_shortcode( $tag );
  //* Do something useful
  //* Restore the shortcode
  add_shortcode( $tag, $func );
  return $content;
}