PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 15.0
Jetpack – WP Security, Backup, Speed, & Growth v15.0
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 14.4.2 All 500 releases
jetpack / 3rd-party / wpcom-reader.php
wpcom-reader.php
71 lines 1.8 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 if ( ! defined( 'ABSPATH' ) ) {
20 exit( 0 );
21 }
22
23 foreach ( array( 'rss_head', 'rss1_head', 'rss2_head' ) as $rss_head_action ) {
24 add_action( $rss_head_action, 'jetpack_wpcomreader_feed_id' );
25 }
26 foreach ( array( 'rss_item', 'rss1_item', 'rss2_item' ) as $rss_item_action ) {
27 add_action( $rss_item_action, 'jetpack_wpcomreader_post_id' );
28 }
29
30 /**
31 * Output feed identifier based on blog ID.
32 *
33 * @return void
34 */
35 function jetpack_wpcomreader_feed_id() {
36 if (
37 ( new Host() )->is_wpcom_simple()
38 || (
39 ( new Connection_Manager() )->is_connected()
40 && ! ( new Status() )->is_offline_mode()
41 )
42 ) {
43 $blog_id = Connection_Manager::get_site_id( true ); // Silence since we're not wanting to handle the error state.
44 if ( ! $blog_id ) {
45 return;
46 }
47
48 printf(
49 '<site xmlns="com-wordpress:feed-additions:1">%d</site>',
50 (int) $blog_id
51 );
52 }
53 }
54
55 /**
56 * Output feed item identifier based on current post ID.
57 *
58 * @return void
59 */
60 function jetpack_wpcomreader_post_id() {
61 $id = get_the_ID();
62 if ( ! $id ) {
63 return;
64 }
65
66 printf(
67 '<post-id xmlns="com-wordpress:feed-additions:1">%d</post-id>',
68 (int) $id
69 );
70 }
71