I want to hook run_shortcode
inside WP_Embed
, but I can't figure out how to pass $tag
argument to add_filter
global $wp_embed;
add_filter( '$wp_embed->run_shortcode' , 'my_run_shortcode' , 0);
don't work.
I want to hook run_shortcode
inside WP_Embed
, but I can't figure out how to pass $tag
argument to add_filter
global $wp_embed;
add_filter( '$wp_embed->run_shortcode' , 'my_run_shortcode' , 0);
don't work.
Share Improve this question edited Sep 10, 2015 at 11:33 Pieter Goosen 55.4k23 gold badges116 silver badges210 bronze badges asked Sep 10, 2015 at 10:05 MrWuMrWu 112 bronze badges1 Answer
Reset to default 1Hooks are only available when you see apply_filters
, apply_filters_ref_array
, do_action
, and do_action_ref_array
. They are all basically handled the same way but have some small differences like filters always expecting a returned value.
e.g.:
// seeing this in some WordPress code
$the_content = apply_filters( 'the_content', $the_content );
// means you can then use something like this to modify it
add_filter( 'the_content, function ( $content ) { return $content; } );
The method you refer to has none of those function calls directly in it, so you will need to find a place, either up or down the call chain, where a filter is applied that relates to what you want to modify.
You may be better to ask how to achieve your ultimate goal rather than asking about how to make this work as there aren't any filters or actions in WP_Embed::run_shortcode
or the do_shortcode
it calls or the do_shortcode_tags
and do_shortcodes_in_html_tags
.
For example, there is a filter for the embed handler html output that might be enough for your needs:
class-wp-embed.php#L171:
...
return apply_filters( 'embed_handler_html', $return, $url, $attr );
...
which would mean you could do:
add_filter( 'embed_handler_html', 'wpse_202291_embed_handler_html', 1, 3 );
function wpse_202291_embed_handler_html( $return, $url, $attr ) {
// process $return
return $return;
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745140020a4613385.html
评论列表(0条)