Files
sage/lib/htaccess.php
Ben Word fea92a61aa Rewrites organization
- Create lib/rewrites.php and move everything from lib/htaccess.php
except the H5BP htaccess functionality into it

- In the config, change add_theme_support('rewrite-urls') to
add_theme_support('rewrites')

- Remove the Apache/LightSpeed HTTPD check for rewrites

- Update docs with better Nginx rewrite rules
2013-02-04 19:56:42 -06:00

29 lines
1.0 KiB
PHP

<?php
/**
* Add HTML5 Boilerplate's .htaccess via WordPress
*/
// Add the contents of h5bp-htaccess into .htaccess
function roots_add_h5bp_htaccess($content) {
global $wp_rewrite;
$home_path = function_exists('get_home_path') ? get_home_path() : ABSPATH;
$htaccess_file = $home_path . '.htaccess';
$mod_rewrite_enabled = function_exists('got_mod_rewrite') ? got_mod_rewrite() : false;
if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
if ($mod_rewrite_enabled) {
$h5bp_rules = extract_from_markers($htaccess_file, 'HTML5 Boilerplate');
if ($h5bp_rules === array()) {
$filename = dirname(__FILE__) . '/h5bp-htaccess';
return insert_with_markers($htaccess_file, 'HTML5 Boilerplate', extract_from_markers($filename, 'HTML5 Boilerplate'));
}
}
}
return $content;
}
if (current_theme_supports('h5bp-htaccess')) {
add_action('generate_rewrite_rules', 'roots_add_h5bp_htaccess');
}