I’ve decided to share higher-level stuff on my blog. I’ve been studying the WooFramework and decided I wanted to insert my own custom options into the WooFramework Options Panel. The woo_options_add function allows you to easily drop in your own options in the $options array by adding new values to the end of the array. I didn’t want to do that because I want these options in the Header options panel and not at the bottom or in its own panel. I found this article by WooThemes that tells me to edit the theme-options.php file but I didn’t want to do that either. So, I wrote my own function and placed it inside of the woo_options_add function in the parent functions.php file. It may not be perfect but it’s working for me.
The function below loops through the multidimsensional $options array trying to match $value['name']. If match is TRUE, insert the new field into the $options array. As you can see, I’m generating new keys too. If you know a better way to do this, please share. Also, check out my support group at http://fb.com/groups/internet.questions/
You can see in the image below that this function inserts a couple checkbox fields into the Options Panel.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
function woo_options_add($options){ $i = 0; while(list($key, $value) = each($options)) { if($value['name'] == 'Header Padding Left/Right') { $array[$i] = $value; $i++; $array[$i] = array( "name" => __( 'Site Title Visibility', 'woothemes' ), "desc" => __( 'Hide the site title within the header.', 'woothemes' ), "id" => $shortname."_title_visibility", "std" => '', "type" => "checkbox"); } elseif($value['name'] == 'Site Title Font Style') { $array[$i] = $value; $i++; $array[$i] = array( "name" => __( 'Site Description Visibility', 'woothemes' ), "desc" => __( 'Hide the site description within the header.', 'woothemes' ), "id" => $shortname."_description_visibility", "std" => '', "type" => "checkbox"); } else { $array[$i] = $value; } $i++; } return $array; } |





