Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixarntz/267580bb4d40ce4503c1250a8c7cc975 to your computer and use it in GitHub Desktop.
Save felixarntz/267580bb4d40ce4503c1250a8c7cc975 to your computer and use it in GitHub Desktop.
<?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 );
}
);
@aaemnnosttv
Copy link

"Plugin Name" needs to be updated 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment