PHP code example of inc2734 / wp-share-buttons

1. Go to this page and download the library: Download inc2734/wp-share-buttons library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

inc2734 / wp-share-buttons example snippets



new \Inc2734\WP_Share_Buttons\Bootstrap();

/**
 * @see https://developers.facebook.com/tools/accesstoken
 */
add_filter(
  'inc2734_wp_share_buttons_facebook_app_token',
  function() {
    return 'Your App Token';
  }
);

/**
 * Set count cache time
 *
 * @param  {int} $seconds
 * @return {int}
 */
add_filter(
	'inc2734_wp_share_buttons_count_cache_seconds',
	function( $seconds ) {
		return 300;
	}
);

/**
 * When permalink is https, whether or not to sum http and https
 *
 * @param  {bool} $bool
 * @return {bool}
 */
add_filter(
	'inc2734_wp_share_buttons_apply_https_total_count',
	function( $bool ) {
		return true;
	}
);

/**
 * Set handle of localize_script
 *
 * @param  {string} $handle
 * @return {string}
 */
add_filter(
	'inc2734_wp_share_buttons_localize_script_handle',
	function( $handle ) {
		return $handle;
	}
);

/**
 * Add facebook sahre button when using official facebook like button
 *
 * @param  {boolean} $boolean
 * @return {boolean}
 */
add_filter(
	'inc2734_wp_share_buttons_facebook_official_button_share',
	function( $boolean ) {
		return $boolean;
	}
);

/**
 * Customize shared title
 *
 * @param  {string} $title
 * @param  {string} $service twitter or copy
 * @return {string}
 */
add_filter(
	'inc2734_wp_share_buttons_shared_title',
	function( $title, $service ) {
		if ( 'twitter' === $service ) {
			return $title . ' #hashtag';
		}
		return $title;
	},
	10,
	2
);

/**
 * Customize shared title
 *
 * @param  {string} $title
 * @param  {string} $service twitter or copy
 * @return {string}
 */
add_filter(
	'inc2734_wp_share_buttons_shared_hashtags',
	function( $hashtags, $service ) {
		if ( 'twitter' === $service ) {
			return 'hashtagA,hashtagB';
		}
		return $title;
	},
	10,
	2
);

/**
 * Customize share count caching time
 *
 * @param $seconds
 * @return $seconds
 */
add_filter(
	'inc2734_wp_share_buttons_count_cache_seconds',
	function( $seconds ) {
		return $seconds;
	},
	10
);

/**
 * Set Facebook app token.
 *
 * @param string|false
 * @return string|false
 */
add_filter(
	'inc2734_wp_share_buttons_facebook_app_token',
	function( $token ) {
		return $token;
	},
	10
);