Created
March 7, 2017 07:21
-
-
Save Steveorevo/e83c0f54bb540edcf7740603a203809b to your computer and use it in GitHub Desktop.
Suggested DraftCode fix.
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 | |
if ( !class_exists( 'DraftCode' ) ) { | |
/** | |
* Our DraftCode class fixes WordPress compatibility issues. | |
*/ | |
class DraftCode | |
{ | |
public function __construct() | |
{ | |
global $wp_filter; | |
$wp_filter['redirect_canonical'][0]['dc_redirect_canonical'] = array( 'function' => array(&$this, 'dc_redirect_canonical'), 'accepted_args' => 1 ); | |
$wp_filter['pre_update_option_siteurl'][0]['dc_pre_update_option_siteurl'] = array( 'function' => array(&$this, 'dc_pre_update_option_siteurl'), 'accepted_args' => 1 ); | |
} | |
/** | |
* Hook redirect_url event to make canonical.php redirection loop fix | |
*/ | |
public function dc_redirect_canonical( $redirect_url ) | |
{ | |
$redirect_url = preg_replace('|index\.php$|', '/', $redirect_url); | |
return $redirect_url; | |
} | |
/** | |
* Suppress initial Apache warning from SQLite Integration plugin | |
*/ | |
public function dc_pre_update_option_siteurl( $value ) | |
{ | |
global $_SERVER; | |
$_SERVER['SERVER_SOFTWARE'] = 'apache'; | |
return $value; | |
} | |
} | |
global $draftCode; | |
$draftCode = new DraftCode(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment