Skip to content

Instantly share code, notes, and snippets.

@sebadima
Last active June 30, 2019 14:10
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 sebadima/af0b144e109be6721a29837f37dda86b to your computer and use it in GitHub Desktop.
Save sebadima/af0b144e109be6721a29837f37dda86b to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Social Buttons
* Plugin URI: https://www.sebadima.com
* Description: A simple plugin to share a post on socials networks.
* Version: 1.3a
* Author: Sebastiano Dimartina
* Author URI: https://www.sebadima.com
*/
add_action( 'the_content', 'dsse_sharing' );
add_action( 'wp_enqueue_scripts', 'dsse_load_plugin_css' );
function dsse_load_plugin_css() {
$plugin_url = plugin_dir_url( __FILE__ );
wp_enqueue_style( 'style', $plugin_url . 'css/style.css' );
}
function dsse_sharing ( $content ) {
$html = "Condividi se ti è piaciuto";
$html = $html . "<br>";
global $post;
$url = get_permalink($post->ID);
$url = esc_url($url);
$html = $html . "<div class='facebook'><a target='_blank' href='http://www.facebook.com/sharer.php?u=" . $url . "'>💙 </a></div>";
$html = $html . "<a>&nbsp;&nbsp;</a>";
$html = $html . "<div class='twitter'><a target='_blank' href='https://twitter.com/share?url=" . $url . "'>💙</a></div>";
$html = $html . "<br>";
$html = $html . "<br>";
return $content = $content . $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment