Skip to content

Instantly share code, notes, and snippets.

@robincornett
Last active December 17, 2018 13:53
Show Gist options
  • Save robincornett/dd86b2e533220a5d947a33c321f2bc5b to your computer and use it in GitHub Desktop.
Save robincornett/dd86b2e533220a5d947a33c321f2bc5b to your computer and use it in GitHub Desktop.
Add a button for Pocket to Scriptless Social Sharing.
<?php
add_filter( 'scriptlesssocialsharing_pocket_url', 'prefix_add_pocket', 10, 3 );
/**
* Create the URL for the Pocket share/save button.
*
* @param $url
* @param $button
* @param $attributes
*
* @return string
*/
function prefix_add_pocket( $url, $button, $attributes ) {
return sprintf( 'https://getpocket.com/save?url=%s&title=%s', $attributes['permalink'], $attributes['title'] );
}
add_filter( 'scriptlesssocialsharing_networks', 'prefix_scriptless_networks_pocket' );
/**
* Add Pocket to settings/allowed sharing buttons
*
* @param $networks
*
* @return mixed
*/
function prefix_scriptless_networks_pocket( $networks ) {
$networks['pocket'] = array(
'name' => 'pocket',
'label' => __( 'Pocket', 'scriptless-social-sharing' ),
'icon' => 'f265',
'color' => '#ef4056',
);
return $networks;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment