函数中有add\\u action()函数,该函数是add\\u shortcode()的回调函数。你知道如何在自定义插件的帮助下删除这个动作吗?我是否应该挂接到稍后调用的任何操作,然后再添加\\u shortcode()函数?我不想删除和重新添加短代码,因为它之外还有巨大的功能。
简单示例:
function test_shortcode() {
  ... other code ...
  add_action( \'some_hook\', \'custom_function\');
  ... other code ...
}
add_action( \'wp_head\', \'setup_theme\' );
function setup_theme() {
  ... other code...
  add_shortcode( \'test\', \'test_shortcode\' );
  ... other code ...
}
 我需要从此短代码中删除custom\\u function()。
谢谢你的帮助。。。
 
                    最合适的回答,由SO网友:user3316 整理而成
                    好吧,我找到了一个方法。为优先级为11(在wpautop之后)的\\u内容筛选器调用函数add\\u shortcode。因此,要删除custom\\u function(),必须借助此过滤器(也具有优先级11)完成。解决方案
add_filter( \'the_content\', \'unhook_custom_function\', 11 );
function unhook_custom_function( $content ) {
  remove_action( \'some_hook\', \'custom_function\' );
  return $content;
}
 对我来说效果很好。谢谢大家的想法!
 
                
                
                SO网友:Funkyphenix Funky the fisrt
                在上找到下面的代码https://gist.github.com/1887242
if ( ! function_exists( \'shortcode_exists\' ) ) :
/**
 * Check if a shortcode is registered in WordPress.
 *
 * Examples: shortcode_exists( \'caption\' ) - will return true.
 *           shortcode_exists( \'blah\' )    - will return false.
 */
function shortcode_exists( $shortcode = false ) {
    global $shortcode_tags;
    if ( ! $shortcode )
        return false;
    if ( array_key_exists( $shortcode, $shortcode_tags ) )
        return true;
    return false;
}
endif;
 似乎它能完成任务;-)