Jetpack_Publicize

Module Name: Publicize Module Description: Automated social marketing.

Defined (1)

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

/modules/publicize.php  
  1. class Jetpack_Publicize { 
  2.  
  3. public $in_jetpack = true; 
  4.  
  5. function __construct() { 
  6. global $publicize_ui; 
  7.  
  8. $this->in_jetpack = ( class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'enable_module_configurable' ) ) ? true : false; 
  9.  
  10. if ( $this->in_jetpack && method_exists( 'Jetpack', 'module_configuration_load' ) ) { 
  11. Jetpack::enable_module_configurable( __FILE__ ); 
  12. Jetpack::module_configuration_load( __FILE__, array( $this, 'jetpack_configuration_load' ) ); 
  13. add_action( 'init', array( $this, 'sync_posts_init' ), 999 ); 
  14.  
  15. require_once dirname( __FILE__ ) . '/publicize/publicize.php'; 
  16.  
  17. if ( $this->in_jetpack ) 
  18. require_once dirname( __FILE__ ) . '/publicize/publicize-jetpack.php'; 
  19. else { 
  20. require_once dirname( dirname( __FILE__ ) ) . '/mu-plugins/keyring/keyring.php'; 
  21. require_once dirname( __FILE__ ) . '/publicize/publicize-wpcom.php'; 
  22.  
  23. require_once dirname( __FILE__ ) . '/publicize/ui.php'; 
  24. $publicize_ui = new Publicize_UI(); 
  25. $publicize_ui->in_jetpack = $this->in_jetpack; 
  26.  
  27. // Jetpack specific checks / hooks 
  28. if ( $this->in_jetpack) { 
  29. add_action( 'jetpack_activate_module_publicize', array( $this, 'module_state_toggle' ) ); 
  30. add_action( 'jetpack_deactivate_module_publicize', array( $this, 'module_state_toggle' ) ); 
  31. add_filter( 'jetpack_sync_post_module_custom_data', array( $this, 'sync_post_module_custom_data' ), 10, 2 ); 
  32. // if sharedaddy isn't active, the sharing menu hasn't been added yet 
  33. $active = Jetpack::get_active_modules(); 
  34. if ( in_array( 'publicize', $active ) && !in_array( 'sharedaddy', $active ) ) 
  35. add_action( 'admin_menu', array( &$publicize_ui, 'sharing_menu' ) ); 
  36.  
  37. function sync_posts_init() { 
  38. $post_types = array( 'post', 'page' ); 
  39. $all_post_types = get_post_types(); 
  40. foreach ( $all_post_types as $post_type ) { 
  41. // sync Custom Post Types that support publicize 
  42. if ( post_type_supports( $post_type, 'publicize' ) ) { 
  43. $post_types[] = $post_type; 
  44. Jetpack_Sync::sync_posts( __FILE__, array( 
  45. 'post_types' => $post_types,  
  46. ) ); 
  47.  
  48. function sync_post_module_custom_data( $custom_data, $post ) { 
  49. if ( post_type_supports( get_post_type( $post ), 'publicize' ) ) { 
  50. $custom_data['cpt_publicizeable'] = true; 
  51. return $custom_data; 
  52.  
  53. function module_state_toggle() { 
  54. // extra check that we are on the JP blog, just incase 
  55. if ( class_exists( 'Jetpack' ) && $this->in_jetpack ) { 
  56. $jetpack = Jetpack::init(); 
  57. $jetpack->sync->register( 'noop' ); 
  58.  
  59. function jetpack_configuration_load() { 
  60. wp_safe_redirect( menu_page_url( 'sharing', false ) ); 
  61. exit;