Browse files

Added Pinterest to sharing-sources-custom.php

And all the other stuff I'd figured out from before
  • Loading branch information...
1 parent 2e38515 commit 6a63c6ddfd8ea57dcc86529862b25e9640d12821 @andymatic committed Apr 6, 2012
Showing with 107 additions and 13 deletions.
  1. +11 −13 admin-sharing.css
  2. BIN images/pinterest.png
  3. +1 −0 sharing-service.php
  4. +95 −0 sharing-sources-custom.php
View
24 admin-sharing.css
@@ -80,6 +80,7 @@
.services ul li#facebook, .preview-facebook div.option-smart-off{background: #FFF url(images/facebook.png) no-repeat 4px 5px;}
.services ul li#twitter, .preview-twitter div.option-smart-off{background: #FFF url(images/twitter.png) no-repeat 4px 5px;}
.services ul li#googleplusone, .preview-googleplusone div.option-smart-off{background: #FFF url(images/googleplusone-nocount.png) no-repeat 4px 5px;}
+services ul li#pinterest, .preview-pinterest div.option-smart-off{background: #FFF url(images/pinterest.png) no-repeat 4px 5px;}
.services ul li#wordpress, .preview-wordpress{background: #FFF url(images/wordpress.png) no-repeat 4px 5px;}
.services ul li#digg, .preview-digg div.option-smart-off{background: #FFF url(images/digg.png) no-repeat 4px 5px;}
.services ul li#reddit, .preview-reddit div.option-smart-off{background: #FFF url(images/reddit.png) no-repeat 4px 5px;}
@@ -101,11 +102,11 @@
cursor: default;
}
-.preview li.preview-digg, .preview li.preview-reddit, .preview li.preview-stumbleupon, .preview li.preview-facebook, .preview li.preview-twitter, .preview li.preview-googleplusone, .preview li.preview-linkedin {
+.preview li.preview-digg, .preview li.preview-reddit, .preview li.preview-stumbleupon, .preview li.preview-facebook, .preview li.preview-twitter, .preview li.preview-googleplusone, .preview li.preview-pinterest, .preview li.preview-linkedin {
padding: 0;
}
-.preview-digg .option-smart-off, .preview-reddit .option-smart-off, .preview-stumbleupon .option-smart-off, .preview-facebook .option-smart-off, .preview-twitter .option-smart-off, .preview-linkedin .option-smart-off {
+.preview-digg .option-smart-off, .preview-reddit .option-smart-off, .preview-stumbleupon .option-smart-off, .preview-facebook .option-smart-off, .preview-twitter .option-smart-off, .preview-linkedin .option-smart-off, .preview-pinterest .option-smart-off {
background-position: 0px 5px !important;
padding: 5px 0px 5px 20px;
}
@@ -114,6 +115,13 @@
padding: 5px 0px 5px 28px;
}
+.preview-pinterest .option-smart-on {
+ background: #FFF url(images/smart-reddit.png) no-repeat top left;
+ width:104px;
+ height:21px;
+ margin-top: 3px;
+}
+
.preview-digg .option-smart-on {
background: #FFF url(images/smart-digg.png) no-repeat top left;
width:76px;
@@ -341,7 +349,7 @@
width: 100px;
}
-.sharing-hidden .preview-digg, .sharing-hidden .preview-reddit, .sharing-hidden .preview-stumbleupon, .sharing-hidden .preview-facebook, .sharing-hidden .preview-twitter, .sharing-hidden .preview-googleplusone, .sharing-hidden .preview-linkedin {
+.sharing-hidden .preview-digg, .sharing-hidden .preview-reddit, .sharing-hidden .preview-stumbleupon, .sharing-hidden .preview-facebook, .sharing-hidden .preview-twitter, .sharing-hidden .preview-googleplusone, .preview-pinterest, .sharing-hidden .preview-linkedin {
width: 120px !important;
}
@@ -360,13 +368,3 @@
border: 0;
padding: 4px 6px 0 0;
}
-
-/**
- * Google +1
- */
-/*
-.services ul li#googleplusone { background: #fff url('images/googleplusone.png') no-repeat 4px 5px; padding-left: 35px; }
-.preview li.preview-googleplusone { padding-left: 5px; }
-.preview-googleplusone .option-smart-true { background: #FFF url('images/googleplusone-count.png') no-repeat top left; width:53px; height:17px; margin-top: -2px; padding: 5px 0px 5px 20px;}
-.preview-googleplusone .option-smart-false { background: #FFF url('images/googleplusone-nocount.png') no-repeat top left; width:28px; height:17px; margin-top: -2px; padding: 5px 0px 5px 20px;}
-*/
View
BIN images/pinterest.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1 sharing-service.php
@@ -46,6 +46,7 @@ private function get_all_services() {
'stumbleupon' => 'Share_Stumbleupon',
'twitter' => 'Share_Twitter',
'press-this' => 'Share_PressThis',
+ 'pinterest' => 'Share_Pinterest',
'googleplusone' => 'Share_GooglePlusOne'
);
View
95 sharing-sources-custom.php
@@ -7,6 +7,101 @@
*/
/**
+ * Class for Pinterest
+ *
+ * Implementation of Pinterest Service for Sharedaddy
+ *
+ * @category Wordpress
+ * @package Sharedaddy
+ * @author Andy Wibbels (andy at andy wibbels dot com)
+ * @copyright Copyright (c) 2012, Andy Wibbels
+ * Licensed under the GNU GPLv3.
+ *
+ */
+
+
+
+class Share_Pinterest extends Sharing_Advanced_Source {
+ private $smart = false;
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['smart'] ) )
+ $this->smart = $settings['smart'];
+ }
+
+ public function get_name() {
+ return __( 'Pinterest', 'sharedaddy' );
+ }
+
+ public function display_footer() {
+ echo '<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>';
+ }
+ public function has_custom_button_style() {
+ return $this->smart;
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart == 'smart' )
+ return '<a href="http://pinterest.com/pin/create/button/?url=' . urlencode( get_permalink( $post->ID ) ) . '&description=' . urlencode( $post->post_title ) . '" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a><script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>';
+ else
+ return '<a href="http://pinterest.com/pin/create/button/?url=' . urlencode( get_permalink( $post->ID ) ) . '&description=' . urlencode( $post->post_title ) . '" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a><script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>';
+ }
+
+ public function display_preview() {
+?>
+ <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>">
+ <?php
+ if ( !$this->smart ) {
+ if ( $this->button_style == 'text' || $this->button_style == 'icon-text' )
+ echo $this->get_name();
+ else
+ echo '&nbsp;';
+ }
+ ?>
+ </div>
+<?php
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $pinterest_url = 'http://www.pinterest.com/submit?url=' . urlencode( get_permalink( $post->ID ) ) . '&title=' . urlencode( $post->post_title );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Pinterest
+ wp_redirect( $pinterest_url );
+ die();
+ }
+
+ public function update_options( array $data ) {
+ $this->smart = false;
+
+ if ( isset( $data['smart'] ) )
+ $this->smart = true;
+ }
+
+ public function get_options() {
+ return array(
+ 'smart' => $this->smart
+ );
+ }
+
+ public function display_options() {
+?>
+ <div class="input">
+ <label>
+ <input name="smart" type="checkbox"<?php if ( $this->smart ) echo ' checked="checked"'; ?>/>
+
+ <?php _e( 'Use smart button', 'sharedaddy' ); ?>
+ </label>
+ </div>
+<?php
+ }
+}
+
+/**
* Class for Google+1
*
* Implementation of Google+1 Service for Sharedaddy

0 comments on commit 6a63c6d

Please sign in to comment.