Doug Stewart avatar Doug Stewart committed 51b475c

Minor clean-up, more tabbed admin work, a little bit of documentation.

Front end is working. Options detection and proper saving to the db -- not so much.

Comments (0)

Files changed (5)

 5. Configure settings to your liking.
 6. Click "Save changes".
 
+#### Via Git (git) ####
+1. Check out the repository from https://github.com/zamoose/Elbee-Elgee into your site's `wp-content/themes/` directory, e.g. `git clone git://github.com/zamoose/Elbee-Elgee.git elbee-elgee`
+2. Navigate to your WordPress Dashboard and go to Appearance -> Themes.
+3. Activate Elbee Elgee.
+4. Go to Appearance -> Elbee Elgee Settings.
+5. Configure settings to your liking.
+6. Click "Save changes".
+
 #### Via Subversion (SVN) ####
-1. Check out the repository from http://bitbucket.org/zamoose/elbee-elgee/trunk into your site's `wp-content/themes/` directory, e.g. `svn cp http://bitbucket.org/zamoose/elbee-elgee/trunk elbee-elgee`
+1. Check out the repository from http://bitbucket.org/zamoose/elbee-elgee/trunk into your site's `wp-content/themes/` directory, e.g. `svn co http://bitbucket.org/zamoose/elbee-elgee/trunk elbee-elgee`
 2. Navigate to your WordPress Dashboard and go to Appearance -> Themes.
 3. Activate Elbee Elgee.
 4. Go to Appearance -> Elbee Elgee Settings.
 * General code clean-up/optimization.
 * Better documentation.
 * <del>Fully-integrated bbPress support.</del> Added in 1.1.
-* Editor styling (particularly important after WP 3.2's addition of Distraction-Free Writing [DFW])
+* <del>Editor styling (particularly important after WP 3.2's addition of Distraction-Free Writing [DFW])</del> Added in 1.2.
 
 ### ONGOING DEVELOPMENT ###
 I have switched my development workflow from Subversion to [Mercurial](<http://mercurial.selenic.com>) (I spend a great deal of time on the train and Hg's distributed nature is *ideal* for such disconnected development) and, as such, host my code at <http://bitbucket.org/zamoose/elbee-elgee>. Please submit feature requests and bug reports using the issue tracker available at BitBucket.

includes/functions/admin.php

 	
 	$page = 'lblg_options_page';
 	
-	if( isset($_GET['tab'] )) {
-		$current_tab = $_GET['tab'];
+	if( empty( $lblg_default_options['tabs']) && empty($lblg_default_options['child_tabs']) ){
+		// If both sets of tab options are empty, don't output anything.
 	} else {
-		$current_tab = 'general';
+		if( isset($_GET['tab'] )) {
+			$current_tab = $_GET['tab'];
+		} else {
+			$current_tab = 'general';
+		}
+	
+		$tabs = $lblg_default_options['tabs'];
+		$child_tabs = $lblg_default_options['child_tabs'];
+	
+		echo '<h2 class="nav-tab-wrapper">';
+	
+		if( !empty($tabs) ){
+			foreach( $tabs as $tab ){
+				$name = $lblg_default_options[$tab]['name'];
+				if( $current_tab == $tab ){
+					$activeclass = ' nav-tab-active';
+				} else {
+					$activeclass = '';
+				}
+				echo "<a href=\"?page=$page&tab=$tab\" class=\"nav-tab$activeclass\">$name</a>";
+			}
+		}
+	
+		if( !empty($child_tabs) ){
+			foreach( $child_tabs as $tab ){
+				$name = $lblg_default_options[$tab]['name'];
+				if( $current_tab == $tab ){
+					$activeclass = ' nav-tab-active';
+				} else {
+					$activeclass = '';
+				}
+				echo "<a href=\"?page=$page&tab=$tab\" class=\"nav-tab$activeclass\">$name</a>";			
+			}
+		}
+	
+		echo "</h2>";
 	}
-	
-	$tabs = $lblg_default_options['tabs'];
-	
-	echo '<h2 class="nav-tab-wrapper">';
-	
-	foreach( $tabs as $tab => $name ){
-		if( $current_tab == $tab ){
-			echo '<a href="' . $PHP_SELF . '?page=' . $page . '&tab='. $tab . '" class="nav-tab nav-tab-active">' . $name . '</a>';			
-		} else {
-			echo '<a href="' . $PHP_SELF . '?page=' . $page . '&tab='. $tab . '" class="nav-tab">' . $name . '</a>';			
-		}
-	}
-	
-	echo "</h2>";
 }
 add_action( 'lblg_after_admin_header', 'lblg_output_admin_tabs' );
 
 /**
- * Grab all the options tab names/links to display.
- *
- * @global array $lblg_default_options 
- * @return array
- */
-function lblg_get_admin_tabs(){
-	global $lblg_default_options;
-	
-	print_r($lblg_default_options['tabs']);
-	// foreach( $lblg_default_options as $option => $values ){
-	// 		if( 'tab' == $values['type'] ){
-	// 			$admin_tabs[$option] = $values['name'];
-	// 		}
-	// 	}
-	
-	return $admin_tabs;
-}
-
-/**
  * Display the theme options page
  *
  * @global string $lblg_shortname
  * lblg_options_walker() is responsible for printing all the 
  * theme options in the theme's options screen.
  *
- * @global array $lblg_options
- * @global array $lblg_default_options
- * @global string $lblg_shortname 
+ * @param array $options
+ * @param array $default_options
+ * @param string $shortname 
  */
-function lblg_options_walker(){
-	global $lblg_options, $lblg_default_options, $lblg_shortname;
-		
+function lblg_options_walker( $options, $default_options, $shortname ){
+	
+	echo "<h2>Options</h2>";
+	print_r($options);
+	echo "<h2>Defaut Options</h2>";
+	print_r($default_options);
 	$section = '';
-	$lblg_options_group = $lblg_shortname . '_theme_options';
-	$options = $lblg_options;
-	$default_options = $lblg_default_options;
+	$lblg_options_group = $shortname . '_theme_options';
 
 	add_settings_section( 'lblg_options', 'lblg', 'lblg_options', 'lblg' );
+
 	foreach ( $default_options as $key => $value ) { 	
 		switch ( $value['type'] ) {
-			
 			// Prints a subheader (useful for dividing options up into similar sections)
 			case 'subhead':
 			$section = 'lblg';
 			?>
 				</tbody>
 				</table>
-				
+			
 				<h3><?php echo $value['name']; ?></h3>
-				
+			
 				<table class="form-table">
 				<tbody>
 			<?php
 			break;
-			
+		
 			// Prints a simple text <input> element
 			case 'text':
 			add_settings_field( $key, $value['name'], '', $lblg_options_group, $section );
 			<?php
 			lblg_option_wrapper_footer( $value );
 			break;
-			
+		
 			// Prints a drop-down <select> element
 			case 'select':
 			add_settings_field( $key, $value['name'], '', $lblg_options_group, $section );
 			<?php
 			lblg_option_wrapper_footer( $value );
 			break;
-			
+		
 			// Prints a <textarea> element
 			case 'textarea':
 			add_settings_field( $key, $value['name'], '', $lblg_options_group, $section );
 			<?php
 			lblg_option_wrapper_footer( $value );
 			break;
-	
+
 			// Prints a series of radio <input> elements
 			case "radio":
 			add_settings_field( $key, $value['name'], '', $lblg_options_group, $section );			
 			    		echo "<input type=\"radio\" name=\"$tmp_name\" value=\"$opt_key\"" . checked( $opt_key, $lblg_options[$key], false ) . " />$opt_value<br />\n";
 				}
 			}
-			 
+		 
 			lblg_option_wrapper_footer( $value );
 			break;
-			
+		
 			// Prints a checbox <input> element
 			case "checkbox":
 			add_settings_field( $key, $value['name'], '', $lblg_options_group, $section );
 
 			lblg_option_wrapper_footer( $value );
 			break;
-	
+
 			default:
-	
+
 			break;
 		}
 	}
+}
 
-}
+/**
+ * Wrapper function to intercept the current tab (if any)
+ * and spawn the display of the current screen's options
+ *
+ * @global array $lblg_default_options
+ * @global array $lblg_options
+ * @global string $lblg_shortname
+ */
+function lblg_display_options(){
+	global $lblg_default_options, $lblg_options, $lblg_shortname;
+	
+	if( empty($lblg_default_options['tabs']) && empty($lblg_default_options['child_tabs']) ){
+		lblg_options_walker( $lblg_options, $lblg_default_options, $lblg_shortname );
+	} else {
+		if( isset($_GET['tab'] )) {
+			$current_tab = $_GET['tab'];
+		} else {
+			$current_tab = 'general';
+		}
+		
+		lblg_options_walker( $lblg_options, $lblg_default_options[$current_tab]['contents'], $lblg_shortname );
+	}
+}
+add_action( 'lblg_print_options', 'lblg_display_options' );

includes/functions/hooks.php

 <?php
-/*
-* Elbee Elgee Theme Hooks
-*/
+/**
+ * Elbee Elgee Theme Hooks
+ *
+ * @package 		Elbee-Elgee
+ * @copyright	Copyright (c) 2011, Doug Stewart
+ * @license		http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer)
+ *
+ * @since 		Elbee-Elgee 1.0
+ */
 
-/*
+/**
 *  Action hooks
 */
 function lblg_set_themename(){
 	do_action( 'lblg_set_themename' );
 }
 
-
 function lblg_after_admin_header(){
 	do_action( 'lblg_after_admin_header' );
 }
 add_action( 'lblg_print_menu', 'lblg_menu' );
 add_action( 'lblg_print_copyright', 'lblg_echo_copyright' );
 add_action( 'lblg_print_credits', 'lblg_credits' );
-add_action( 'lblg_print_options', 'lblg_options_walker' );
 
 // WordPress core hooks

includes/functions/options.php

 function lblg_get_options_from_defaults( $default_options ){
 	$stripped_opts = array();
 	
+	$c = 0;
 	foreach( $default_options as $key => $value ){
-		if('subhead' != $value['type']){
+		switch($value['type']){
+			case 'tab':
+				$stripped_opts = $stripped_opts + lblg_get_options_from_defaults($value['contents']);
+			break;
+			case 'subhead':
+			break;
+			default:
 			$stripped_opts[$key] = $value['std'];
+			break;
 		}
+		echo "<h2>Iteration $c</h2>";
+		print_r($stripped_opts);
+		$c++;
 	}
 	
 	return $stripped_opts;
 				case 'textarea':
 					if( isset($input[$key]) ){
 						$valid_input[ $key ] = wp_kses_post( $input[ $key ] );
-						//$valid_input[ $key ] = esc_attr( $input[$key] );
 					}
 				break;
 

includes/parent-options.php

  * @since		Elbee-Elgee 1.0
  */
 
-/** 
- * Current choices:
- * 'tabbed': use WordPress' built-in tabbing to separate sections
- * 'single': single page of options
- */
-$parent_theme_array[ 'admin_layout' ] = 'tabbed';
-
 // Look for layout CSS files to auto-load
 $layout_path = TEMPLATEPATH . '/layouts/'; 
 $layouts = array();
 $alt_stylesheets_tmp = asort($alt_stylesheets);
 $alt_stylesheets_tmp = array_unshift($alt_stylesheets, "Select a stylesheet:", "*none*");
 
-$parent_options_array = array (
+$parent_options_array = array(
 	"tabs" => array( 'general' ),
 	
 	"general" => array(
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.