@@ -20,11 +20,21 @@ class Jetpack {
20
20
* Initialize the class, registering WordPress hooks.
21
21
*/
22
22
public static function init () {
23
- \add_filter ( 'jetpack_sync_post_meta_whitelist ' , array ( self ::class, 'add_sync_meta ' ) );
24
- \add_filter ( 'jetpack_sync_comment_meta_whitelist ' , array ( self ::class, 'add_sync_comment_meta ' ) );
25
- \add_filter ( 'jetpack_sync_whitelisted_comment_types ' , array ( self ::class, 'add_comment_types ' ) );
26
- \add_filter ( 'jetpack_json_api_comment_types ' , array ( self ::class, 'add_comment_types ' ) );
27
- \add_filter ( 'jetpack_api_include_comment_types_count ' , array ( self ::class, 'add_comment_types ' ) );
23
+ if ( ! \defined ( 'IS_WPCOM ' ) ) {
24
+ \add_filter ( 'jetpack_sync_post_meta_whitelist ' , array ( self ::class, 'add_sync_meta ' ) );
25
+ \add_filter ( 'jetpack_sync_comment_meta_whitelist ' , array ( self ::class, 'add_sync_comment_meta ' ) );
26
+ \add_filter ( 'jetpack_sync_whitelisted_comment_types ' , array ( self ::class, 'add_comment_types ' ) );
27
+ \add_filter ( 'jetpack_json_api_comment_types ' , array ( self ::class, 'add_comment_types ' ) );
28
+ \add_filter ( 'jetpack_api_include_comment_types_count ' , array ( self ::class, 'add_comment_types ' ) );
29
+ }
30
+
31
+ if (
32
+ ( \defined ( 'IS_WPCOM ' ) && IS_WPCOM ) ||
33
+ ( \class_exists ( '\Jetpack ' ) && \Jetpack::is_connection_ready () )
34
+ ) {
35
+ \add_filter ( 'activitypub_following_row_actions ' , array ( self ::class, 'add_reader_link ' ), 10 , 2 );
36
+ \add_filter ( 'pre_option_activitypub_following_ui ' , array ( self ::class, 'pre_option_activitypub_following_ui ' ) );
37
+ }
28
38
}
29
39
30
40
/**
@@ -68,4 +78,47 @@ public static function add_comment_types( $comment_types ) {
68
78
69
79
return array_unique ( \array_merge ( $ comment_types , Comment::get_comment_type_slugs () ) );
70
80
}
81
+
82
+ /**
83
+ * Add a "Reader" link to the bulk actions dropdown on the following list screen.
84
+ *
85
+ * @param array $actions The bulk actions.
86
+ * @param array $item The current following item.
87
+ *
88
+ * @return array The bulk actions with the "Reader" link.
89
+ */
90
+ public static function add_reader_link ( $ actions , $ item ) {
91
+ // Do not show the link for pending follow requests.
92
+ if ( 'pending ' === $ item ['status ' ] ) {
93
+ return $ actions ;
94
+ }
95
+
96
+ $ feed = \get_post_meta ( $ item ['id ' ], '_activitypub_actor_feed ' , true );
97
+
98
+ if ( isset ( $ feed ['feed_id ' ] ) ) {
99
+ $ url = sprintf ( 'https://wordpress.com/reader/feed/%d ' , (int ) $ feed ['feed_id ' ] );
100
+ } else {
101
+ $ url = sprintf ( 'https://wordpress.com/reader/feeds/lookup/%s ' , rawurlencode ( $ item ['identifier ' ] ) );
102
+ }
103
+
104
+ return array_merge (
105
+ array (
106
+ 'reader ' => sprintf (
107
+ '<a href="%s" target="_blank">%s</a> ' ,
108
+ esc_url ( $ url ),
109
+ esc_html__ ( 'View Feed ' , 'activitypub ' )
110
+ ),
111
+ ),
112
+ $ actions
113
+ );
114
+ }
115
+
116
+ /**
117
+ * Force the ActivityPub Following UI to be enabled when Jetpack is active.
118
+ *
119
+ * @return string '1' to enable the ActivityPub Following UI.
120
+ */
121
+ public static function pre_option_activitypub_following_ui () {
122
+ return '1 ' ;
123
+ }
71
124
}
0 commit comments