Skip to content

Add custom share buttons

Thomas Kuther edited this page Feb 15, 2017 · 8 revisions

You may want to add share buttons for other services than "the big 3".

This is requested quite often, and can be achieved quite easily by creating a custom plugin that adds some jQuery code.

  1. Go to Administration -> Plugins -> Local Files Editor -> Personal Plugin
  2. Add this code:
<?php

add_event_handler('loc_end_picture', 'add_custom_share_buttons');
function add_custom_share_buttons() {
  global $template;

  //heredoc multiline, take care
  $script_content = <<<EOT

$(document).ready(function() {
  $('#theImageShareButtons>section').append('<a href="mailto:me@xy.net" title="Mail"><i class="fa fa-envelope"></a>');
})

EOT;
  $template->block_footer_script(array('require' => 'jquery'), $script_content);
}

?>```
The interesting part here is the ```<a href="mailto:me@xy.net" title="Mail"><i class="fa fa-envelope"></a>')```. You can paste any HTML code here from any service. The ```<i class="fa fa-envelope">```defines the icon to be shown. See http://fontawesome.io/icons/ for a full list of all icons.

3. Enable the Personal Plugin in **Administration->Plugins**

Clone this wiki locally