Hi all,
Could you please help me better understanding how to setup Roots Share Buttons (plugin).
What I did so far:
- Bought the Roots Share Buttons plugin and read the README file
- Copied the contents to my Plugin folder
- In the Admin settings page, I activated all buttons and decided to show Share buttons âafter the (Single Templates) contentâ
- Ran Gulp and bottons are showing up⌠Great!
But:
Now I would like to customize the buttons appearance (CSS) and to be able to show them exactly where I want them to be in my custom Single Template⌠which is obviously in the Templates directory. To be more precise: I want the Share buttons to show up between the Entry Meta and the Comments in my custom Single TemplateâŚ
What I did next:
- Copied âshortcode-share.phpâ to my themeâs /Templates directory
- Added the following code to /lib/extras.php
/* * Roots Share Buttons Customization * Custom [share] shortcode template */ function custom_roots_share_buttons_template() { return get_template_directory() . '/templates/shortcode-share.php'; } add_action('roots/share_template', 'custom_roots_share_buttons_template');
/* * Roots Share Buttons Customization * Removing plugin assets */ function remove_roots_share_buttons_assets() { wp_dequeue_style('roots-share-buttons'); wp_dequeue_script('roots-share-buttons'); } add_action('wp_enqueue_scripts', 'remove_roots_share_buttons_assets');
If I understand this correctly, I am now saying that the plugin should look for my themeâs /templates/shortcode-share.php instead of the default plugin directory. We have also removed the Share Buttons Assets.
The buttons are not showing up after adding the code to /lib/extras.php
I guess I have to enqueue the Share Buttons assests again in my theme but Iâm not sure how to do this correctly. Can you please explain how to do this. Next, I will have to call the Share buttons in my custom Single Template file, but how?
Recently I have added a custom JS file by adding the following line to /lib/setup.php.
It works but I am still wondering if this is the right place? Should I enqueue the Share Buttonâs assets here too?
function assets() {
wp_enqueue_style(âsage/cssâ, Assets\asset_path(âstyles/main.cssâ), false, null);
if (is_single() && comments_open() && get_option(âthread_commentsâ)) {
wp_enqueue_script(âcomment-replyâ);
}
wp_enqueue_script(âsage/jsâ, Assets\asset_path(âscripts/main.jsâ), [âjqueryâ], null, true);
wp_enqueue_script(âsage/custom_jsâ, Assets\asset_path(âscripts/custom.jsâ), [âsage/jsâ], null, true);
}
add_action(âwp_enqueue_scriptsâ, _ _ NAMESPACE _ _ . â\assetsâ, 100);
Excuse me this is not very clear to me, I am a designer and trying to learn front end dev, Sage, Gulp⌠on my own Thank you for clarifing this!
Keep up the good work Roots theme and community! Happy new year!