Merge pull request #227 from Alkymst/master

possible fix for 500 server error
This commit is contained in:
Ben Word
2012-01-16 11:55:16 -08:00
2 changed files with 23 additions and 23 deletions

View File

@@ -1,5 +1,4 @@
# BEGIN HTML5 Boilerplate .htaccess
## BEGIN HTML5 Boilerplate
###
### This contains the HTML5 Boilerplate .htaccess that can be found at:
@@ -18,7 +17,7 @@
###
### Anytime you update this file the .htaccess file in the root of your
### WordPress install is automatically updated with the changes whenever
### the admin is refreshed (see roots-htaccess.php)
### the permalinks are flushed or set
###
@@ -552,4 +551,4 @@ AddCharset utf-8 .css .js .xml .json .rss .atom
php_value session.cookie_httponly true
</IfModule>
# END HTML5 Boilerplate
# END HTML5 Boilerplate

View File

@@ -21,25 +21,19 @@ if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
// rewrite /wp-content/themes/roots/img/ to /js/
// rewrite /wp-content/plugins/ to /plugins/
function roots_flush_rewrites() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
function roots_add_rewrites($content) {
$theme_name = next(explode('/themes/', get_stylesheet_directory()));
global $wp_rewrite;
$theme_name = next(explode('/themes/', get_stylesheet_directory()));
$roots_new_non_wp_rules = array(
'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1',
'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1',
'img/(.*)' => 'wp-content/themes/'. $theme_name . '/img/$1',
'plugins/(.*)' => 'wp-content/plugins/$1'
);
$wp_rewrite->non_wp_rules += $roots_new_non_wp_rules;
$wp_rewrite->non_wp_rules = $roots_new_non_wp_rules;
return $content;
}
add_action('admin_init', 'roots_flush_rewrites');
function roots_clean_assets($content) {
$theme_name = next(explode('/themes/', $content));
$current_path = '/wp-content/themes/' . $theme_name;
@@ -58,6 +52,7 @@ if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
// only use clean urls if the theme isn't a child or an MU (Network) install
if (!is_multisite() && !is_child_theme()) {
add_action('generate_rewrite_rules', 'roots_add_rewrites');
add_action('generate_rewrite_rules', 'roots_add_h5bp_htaccess');
if (!is_admin()) {
add_filter('plugins_url', 'roots_clean_plugins');
add_filter('bloginfo', 'roots_clean_assets');
@@ -69,19 +64,25 @@ if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
}
// add the contents of h5bp-htaccess into the .htaccess file
function roots_add_h5bp_htaccess($rules) {
global $wp_filesystem;
function roots_add_h5bp_htaccess($content) {
global $wp_rewrite;
if (!defined('FS_METHOD')) define('FS_METHOD', 'direct');
if (is_null($wp_filesystem)) WP_Filesystem(array(), ABSPATH);
$filename = __DIR__ . '/h5bp-htaccess';
return $rules . $wp_filesystem->get_contents($filename);
$home_path = get_home_path();
$htaccess_file = $home_path . '.htaccess';
if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
if (got_mod_rewrite()) {
$h5bp_rules = extract_from_markers($htaccess_file, 'HTML5 Boilerplate');
if ($h5bp_rules === array()) {
$filename = __DIR__ . '/h5bp-htaccess';
return insert_with_markers($htaccess_file, 'HTML5 Boilerplate', extract_from_markers($filename, 'HTML5 Boilerplate'));
}
}
}
return $content;
}
add_filter('mod_rewrite_rules', 'roots_add_h5bp_htaccess');
}
?>