PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 11.2
Jetpack – WP Security, Backup, Speed, & Growth v11.2
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / enhanced-distribution.php

enhanced-distribution.php in Jetpack – WP Security, Backup, Speed, & Growth 11.2, at modules/enhanced-distribution.php

82 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 * @package automattic/jetpack
14 */
15
16 /**
17 * In case it's active prior to upgrading to '1.9'.
18 */
19 function jetpack_enhanced_distribution_before_activate_default_modules() {
20 $old_version = Jetpack_Options::get_option( 'old_version' );
21 list( $old_version ) = explode( ':', $old_version );
22
23 if ( version_compare( $old_version, '1.9-something', '>=' ) ) {
24 return;
25 }
26
27 Jetpack::check_privacy( __FILE__ );
28 }
29
30 add_action( 'jetpack_before_activate_default_modules', 'jetpack_enhanced_distribution_before_activate_default_modules' );
31
32 if ( isset( $_GET['get_freshly_pressed_data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
33 /**
34 * If a request has ?get_freshly_pressed_data=true appended
35 * to the end, then let's provide the necessary data back via JSON.
36 */
37 function jetpack_get_freshly_pressed_data() {
38 if ( is_single() ) {
39 wp_send_json_success(
40 array(
41 'blog_id' => Jetpack_Options::get_option( 'id' ),
42 'post_id' => get_the_ID(),
43 )
44 );
45 } else {
46 wp_send_json_error(
47 array(
48 'message' => 'Not Singular',
49 )
50 );
51 }
52 }
53 add_action( 'template_redirect', 'jetpack_get_freshly_pressed_data' );
54 }
55
56 add_action( 'rss_head', 'jetpack_enhanced_distribution_feed_id' );
57 add_action( 'rss_item', 'jetpack_enhanced_distribution_post_id' );
58 add_action( 'rss2_head', 'jetpack_enhanced_distribution_feed_id' );
59 add_action( 'rss2_item', 'jetpack_enhanced_distribution_post_id' );
60
61 /**
62 * Output feed identifier based on blog ID.
63 */
64 function jetpack_enhanced_distribution_feed_id() {
65 $id = (int) Jetpack_Options::get_option( 'id' );
66 if ( $id > 0 ) {
67 $output = sprintf( '<site xmlns="com-wordpress:feed-additions:1">%d</site>', $id );
68 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
69 }
70 }
71
72 /**
73 * Output feed item identifier based on current post ID.
74 */
75 function jetpack_enhanced_distribution_post_id() {
76 $id = (int) get_the_ID();
77 if ( $id ) {
78 $output = sprintf( '<post-id xmlns="com-wordpress:feed-additions:1">%d</post-id>', $id );
79 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
80 }
81 }
82