icon ), '"' ) . '");' ) . '">', $str );
}
public function process_request( $post, array $post_data ) {
$url = str_replace( '&', '&', $this->url );
$url = str_replace( '%post_url%', rawurlencode( $this->get_share_url( $post->ID ) ), $url );
$url = str_replace( '%post_full_url%', rawurlencode( get_permalink( $post->ID ) ), $url );
$url = str_replace( '%post_title%', rawurlencode( $this->get_share_title( $post->ID ) ), $url );
if ( strpos( $url, '%post_tags%' ) !== false ) {
$tags = get_the_tags( $post->ID );
$tagged = '';
if ( $tags ) {
foreach ( $tags AS $tag ) {
$tagged[] = rawurlencode( $tag->name );
}
$tagged = implode( ',', $tagged );
}
$url = str_replace( '%post_tags%', $tagged, $url );
}
if ( strpos( $url, '%post_excerpt%' ) !== false ) {
$url_excerpt = $post->post_excerpt;
if ( empty( $url_excerpt ) )
$url_excerpt = $post->post_content;
$url_excerpt = strip_tags( strip_shortcodes( $url_excerpt ) );
$url_excerpt = wp_html_excerpt( $url_excerpt, 100 );
$url_excerpt = rtrim( preg_replace( '/[^ .]*$/', '', $url_excerpt ) );
$url = str_replace( '%post_excerpt%', rawurlencode( $url_excerpt ), $url );
}
// Record stats
parent::process_request( $post, $post_data );
// Redirect
wp_redirect( $url );
die();
}
public function display_options() {
?>
name = $name;
if ( $url )
$this->url = $url;
if ( $icon )
$this->icon = $icon;
}
public function get_options() {
return array(
'name' => $this->name,
'icon' => $this->icon,
'url' => $this->url,
);
}
public function display_preview( $echo = true, $force_smart = false, $button_style = null ) {
$opts = $this->get_options();
$text = ' ';
if ( !$this->smart )
if ( $this->button_style != 'icon' )
$text = $this->get_name();
$klasses = array( 'share-'.$this->shortname );
if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' )
$klasses[] = 'share-icon';
if ( $this->button_style == 'icon' ) {
$text = '';
$klasses[] = 'no-text';
}
if ( $this->button_style == 'text' )
$klasses[] = 'no-icon';
$link = sprintf(
'%s',
implode( ' ', $klasses ),
$this->get_name(),
addcslashes( esc_url_raw( $opts['icon'] ), '"' ),
$text
);
?>
button_style )
$this->smart = true;
else
$this->smart = false;
}
public function get_name() {
return __( 'Tumblr', 'jetpack' );
}
public function get_display( $post ) {
if ( $this->smart ) {
$target = '';
if ( 'new' == $this->open_links )
$target = '_blank';
return '' . __( 'Share on Tumblr', 'jetpack' ) . '';
} else {
return $this->get_link( get_permalink( $post->ID ), _x( 'Tumblr', 'share to', 'jetpack' ), __( 'Click to share on Tumblr', 'jetpack' ), 'share=tumblr' );
}
}
public function process_request( $post, array $post_data ) {
// Record stats
parent::process_request( $post, $post_data );
// Redirect to Tumblr's sharing endpoint (a la their bookmarklet)
$url = 'http://www.tumblr.com/share?v=3&u=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&t=' . rawurlencode( $this->get_share_title( $post->ID ) ) . '&s=';
wp_redirect( $url );
die();
}
// http://www.tumblr.com/share?v=3&u=URL&t=TITLE&s=
public function display_footer() {
if ( $this->smart ) {
?>js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
}
}
}
class Share_Pinterest extends Sharing_Source {
var $shortname = 'pinterest';
var $genericon = '\f209';
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
if ( 'official' == $this->button_style )
$this->smart = true;
else
$this->smart = false;
}
public function get_name() {
return __( 'Pinterest', 'jetpack' );
}
public function get_display( $post ) {
$share_url = 'http://pinterest.com/pin/create/button/?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&description=' . rawurlencode( $post->post_title );
$display = '';
if ( $this->smart )
$display .= sprintf( '', esc_url( $share_url ) );
else
$display = $this->get_link( get_permalink( $post->ID ), _x( 'Pinterest', 'share to', 'jetpack' ), __( 'Click to share on Pinterest', 'jetpack' ), 'share=pinterest', 'sharing-pinterest-' . $post->ID );
if ( apply_filters( 'jetpack_register_post_for_share_counts', true, $post->ID, 'linkedin' ) ) {
sharing_register_post_for_share_counts( $post->ID );
}
return $display;
}
public function process_request( $post, array $post_data ) {
// Record stats
parent::process_request( $post, $post_data );
// If we're triggering the multi-select panel, then we don't need to redirect to Pinterest
if ( !isset( $_GET['js_only'] ) ) {
$pinterest_url = esc_url_raw( 'http://pinterest.com/pin/create/button/?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&description=' . rawurlencode( $this->get_share_title( $post->ID ) ) );
wp_redirect( $pinterest_url );
} else {
echo '// share count bumped';
}
die();
}
public function display_footer() {
?>
smart ) : ?>
button_style )
$this->smart = true;
else
$this->smart = false;
}
public function get_name() {
return __( 'Pocket', 'jetpack' );
}
public function process_request( $post, array $post_data ) {
// Record stats
parent::process_request( $post, $post_data );
$pocket_url = esc_url_raw( 'https://getpocket.com/save/?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&title=' . rawurlencode( $this->get_share_title( $post->ID ) ) );
wp_redirect( $pocket_url );
exit;
}
public function get_display( $post ) {
if ( $this->smart ) {
$post_count = 'horizontal';
$button = '';
$button .= '';
return $button;
} else {
return $this->get_link( get_permalink( $post->ID ), _x( 'Pocket', 'share to', 'jetpack' ), __( 'Click to share on Pocket', 'jetpack' ), 'share=pocket' );
}
}
function display_footer() {
if ( $this->smart ) :
?>
js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
endif;
}
}