Skip to content

Instantly share code, notes, and snippets.

@itspluxstahre
Created February 28, 2012 15:52
Show Gist options
  • Save itspluxstahre/1933288 to your computer and use it in GitHub Desktop.
Save itspluxstahre/1933288 to your computer and use it in GitHub Desktop.
<?php
/// HACK TO WORKAROUND A BUG IN WORDPRESS
function yogasutra_fix_get_home_path() {
if ( !function_exists('get_home_path') && !is_admin()) :
function get_home_path() {
$home = get_option( 'home' );
$siteurl = get_option( 'siteurl' );
if ( $home != '' && $home != $siteurl ) {
$wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */
$pos = strpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
$home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
$home_path = trailingslashit( $home_path );
} else {
$home_path = ABSPATH;
}
return $home_path;
}
endif;
}
add_action('init', 'yogasutra_fix_get_home_path');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment