Add/update code comments
This commit is contained in:
@@ -1,11 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
// Using a server other than Apache? See:
|
* URL rewriting and addition of HTML5 Boilerplate's .htaccess
|
||||||
// https://github.com/retlehs/roots/wiki/Nginx
|
*
|
||||||
// https://github.com/retlehs/roots/wiki/Lighttpd
|
* Rewrites currently do not happen for child themes (or network installs)
|
||||||
|
* @todo https://github.com/retlehs/roots/issues/461
|
||||||
|
*
|
||||||
|
* Rewrite:
|
||||||
|
* /wp-content/themes/themename/css/ to /css/
|
||||||
|
* /wp-content/themes/themename/js/ to /js/
|
||||||
|
* /wp-content/themes/themename/img/ to /img/
|
||||||
|
* /wp-content/plugins/ to /plugins/
|
||||||
|
*
|
||||||
|
* If you aren't using Apache, alternate configuration settings can be found in the wiki.
|
||||||
|
*
|
||||||
|
* @link https://github.com/retlehs/roots/wiki/Nginx
|
||||||
|
* @link https://github.com/retlehs/roots/wiki/Lighttpd
|
||||||
|
*/
|
||||||
|
|
||||||
if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') || stristr($_SERVER['SERVER_SOFTWARE'], 'litespeed') !== false) {
|
if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') || stristr($_SERVER['SERVER_SOFTWARE'], 'litespeed') !== false) {
|
||||||
|
|
||||||
|
// Show an admin notice if .htaccess isn't writable
|
||||||
function roots_htaccess_writable() {
|
function roots_htaccess_writable() {
|
||||||
if (!is_writable(get_home_path() . '.htaccess')) {
|
if (!is_writable(get_home_path() . '.htaccess')) {
|
||||||
if (current_user_can('administrator')) {
|
if (current_user_can('administrator')) {
|
||||||
@@ -16,12 +30,6 @@ if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') || stristr($_SERVER['SERVER_S
|
|||||||
|
|
||||||
add_action('admin_init', 'roots_htaccess_writable');
|
add_action('admin_init', 'roots_htaccess_writable');
|
||||||
|
|
||||||
// Rewrites DO NOT happen for child themes
|
|
||||||
// rewrite /wp-content/themes/roots/css/ to /css/
|
|
||||||
// rewrite /wp-content/themes/roots/js/ to /js/
|
|
||||||
// rewrite /wp-content/themes/roots/img/ to /js/
|
|
||||||
// rewrite /wp-content/plugins/ to /plugins/
|
|
||||||
|
|
||||||
function roots_add_rewrites($content) {
|
function roots_add_rewrites($content) {
|
||||||
global $wp_rewrite;
|
global $wp_rewrite;
|
||||||
$roots_new_non_wp_rules = array(
|
$roots_new_non_wp_rules = array(
|
||||||
@@ -42,7 +50,6 @@ if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') || stristr($_SERVER['SERVER_S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only use clean urls if the theme isn't a child or an MU (Network) install
|
|
||||||
if (!is_multisite() && !is_child_theme() && get_option('permalink_structure')) {
|
if (!is_multisite() && !is_child_theme() && get_option('permalink_structure')) {
|
||||||
if (current_theme_supports('rewrite-urls')) {
|
if (current_theme_supports('rewrite-urls')) {
|
||||||
add_action('generate_rewrite_rules', 'roots_add_rewrites');
|
add_action('generate_rewrite_rules', 'roots_add_rewrites');
|
||||||
@@ -66,7 +73,7 @@ if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') || stristr($_SERVER['SERVER_S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the contents of h5bp-htaccess into the .htaccess file
|
// Add the contents of h5bp-htaccess into the .htaccess file
|
||||||
function roots_add_h5bp_htaccess($content) {
|
function roots_add_h5bp_htaccess($content) {
|
||||||
global $wp_rewrite;
|
global $wp_rewrite;
|
||||||
$home_path = function_exists('get_home_path') ? get_home_path() : ABSPATH;
|
$home_path = function_exists('get_home_path') ? get_home_path() : ABSPATH;
|
||||||
@@ -76,10 +83,10 @@ if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') || stristr($_SERVER['SERVER_S
|
|||||||
if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
|
if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
|
||||||
if ($mod_rewrite_enabled) {
|
if ($mod_rewrite_enabled) {
|
||||||
$h5bp_rules = extract_from_markers($htaccess_file, 'HTML5 Boilerplate');
|
$h5bp_rules = extract_from_markers($htaccess_file, 'HTML5 Boilerplate');
|
||||||
if ($h5bp_rules === array()) {
|
if ($h5bp_rules === array()) {
|
||||||
$filename = dirname(__FILE__) . '/h5bp-htaccess';
|
$filename = dirname(__FILE__) . '/h5bp-htaccess';
|
||||||
return insert_with_markers($htaccess_file, 'HTML5 Boilerplate', extract_from_markers($filename, 'HTML5 Boilerplate'));
|
return insert_with_markers($htaccess_file, 'HTML5 Boilerplate', extract_from_markers($filename, 'HTML5 Boilerplate'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user