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
|
|
|
// In case it's active prior to upgrading to 1.9 |
15
|
|
|
function jetpack_enhanced_distribution_before_activate_default_modules() { |
16
|
|
|
$old_version = Jetpack_Options::get_option( 'old_version' ); |
17
|
|
|
list( $old_version ) = explode( ':', $old_version ); |
18
|
|
|
|
19
|
|
|
if ( version_compare( $old_version, '1.9-something', '>=' ) ) { |
20
|
|
|
return; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
Jetpack::check_privacy( __FILE__ ); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
add_action( 'jetpack_before_activate_default_modules', 'jetpack_enhanced_distribution_before_activate_default_modules' ); |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* If a request has ?get_freshly_pressed_data=true appended |
30
|
|
|
* to the end, then let's provide the necessary data back via JSON. |
31
|
|
|
*/ |
32
|
|
|
if ( isset( $_GET['get_freshly_pressed_data'] ) ) { |
33
|
|
|
add_action( 'template_redirect', 'jetpack_get_freshly_pressed_data' ); |
34
|
|
|
function jetpack_get_freshly_pressed_data() { |
35
|
|
|
if ( is_single() ) { |
36
|
|
|
wp_send_json_success( array( |
37
|
|
|
'blog_id' => Jetpack_Options::get_option( 'id' ), |
38
|
|
|
'post_id' => get_the_ID(), |
39
|
|
|
) ); |
40
|
|
|
} else { |
41
|
|
|
wp_send_json_error( array( |
42
|
|
|
'message' => 'Not Singular', |
43
|
|
|
) ); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
add_action( 'rss_head', 'jetpack_enhanced_distribution_feed_id' ); |
49
|
|
|
add_action( 'rss_item', 'jetpack_enhanced_distribution_post_id' ); |
50
|
|
|
add_action( 'rss2_head', 'jetpack_enhanced_distribution_feed_id' ); |
51
|
|
|
add_action( 'rss2_item', 'jetpack_enhanced_distribution_post_id' ); |
52
|
|
|
|
53
|
|
|
function jetpack_enhanced_distribution_feed_id(){ |
54
|
|
|
(int) $id = Jetpack_Options::get_option( 'id' ); |
55
|
|
|
if ( $id > 0 ) { |
56
|
|
|
$output = sprintf( '<site xmlns="com-wordpress:feed-additions:1">%d</site>', $id ); |
57
|
|
|
echo $output; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
function jetpack_enhanced_distribution_post_id(){ |
62
|
|
|
$id = get_the_ID(); |
63
|
|
|
if ( $id ) { |
64
|
|
|
$output = sprintf( '<post-id xmlns="com-wordpress:feed-additions:1">%d</post-id>', $id ); |
65
|
|
|
echo $output; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|