Commit b1e96095 authored by lucha's avatar lucha
Browse files

[auto] plugin: dvk-social-sharing None

parent 3f5992e3
Changelog
===================
#### 1.3.2 - March 23, 2018
- Minor code optimisations
- Added `linkedin_text` shortcode argument to FAQ.
#### 1.3.1 - October 26, 2017
Misc. textual improvements.
#### 1.3 - October 4, 2017
**Additions**
- Added LinkedIn.
#### 1.2.7 - January 6, 2017
**Improvements**
- Use `https://` protocol for sharing links.
- Use SVG icons.
**Additions**
- Add "large" icon size option.
- Choose social network options from settings page.
- Added Italian translations, thanks to Alessandro Guidi.
#### 1.2.6 - March 29, 2016
**Fixes**
- Apostrophes in titles not properly escaped in sharing URL's. Thanks Robin Aldenhoven!
#### 1.2.5 - January 26, 2015
**Improvements**
- Minor improvements to pop-up script
**Additions**
- Added Finnish (fi_FI) translations, thanks to [Ari-Pekka Koponen](http://versi.fi/)
#### 1.2.4 - November 17, 2014
**Improvements**
- Wrapped link text in element so it can be hidden using CSS
- Improvements to pop-up JavaScript
#### 1.2.3 - September 4, 2014
**Improvements**
- Added minified scripts and option to load minified version
- Some textual improvements
#### 1.2.2 - April 30, 2014
**Fixes**
- Fixed not being able to save all "auto add to .." checkboxes unchecked
#### 1.2.1 - April 29, 2014
**Additions**
- Added German translations, thanks Andreas Kuhl!
**Improvements**
- Wrapped non-translatable strings in translation calls.
- Updated Dutch translations
#### 1.2 - March 19, 2014
**Additions**
- Added option to automatically add sharing options to all registered post types
- Added Spanish translations, props to [Luciano A. Ferrer](http://cbasites.net/).
**Improvements**
- Disabled Pop-up JS by default until we figure out a cross-browser compatibility fix.
#### 1.1 - February 19, 2014
- Added: Slovenian translations, thanks to [Domen Hrabar, Viking Marketing](http://www.vikingmarketing.si/)
- Improved: direct file access security
#### 1.0.9 - December 30, 2013
- Added: Danish translation, thanks to [Finn Hoelgaard](http://fhn.dk/)!
- Added: Russian translation, thanks to Nikita!
- Improved: Pop-up script now waits for full page load.
#### 1.0.6 - December 20, 2013
- Improved: Pop-up JS now used addEventListener to enable multiple event listeners (like a Google Analytics plugin) attaching to the sharing links.
#### 1.0.5 - December 9, 2013
- Added: French translations, thanks to [Said](http://www.ninapeople.com/)
- Improved: All backend strings are now translatable
- Improved: Prevented direct access or search engine indexing of plugin files
- Improved: Facebook URL sharing parameters
#### 1.0.4 - December 2, 2013
- Improved: Minified pop-up script to 480 bytes.
- Improved: Removed image attribute from Facebook Share URL. FB will now pick up `og:image` meta tags.
#### 1.0.3 - November 25, 2013
- Fixed: undefined index notice when saving options.
#### 1.0.2 - November 20, 2013
- Added: Dutch translation
- Added: Option to change the text that shows before the sharing links.
#### 1.0.1 - November 20, 2013
- Fixed: Added settings link to plugins overview page
- Fixed: "tweet about" option in admin now tweets about the correct plugin.
#### 1.0 - November 17, 2013
- Initial release.
.dvkss-container{
max-width:1200px;
}
.dvkss-primary{
width:60%;
}
.dvkss-column{
float:left;
}
.dvkss-secondary {
width:35%;
margin-left: 2%;
padding-left:2%;
border-left: 1px solid #ddd;
}
.dvkss-error{
color:red;
}
.dvkss-box{
margin:0 0 25px;
clear:both;
}
.dvkss-info {
padding:5px 15px;
color: #3a87ad;
background-color: #d9edf7;
border-color: #bce8f1;
}
.dvkss-alert {
padding:5px 15px;
color: #c09853;
background-color: #fcf8e3;
border-color: #faebcc;
}
.dvkss-title{ margin-top: 2em; }
@media(max-width: 919px) {
.dvkss-column{
float: none;
width: 100%;
}
.dvkss-secondary{
padding:0;
margin:25px 0;
border-left:0;
}
.dvkss-box{
border-top: 1px solid #efefef;
padding-top:25px;
}
}
\ No newline at end of file
.dvkss-container{max-width:1200px}.dvkss-primary{width:60%}.dvkss-column{float:left}.dvkss-secondary{width:35%;margin-left:2%;padding-left:2%;border-left:1px solid #ddd}.dvkss-error{color:red}.dvkss-box{margin:0 0 25px;clear:both}.dvkss-info{padding:5px 15px;color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.dvkss-alert{padding:5px 15px;color:#c09853;background-color:#fcf8e3;border-color:#faebcc}.dvkss-title{margin-top:2em}@media(max-width:919px){.dvkss-column{float:none;width:100%}.dvkss-secondary{padding:0;margin:25px 0;border-left:0}.dvkss-box{border-top:1px solid #efefef;padding-top:25px}}
\ No newline at end of file
.dvk-social-sharing {
line-height: 16px;
}
.dvk-social-sharing > a{
margin-left:12px;
display: inline-block;
text-decoration: none;
border-bottom: 0;
}
.dvk-social-sharing > a:hover .ss-icon,
.dvk-social-sharing > a:focus .ss-icon {
opacity: 1;
}
.dvk-social-sharing > span:first-of-type {
font-weight: bold;
}
.ss-icon {
width: 16px;
height: 16px;
display: inline-block;
background-repeat: no-repeat;
margin-right:6px;
vertical-align: middle;
background-size: cover;
opacity: 0.6;
}
.ss-icon-twitter {
background-image: url('../img/twitter.svg')
}
.ss-icon-facebook {
background-image: url('../img/facebook.svg')
}
.ss-icon-googleplus {
background-image: url('../img/google-plus.svg')
}
.ss-icon-linkedin {
background-image: url('../img/linkedin.svg')
}
.ss-icon-size-32 {
line-height: 32px;
}
.ss-icon-size-32 .ss-icon {
width: 32px;
height: 32px;
}
.ss-icon-size-48 {
line-height: 48px;
}
.ss-icon-size-48 .ss-icon {
width: 48px;
height: 48px;
}
.dvk-social-sharing{line-height:16px}.dvk-social-sharing>a{margin-left:12px;display:inline-block;text-decoration:none;border-bottom:0}.dvk-social-sharing>a:focus .ss-icon,.dvk-social-sharing>a:hover .ss-icon{opacity:1}.dvk-social-sharing>span:first-of-type{font-weight:700}.ss-icon{width:16px;height:16px;display:inline-block;background-repeat:no-repeat;margin-right:6px;vertical-align:middle;background-size:cover;opacity:.6}.ss-icon-twitter{background-image:url(../img/twitter.svg)}.ss-icon-facebook{background-image:url(../img/facebook.svg)}.ss-icon-googleplus{background-image:url(../img/google-plus.svg)}.ss-icon-linkedin{background-image:url(../img/linkedin.svg)}.ss-icon-size-32{line-height:32px}.ss-icon-size-32 .ss-icon{width:32px;height:32px}.ss-icon-size-48{line-height:48px}.ss-icon-size-48 .ss-icon{width:48px;height:48px}
\ No newline at end of file
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg enable-background="new 0 0 128 128" height="128px" id="Layer_1" version="1.1" viewBox="0 0 128 128" width="128px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M128,112c0,8.8-7.2,16-16,16H16c-8.8,0-16-7.2-16-16V16C0,7.2,7.2,0,16,0h96c8.8,0,16,7.2,16,16V112z" fill="#3C579E"/><path d="M68.877,128V78.188h-17.78V60.425h17.784V44.029c0-16.537,9.764-26.279,24.514-26.279 c7.068,0,12.834,0.756,14.605,0.991v18.573l-11.874-0.005c-8.022,0-9.523,3.979-9.523,9.572v13.544h20.556l-2.904,17.763H86.603V128 H68.877z" fill="#FFFFFF"/></svg>
\ No newline at end of file
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg enable-background="new 0 0 128 128" height="128px" id="Layer_1" version="1.1" viewBox="0 0 128 128" width="128px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M128,112c0,8.8-7.2,16-16,16H16c-8.8,0-16-7.2-16-16V16C0,7.2,7.2,0,16,0h96c8.8,0,16,7.2,16,16V112z" fill="#D95032"/><g><path d="M49.211,70.989h16.882c-1.939,7.841-7.911,12.214-17.033,12.214c-10.781,0-19.554-8.615-19.554-19.202 c0-10.59,8.772-19.204,19.554-19.204c4.715,0,9.268,1.671,12.821,4.706l8.116-9.161c-5.803-4.958-13.238-7.689-20.937-7.689 c-17.6,0-31.917,14.063-31.917,31.347c0,17.283,14.317,31.345,31.917,31.345c17.994,0,30.083-12.229,30.083-30.427v-6.073H49.211 V70.989z" fill="#FFFFFF"/><polygon fill="#FFFFFF" points="117.143,58.741 106.143,58.741 106.143,47.741 98.143,47.741 98.143,58.741 87.143,58.741 87.143,66.741 98.143,66.741 98.143,77.741 106.143,77.741 106.143,66.741 117.143,66.741 "/></g></svg>
\ No newline at end of file
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'><svg enable-background="new 0 0 32 32" height="32px" id="Layer_1" version="1.0" viewBox="0 0 32 32" width="32px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g><path d="M32,30c0,1.104-0.896,2-2,2H2c-1.104,0-2-0.896-2-2V2c0-1.104,0.896-2,2-2h28c1.104,0,2,0.896,2,2V30z" fill="#007BB5"/><g><rect fill="#FFFFFF" height="14" width="4" x="7" y="11"/><path d="M20.499,11c-2.791,0-3.271,1.018-3.499,2v-2h-4v14h4v-8c0-1.297,0.703-2,2-2c1.266,0,2,0.688,2,2v8h4v-7 C25,14,24.479,11,20.499,11z" fill="#FFFFFF"/><circle cx="9" cy="8" fill="#FFFFFF" r="2"/></g></g><g/><g/><g/><g/><g/><g/></svg>
\ No newline at end of file
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg enable-background="new 0 0 128 128" height="128px" id="Layer_1" version="1.1" viewBox="0 0 128 128" width="128px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M128,112c0,8.8-7.2,16-16,16H16c-8.8,0-16-7.2-16-16V16C0,7.2,7.2,0,16,0h96c8.8,0,16,7.2,16,16V112z" fill="#55ACEE"/><g><path d="M109.001,37.711c-3.236,1.437-6.716,2.407-10.37,2.842c3.729-2.234,6.589-5.771,7.938-9.988 c-3.488,2.069-7.354,3.572-11.465,4.381c-3.293-3.509-7.985-5.702-13.177-5.702c-9.973,0-18.056,8.083-18.056,18.053 c0,1.416,0.16,2.792,0.468,4.115c-15.007-0.753-28.309-7.941-37.213-18.863c-1.554,2.665-2.445,5.768-2.445,9.076 c0,6.263,3.188,11.79,8.032,15.027c-2.959-0.094-5.745-0.907-8.178-2.26c-0.002,0.076-0.002,0.152-0.002,0.228 c0,8.75,6.223,16.042,14.482,17.703c-1.516,0.412-3.11,0.633-4.756,0.633c-1.164,0-2.295-0.114-3.397-0.325 c2.298,7.173,8.966,12.396,16.865,12.539c-6.178,4.84-13.963,7.726-22.422,7.726c-1.458,0-2.895-0.082-4.307-0.252 c7.989,5.123,17.481,8.112,27.676,8.112c33.207,0,51.367-27.511,51.367-51.368c0-0.782-0.021-1.562-0.055-2.335 C103.521,44.511,106.58,41.331,109.001,37.711" fill="#FFFFFF"/></g></svg>
\ No newline at end of file
(function($) {
var $f = $("#dvkss_settings");
function toggleRows() {
$f.find('.row-icon-size').toggle( ($f.find('.row-load-icon-css input:checked').val() == 1) );
}
$f.change(toggleRows);
// run once on init
toggleRows();
})(jQuery);
\ No newline at end of file
!function(a){function b(){c.find(".row-icon-size").toggle(1==c.find(".row-load-icon-css input:checked").val())}var c=a("#dvkss_settings");c.change(b),b()}(jQuery);
\ No newline at end of file
(function() {
'use strict';
/**
* Initialises the Social Sharing plugin
*/
function initSocialSharing() {
var links;
links = document.querySelectorAll('.dvk-social-sharing a');
for (var i = 0; i < links.length; i++) {
addEvent(links[i], 'click', openPopup);
}
}
/**
* Open a popup
*
* @param e
* @returns {boolean}
*/
function openPopup(e) {
var top = (screen.availHeight - 500) / 2;
var left = (screen.availWidth - 500) / 2;
var popup = window.open(
this.href,
'social',
'width=550,height=420,left='+ left +',top='+ top +',location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1'
);
if(popup) {
popup.focus();
e.preventDefault();
return false;
}
return true;
}
/**
* Add event, compatible with IE.
*
* @param element
* @param eventName
* @param callback
*/
function addEvent(element, eventName, callback) {
if (element.addEventListener) {
element.addEventListener(eventName, callback, false);
} else {
element.attachEvent("on" + eventName, callback);
}
}
addEvent(window, 'load', initSocialSharing);
})();
\ No newline at end of file
!function(){"use strict";function a(){var a;a=document.querySelectorAll(".dvk-social-sharing a");for(var d=0;d<a.length;d++)c(a[d],"click",b)}function b(a){var b=(screen.availHeight-500)/2,c=(screen.availWidth-500)/2,d=window.open(this.href,"social","width=550,height=420,left="+c+",top="+b+",location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1");return d?(d.focus(),a.preventDefault(),!1):!0}function c(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)}c(window,"load",a)}();
\ No newline at end of file
<?php
class DVKSS_Admin {
/**
* @var int
*/
private $code_version = 1;
/**
* @var string
*/
private $slug = 'dvk-social-sharing/index.php';
/**
* @var string
*/
private $plugin_file;
/**
* Constructor
*/
public function __construct( $plugin_file ) {
$this->plugin_file = $plugin_file;
}
public function hook() {
add_action( 'admin_init', array( $this, 'maybe_run_upgrade_routine' ) );
add_action( 'admin_init', array( $this, 'register_settings' ) );
add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
add_filter( "plugin_action_links_{$this->slug}", array( $this, 'add_settings_link' ) );
if ( isset( $_GET['page'] ) && $_GET['page'] === 'dvkss' ) {
// load css
add_action( 'admin_enqueue_scripts', array( $this, 'load_css' ) );
}
}
/**
* Upgrade routine
*
* @return bool
*/
public function maybe_run_upgrade_routine() {
// only run if code version is higher than stored code version
$db_version = absint( get_option( 'dvkss_code_version', 0 ) );
if( $this->code_version <= $db_version ) {
return false;
}
$opts = dvkss_get_options();
if( isset( $opts['auto_add'] ) && $opts['auto_add'] ) {
$opts['auto_add_post_types'][] = 'post';
unset( $opts['auto_add'] );
}
update_option( 'dvk_social_sharing', $opts );
update_option( 'dvkss_code_version', $this->code_version );
return true;
}
/**
* Load admin scripts and stylesheets
*/
public function load_css() {
$suffix = ( defined( SCRIPT_DEBUG ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_enqueue_style( 'dvk-social-sharing', plugins_url( '/assets/css/admin-styles' . $suffix .'.css', $this->plugin_file ) );
wp_enqueue_script( 'dvk-social-sharing', plugins_url( 'assets/js/admin-script' . $suffix .'.js', $this->plugin_file ), array( 'jquery' ), DVKSS_VERSION , true );
}
/**
* Register the plugin settings
*/
public function register_settings() {
register_setting( 'dvk_social_sharing', 'dvk_social_sharing', array($this, 'sanitize_settings') );
}
/**
* Sanitize settings
*
* @param array $settings
* @return array $settings
*/
public function sanitize_settings( $settings ) {
$settings['before_text'] = strip_tags( $settings['before_text'], '<a><br><strong><i><em><b><span>' );
$settings['icon_size'] = trim( absint( $settings['icon_size'] ) );
$settings['twitter_username'] = trim( strip_tags( $settings['twitter_username'] ) );
$settings['auto_add_post_types'] = ( isset( $settings['auto_add_post_types'] ) ) ? $settings['auto_add_post_types'] : array();
$settings['social_options'] = ( isset( $settings['social_options'] ) ) ? $settings['social_options'] : array();
return $settings;
}
/**
* Add settings link to Plugin overview
*
* @return array $links
*/
public function add_settings_link( $links ) {
$settings_link = '<a href="options-general.php?page=dvkss">'. __('Settings') . '</a>';
array_unshift( $links, $settings_link );
return $links;
}
/**
* Add options page to Admin menu
*/
public function add_menu_item() {
add_options_page( 'Social Sharing By Danny', 'Social Sharing', 'manage_options', 'dvkss', array( $this, 'show_settings_page' ) );
}
/**
* Show the plugin settings page
*/
public function show_settings_page() {
$opts = dvkss_get_options();
$post_types = get_post_types( array( 'public' => true ), 'objects' );
include DVKSS_PLUGIN_DIR . '/includes/views/settings-page.php';
}
}
<?php
class DVKSS_Public {
private $plugin_file;
/**
* Constructor
*/
public function __construct( $plugin_file ) {
$this->plugin_file = $plugin_file;
}
public function hook() {
add_action( 'wp_enqueue_scripts', array( $this, 'load_assets' ), 99 );
add_filter( 'the_content', array( $this, 'add_links' ) );
add_shortcode( 'dvk_social_sharing', 'dvk_social_sharing' );
}
/**
* Load plugin stylesheets and scripts
*/
public function load_assets()
{
$opts = dvkss_get_options();
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
if( $opts['load_icon_css'] ) {
wp_enqueue_style( 'dvk-social-sharing', plugins_url( '/assets/css/styles' . $suffix . '.css', $this->plugin_file ), array(), DVKSS_VERSION );
}
if( $opts['load_popup_js'] ) {
wp_enqueue_script( 'dvk-social-sharing', plugins_url( '/assets/js/script' . $suffix . '.js', $this->plugin_file ), array( ), DVKSS_VERSION, true );
}
}
/**
* Automatically adds links to post content
*
* @param string $content
* @return string
*/
public function add_links( $content )
{
$opts = dvkss_get_options();
$show_buttons = false;
if( ! empty( $opts['auto_add_post_types'] ) && in_array( get_post_type(), $opts['auto_add_post_types'] ) && is_singular( $opts['auto_add_post_types'] ) ) {
$show_buttons = true;
}
// allow custom conditionals
$show_buttons = apply_filters( 'dvkss_display', $show_buttons );
if( ! $show_buttons ) {
return $content;
}
// add buttons to content
return $content . dvk_social_sharing();
}
}
<?php
/**
* Get social sharing button options
* @return array Options in array format
*/
function dvkss_get_options()
{
static $options;
// load options from database
if( ! $options ) {
// default options
$defaults = array(
'load_icon_css' => 1,
'load_popup_js' => 0,
'icon_size' => 32,
'twitter_username' => '',
'auto_add_post_types' => array( 'post' ),
'before_text' => "Share this post: ",
'social_options' => array( 'twitter', 'facebook', 'googleplus' ),
);
// get options from db
$db_option = get_option( 'dvk_social_sharing', array() );