Skip to content

Instantly share code, notes, and snippets.

@elvismdev
Last active August 21, 2017 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elvismdev/d776e443c396360b45fb617589ac9395 to your computer and use it in GitHub Desktop.
Save elvismdev/d776e443c396360b45fb617589ac9395 to your computer and use it in GitHub Desktop.
WordPress AddThis plugin (v6+) - Output and control programmatically the AddThis floating sidebar with it's "Smart Layers API": https://www.addthis.com/academy/smart-layers-api/
<?php
/**
* Output an AddThis floating share sidebar to the left with selected services.
*
* Notice 'desktop' and 'mobile' parameters, they take a Boolean data type as value, meaning it can be used to
* allow a more dynamic control and display of the sharing sidebar.
*
* More options to play with can be found here in the docs: https://www.addthis.com/academy/smart-layers-api/
* Just notice to convert the JSON format in the examples to PHP's array() format
* to add/change it's settings and display options.
*/
add_filter( 'addthis_layers_array', function ( $addthis_layers ) {
$addthis_layers = array(
'share' => array(
'position' => 'left',
'services' => 'twitter,facebook,linkedin,email',
'desktop' => true,
'mobile' => false
)
);
return $addthis_layers;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment