Merge branch 'master' into grunt

This commit is contained in:
Paul Yoder
2012-11-22 05:51:36 -06:00
8 changed files with 350 additions and 585 deletions

View File

@@ -25,7 +25,8 @@ add_filter('option_page_capability_roots_activation_options', 'roots_activation_
function roots_theme_activation_options_add_page() {
$roots_activation_options = roots_get_theme_activation_options();
if (!$roots_activation_options['first_run']) {
if ($roots_activation_options['first_run']) {
$theme_page = add_theme_page(
__('Theme Activation', 'roots'),
__('Theme Activation', 'roots'),
@@ -46,7 +47,7 @@ add_action('admin_menu', 'roots_theme_activation_options_add_page', 50);
function roots_get_default_theme_activation_options() {
$default_theme_activation_options = array(
'first_run' => false,
'first_run' => true,
'create_front_page' => false,
'change_permalink_structure' => false,
'change_uploads_folder' => false,
@@ -75,7 +76,7 @@ function roots_theme_activation_options_render_page() { ?>
$roots_default_activation_options = roots_get_default_theme_activation_options();
?>
<input type="hidden" value="1" name="roots_theme_activation_options[first_run]">
<input type="hidden" value="false" name="roots_theme_activation_options[first_run]">
<table class="form-table">
@@ -83,8 +84,8 @@ function roots_theme_activation_options_render_page() { ?>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Create static front page?', 'roots'); ?></span></legend>
<select name="roots_theme_activation_options[create_front_page]" id="create_front_page">
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
<option value="no"><?php echo _e('No', 'roots'); ?></option>
<option selected="selected" value="true"><?php echo _e('Yes', 'roots'); ?></option>
<option value="false"><?php echo _e('No', 'roots'); ?></option>
</select>
<br>
<small class="description"><?php printf(__('Create a page called Home and set it to be the static front page', 'roots')); ?></small>
@@ -96,8 +97,8 @@ function roots_theme_activation_options_render_page() { ?>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Update permalink structure?', 'roots'); ?></span></legend>
<select name="roots_theme_activation_options[change_permalink_structure]" id="change_permalink_structure">
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
<option value="no"><?php echo _e('No', 'roots'); ?></option>
<option selected="selected" value="true"><?php echo _e('Yes', 'roots'); ?></option>
<option value="false"><?php echo _e('No', 'roots'); ?></option>
</select>
<br>
<small class="description"><?php printf(__('Change permalink structure to /&#37;postname&#37;/', 'roots')); ?></small>
@@ -109,8 +110,8 @@ function roots_theme_activation_options_render_page() { ?>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Update uploads folder?', 'roots'); ?></span></legend>
<select name="roots_theme_activation_options[change_uploads_folder]" id="change_uploads_folder">
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
<option value="no"><?php echo _e('No', 'roots'); ?></option>
<option selected="selected" value="true"><?php echo _e('Yes', 'roots'); ?></option>
<option value="false"><?php echo _e('No', 'roots'); ?></option>
</select>
<br>
<small class="description"><?php printf(__('Change uploads folder to /assets/ instead of /wp-content/uploads/', 'roots')); ?></small>
@@ -122,8 +123,8 @@ function roots_theme_activation_options_render_page() { ?>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Create navigation menu?', 'roots'); ?></span></legend>
<select name="roots_theme_activation_options[create_navigation_menus]" id="create_navigation_menus">
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
<option value="no"><?php echo _e('No', 'roots'); ?></option>
<option selected="selected" value="true"><?php echo _e('Yes', 'roots'); ?></option>
<option value="false"><?php echo _e('No', 'roots'); ?></option>
</select>
<br>
<small class="description"><?php printf(__('Create the Primary Navigation menu and set the location', 'roots')); ?></small>
@@ -135,8 +136,8 @@ function roots_theme_activation_options_render_page() { ?>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Add pages to menu?', 'roots'); ?></span></legend>
<select name="roots_theme_activation_options[add_pages_to_primary_navigation]" id="add_pages_to_primary_navigation">
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
<option value="no"><?php echo _e('No', 'roots'); ?></option>
<option selected="selected" value="true"><?php echo _e('Yes', 'roots'); ?></option>
<option value="false"><?php echo _e('No', 'roots'); ?></option>
</select>
<br>
<small class="description"><?php printf(__('Add all current published pages to the Primary Navigation', 'roots')); ?></small>
@@ -155,61 +156,20 @@ function roots_theme_activation_options_render_page() { ?>
function roots_theme_activation_options_validate($input) {
$output = $defaults = roots_get_default_theme_activation_options();
if (isset($input['first_run'])) {
if ($input['first_run'] === '1') {
$input['first_run'] = true;
}
$output['first_run'] = $input['first_run'];
}
$options = array(
'first_run',
'create_front_page',
'change_permalink_structure',
'change_uploads_folder',
'create_navigation_menus',
'add_pages_to_primary_navigation'
);
if (isset($input['create_front_page'])) {
if ($input['create_front_page'] === 'yes') {
$input['create_front_page'] = true;
foreach($options as $option_name) {
if (isset($input[$option_name])) {
$input[$option_name] = ($input[$option_name] === 'true') ? true : false;
$output[$option_name] = $input[$option_name];
}
if ($input['create_front_page'] === 'no') {
$input['create_front_page'] = false;
}
$output['create_front_page'] = $input['create_front_page'];
}
if (isset($input['change_permalink_structure'])) {
if ($input['change_permalink_structure'] === 'yes') {
$input['change_permalink_structure'] = true;
}
if ($input['change_permalink_structure'] === 'no') {
$input['change_permalink_structure'] = false;
}
$output['change_permalink_structure'] = $input['change_permalink_structure'];
}
if (isset($input['change_uploads_folder'])) {
if ($input['change_uploads_folder'] === 'yes') {
$input['change_uploads_folder'] = true;
}
if ($input['change_uploads_folder'] === 'no') {
$input['change_uploads_folder'] = false;
}
$output['change_uploads_folder'] = $input['change_uploads_folder'];
}
if (isset($input['create_navigation_menus'])) {
if ($input['create_navigation_menus'] === 'yes') {
$input['create_navigation_menus'] = true;
}
if ($input['create_navigation_menus'] === 'no') {
$input['create_navigation_menus'] = false;
}
$output['create_navigation_menus'] = $input['create_navigation_menus'];
}
if (isset($input['add_pages_to_primary_navigation'])) {
if ($input['add_pages_to_primary_navigation'] === 'yes') {
$input['add_pages_to_primary_navigation'] = true;
}
if ($input['add_pages_to_primary_navigation'] === 'no') {
$input['add_pages_to_primary_navigation'] = false;
}
$output['add_pages_to_primary_navigation'] = $input['add_pages_to_primary_navigation'];
}
return apply_filters('roots_theme_activation_options_validate', $output, $input, $defaults);
@@ -277,12 +237,12 @@ function roots_theme_activation_action() {
$roots_nav_theme_mod = false;
$existing_nav = wp_get_nav_menu_object('Primary Navigation');
if (!$existing_nav) {
$primary_nav = wp_get_nav_menu_object('Primary Navigation');
if (!$primary_nav) {
$primary_nav_id = wp_create_nav_menu('Primary Navigation', array('slug' => 'primary_navigation'));
$roots_nav_theme_mod['primary_navigation'] = $primary_nav_id;
} else {
$primary_nav = wp_get_nav_menu_object('Primary Navigation');
$roots_nav_theme_mod['primary_navigation'] = $primary_nav->term_id;
}
@@ -297,6 +257,7 @@ function roots_theme_activation_action() {
$primary_nav = wp_get_nav_menu_object('Primary Navigation');
$primary_nav_term_id = (int) $primary_nav->term_id;
$menu_items= wp_get_nav_menu_items($primary_nav_term_id);
if (!$menu_items || empty($menu_items)) {
$pages = get_pages();
foreach($pages as $page) {

View File

@@ -11,10 +11,9 @@
* /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.
* If you aren't using Apache, alternate configuration settings can be found in the docs.
*
* @link https://github.com/retlehs/roots/wiki/Nginx
* @link https://github.com/retlehs/roots/wiki/Lighttpd
* @link https://github.com/retlehs/roots/blob/master/doc/rewrites.md
*/
if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') || stristr($_SERVER['SERVER_SOFTWARE'], 'litespeed') !== false) {

View File

@@ -60,7 +60,7 @@ class Roots_Nav_Walker extends Walker_Nav_Menu {
function roots_nav_menu_css_class($classes, $item) {
$slug = sanitize_title($item->title);
$classes = preg_replace('/(current(-menu-|[-_]page[-_])(item|parent|ancestor))/', 'active', $classes);
$classes = preg_replace('/((menu|page)[-_\w+]+)+/', '', $classes);
$classes = preg_replace('/^((menu|page)[-_\w+]+)+/', '', $classes);
$classes[] = 'menu-' . $slug;