Socialsnap Shortcodes

Below, you’ll find a detailed guide on how to add the Socialsnap Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Socialsnap Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Socialsnap Plugin and the shortcodes it provides:

Plugin Icon
Social Share Buttons, Social Sharing Icons, Click to Tweet — Social Media Plugin by Social Snap

"Social Share Buttons by Social Snap is a dynamic plugin for WordPress. It enables quick sharing across various social media platforms through interactive icons and a 'Click to Tweet' feature."

★★★★✩ (55) Active Installs: 10000+ Tested with: 6.3.2 PHP Version: 5.2.4
Included Shortcodes:
  • [ss_click_to_tweet]
  • [socialpug_tweet]
  • [ss_social_share]
  • [ss_social_share]
  • [ss_on_media_share]

Socialsnap [ss_click_to_tweet] Shortcode

The SocialSnap ‘ss_click_to_tweet’ shortcode is designed to facilitate easy sharing of your content on Twitter. It allows you to customize the tweet content, style, and related link. . The shortcode applies default settings and settings from the settings panel. If no tweet content is provided, it uses the default content. It also has a feature to hide the tweet on mobile devices. The shortcode generates a tweet URL and enqueues necessary assets. It then creates a ‘Click to Tweet’ button with your custom content and Twitter icon.

Shortcode: [ss_click_to_tweet]

Parameters

Here is a list of all possible ss_click_to_tweet shortcode parameters and attributes:

  • tweet – Defines the text content that will be tweeted.
  • content – Sets the default tweet content if none is specified.
  • style – Sets the visual style of the tweet button.
  • link – Sets the URL that will be included in the tweet.
  • via – Specifies the Twitter username to mention in the tweet.
  • related – Suggests Twitter accounts for the user to follow after they tweet.
  • hide_on_mobile – Hides the feature on mobile devices when set to true.

Examples and Usage

Basic example – A simple usage of the shortcode to create a click to tweet box with default settings.

[ss_click_to_tweet content="This is a tweetable content."]

Advanced examples

Creating a click to tweet box with specified tweet content, a custom style, and a link to the tweet. It also includes a username in the ‘via’ attribute and hides the tweet box on mobile devices.

[ss_click_to_tweet tweet="Custom tweet content" style="custom" link="https://www.example.com/tweet-link" via="username" hide_on_mobile="true"]

Using the shortcode to create a click to tweet box with a specific style, a link, and related Twitter accounts. The ‘related’ attribute accepts a comma-separated list of Twitter usernames.

[ss_click_to_tweet style="custom" link="https://www.example.com/tweet-link" related="username1,username2"]

PHP Function Code

In case you have difficulties debugging what causing issues with [ss_click_to_tweet] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ss_click_to_tweet', array( $this, 'register_shortcodes' ) );

Shortcode PHP function:

function register_shortcodes( $atts ) {

		// Default Settings.
		$ctt = array(
			'tweet'          => '',
			'content'        => __( 'Enter Tweet Content here...', 'socialsnap' ),
			'style'          => 'default',
			'link'           => '',
			'via'            => '',
			'related'        => '',
			'hide_on_mobile' => '',
		);

		// Apply settings from settings panel.
		$ctt = apply_filters( 'socialsnap_ctt_settings', $ctt );

		$ctt = shortcode_atts( $ctt, $atts );

		if ( '' == $ctt['tweet'] ) {
			$ctt['tweet'] = $ctt['content'];
		}

		if ( '' == $ctt['content'] ) {
			$ctt['content'] = $ctt['tweet'];
		}

		if ( isset( $ctt['hide_on_mobile'] ) && $ctt['hide_on_mobile'] ) {
			$ctt['hide_on_mobile'] = ' ss-hide-on-mobile';
		} else {
			$ctt['hide_on_mobile'] = '';
		}

		if ( '' !== $ctt['link'] && '0' !== $ctt['link'] && 'false' !== $ctt['link'] ) {
			$ctt['link'] = socialsnap_get_shared_permalink( array( 'network' => 'twitter' ) );
			$ctt['link'] = apply_filters( 'socialsnap_complete_shared_permalink', $ctt['link'], 'twitter' );
		}

		if ( '' === $ctt['via'] || '0' === $ctt['via'] || 'false' === $ctt['via'] ) {
			$ctt['via'] = '';
		} else {
			$ctt['via'] = apply_filters( 'socialsnap_sanitize_username', socialsnap_settings( 'ss_twitter_username' ) );
		}

		if ( 'default' === $ctt['style'] || ! $ctt['style'] ) {
			$ctt['style'] = socialsnap_settings( 'ss_ctt_preview_style' );
		}

		// Generate tweet URL.
		$tweet_url = socialsnap_twitter_share_url(
			wp_strip_all_tags( html_entity_decode( $ctt['tweet'], ENT_QUOTES, get_bloginfo( 'charset' ) ) ),
			$ctt['link'],
			$ctt['via'],
			$ctt['related']
		);

		// Enqueue assets.
		socialsnap_enqueue_assets();

		ob_start();
		?>
		<div class="ss-ctt-wrapper ss-ctt-style-<?php echo esc_attr( $ctt['style'] . $ctt['hide_on_mobile'] ); ?>" data-ss-post-id="<?php the_ID(); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'socialsnap-ctt-add-to-db' ) ); ?>">

			<a href="<?php echo esc_url( $tweet_url ); ?>" class="ss-ctt-tweet" data-title="<?php esc_html_e( 'Click to Tweet', 'socialsnap' ); ?>" rel="nofollow noopener" target="_blank"><?php echo wp_kses( html_entity_decode( $ctt['content'] ), socialsnap_get_allowed_html_tags( 'post' ) ); ?></a>

			<a href="<?php echo esc_url( $tweet_url ); ?>" class="ss-ctt-link" data-title="<?php esc_html_e( 'Click to Tweet', 'socialsnap' ); ?>" rel="nofollow noopener" target="_blank">
				<span><?php esc_html_e( 'Click to Tweet', 'socialsnap' ); ?></span>
				<?php echo socialsnap()->icons->get_svg( 'twitter' ); // phpcs:ignore ?>
			</a>

		</div><!-- END .ss-ctt-wrapper -->

		<?php
		return ob_get_clean();
	}

Code file location:

socialsnap/socialsnap/includes/class-click-to-tweet.php

Socialsnap [socialpug_tweet] Shortcode

The SocialSnap Tweet shortcode allows users to customize tweets shared from their WordPress site. This shortcode provides options to modify the tweet style, content, and whether to include a username or URL. It generates a tweet based on these parameters and enables users to share it directly from the webpage.

Shortcode: [socialpug_tweet]

Parameters

Here is a list of all possible socialpug_tweet shortcode parameters and attributes:

  • style – defines the appearance of the tweet button
  • tweet – sets the actual content of the tweet
  • display_tweet – determines what text is displayed on the page
  • remove_username – if set to ‘yes’, the username is not included in the tweet
  • remove_url – if set to ‘yes’, the URL is not included in the tweet

Examples and Usage

Basic example – The shortcode is used to create a clickable tweet on your site. By default, it includes the tweet text and a link to your post.

[socialpug_tweet tweet="Hello World" /]

Advanced examples

Using the shortcode to create a tweet with a specific style. The style parameter allows you to customize the appearance of your tweet.

[socialpug_tweet style="style1" tweet="Hello World" /]

Using the shortcode to create a tweet without the username. If you don’t want to include your Twitter handle in the tweet, you can set the remove_username parameter to ‘yes’.

[socialpug_tweet tweet="Hello World" remove_username="yes" /]

Using the shortcode to create a tweet without the URL. If you don’t want to include the URL of your post in the tweet, you can set the remove_url parameter to ‘yes’.

[socialpug_tweet tweet="Hello World" remove_url="yes" /]

Using the shortcode to create a tweet with a custom display tweet. The display_tweet parameter allows you to set a different text for the tweet that will be displayed on your site.

[socialpug_tweet tweet="Hello World" display_tweet="Click to tweet this!" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [socialpug_tweet] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'socialpug_tweet', array( $this, 'click_to_tweet_shortcode' ) );

Shortcode PHP function:

function click_to_tweet_shortcode( $atts ) {

		$shortcode = '[ss_click_to_tweet';

		if ( isset( $atts['style'] ) && '' !== $atts['style'] ) {
			$shortcode .= ' style="' . $atts['style'] . '"';
		}

		if ( isset( $atts['tweet'] ) && '' !== $atts['tweet'] ) {
			$shortcode .= ' tweet="' . $atts['tweet'] . '"';
		}

		if ( isset( $atts['display_tweet'] ) && '' !== $atts['display_tweet'] ) {
			$shortcode .= ' content="' . $atts['display_tweet'] . '"';
		} else {
			$shortcode .= ' content="' . $atts['tweet'] . '"';
		}

		if ( isset( $atts['remove_username'] ) && 'yes' == $atts['remove_username'] ) {
			$shortcode .= ' via="false"';
		} else {
			$shortcode .= ' via="true"';
		}

		if ( isset( $atts['remove_url'] ) && 'yes' == $atts['remove_url'] ) {
			$shortcode .= ' link="false"';
		} else {
			$shortcode .= ' link="true"';
		}

		$shortcode .= ']';

		ob_start();

		echo do_shortcode( $shortcode );

		return ob_get_clean();
	}

Code file location:

socialsnap/socialsnap/includes/compatibility/class-dpsp-compatibility.php

Socialsnap [ss_social_share] Shortcode

The SocialSnap Plugin shortcode is a versatile tool that generates social share buttons on your WordPress site. It allows customization of share buttons, including network selection, size, URL for sharing, alignment, share count, and icon display. The generated buttons encourage user engagement, boosting your site’s social media presence.

Shortcode: [ss_social_share]

Parameters

Here is a list of all possible ss_social_share shortcode parameters and attributes:

  • networks – Specifies the social networks to be displayed.
  • size – Determines the size of the social buttons, default is ‘regular’.
  • url – Defines the URL to be shared when the buttons are clicked.
  • align – Sets the alignment of the share buttons on the page.
  • shares – Sets the number of shares to be displayed, default is ‘1’.
  • icons – Determines whether to display icons only or with labels.

Examples and Usage

Basic example – A shortcode that displays share buttons with default settings.

[mashshare /]

Advanced examples:

Using the shortcode to display share buttons for specific social networks. In this example, the ‘networks’ attribute is set to ‘facebook,twitter’ which means the share buttons for Facebook and Twitter will be displayed.

[mashshare networks="facebook,twitter" /]

Using the shortcode to display share buttons with a custom size. The ‘size’ attribute can be set to ‘small’, ‘regular’ or ‘large’. In this example, it is set to ‘small’.

[mashshare size="small" /]

Using the shortcode to display share buttons with a specific alignment. The ‘align’ attribute can be set to ‘left’, ‘center’ or ‘right’. In this example, it is set to ‘center’.

[mashshare align="center" /]

Using the shortcode to display share buttons for a specific URL. The ‘url’ attribute can be set to any valid URL. In this example, it is set to ‘https://www.example.com’.

[mashshare url="https://www.example.com" /]

Using the shortcode to display share buttons with a specific number of shares. The ‘shares’ attribute can be set to any integer. In this example, it is set to ‘100’.

[mashshare shares="100" /]

Using the shortcode to display share buttons with or without icons. The ‘icons’ attribute can be set to ‘true’ or ‘false’. In this example, it is set to ‘false’.

[mashshare icons="false" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [ss_social_share] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'mashshare', array( $this, 'share_buttons_shortcode' ) );

Shortcode PHP function:

function share_buttons_shortcode( $atts ) {

		$shortcode = '[ss_social_share';

		if ( isset( $atts['networks'] ) && '' !== $atts['networks'] ) {
			$shortcode .= ' networks="' . $atts['networks'] . '"';
		}

		if ( isset( $atts['size'] ) && '' !== $atts['size'] ) {
			$atts['size'] = 'medium' === $atts['size'] ? 'regular' : $atts['size'];
			$shortcode   .= ' size="' . $atts['size'] . '"';
		} else {
			$shortcode .= ' size="regular"';
		}

		if ( isset( $atts['url'] ) && '' !== $atts['url'] ) {
			$shortcode .= ' share_target="' . $atts['url'] . '"';
		}

		if ( isset( $atts['align'] ) && '' !== $atts['align'] ) {
			$shortcode .= ' total_share_placement="' . $atts['align'] . '"';
		}

		if ( isset( $atts['shares'] ) ) {
			$shares     = 'true' === $atts['shares'] ? true : false;
			$shortcode .= ' total="' . intval( $atts['shares'] ) . '"';
		} else {
			$shortcode .= ' total="1"';
		}

		if ( isset( $atts['icons'] ) && true === boolval( $atts['icons'] ) ) {
			$shortcode .= ' labels="none" align="left"';
		} else {
			$shortcode .= ' labels="label" align="stretched"';
		}

		$shortcode .= ']';

		ob_start();

		echo do_shortcode( $shortcode );

		return ob_get_clean();
	}

Code file location:

socialsnap/socialsnap/includes/compatibility/class-mashshare-compatibility.php

Socialsnap [ss_social_share] Shortcode

The SocialSnap shortcode ‘ss_social_share’ enables users to customize their social share buttons. It offers options to select specific networks, button shape, size, and alignment. It also allows setting visibility preferences for mobile and desktop.

Shortcode: [ss_social_share]

Parameters

Here is a list of all possible ss_social_share shortcode parameters and attributes:

  • networks – defines the social networks to be displayed.
  • share_text – sets the text to be displayed along with the share buttons.
  • align – sets the alignment of the share buttons.
  • total – determines whether the total share count will be displayed.
  • shape – sets the shape of the share buttons.
  • size – sets the size of the share buttons.
  • labels – decides if the network names should be displayed on the buttons.
  • spacing – sets the spacing between the share buttons.
  • hide_on_mobile – determines if the share buttons should be hidden on mobile devices.
  • all_networks – decides whether all networks should be displayed or not.
  • format_number – formats the number of shares to be more readable.

Examples and Usage

Basic example – Displays social share buttons with default settings.

[ss_social_share /]

Advanced examples

Displays social share buttons with specified networks and custom share text.

[ss_social_share networks="facebook;twitter;linkedin" share_text="Share this post!"/]

Displays social share buttons with specified button size, button shape, and alignment.

[ss_social_share size="large" shape="circle" align="center"/]

Using the shortcode to hide social share buttons on mobile devices and to show the total share count.

[ss_social_share hide_on_mobile="true" total="true"/]

Using the shortcode to display all available social networks and to format the share count number.

[ss_social_share all_networks="true" format_number="true"/]

PHP Function Code

In case you have difficulties debugging what causing issues with [ss_social_share] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ss_social_share', array( $this, 'shortcode_social_share' ) );

Shortcode PHP function:

function shortcode_social_share( $atts ) {

		$defaults = array(
			'networks'       => '',
			'share_text'     => '',
			'align'          => socialsnap_settings( 'ss_ss_inline_content_position' ),
			'total'          => socialsnap_settings( 'ss_ss_inline_content_total_count' ),
			'shape'          => socialsnap_settings( 'ss_ss_inline_content_button_shape' ),
			'size'           => socialsnap_settings( 'ss_ss_inline_content_button_size' ),
			'labels'         => socialsnap_settings( 'ss_ss_inline_content_button_label' ),
			'spacing'        => socialsnap_settings( 'ss_ss_inline_content_button_spacing' ),
			'hide_on_mobile' => socialsnap_settings( 'ss_ss_inline_content_hide_on_mobile' ),
			'all_networks'   => socialsnap_settings( 'ss_ss_inline_content_all_networks' ),
			'format_number'  => true,
		);

		$defaults = apply_filters( 'socialsnap_social_share_shortcode_atts', $defaults );

		$atts = shortcode_atts(
			$defaults,
			$atts
		);

		$networks_default = $this->networks;
		$networks_mobile  = socialsnap_get_mobile_only_social_share_networks();
		$allowed_networks = array_keys( socialsnap_get_social_share_networks() );

		if ( '' === $atts['networks'] ) {
			$atts['networks'] = $networks_default;
		} else {

			$networks         = explode( ';', strtolower( str_replace( ' ', '', $atts['networks'] ) ) );
			$atts['networks'] = array();

			if ( is_array( $networks ) && ! empty( $networks ) ) {
				foreach ( $networks as $network ) {

					if ( ! in_array( $network, $allowed_networks ) ) {
						continue;
					}

					if ( isset( $networks_default[ $network ] ) ) {
						$atts['networks'][ $network ] = $networks_default[ $network ];
					} else {
						$atts['networks'][ $network ] = array(
							'text'               => socialsnap_get_network_name( $network ),
							'desktop_visibility' => isset( $networks_mobile[ $network ] ) ? false : true,
							'mobile_visibility'  => true,
						);
					}
				}
			}
		}

		$options = array(
			'networks'            => $atts['networks'],
			'share_text'          => $atts['share_text'],
			'button_shape'        => $atts['shape'],
			'button_size'         => $atts['size'],
			'button_spacing'      => $atts['spacing'],
			'position'            => $atts['align'],
			'inline_button_label' => $atts['labels'],
			'hide_on_mobile'      => $atts['hide_on_mobile'],
			'show_total_count'    => $atts['total'],
			'all_networks'        => $atts['all_networks'],
			'share_label'         => false,
			'format_number'       => $atts['format_number'],
		);

		$options = apply_filters( 'socialsnap_social_share_shotcode_options', $options, $atts );

		ob_start();

		$this->render_position_inline_content( $options );

		$output = ob_get_clean();

		$search = array(
			'/\>[^\S ]+/s',     // strip whitespaces after tags, except space.
			'/[^\S ]+\</s',     // strip whitespaces before tags, except space.
			'/(\s)+/s',         // shorten multiple whitespace sequences.
			'/<!--(.|\s)*?-->/', // Remove HTML comments.
		);

		$replace = array(
			'>',
			'<',
			'\\1',
			'',
		);

		$output = preg_replace( $search, $replace, $output );

		return $output;
	}

Code file location:

socialsnap/socialsnap/includes/share/class-social-share.php

Socialsnap [ss_on_media_share] Shortcode

The SocialSnap plugin shortcode, ‘ss_on_media_share’, is designed to enhance social media sharing. This shortcode filters content to be shared on social media platforms. It accepts attributes and content, allowing customization of shared content.

Shortcode: [ss_on_media_share]

Examples and Usage

Basic example – The shortcode is utilized to display the social media sharing buttons on your media files. This is a simple implementation of the shortcode.

[ss_on_media_share /]

PHP Function Code

In case you have difficulties debugging what causing issues with [ss_on_media_share] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ss_on_media_share', array( $this, 'shortcode_on_media_share' ) );

Shortcode PHP function:

function shortcode_on_media_share( $atts, $content = '' ) {
		return $this->filter_content_on_media_share( do_shortcode( $content ), $atts );
	}

Code file location:

socialsnap/socialsnap/includes/share/class-social-share.php

Conclusion

Now that you’ve learned how to embed the Socialsnap Plugin shortcodes, 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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *