From d36127b14747bfc82aebc7bc150d3262083544ce Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Fri, 2 Nov 2012 12:43:39 -0400 Subject: [PATCH 1/5] Refactor activation options validation --- lib/activation.php | 65 +++++++++------------------------------------- 1 file changed, 12 insertions(+), 53 deletions(-) diff --git a/lib/activation.php b/lib/activation.php index 867045e..48e9c6a 100644 --- a/lib/activation.php +++ b/lib/activation.php @@ -155,61 +155,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' => 1, + 'create_front_page' => 'yes', + 'change_permalink_structure' => 'yes', + 'change_uploads_folder' => 'yes', + 'create_navigation_menus' => 'yes', + 'add_pages_to_primary_navigation' => 'yes' + ); - if (isset($input['create_front_page'])) { - if ($input['create_front_page'] === 'yes') { - $input['create_front_page'] = true; + foreach($options as $name => $value) { + if (isset($input[$name])) { + $input[$name] = ($input[$name] === $value) ? true : false; + $output[$name] = $input[$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); From 18acf1af0b4da48abb2ef89e57c9a32fdbf8adac Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Fri, 2 Nov 2012 12:44:53 -0400 Subject: [PATCH 2/5] Yes, this is PHP --- lib/activation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/activation.php b/lib/activation.php index 48e9c6a..79e8ddb 100644 --- a/lib/activation.php +++ b/lib/activation.php @@ -155,7 +155,7 @@ function roots_theme_activation_options_render_page() { ?> function roots_theme_activation_options_validate($input) { $output = $defaults = roots_get_default_theme_activation_options(); - $options = Array( + $options = array( 'first_run' => 1, 'create_front_page' => 'yes', 'change_permalink_structure' => 'yes', From 2c1fe0b2efbf0b1ab6c3479b21c6a57b90cca01a Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Fri, 2 Nov 2012 12:59:13 -0400 Subject: [PATCH 3/5] Simplify even more --- lib/activation.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/activation.php b/lib/activation.php index 79e8ddb..b07265f 100644 --- a/lib/activation.php +++ b/lib/activation.php @@ -75,7 +75,7 @@ function roots_theme_activation_options_render_page() { ?> $roots_default_activation_options = roots_get_default_theme_activation_options(); ?> - + @@ -83,8 +83,8 @@ function roots_theme_activation_options_render_page() { ?>

@@ -96,8 +96,8 @@ function roots_theme_activation_options_render_page() { ?>

@@ -109,8 +109,8 @@ function roots_theme_activation_options_render_page() { ?>

@@ -122,8 +122,8 @@ function roots_theme_activation_options_render_page() { ?>

@@ -135,8 +135,8 @@ function roots_theme_activation_options_render_page() { ?>

@@ -156,17 +156,17 @@ function roots_theme_activation_options_validate($input) { $output = $defaults = roots_get_default_theme_activation_options(); $options = array( - 'first_run' => 1, - 'create_front_page' => 'yes', - 'change_permalink_structure' => 'yes', - 'change_uploads_folder' => 'yes', - 'create_navigation_menus' => 'yes', - 'add_pages_to_primary_navigation' => 'yes' + 'first_run', + 'create_front_page', + 'change_permalink_structure', + 'change_uploads_folder', + 'create_navigation_menus', + 'add_pages_to_primary_navigation' ); - foreach($options as $name => $value) { - if (isset($input[$name])) { - $input[$name] = ($input[$name] === $value) ? true : false; + foreach($options as $option_name) { + if (isset($input[$option_name])) { + $input[$option_name] = ($input[$option_name] === 'true') ? true : false; $output[$name] = $input[$name]; } } From d55ce57cbbdc59644d8d9a4163a0a57c5d6a5481 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Mon, 5 Nov 2012 13:02:44 -0500 Subject: [PATCH 4/5] Fix option name variable --- lib/activation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/activation.php b/lib/activation.php index b07265f..d2c3a2c 100644 --- a/lib/activation.php +++ b/lib/activation.php @@ -167,7 +167,7 @@ function roots_theme_activation_options_validate($input) { foreach($options as $option_name) { if (isset($input[$option_name])) { $input[$option_name] = ($input[$option_name] === 'true') ? true : false; - $output[$name] = $input[$name]; + $output[$option_name] = $input[$option_name]; } } From f165a26800422aa2386b52dab41d5dd8429bf720 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Mon, 5 Nov 2012 15:02:29 -0500 Subject: [PATCH 5/5] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1326ebd..39f1ae2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### HEAD * Use `entry-summary` class for excerpts per Readability's Article Publishing Guidelines +* Cleanup/refactor `lib/activation.php` * Remove `lib/post-types.php` and `lib/metaboxes.php` * Make sure Primary Navigation menu always gets created and has the location set upon activation, update activation permalink method * Update to Bootstrap 2.2.1