I've been working on a plugin that adds a script to the sidebar when activated. So far, I've been able to display the code, but it loads at the bottom of the page and not in the sidebar.
I'm pretty new to developing WordPress plugins, so more detailed instructions would be greatly appreciated.
Here's the link to the code on Github.
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
echo $args['before_widget'];
if ( ! empty( $instance['title'] ) ) {
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
}
wp_enqueue_script( 'external-script', 'https://d21djfthp4qopy.cloudfront.net/humanitybox.js', array( 'jquery' ), '1.0.0', true );
//echo __( 'Hello, World!', 'text_domain' );
echo $args['after_widget'];
}