我想知道您是否可以覆盖[rev_slider]
使用这种包装:
add_shortcode( \'rev_slider\', function( $atts = array(), $content = \'\' )
{
$html = \'\';
// Your custom banner HTML
$banner = \'<div id="bannerHTML"><!-- banner HTML goes here --></div>\';
// Append your banner HTML to the revslider\'s output
if( function_exists( \'rev_slider_shortcode\' ) )
$html = rev_slider_shortcode( $atts, $content ) . $banner;
return $html;
} );
我们假设原始短代码的回调是
rev_slider_shortcode()
. 我们必须在原来的基础上运行。
按照@Sumit的建议更新,我们可以尝试从$shortcode_tags
大堆
下面是一个示例:
add_action( \'after_setup_theme\', function() use ( &$shortcode_tags )
{
// Shortcode to override. Edit to your needs
$shortcode = \'rev_slider\';
// Nothing to do if it\'s not registered as shortcode
if( ! shortcode_exists( $shortcode ) )
return;
// Get the shortcode\'s callback
$callback = $shortcode_tags[$shortcode];
// Override the shortcode
add_shortcode( $shortcode, function( $atts = array(), $content = \'\' ) use ( $callback )
{
// Your custom banner HTML
$banner = \'<div id="bannerHTML">123<!-- banner HTML goes here --></div>\';
// Append your banner HTML to the revslider\'s output
return
is_callable( $callback )
? call_user_func( $callback, $atts, $content, $callback ) . $banner
: \'\';
} );
}, PHP_INT_MAX );
在这里,我们很晚才进入
after_setup_theme
操作和使用
call_user_func()
运行前一个短代码的回调,类似于
do_shortcode_tag()
.