'null', ), $atts ); $id = $a['id']; if ($id !== 'null') { //DVD: widget by ID is not currently working //the WP requirement to use enqueue doesn't allow us to place our JS in the DOM next to the container div $sp_widget_block = <<
EOD; } else { //regular embed $sp_widget_block = <<<'EOD'
EOD; } //loads the embed script in the footer wp_enqueue_script( 'sp_widget.min.js' ); //returns the div container where the shortcode is placed return $sp_widget_block; } //create shortcode add_shortcode('action_button', 'speakable_action_button'); //seperate enqueue and register to keep the embed JS only on pages that include the shortcode add_action( 'wp_enqueue_scripts', 'sp_register_ab_script' ); function sp_register_ab_script() { wp_register_script( 'sp_widget.min.js', 'https://embed.actionbutton.co/widget/widget.min.js', array(), null, true); }