PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 13.6
Jetpack – WP Security, Backup, Speed, & Growth v13.6
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 / 3rd-party / wpcom-reader.php

wpcom-reader.php in Jetpack – WP Security, Backup, Speed, & Growth 13.6, at 3rd-party/wpcom-reader.php

67 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This provides minor tweaks to improve the experience for Jetpack feed in the WordPress.com Reader.
4 *
5 * This does not make sites available in the Reader—that depends on the public access to /feed/ as a method on the WP.com side
6 * to check if a site is public. It also does not add any content to the feed. Any content that should not be displayed in the Reader
7 * or other RSS readers should be filtered out elsewhere.
8 *
9 * These hooks were originally part of the now-deprecated Enhanced Distribution.
10 *
11 * @since 13.3
12 * @package Automattic/jetpack
13 */
14
15 use Automattic\Jetpack\Connection\Manager as Connection_Manager;
16 use Automattic\Jetpack\Status;
17 use Automattic\Jetpack\Status\Host;
18
19 foreach ( array( 'rss_head', 'rss1_head', 'rss2_head' ) as $rss_head_action ) {
20 add_action( $rss_head_action, 'jetpack_wpcomreader_feed_id' );
21 }
22 foreach ( array( 'rss_item', 'rss1_item', 'rss2_item' ) as $rss_item_action ) {
23 add_action( $rss_item_action, 'jetpack_wpcomreader_post_id' );
24 }
25
26 /**
27 * Output feed identifier based on blog ID.
28 *
29 * @return void
30 */
31 function jetpack_wpcomreader_feed_id() {
32 if (
33 ( new Host() )->is_wpcom_simple()
34 || (
35 ( new Connection_Manager() )->is_connected()
36 && ! ( new Status() )->is_offline_mode()
37 )
38 ) {
39 $blog_id = Connection_Manager::get_site_id( true ); // Silence since we're not wanting to handle the error state.
40 if ( ! $blog_id ) {
41 return;
42 }
43
44 printf(
45 '<site xmlns="com-wordpress:feed-additions:1">%d</site>',
46 (int) $blog_id
47 );
48 }
49 }
50
51 /**
52 * Output feed item identifier based on current post ID.
53 *
54 * @return void
55 */
56 function jetpack_wpcomreader_post_id() {
57 $id = get_the_ID();
58 if ( ! $id ) {
59 return;
60 }
61
62 printf(
63 '<post-id xmlns="com-wordpress:feed-additions:1">%d</post-id>',
64 (int) $id
65 );
66 }
67