Share_PressThis

The Jetpack by WordPress.com Share PressThis class.

Defined (1)

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

/modules/sharedaddy/sharing-sources.php  
  1. class Share_PressThis extends Sharing_Source { 
  2. public $shortname = 'pressthis'; 
  3. public $genericon = '\f205'; 
  4. public function __construct( $id, array $settings ) { 
  5. parent::__construct( $id, $settings ); 
  6.  
  7. if ( 'official' == $this->button_style ) 
  8. $this->smart = true; 
  9. else 
  10. $this->smart = false; 
  11.  
  12. public function get_name() { 
  13. return __( 'Press This', 'jetpack' ); 
  14.  
  15. public function process_request( $post, array $post_data ) { 
  16. global $current_user; 
  17.  
  18. $primary_blog = (int) get_user_meta( $current_user->ID, 'primary_blog', true ); 
  19. if ( $primary_blog ) { 
  20. $primary_blog_details = get_blog_details( $primary_blog ); 
  21. } else { 
  22. $primary_blog_details = false; 
  23.  
  24. if ( $primary_blog_details ) { 
  25. $blogs = array( $primary_blog_details ); 
  26. } elseif ( function_exists( 'get_active_blogs_for_user' ) ) { 
  27. $blogs = get_active_blogs_for_user(); 
  28. if ( empty( $blogs ) ) { 
  29. $blogs = get_blogs_of_user( $current_user->ID ); 
  30. } else { 
  31. $blogs = get_blogs_of_user( $current_user->ID ); 
  32.  
  33. if ( empty( $blogs ) ) { 
  34. wp_safe_redirect( get_permalink( $post->ID ) ); 
  35. die(); 
  36.  
  37. $blog = current( $blogs ); 
  38.  
  39. $url = $blog->siteurl.'/wp-admin/press-this.php?u='.rawurlencode( $this->get_share_url( $post->ID ) ).'&t='.rawurlencode( $this->get_share_title( $post->ID ) ); 
  40.  
  41. if ( isset( $_GET['sel'] ) ) 
  42. $url .= '&s='.rawurlencode( $_GET['sel'] ); 
  43.  
  44. // Record stats 
  45. parent::process_request( $post, $post_data ); 
  46.  
  47. // Redirect to Press This 
  48. wp_safe_redirect( $url ); 
  49. die(); 
  50.  
  51. public function get_display( $post ) { 
  52. return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Press This', 'share to', 'jetpack' ), __( 'Click to Press This!', 'jetpack' ), 'share=press-this' );