I would also love to know why on the gallery I added below the native gallery where I can filter by Tag why the share button is slightly hidden please? Would love to fix that. Thanks
Can ignore 2nd post. WhatsApp image send and blank wording above the image in the tweet would be great though.
Plugin Author
ILLID
(@mihail-barinov)
Hello,
Looks like I found the solution for you. Please use following code snippet
add_action( 'wp_enqueue_scripts', 'sti_wp_enqueue_scripts', 9999999 );
function sti_wp_enqueue_scripts() {
$script = "
function sti_url( url, options ) {
if ( options.data.network === 'whatsapp' ) {
url = 'https://api.whatsapp.com/send?';
url += 'text=' + encodeURIComponent( options.data.media );
}
}
function sti_data( data ) {
if ( data.network === 'twitter' ) {
data.page = data.local + data.schar + 'img=' + encodeURIComponent( data.media.replace(/^(http?|https):\/\//,'') ) + '&title=' + encodeURIComponent(data.title) + '&network=' + data.network + data.locUrl + data.ssl + data.hash;
}
return data;
}
StiHooks.add_filter( 'sti_sharing_url', sti_url );
StiHooks.add_filter( 'sti_data', sti_data );
";
wp_add_inline_script( 'sti-script', $script);
}
You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.
Regards
Thank you Illid, really appreciate the reply but I am getting this error:
https://drive.google.com/file/d/13_dgHIOxsDhxPdroHp9G37oba5Isf0h-/view?usp=sharing
Any help would be great. Thanks
Plugin Author
ILLID
(@mihail-barinov)
Well in your code I see $#039 chars instead of '.
Place copy and paste code in proper way.
Hi, sorry I must have copied it incorrectly which was weird!
Anyhow I copied it now correctly but now the sharing buttons just return blank even Facebook although your code only seems to change Twitter and WhatsApp. Any chance there’s a slight bug?
Thanks
Plugin Author
ILLID
(@mihail-barinov)
Yes, you are right. Please try this code instead
add_action( 'wp_enqueue_scripts', 'sti_wp_enqueue_scripts', 9999999 );
function sti_wp_enqueue_scripts() {
$script = "
function sti_url( url, options ) {
if ( options.data.network === 'whatsapp' ) {
url = 'https://api.whatsapp.com/send?';
url += 'text=' + encodeURIComponent( options.data.media );
}
return url;
}
function sti_data( data ) {
if ( data.network === 'twitter' ) {
data.page = data.local + data.schar + 'img=' + encodeURIComponent( data.media.replace(/^(http?|https):\/\//,'') ) + '&title=' + encodeURIComponent(data.title) + '&network=' + data.network + data.locUrl + data.ssl + data.hash;
}
return data;
}
StiHooks.add_filter( 'sti_sharing_url', sti_url );
StiHooks.add_filter( 'sti_data', sti_data );
";
wp_add_inline_script( 'sti-script', $script);
}
I’ve added it now. Can’t see much change in Twitter to be honest only I lost an apostrophe from the word – Ireland’s.
WhatsApp seems to send a link rather than the actual image but maybe that’s expected….
Thank you