Share_Tumblr

The Jetpack by WordPress.com Share Tumblr class.

Defined (1)

The class is defined in the following location(s).

/modules/sharedaddy/sharing-sources.php  
  1. class Share_Tumblr extends Sharing_Source { 
  2. public $shortname = 'tumblr'; 
  3. public $genericon = '\f214'; 
  4. public function __construct( $id, array $settings ) { 
  5. parent::__construct( $id, $settings ); 
  6. if ( 'official' == $this->button_style ) 
  7. $this->smart = true; 
  8. else 
  9. $this->smart = false; 
  10.  
  11. public function get_name() { 
  12. return __( 'Tumblr', 'jetpack' ); 
  13.  
  14. public function get_display( $post ) { 
  15. if ( $this->smart ) { 
  16. $target = ''; 
  17. if ( true == $this->open_link_in_new ) 
  18. $target = '_blank'; 
  19.  
  20. return '<a target="' . $target . '" href="http://www.tumblr.com/share/link/?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&name=' . rawurlencode( $this->get_share_title( $post->ID ) ) . '" title="' . __( 'Share on Tumblr', 'jetpack' ) . '" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:62px; height:20px; background:url(\'//platform.tumblr.com/v1/share_2.png\') top left no-repeat transparent;">' . __( 'Share on Tumblr', 'jetpack' ) . '</a>'; 
  21. } else { 
  22. return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Tumblr', 'share to', 'jetpack' ), __( 'Click to share on Tumblr', 'jetpack' ), 'share=tumblr' ); 
  23.  
  24. public function process_request( $post, array $post_data ) { 
  25. // Record stats 
  26. parent::process_request( $post, $post_data ); 
  27.  
  28. // Redirect to Tumblr's sharing endpoint (a la their bookmarklet) 
  29. $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='; 
  30. wp_redirect( $url ); 
  31. die(); 
  32. // http://www.tumblr.com/share?v=3&u=URL&t=TITLE&s= 
  33. public function display_footer() { 
  34. if ( $this->smart ) { 
  35. ?><script type="text/javascript" src="//platform.tumblr.com/v1/share.js"></script><?php 
  36. } else { 
  37. $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );