publicize.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Module Name: Publicize
  4. * Module Description: Automated social marketing.
  5. * Sort Order: 10
  6. * Recommendation Order: 7
  7. * First Introduced: 2.0
  8. * Requires Connection: Yes
  9. * Auto Activate: Yes
  10. * Module Tags: Social, Recommended
  11. * Feature: Engagement
  12. * Additional Search Queries: facebook, twitter, google+, googleplus, google, path, tumblr, linkedin, social, tweet, connections, sharing
  13. */
  14. class Jetpack_Publicize {
  15. public $in_jetpack = true;
  16. function __construct() {
  17. global $publicize_ui;
  18. $this->in_jetpack = ( class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'enable_module_configurable' ) ) ? true : false;
  19. if ( $this->in_jetpack && method_exists( 'Jetpack', 'module_configuration_load' ) ) {
  20. Jetpack::enable_module_configurable( __FILE__ );
  21. Jetpack::module_configuration_load( __FILE__, array( $this, 'jetpack_configuration_load' ) );
  22. }
  23. require_once dirname( __FILE__ ) . '/publicize/publicize.php';
  24. if ( $this->in_jetpack )
  25. require_once dirname( __FILE__ ) . '/publicize/publicize-jetpack.php';
  26. else {
  27. require_once dirname( dirname( __FILE__ ) ) . '/mu-plugins/keyring/keyring.php';
  28. require_once dirname( __FILE__ ) . '/publicize/publicize-wpcom.php';
  29. }
  30. require_once dirname( __FILE__ ) . '/publicize/ui.php';
  31. $publicize_ui = new Publicize_UI();
  32. $publicize_ui->in_jetpack = $this->in_jetpack;
  33. // Jetpack specific checks / hooks
  34. if ( $this->in_jetpack) {
  35. // if sharedaddy isn't active, the sharing menu hasn't been added yet
  36. $active = Jetpack::get_active_modules();
  37. if ( in_array( 'publicize', $active ) && !in_array( 'sharedaddy', $active ) )
  38. add_action( 'admin_menu', array( &$publicize_ui, 'sharing_menu' ) );
  39. }
  40. }
  41. function jetpack_configuration_load() {
  42. wp_safe_redirect( menu_page_url( 'sharing', false ) );
  43. exit;
  44. }
  45. }
  46. global $publicize_ui;
  47. new Jetpack_Publicize;
  48. if( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) && ! function_exists( 'publicize_init' ) ) {
  49. /**
  50. * Helper for grabbing a Publicize object from the "front-end" (non-admin) of
  51. * a site. Normally Publicize is only loaded in wp-admin, so there's a little
  52. * set up that you might need to do if you want to use it on the front end.
  53. * Just call this function and it returns a Publicize object.
  54. *
  55. * @return Publicize Object
  56. */
  57. function publicize_init() {
  58. global $publicize;
  59. if ( ! class_exists( 'Publicize' ) ) {
  60. require_once dirname( __FILE__ ) . '/publicize/publicize.php';
  61. }
  62. return $publicize;
  63. }
  64. }