Care to share the changes you made? Were they part of changes in your theme or in the plugin code?
Always willing to include suggestions of other people of course to make the experience better for everyone 🙂
Yes of course !
In the plugin : I add a jquery dependency on wp_enqueue_script and delete the echo line.
function enqueue_footer_scripts() {
wp_enqueue_script( 'selection-sharer-js', plugins_url('/js/selection-sharer.js', __FILE__),array('script-jquery'), false, '0.1');
//echo "<script>jQuery(document).ready(function ($) { $('p').selectionSharer();});</script>";
}
‘script-jquery’ is the jquery script from my theme.
In my theme : I call the selectionSharer() function in a javascript file
$(function(){
$('p').selectionSharer();
});
What are your thoughts ?
Clément.
Why did you delete the echo line from the plugin and put the same thing straight into your theme file?
The reason I add it with “jQuery(document).ready(function ($)” is exactly because of WordPress, as suggested here for example:
https://premium.wpmudev.org/blog/adding-jquery-scripts-wordpress/
Adding that extra jquery dependency seems like a best practice as well though, so might be a good thing to add that one.