WP Social Sharing - Version 1.1

Version Description

  • July 14, 2014 =

  • Fix facebook share for mobile devices

  • Add Icon order functionality. Now user can reorder the social icon.

  • Add settings link on plugin page.

  • Update plugin shortcode. Add icon_order field

Download this release

Release Info

Developer arjunjain08
Plugin Icon wp plugin WP Social Sharing
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

includes/class-admin.php CHANGED
@@ -14,12 +14,25 @@ class SS_Admin {
14
  add_action( 'admin_init', array( $this, 'register_settings' ) );
15
  add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
16
 
17
- add_filter( "plugin_action_links_social-sharing/index.php", array( $this, 'add_settings_link' ) );
18
 
19
  if ( isset( $_GET['page'] ) && $_GET['page'] === 'wp-social-sharing' ) {
20
  add_action( 'admin_enqueue_scripts', array( $this, 'load_css' ) );
21
  }
22
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  public function load_css() {
25
  wp_enqueue_style( 'social-sharing', SS_PLUGIN_URL . 'static/admin-styles.css' );
@@ -40,7 +53,7 @@ class SS_Admin {
40
  }
41
 
42
  public function add_settings_link( $links ) {
43
- $settings_link = '<a href="options-general.php?page=social-sharing">'. __('Settings') . '</a>';
44
  array_unshift( $links, $settings_link );
45
  return $links;
46
  }
14
  add_action( 'admin_init', array( $this, 'register_settings' ) );
15
  add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
16
 
17
+ add_filter( "plugin_action_links_wp-social-sharing/index.php", array( $this, 'add_settings_link' ) );
18
 
19
  if ( isset( $_GET['page'] ) && $_GET['page'] === 'wp-social-sharing' ) {
20
  add_action( 'admin_enqueue_scripts', array( $this, 'load_css' ) );
21
  }
22
  }
23
+ function wss_plugin_activation_action(){
24
+ $defaults = array(
25
+ 'twitter_username' => "",
26
+ 'auto_add_post_types' => array( 'post' ),
27
+ 'social_options'=>array('facebook','twitter','googleplus'),
28
+ 'load_static'=>array('load_css','load_js'),
29
+ 'facebook_text'=>"Share on Facebook",
30
+ 'twitter_text'=>"Share on Twitter",
31
+ 'googleplus_text'=>"Share on Google+",
32
+ );
33
+ update_option( 'wp_social_sharing', $defaults );
34
+ update_option( 'wss_wp_social_sharing','f,t,g');
35
+ }
36
 
37
  public function load_css() {
38
  wp_enqueue_style( 'social-sharing', SS_PLUGIN_URL . 'static/admin-styles.css' );
53
  }
54
 
55
  public function add_settings_link( $links ) {
56
+ $settings_link = '<a href="options-general.php?page=wp-social-sharing">'. __('Settings') . '</a>';
57
  array_unshift( $links, $settings_link );
58
  return $links;
59
  }
includes/class-public.php CHANGED
@@ -27,11 +27,10 @@ class SS_Public {
27
  if( ! $show_buttons ) {
28
  return $content;
29
  }
30
-
31
- // add buttons to content
32
- return $content . $this->social_sharing();
33
  }
34
-
35
  public function load_assets()
36
  {
37
  $opts = ss_get_options();
@@ -54,35 +53,48 @@ class SS_Public {
54
  'twitter_text' => __( 'Twitter', 'social-sharing' ),
55
  'facebook_text' => __( 'Facebook', 'social-sharing' ),
56
  'googleplus_text' => __( 'Google+', 'social-sharing' ),
 
57
  );
58
 
59
- // create final arguments array
60
- $args = wp_parse_args( $opts, $defaults );
61
  if(!is_array($args['social_options']))
62
  $args['social_options'] = array_filter( array_map( 'trim', explode( ',', $args['social_options'] ) ) );
63
  extract( $args );
64
 
65
  $title = urlencode( get_the_title() );
66
  $url = urlencode( get_permalink() );
 
67
  $loadjs='';
68
  foreach ($opts['load_static'] as $static){
69
  if($static == 'load_js'){
70
  $loadjs='onclick="return ss_plugin_loadpopup_js(this);"';
71
  }
72
  }
 
 
 
 
73
  ob_start();
74
  ?>
75
  <div class="social-sharing">
76
- <?php foreach($social_options as $o) {
 
77
  switch($o) {
78
- case 'facebook':
79
- ?><a <?php echo $loadjs;?> rel="external nofollow" class="button-facebook ss-sbutton" href="http://www.facebook.com/sharer/sharer.php?s=100&p[url]=<?php echo $url; ?>&p[title]=<?php echo $title; ?>" target="_blank" ><?php echo $facebook_text; ?></a><?php
 
 
80
  break;
81
- case 'twitter':
 
82
  ?><a <?php echo $loadjs;?> rel="external nofollow" class="button-twitter ss-sbutton" href="http://twitter.com/intent/tweet/?text=<?php echo $title; ?>&url=<?php echo $url; ?><?php if(!empty($twitter_username)) { echo '&via=' . $twitter_username; } ?>" target="_blank"><?php echo $twitter_text; ?></a><?php
 
83
  break;
84
- case 'googleplus':
 
85
  ?><a <?php echo $loadjs;?> rel="external nofollow" class="button-googleplus ss-sbutton" href="https://plus.google.com/share?url=<?php echo $url; ?>" target="_blank" ><?php echo $googleplus_text; ?></a><?php
 
86
  break;
87
  }
88
  } ?>
27
  if( ! $show_buttons ) {
28
  return $content;
29
  }
30
+ $opts['icon_order']=get_option('wss_wp_social_sharing');
31
+ return $content . $this->social_sharing($opts);
 
32
  }
33
+
34
  public function load_assets()
35
  {
36
  $opts = ss_get_options();
53
  'twitter_text' => __( 'Twitter', 'social-sharing' ),
54
  'facebook_text' => __( 'Facebook', 'social-sharing' ),
55
  'googleplus_text' => __( 'Google+', 'social-sharing' ),
56
+ 'icon_order'=>'f,t,g'
57
  );
58
 
59
+ $opts['icon_order']=get_option('wss_wp_social_sharing');
60
+
61
  if(!is_array($args['social_options']))
62
  $args['social_options'] = array_filter( array_map( 'trim', explode( ',', $args['social_options'] ) ) );
63
  extract( $args );
64
 
65
  $title = urlencode( get_the_title() );
66
  $url = urlencode( get_permalink() );
67
+
68
  $loadjs='';
69
  foreach ($opts['load_static'] as $static){
70
  if($static == 'load_js'){
71
  $loadjs='onclick="return ss_plugin_loadpopup_js(this);"';
72
  }
73
  }
74
+ if($icon_order == '' || $icon_order == null){
75
+ $icon_order = 'f,t,g';
76
+ }
77
+ $icon_order=explode(',',$icon_order);
78
  ob_start();
79
  ?>
80
  <div class="social-sharing">
81
+ <?php
82
+ foreach($icon_order as $o) {
83
  switch($o) {
84
+ case 'f':
85
+ if(in_array('facebook', $social_options)){
86
+ ?><a <?php echo $loadjs;?> rel="external nofollow" class="button-facebook ss-sbutton" href="http://www.facebook.com/sharer/sharer.php?u=<?php echo $url; ?>" target="_blank" ><?php echo $facebook_text; ?></a><?php
87
+ }
88
  break;
89
+ case 't':
90
+ if(in_array('twitter', $social_options)){
91
  ?><a <?php echo $loadjs;?> rel="external nofollow" class="button-twitter ss-sbutton" href="http://twitter.com/intent/tweet/?text=<?php echo $title; ?>&url=<?php echo $url; ?><?php if(!empty($twitter_username)) { echo '&via=' . $twitter_username; } ?>" target="_blank"><?php echo $twitter_text; ?></a><?php
92
+ }
93
  break;
94
+ case 'g':
95
+ if(in_array('googleplus', $social_options)){
96
  ?><a <?php echo $loadjs;?> rel="external nofollow" class="button-googleplus ss-sbutton" href="https://plus.google.com/share?url=<?php echo $url; ?>" target="_blank" ><?php echo $googleplus_text; ?></a><?php
97
+ }
98
  break;
99
  }
100
  } ?>
includes/plugin.php CHANGED
@@ -20,7 +20,7 @@ function ss_get_options()
20
  'googleplus_text'=>"Share on Google+",
21
  );
22
 
23
- $db_option = get_option( 'wp_social_sharing', array() );
24
  if(!isset($db_option['load_static'])){
25
  $db_option['load_static']=array();
26
  }
@@ -30,12 +30,39 @@ function ss_get_options()
30
  if(!isset($db_option['auto_add_post_types'])){
31
  $db_option['auto_add_post_types']=array();
32
  }
33
-
34
  if( ! $db_option ) {
35
  update_option( 'wp_social_sharing', $defaults );
36
  }
37
-
38
  $options = wp_parse_args( $db_option, $defaults );
39
  }
40
  return $options;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
20
  'googleplus_text'=>"Share on Google+",
21
  );
22
 
23
+ $db_option = get_option( 'wp_social_sharing', array());
24
  if(!isset($db_option['load_static'])){
25
  $db_option['load_static']=array();
26
  }
30
  if(!isset($db_option['auto_add_post_types'])){
31
  $db_option['auto_add_post_types']=array();
32
  }
33
+
34
  if( ! $db_option ) {
35
  update_option( 'wp_social_sharing', $defaults );
36
  }
37
+
38
  $options = wp_parse_args( $db_option, $defaults );
39
  }
40
  return $options;
41
+ }
42
+ add_action('admin_footer','include_icon_order_script');
43
+ function include_icon_order_script(){
44
+ wp_enqueue_script( 'jquery-ui-sortable' );
45
+ ?>
46
+ <script type="text/javascript">
47
+ jQuery(document).ready(function($){
48
+ $('.dndicon').sortable({
49
+ stop:function(event,ui){
50
+ var new_order='';
51
+ $('.dndicon > div').each(function(e,i){
52
+ new_order += $(i).attr('id')+',';
53
+ });
54
+ new_order = new_order.slice(0,new_order.length-1);
55
+ var ajax_data={'action':'wss_update_icon_order','new_order':new_order};
56
+ $.post(ajaxurl,ajax_data,function(response){});
57
+ }
58
+ });
59
+ });
60
+ </script>
61
+ <?php
62
+ }
63
+
64
+ add_action('wp_ajax_wss_update_icon_order','include_icon_order_action');
65
+ function include_icon_order_action(){
66
+ update_option('wss_wp_social_sharing', rtrim($_POST['new_order'],','));
67
+ die;
68
  }
includes/settings-page.php CHANGED
@@ -22,6 +22,31 @@ if( ! defined("SS_VERSION") ) {
22
  <input type="checkbox" id="googleplus_share" name="wp_social_sharing[social_options][]" value="googleplus" <?php checked( in_array( 'googleplus', $opts['social_options'] ), true ); ?>><label for="googleplus_share"><?php echo _e('Google Plus','wp-social-sharing')?></label>
23
  </td>
24
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  <tr valign="top">
26
  <th><label for="facebook_text"><?php _e('Facebook Share button text','wp-social-sharing');?></label></th>
27
  <td>
22
  <input type="checkbox" id="googleplus_share" name="wp_social_sharing[social_options][]" value="googleplus" <?php checked( in_array( 'googleplus', $opts['social_options'] ), true ); ?>><label for="googleplus_share"><?php echo _e('Google Plus','wp-social-sharing')?></label>
23
  </td>
24
  </tr>
25
+ <tr valign="top">
26
+ <th>Social Icon order</th>
27
+ <td>
28
+ <div class="dndicon">
29
+
30
+ <?php $s_order=get_option('wss_wp_social_sharing');
31
+ if(empty($s_order)) $s_order='f,t,g';
32
+ $io=explode(',',rtrim($s_order,','));
33
+ foreach ($io as $i){
34
+ switch($i){
35
+ case 'f':
36
+ echo '<div class="s-icon facebook-icon" id="f"></div>';
37
+ break;
38
+ case 'g':
39
+ echo '<div class="s-icon googleplus-icon" id="g"></div>';
40
+ break;
41
+ case 't':
42
+ echo '<div class="s-icon twitter-icon" id="t"></div>';
43
+ break;
44
+ }
45
+ }?>
46
+ </div>
47
+ <br /><small><?php _e('Drag the social icon to change the order. No need to save.', 'wp-social-sharing'); ?></small>
48
+ </td>
49
+ </tr>
50
  <tr valign="top">
51
  <th><label for="facebook_text"><?php _e('Facebook Share button text','wp-social-sharing');?></label></th>
52
  <td>
index.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: WP Social Sharing
4
- Version: 1.0
5
  Plugin URI: http://wordpress.org/plugins/wp-social-sharing/
6
  Description: Adds very attractive responsive social sharing buttons of Facebook, Twitter and Google+ to wordpress posts, pages or media.
7
  Author: Arjun Jain
@@ -28,4 +28,6 @@ if( ! is_admin() ) {
28
  } elseif( ! defined("DOING_AJAX") || ! DOING_AJAX ) {
29
  require SS_PLUGIN_DIR . 'includes/class-admin.php';
30
  new SS_Admin();
31
- }
 
 
1
  <?php
2
  /*
3
  Plugin Name: WP Social Sharing
4
+ Version: 1.1
5
  Plugin URI: http://wordpress.org/plugins/wp-social-sharing/
6
  Description: Adds very attractive responsive social sharing buttons of Facebook, Twitter and Google+ to wordpress posts, pages or media.
7
  Author: Arjun Jain
28
  } elseif( ! defined("DOING_AJAX") || ! DOING_AJAX ) {
29
  require SS_PLUGIN_DIR . 'includes/class-admin.php';
30
  new SS_Admin();
31
+ }
32
+
33
+ register_activation_hook(__FILE__, array('SS_Admin','wss_plugin_activation_action'));
readme.txt CHANGED
@@ -6,14 +6,15 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=SQC4WR7X
6
  Tags: responsive social buttons, responsive social sharing buttons, responsive button, social buttons, social sharing, sharing buttons, twitter, googleplus, facebook
7
  Requires at least: 3.5
8
  Tested up to: 3.9.1
9
- Stable tag: 1.0
10
  License: GPLv3
11
 
12
  Adds very attractive responsive social sharing buttons of Facebook, Twitter and Google+ to wordpress posts, pages or media.
13
 
14
  == Description ==
15
 
16
- WP Social sharing adds very attractive, responsive social share buttons of Facebook, Twitter and Google+ to WordPress posts, page or media. This plugin is very lightweight and simple social sharing plugin. This plugin provides option whether you want to include plugin CSS/JS or not. Most of the social sharing plugins uses images/api to display social share buttons, but this plugin created large buttons using CSS3. Also, these social sharing buttons are responsive. For device width <strong>less than 480px</strong> these button converted into their respective icons.
 
17
 
18
  **Plugin Features**
19
 
@@ -21,6 +22,7 @@ WP Social sharing adds very attractive, responsive social share buttons of Faceb
21
  - Auto display to Post, Page and Media.
22
  - Custom Social Button text.
23
  - 100% responsive.
 
24
  - No Image, button created using CSS3. For device width less than 480px, this plugin used one single image to display social icons.
25
  - Provide Shortcode, can integrated with any theme easily.
26
 
@@ -33,7 +35,7 @@ You can also use following shortcode
33
  This shortcode will use default wp social sharing plugin settings.
34
 
35
  `
36
- [wp_social_sharing social_options='facebook,twitter,googleplug' twitter_username='arjun077' facebook_text='Share on Facebook' twitter_text='Share on Twitter' googleplus_text='Share on Google+']
37
  `
38
 
39
  == Support ==
@@ -54,6 +56,12 @@ This shortcode will use default wp social sharing plugin settings.
54
  2. Alternatively, download the plugin and upload the contents of `wp-social-sharing.zip` to your plugins directory, which usually is `/wp-content/plugins/`. Activate the plugin.
55
 
56
  == Changelog ==
 
 
 
 
 
 
57
 
58
  = 1.0 - June 30, 2014 =
59
 
6
  Tags: responsive social buttons, responsive social sharing buttons, responsive button, social buttons, social sharing, sharing buttons, twitter, googleplus, facebook
7
  Requires at least: 3.5
8
  Tested up to: 3.9.1
9
+ Stable tag: 1.1
10
  License: GPLv3
11
 
12
  Adds very attractive responsive social sharing buttons of Facebook, Twitter and Google+ to wordpress posts, pages or media.
13
 
14
  == Description ==
15
 
16
+ WP Social sharing adds very attractive responsive social share buttons of Facebook, Twitter and Google+ to wordpress posts, page or media. This plugin is very lightweight and simple social sharing plugin. This plugin provide option whether you want to include plugin CSS/JS or not.
17
+ Most of the social sharing plugins uses images/api to display social share buttons, but this plugin created large buttons using CSS3. Also these social sharing buttons are responsive. For device width <strong>less than 480px</strong> these button converted into their respective icons.
18
 
19
  **Plugin Features**
20
 
22
  - Auto display to Post, Page and Media.
23
  - Custom Social Button text.
24
  - 100% responsive.
25
+ - Reorder Social icon order easily.
26
  - No Image, button created using CSS3. For device width less than 480px, this plugin used one single image to display social icons.
27
  - Provide Shortcode, can integrated with any theme easily.
28
 
35
  This shortcode will use default wp social sharing plugin settings.
36
 
37
  `
38
+ [wp_social_sharing social_options='facebook,twitter,googleplus' twitter_username='arjun077' facebook_text='Share on Facebook' twitter_text='Share on Twitter' googleplus_text='Share on Google+' icon_order='f,t,g']
39
  `
40
 
41
  == Support ==
56
  2. Alternatively, download the plugin and upload the contents of `wp-social-sharing.zip` to your plugins directory, which usually is `/wp-content/plugins/`. Activate the plugin.
57
 
58
  == Changelog ==
59
+ = 1.1 - July 14, 2014 =
60
+
61
+ - Fix facebook share for mobile devices
62
+ - Add Icon order functionality. Now user can reorder the social icon.
63
+ - Add settings link on plugin page.
64
+ - Update plugin shortcode. Add *icon_order* field
65
 
66
  = 1.0 - June 30, 2014 =
67
 
static/admin-styles.css CHANGED
@@ -7,6 +7,11 @@
7
  .ss-info {padding:5px 15px;color: #3a87ad;background-color: #d9edf7;border-color: #bce8f1;}
8
  .ss-alert { padding:5px 15px;color: #c09853;background-color: #fcf8e3;border-color: #faebcc;}
9
  .ss-title{ margin-top: 2em;}
 
 
 
 
 
10
 
11
  @media(max-width: 919px) {
12
  .ss-column{float: none;width: 100%;}
7
  .ss-info {padding:5px 15px;color: #3a87ad;background-color: #d9edf7;border-color: #bce8f1;}
8
  .ss-alert { padding:5px 15px;color: #c09853;background-color: #fcf8e3;border-color: #faebcc;}
9
  .ss-title{ margin-top: 2em;}
10
+ .dndicon {border:1px solid;display: inline-block;padding: 5px 0;}
11
+ .dndicon .s-icon{cursor:pointer; background-image:url('socialshare.png'); background-repeat: no-repeat;height: 45px; width: 45px; float: left;margin:0 10px}
12
+ .dndicon .facebook-icon{background-position: 0 -45px;}
13
+ .dndicon .twitter-icon {background-position: -45px -45px;}
14
+ .dndicon .googleplus-icon{background-position: -90px -45px;}
15
 
16
  @media(max-width: 919px) {
17
  .ss-column{float: none;width: 100%;}