summaryrefslogtreecommitdiff
blob: dd2fdab01513bad185fe65aca981e64fc1b4647c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
 * Module Name: Enhanced Distribution
 * Module Description: Increase reach and traffic.
 * Sort Order: 5
 * First Introduced: 1.2
 * Requires Connection: Yes
 * Auto Activate: Public
 * Module Tags: Writing
 * Feature: Traffic
 * Additional Search Queries: google, seo, firehose, search, broadcast, broadcasting
 */

Jetpack_Sync::sync_posts( __FILE__ );
Jetpack_Sync::sync_comments( __FILE__ );

function jetpack_enhanced_distribution_activate() {
	Jetpack::check_privacy( __FILE__ );
}


// In case it's active prior to upgrading to 1.9
function jetpack_enhanced_distribution_before_activate_default_modules() {
	$old_version = Jetpack_Options::get_option( 'old_version' );
	list( $old_version ) = explode( ':', $old_version );

	if ( version_compare( $old_version, '1.9-something', '>=' ) ) {
		return;
	}

	Jetpack::check_privacy( __FILE__ );
}

add_action( 'jetpack_activate_module_enhanced-distribution', 'jetpack_enhanced_distribution_activate' );
add_action( 'jetpack_before_activate_default_modules', 'jetpack_enhanced_distribution_before_activate_default_modules' );

/**
 * If a request has ?get_freshly_pressed_data=true appended
 * to the end, then let's provide the necessary data back via JSON.
 */
if ( isset( $_GET['get_freshly_pressed_data'] ) ) {
	add_action( 'template_redirect', 'jetpack_get_freshly_pressed_data' );
	function jetpack_get_freshly_pressed_data() {
		if ( is_single() ) {
			wp_send_json_success( array(
				'blog_id' => Jetpack_Options::get_option( 'id' ),
				'post_id' => get_the_ID(),
			) );
		} else {
			wp_send_json_error( array(
				'message' => 'Not Singular',
			) );
		}
	}
}