Below, you’ll find a detailed guide on how to add the Nobs • Share Buttons Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Nobs • Share Buttons Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Nobs • Share Buttons Plugin and the shortcodes it provides:
"Nobs • Share Buttons is a user-friendly WordPress plugin that enables seamless social media sharing. With its unique 'juiz-social-post-sharer' slug, it facilitates easy post sharing across various platforms."
- [juiz_social]
Nobs [juiz_social] Shortcode
The Juiz Social Post Sharer shortcode allows you to share your posts on social networks. It supports customization of buttons, counters, and URLs. The shortcode accepts parameters like ‘buttons’ for specifying networks, ‘counters’ to activate counters, and ‘current’ to share the current URL. The ‘url’ parameter allows sharing a different URL. It then processes these parameters, enqueues necessary scripts, and generates the HTML for sharing buttons. The output is filtered before being returned, allowing further customization.
Shortcode: [juiz_social]
Parameters
Here is a list of all possible juiz_social shortcode parameters and attributes:
buttons
– Defines which social networks to display, separated by commas.counters
– Activates share counters when set to 1, 0 hides counters.current
– When set to 1, shares the current URL, 0 allows sharing custom URL.url
– Specifies the URL to share when ‘current’ is set to 0.
Examples and Usage
Basic example – Display social share buttons for Twitter and LinkedIn without counters
[juiz_social buttons="twitter,linkedin" counters=0]
Advanced examples
Share buttons for Twitter and LinkedIn with counters, sharing the current URL
[juiz_social buttons="twitter,linkedin" counters=1 current=1]
Share buttons for Twitter and LinkedIn without counters, sharing a specific URL
[juiz_social buttons="twitter,linkedin" counters=0 current=0 url="https://example.com"]
Share buttons for multiple social networks with counters, sharing the current URL
[juiz_social buttons="twitter,linkedin,facebook,digg,mail" counters=1 current=1]
PHP Function Code
In case you have difficulties debugging what causing issues with [juiz_social]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'juiz_social','sc_4_jsps' );
Shortcode PHP function:
function sc_4_jsps( $atts ) {
$atts = shortcode_atts( array(
'buttons' => 'twitter,linkedin',
'counters' => 0,
'current' => 1,
'url' => NULL
), $atts );
/**
* Filters the attributes of the shortcode `juiz_social` or `juiz_sps`
*
* @hook juiz_sps_shortcode_atts
*
* @since 2.0.0 First version
*
* @param {array} atts The shortcode attributes.
* @param {string} atts.buttons="twitter,linkedin" The list of network shortnames separated by a comma.
* @param {int} atts.counters=0 `1` to activate counters.
* @param {int} atts.current=1 `0` to share something else than the current URL.
* @param {string} atts.url=NULL The URL to share.
*
* @return {array} The filtered shortcode attributes.
*/
$atts = apply_filters( 'juiz_sps_shortcode_atts', $atts );
// Buttons become array
// "digg,mail", "digg ,mail", "digg, mail", "digg , mail", are correct syntaxes
$jsps_networks = preg_split( '#[\s+,\s+]#', $atts['buttons'] );
$jsps_counters = intval( $atts['counters'] );
$jsps_current_page = intval( $atts['current'] );
$jsps_url = $atts['url'];
if ( $jsps_current_page == 1 ) {
jsps_enqueue_scripts();
}
ob_start();
juiz_sps( $jsps_networks, $jsps_counters, $jsps_current_page, 1, $jsps_url ); //do an echo
$jsps_sc_output = ob_get_contents();
ob_end_clean();
/**
* Filters content before returning the HTML generated by the `juiz_social` or `juiz_sps` Shortcode.
*
* @hook juiz_sps_shortcode
*
* @since 2.0.0 First version
*
* @param {string} $output The original HTML output of the shortcode.
* @param {array} $atts The shortcode attributes. Can be filtered {@link juiz_sps_shortcode_atts}
*
* @return {string} Return the filtered HTML content.
*/
return apply_filters_deprecated( 'juiz_sps_should_display_shortcode', array( $jsps_sc_output, $atts ), '2.0.0', 'juiz_sps_shortcode' );
}
Code file location:
juiz-social-post-sharer/juiz-social-post-sharer/inc/front/shortcode.php
Conclusion
Now that you’ve learned how to embed the Nobs • Share Buttons Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply