Last active
October 9, 2020 15:48
-
-
Save felixarntz/267580bb4d40ce4503c1250a8c7cc975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Ensures Site Kit ignores contextual home URL path modifications added by certain multilingual plugins. | |
* | |
* @author Felix Arntz, Google | |
* @license Apache 2.0 | |
* @copyright 2020 Google Inc. | |
* | |
* @wordpress-plugin | |
* Plugin Name: Fix Site Kit Canonical Home URL Multilingual | |
* Description: Ensures Site Kit ignores contextual home URL path modifications added by certain multilingual plugins. | |
* Plugin URI: https://gist.github.com/felixarntz/267580bb4d40ce4503c1250a8c7cc975 | |
* Version: 0.1.0 | |
* Author: Felix Arntz, Google | |
* Author URI: https://felix-arntz.me | |
* License: Apache License 2.0 | |
* License URI: https://www.apache.org/licenses/LICENSE-2.0 | |
*/ | |
add_filter( | |
'googlesitekit_canonical_home_url', | |
function( $home_url ) { | |
// Strips language path suffixes in URLs such as https://example.com/es/ | |
return preg_replace( '/\/([a-z]{2})(\/{0,1})$/', '$2', $home_url ); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"Plugin Name" needs to be updated 😄