Skip to content

Instantly share code, notes, and snippets.

@zacscott
Last active March 11, 2017 11:07
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 zacscott/d874a53054bad8962a14b3f78580ffc4 to your computer and use it in GitHub Desktop.
Save zacscott/d874a53054bad8962a14b3f78580ffc4 to your computer and use it in GitHub Desktop.
Fixes the canonical URL to always be HTTP (SEO)
<?php
/**
* Plugin Name: Allow HTTPS
* Description: Fixes the canonical URL to always be HTTP
* Version: 1.0
* Author: Zachary Scott
*/
namespace zacscott;
/**
* Allow HTTPS plugin driver class.
*
* @author Zachary Scott <zscott.dev@gmail.com>
*/
class AllowHttpsPlugin {
function __construct() {
add_filter( 'wpseo_canonical', array( $this, 'rewrite_canonical' ), 999999999 );
}
// Force canonical URL to be HTTP
function rewrite_canonical( $permalink ) {
if ( ! empty( $permalink ) ) {
return str_replace( 'https://', 'http://', $permalink );
} else {
return $permalink;
}
}
}
// Boot
new AllowHttpsPlugin();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment