|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Module Name: Enhanced Distribution |
|
4
|
|
|
* Module Description: Increase reach and traffic. |
|
5
|
|
|
* Sort Order: 5 |
|
6
|
|
|
* First Introduced: 1.2 |
|
7
|
|
|
* Requires Connection: Yes |
|
8
|
|
|
* Auto Activate: Public |
|
9
|
|
|
* Module Tags: Writing |
|
10
|
|
|
* Feature: Engagement |
|
11
|
|
|
* Additional Search Queries: google, seo, firehose, search, broadcast, broadcasting |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
function jetpack_enhanced_distribution_activate() { |
|
15
|
|
|
Jetpack::check_privacy( __FILE__ ); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
// In case it's active prior to upgrading to 1.9 |
|
20
|
|
|
function jetpack_enhanced_distribution_before_activate_default_modules() { |
|
21
|
|
|
$old_version = Jetpack_Options::get_option( 'old_version' ); |
|
22
|
|
|
list( $old_version ) = explode( ':', $old_version ); |
|
23
|
|
|
|
|
24
|
|
|
if ( version_compare( $old_version, '1.9-something', '>=' ) ) { |
|
25
|
|
|
return; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
Jetpack::check_privacy( __FILE__ ); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
add_action( 'jetpack_activate_module_enhanced-distribution', 'jetpack_enhanced_distribution_activate' ); |
|
32
|
|
|
add_action( 'jetpack_before_activate_default_modules', 'jetpack_enhanced_distribution_before_activate_default_modules' ); |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* If a request has ?get_freshly_pressed_data=true appended |
|
36
|
|
|
* to the end, then let's provide the necessary data back via JSON. |
|
37
|
|
|
*/ |
|
38
|
|
|
if ( isset( $_GET['get_freshly_pressed_data'] ) ) { |
|
39
|
|
|
add_action( 'template_redirect', 'jetpack_get_freshly_pressed_data' ); |
|
40
|
|
|
function jetpack_get_freshly_pressed_data() { |
|
41
|
|
|
if ( is_single() ) { |
|
42
|
|
|
wp_send_json_success( array( |
|
43
|
|
|
'blog_id' => Jetpack_Options::get_option( 'id' ), |
|
44
|
|
|
'post_id' => get_the_ID(), |
|
45
|
|
|
) ); |
|
46
|
|
|
} else { |
|
47
|
|
|
wp_send_json_error( array( |
|
48
|
|
|
'message' => 'Not Singular', |
|
49
|
|
|
) ); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
add_action( 'rss_head', 'jetpack_enhanced_distribution_feed_id' ); |
|
55
|
|
|
add_action( 'rss_item', 'jetpack_enhanced_distribution_post_id' ); |
|
56
|
|
|
add_action( 'rss2_head', 'jetpack_enhanced_distribution_feed_id' ); |
|
57
|
|
|
add_action( 'rss2_item', 'jetpack_enhanced_distribution_post_id' ); |
|
58
|
|
|
|
|
59
|
|
|
function jetpack_enhanced_distribution_feed_id(){ |
|
60
|
|
|
(int) $id = Jetpack_Options::get_option( 'id' ); |
|
61
|
|
|
if ( $id > 0 ) { |
|
62
|
|
|
$output = sprintf( '<site xmlns="com-wordpress:feed-additions:1">%d</site>', $id ); |
|
63
|
|
|
echo $output; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
function jetpack_enhanced_distribution_post_id(){ |
|
68
|
|
|
$id = get_the_ID(); |
|
69
|
|
|
if ( $id ) { |
|
70
|
|
|
$output = sprintf( '<post-id xmlns="com-wordpress:feed-additions:1">%d</post-id>', $id ); |
|
71
|
|
|
echo $output; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|