problem with sending parameters in do_action
-
Hi
I am creating a plugin works with shortcode. The shortcode attributes include some settings for styling and javascript parameters. I use wp_head action to add style and js codes to head section. To set parameters for style and js tags, I call do_action in shortcode callback function with an array of parameters, but the parameters are not sent and I receive multiple ‘warning : Illegal string offset’ messages. I don’t know what is the problem. Please guide me.My code is a something like this:
add_action( 'wp_enqueue_scripts', 'tbfs_plugin_scripts' ); add_action( 'wp_head', 'tbfs_plugin_custom_scripts' ); function tbfs_plugin_custom_scripts($listparams) { //echo js and style tags } function tbfs_make_shrotcode($atts){ // $listparams=shortcode_atts(array('textalign'=>'center','bgcolor'=>'red'),$atts); do_action('wp_head',$listparams); ob_start(); //Here I place some conditional statements and HTML output return ob_get_clean(); } add_shortcode('my_plugin_shortcode_output','tbfs_make_shrotcode');
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘problem with sending parameters in do_action’ is closed to new replies.