Skip to content

Commit 771dbc8

Browse files
committed
Add backwards compatibility for the blog subdomain
Still send pings for the old `blog.opensource.org` Feed-URLs.
1 parent 3a90138 commit 771dbc8

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

2223
themes/*
2324
!themes/osi

mu-plugins/websub-compat.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Plugin Name: WebSub Backwards Compatibility
4+
* Version: 1.0.0
5+
* Author: WordPress.com Special Projects
6+
* Author URI: https://wpspecialprojects.wordpress.com/
7+
*/
8+
9+
if ( ! defined( 'ABSPATH' ) ) {
10+
return;
11+
}
12+
13+
/**
14+
* Filter `pubsubhubbub_feed_urls` and `pubsubhubbub_comment_feed_urls`.
15+
*
16+
* Still send pings for the old `blog.opensource.org` Feed-URLs.
17+
*
18+
* @param array $links Array of Feed URLs.
19+
*
20+
* @return array $links Array of filtered Feed URLs.
21+
*/
22+
function websub_compat( $links ) {
23+
if ( ! $links || ! is_array( $links ) ) {
24+
return $links;
25+
}
26+
27+
$host = wp_parse_url( get_home_url(), PHP_URL_HOST );
28+
$compat_links = array();
29+
30+
foreach ( $links as $link ) {
31+
$compat_links[] = str_replace( $host, 'blog.' . $host, $link );
32+
}
33+
34+
return array_unique( array_merge( $links, $compat_links ) );
35+
}
36+
add_filter( 'pubsubhubbub_feed_urls', 'websub_compat' );
37+
add_filter( 'pubsubhubbub_comment_feed_urls', 'websub_compat' );

0 commit comments

Comments
 (0)