publicize.php
| 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 | |
| 15 | class Jetpack_Publicize { |
| 16 | |
| 17 | public $in_jetpack = true; |
| 18 | |
| 19 | function __construct() { |
| 20 | global $publicize_ui; |
| 21 | |
| 22 | $this->in_jetpack = ( class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'enable_module_configurable' ) ) ? true : false; |
| 23 | |
| 24 | if ( $this->in_jetpack && method_exists( 'Jetpack', 'module_configuration_load' ) ) { |
| 25 | Jetpack::enable_module_configurable( __FILE__ ); |
| 26 | Jetpack::module_configuration_load( __FILE__, array( $this, 'jetpack_configuration_load' ) ); |
| 27 | } |
| 28 | |
| 29 | require_once dirname( __FILE__ ) . '/publicize/publicize.php'; |
| 30 | |
| 31 | if ( $this->in_jetpack ) |
| 32 | require_once dirname( __FILE__ ) . '/publicize/publicize-jetpack.php'; |
| 33 | else { |
| 34 | require_once dirname( dirname( __FILE__ ) ) . '/mu-plugins/keyring/keyring.php'; |
| 35 | require_once dirname( __FILE__ ) . '/publicize/publicize-wpcom.php'; |
| 36 | } |
| 37 | |
| 38 | require_once dirname( __FILE__ ) . '/publicize/ui.php'; |
| 39 | $publicize_ui = new Publicize_UI(); |
| 40 | $publicize_ui->in_jetpack = $this->in_jetpack; |
| 41 | |
| 42 | // Jetpack specific checks / hooks |
| 43 | if ( $this->in_jetpack) { |
| 44 | // if sharedaddy isn't active, the sharing menu hasn't been added yet |
| 45 | $active = Jetpack::get_active_modules(); |
| 46 | if ( in_array( 'publicize', $active ) && !in_array( 'sharedaddy', $active ) ) |
| 47 | add_action( 'admin_menu', array( &$publicize_ui, 'sharing_menu' ) ); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | function jetpack_configuration_load() { |
| 52 | wp_safe_redirect( menu_page_url( 'sharing', false ) ); |
| 53 | exit; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | global $publicize_ui; |
| 58 | new Jetpack_Publicize; |
| 59 | |
| 60 | if( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) && ! function_exists( 'publicize_init' ) ) { |
| 61 | /** |
| 62 | * Helper for grabbing a Publicize object from the "front-end" (non-admin) of |
| 63 | * a site. Normally Publicize is only loaded in wp-admin, so there's a little |
| 64 | * set up that you might need to do if you want to use it on the front end. |
| 65 | * Just call this function and it returns a Publicize object. |
| 66 | * |
| 67 | * @return Publicize Object |
| 68 | */ |
| 69 | function publicize_init() { |
| 70 | global $publicize; |
| 71 | |
| 72 | if ( ! class_exists( 'Publicize' ) ) { |
| 73 | require_once dirname( __FILE__ ) . '/publicize/publicize.php'; |
| 74 | } |
| 75 | |
| 76 | return $publicize; |
| 77 | } |
| 78 | |
| 79 | } |
| 80 |