File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ mu-plugins/*
1818! mu-plugins /mu-autoloader.php
1919! mu-plugins /osi-event-list
2020! mu-plugins /osi-sponsors-list
21+ ! websub-compat.php
2122
2223themes /*
2324! themes /osi
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Plugin Name: WebSub Backwards Compatibility
4+ * Plugin Description: Still send pings for the old `blog.opensource.org` Feed-URLs.
5+ * Version: 1.0.0
6+ * Author: WordPress.com Special Projects
7+ * Author URI: https://wpspecialprojects.wordpress.com/
8+ */
9+
10+ if ( ! defined ( 'ABSPATH ' ) ) {
11+ return ;
12+ }
13+
14+ /**
15+ * Filter `pubsubhubbub_feed_urls` and `pubsubhubbub_comment_feed_urls`.
16+ *
17+ * Still send pings for the old `blog.opensource.org` Feed-URLs.
18+ *
19+ * @param array $links Array of Feed URLs.
20+ *
21+ * @return array $links Array of filtered Feed URLs.
22+ */
23+ function websub_compat ( array $ links ) {
24+ if ( ! $ links ) {
25+ return $ links ;
26+ }
27+
28+ $ host = wp_parse_url ( get_home_url (), PHP_URL_HOST );
29+ $ compat_links = array ();
30+
31+ foreach ( $ links as $ link ) {
32+ $ compat_links [] = str_replace ( $ host , 'blog. ' . $ host , $ link );
33+ }
34+
35+ return array_unique ( array_merge ( $ links , $ compat_links ) );
36+ }
37+ add_filter ( 'pubsubhubbub_feed_urls ' , 'websub_compat ' );
38+ add_filter ( 'pubsubhubbub_comment_feed_urls ' , 'websub_compat ' );
You can’t perform that action at this time.
0 commit comments