cleaning up the part that checks to see if .htaccess is writable

This commit is contained in:
Ben Word
2011-05-29 23:41:14 -06:00
parent 0f3ea1bf0a
commit e9cac02724

View File

@@ -1,24 +1,12 @@
<?php
function roots_get_home_path() {
$home = trailingslashit(get_option( 'home' ));
$siteurl = trailingslashit(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;
function roots_htaccess_writable() {
if (!is_writable(get_home_path() . '.htaccess')) {
add_action('admin_notices', create_function('', "echo '<div class=\"error\"><p>" . sprintf(__('Please make sure your <a href="%s">.htaccess</a> file is writeable ', 'roots'), admin_url('options-permalink.php')) . "</p></div>';"));
};
}
$home_path = roots_get_home_path();
if (!is_writable($home_path . '.htaccess')) {
add_action('admin_notices', create_function('', "echo '<div class=\"error\"><p>" . sprintf(__('Please make sure your <a href="%s">htaccess</a> file is writeable ', 'roots'), admin_url('options-permalink.php')) . "</p></div>';"));
};
add_action('admin_init', 'roots_htaccess_writable');
// thanks to Scott Walkinshaw (scottwalkinshaw.com)