Initial commit

This commit is contained in:
Alexander Agnarson 2018-05-29 22:04:18 +02:00
commit 60e6157f78
4 changed files with 167 additions and 0 deletions

111
alx-extensions.php Normal file
View file

@ -0,0 +1,111 @@
<?php
/*
Plugin Name: Alx Extensions
Plugin URI: http://wordpress.org/plugins/alx-extensions/
Description: Adds social share links to articles
Version: 1.0.0
Author: Alexander Agnarson
Author URI: http://alxmedia.se
Text Domain: alx-extensions
Domain Path: /languages
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
/* load plugin textdomain */
function alx_ext_load_textdomain() {
load_plugin_textdomain( 'alx-extensions', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
add_action( 'init', 'alx_ext_load_textdomain' );
/* enqueue scripts */
function alx_ext_enqueue_scripts() {
if ( is_singular() ) { wp_enqueue_script( 'alx-ext-sharrre', plugin_dir_url( __FILE__ ) . 'js/jquery.sharrre.min.js', array( 'jquery' ),'', true ); }
}
add_action( 'wp_enqueue_scripts', 'alx_ext_enqueue_scripts' );
/* load template */
function alx_ext_sharrre_actions() {
add_action( 'alx_ext_sharrre', 'alx_ext_sharrre_template' );
}
add_action( 'plugins_loaded', 'alx_ext_sharrre_actions' );
/* template */
function alx_ext_sharrre_template() { ?>
<div class="sharrre-container">
<span><?php esc_html_e('Share','alx-extensions'); ?></span>
<div id="twitter" data-url="<?php echo the_permalink(); ?>" data-text="<?php echo the_title(); ?>" data-title="<?php esc_html_e('Tweet', 'alx-extensions'); ?>"></div>
<div id="facebook" data-url="<?php echo the_permalink(); ?>" data-text="<?php echo the_title(); ?>" data-title="<?php esc_html_e('Like', 'alx-extensions'); ?>"></div>
<div id="pinterest" data-url="<?php echo the_permalink(); ?>" data-text="<?php echo the_title(); ?>" data-title="<?php esc_html_e('Pin It', 'alx-extensions'); ?>"></div>
<div id="linkedin" data-url="<?php echo the_permalink(); ?>" data-text="<?php echo the_title(); ?>" data-title="<?php esc_html_e('Share on LinkedIn', 'alx-extensions'); ?>"></div>
</div><!--/.sharrre-container-->
<script type="text/javascript">
// Sharrre
jQuery(document).ready(function(){
jQuery('#twitter').sharrre({
share: {
twitter: true
},
template: '<a class="box" href="#"><div class="count" href="#"><i class="fa fa-plus"></i></div><div class="share"><i class="fa fa-twitter"></i></div></a>',
enableHover: false,
enableTracking: true,
buttons: { twitter: {via: '<?php echo esc_attr( get_theme_mod('twitter-username') ); ?>'}},
click: function(api, options){
api.simulateClick();
api.openPopup('twitter');
}
});
jQuery('#facebook').sharrre({
share: {
facebook: true
},
template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><i class="fa fa-facebook-square"></i></div></a>',
enableHover: false,
enableTracking: true,
buttons:{layout: 'box_count'},
click: function(api, options){
api.simulateClick();
api.openPopup('facebook');
}
});
jQuery('#pinterest').sharrre({
share: {
pinterest: true
},
template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><i class="fa fa-pinterest"></i></div></a>',
enableHover: false,
enableTracking: true,
buttons: {
pinterest: {
description: '<?php echo the_title(); ?>'<?php if( has_post_thumbnail() ){ ?>,media: '<?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?>'<?php } ?>
}
},
click: function(api, options){
api.simulateClick();
api.openPopup('pinterest');
}
});
jQuery('#linkedin').sharrre({
share: {
linkedin: true
},
template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><i class="fa fa-linkedin-square"></i></div></a>',
enableHover: false,
enableTracking: true,
buttons: {
linkedin: {
description: '<?php echo the_title(); ?>'<?php if( has_post_thumbnail() ){ ?>,media: '<?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?>'<?php } ?>
}
},
click: function(api, options){
api.simulateClick();
api.openPopup('linkedin');
}
});
});
</script>
<?php } ?>

1
js/jquery.sharrre.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,35 @@
msgid ""
msgstr ""
"Project-Id-Version: Typecore\n"
"POT-Creation-Date: 2018-05-29 21:29+0100\n"
"PO-Revision-Date: 2018-05-29 21:30+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: English\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.5.7\n"
"X-Poedit-KeywordsList: esc_html__;esc_html_e\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-SearchPath-0: ..\n"
#: ../alx-extensions.php:31
msgid "Share"
msgstr ""
#: ../alx-extensions.php:32
msgid "Tweet"
msgstr ""
#: ../alx-extensions.php:33
msgid "Like"
msgstr ""
#: ../alx-extensions.php:34
msgid "Pin It"
msgstr ""
#: ../alx-extensions.php:35
msgid "Share on LinkedIn"
msgstr ""

20
readme.txt Normal file
View file

@ -0,0 +1,20 @@
=== Alx Extensions ===
Contributors: alxmedia
Tags:
Requires at least: 4.9
Tested up to: 4.9
Stable tag: 1.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Adds social share links to articles
== Description ==
Adds social share links to articles
== Changelog ==
= 1.0.0 - 2018-05-29 =
* Initial release