You should never modify the current theme’s stylesheet via a plugin. What if the theme gets updated, or the user changes themes? Not a good idea. Instead, you should have the plugin create a custom css file, which could be located anywhere you wish, even inside of the current theme’s folder.
The only way to output info just before </body>
tag is by hooking into wp_footer()
, but this will not always result in the content being output just before the </body>
tag, since themes will often place the wp_footer()
function within a DIV tag, or higher up in the footer. If you absolutely must output something just before the </body>
tag, I would use jQuery to insert it. You could easily setup the content or HTML that is outputted with wp_localize_script().
If you are okay with the content/HTML not necessarily being immediately before the </body>
tag, then use the wp_footer()
method, which is what I recommend:
function your_custom_content_function() {
echo 'this is outputted in the footer';
}
add_action('wp_footer', 'your_custom_content_function');