Last active
March 11, 2017 11:07
-
-
Save zacscott/d874a53054bad8962a14b3f78580ffc4 to your computer and use it in GitHub Desktop.
Fixes the canonical URL to always be HTTP (SEO)
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 | |
/** | |
* 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 <[email protected]> | |
*/ | |
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