creating admin options page – array – main top nav
-
hi there
what i want to do: i would like to create a wordpress theme with editable top nav through admin to login.
i have currently got editable side bar by copying snippets of theme called Ikarus which i have to say is one of the best theme’s i have ever seen, it has inspired me to look into php and enjoy the true possibilities and diversity of wordpress.
it uses :
<?php include (TEMPLATEPATH . ‘/options/options.php’); ?>
<!– BEGIN: COLUMNS –>
<div id=”colwrap”>
<?php include (TEMPLATEPATH . ‘/ben.php’); ?>
</div>in the header
then:$themename = “ben”;
$shortname = “tn”;$wp_dropdown_cat_admin = get_categories(‘hide_empty=0&orderby=name’);
$wp_getcat = array();
foreach ($wp_dropdown_cat_admin as $category_list) {
$wp_getcat[$category_list->cat_ID] = $category_list->cat_name;
}
$category_bulk_list = array_unshift($wp_getcat, “Choose a category:”);$options = array (
array( “name” => “Text for navigation link 1”,
“inblock” => “banner”,
“id” => $shortname.”_mz_url_1″,
“std” => “#”,
“type” => “text”),array( “name” => “navigation link 1 – Destination”,
“inblock” => “banner”,
“id” => $shortname.”_mz_url_1″,
“std” => “#”,
“type” => “text”),function mytheme_mz_admin() {
global $themename, $shortname, $options;
if ( $_REQUEST[‘saved’] ) echo ‘<div id=”message” class=”updated fade”><p>‘.$themename.’ settings saved.</p></div>’;
if ( $_REQUEST[‘reset’] ) echo ‘<div id=”message” class=”updated fade”><p>‘.$themename.’ settings reset.</p></div>’;
?><div id=”custom-wrap”>
<div id=”custom-container”><div id=”live-theme-preview”>
<h2>Live Preview (will updated when option save)</h2>
<iframe src=”../?preview=true” width=”100%” height=”300″ ></iframe>
</div><div id=”notes”>
<h3>SPECIAL NOTES:</h3>
<p>Good chance Ben design wont really work – featured-image</p>
<p>All features can activate or deactivate with choice</p>
</div><form method=”post” id=”option-mz-form”>
<div class=”pwrap”>
</div>
<div class=”option-box”>
<h5>Settings</h5>
<?php foreach ($options as $value) {
if (($value[‘inblock’] == “feats”) && ($value[‘type’] == “text”)) { ?><div class=”pwrap”>
<p><?php echo $value[‘name’]; ?>:</p>
<p><input name=”<?php echo $value[‘id’]; ?>” id=”<?php echo $value[‘id’]; ?>” class=”ops-select” type=”<?php echo $value[‘type’]; ?>” value=”<?php if ( get_settings( $value[‘id’] ) != “”) { echo get_settings( $value[‘id’] ); } else { echo $value[‘std’]; } ?>” /></p></div><?php } elseif (($value[‘inblock’] == “feats”) && ($value[‘type’] == “select”)) { ?>
<div class=”pwrap”>
<p><?php echo $value[‘name’]; ?>:</p>
<p><select name=”<?php echo $value[‘id’]; ?>” class=”ops-select” id=”<?php echo $value[‘id’]; ?>”>
<?php foreach ($value[‘options’] as $option) { ?>
<option<?php if ( get_settings( $value[‘id’] ) == $option) { echo ‘ selected=”selected”‘; } elseif ($option == $value[‘std’]) { echo ‘ selected=”selected”‘; } ?>><?php echo $option; ?></option>
<?php } ?>
</select>
</p></div><?php } elseif (($value[‘inblock’] == “feats”) && ($value[‘type’] == “textarea”)) { ?>
<div class=”pwrap”>
<p><?php echo $value[‘name’]; ?>:</p>
<?php $valuex = $value[‘id’];
$valuey = stripslashes($valuex);
$video_code = get_settings($valuey);
?>
<p><textarea name=”<?php echo $valuey; ?>” cols=”40%” rows=”8″ /><?php if ( get_settings($valuey) != “”) { echo stripslashes($video_code); } else { echo $value[‘std’]; } ?></textarea>
</p></div>
<?php }}
?>
</div><p class=”submit”>
<input name=”save” type=”submit” class=”saveme” value=”Save changes” />
<input type=”hidden” name=”action” value=”save” />
</p>
</form><form method=”post”>
<p class=”submit”>
<input name=”reset” type=”submit” class=”saveme” value=”Reset” />
<input type=”hidden” name=”action” value=”reset” />
</p>
</form>
</div>
</div><?php
}function mytheme_add_mz_admin() {
global $themename, $shortname, $options;
if ( $_GET[‘page’] == basename(__FILE__) ) {
if ( ‘save’ == $_REQUEST[‘action’] ) {
foreach ($options as $value) {
update_option( $value[‘id’], $_REQUEST[ $value[‘id’] ] ); }
foreach ($options as $value) {
if( isset( $_REQUEST[ $value[‘id’] ] ) ) { update_option( $value[‘id’], $_REQUEST[ $value[‘id’] ] ); } else { delete_option( $value[‘id’] ); } }
header(“Location: themes.php?page=functions.php&saved=true”);
die;
} else if( ‘reset’ == $_REQUEST[‘action’] ) {
foreach ($options as $value) {
delete_option( $value[‘id’] ); }
header(“Location: themes.php?page=functions.php&reset=true”);
die;
}
}
add_theme_page($themename.” Options”, “Bens crazy Options”, ‘edit_themes’, basename(__FILE__), ‘mytheme_mz_admin’);
}and the ben.php has:
<div class=”module-notitle”>
<div>
<div>
<div>
” target=”_blank”><img src=”<?php echo $tn_mz_url_1; ?>” alt=”ads” border=”0″ />” target=”_blank”><img src=”<?php echo $tn_mz_url_2; ?>” alt=”ads” border=”0″ />
” target=”_blank”><img src=”<?php echo $tn_mz_url_3; ?>” alt=”ads” border=”0″ />
” target=”_blank”> title=”About”<?php echo $tn_mz_url_4; ?>” alt=”ads” border=”0″ />
” target=”_blank”><img src=”<?php echo $tn_mz_url_5; ?>” alt=”ads” border=”0″ />
title=”About”
</div>
</div></div>
</div>thought this would work as the funtion used for copying the inputed url is much the same as the echo funtion i want to edit to the title of the links.
but my lack of understanding of how the php is working…
Any link to a good tutorial on how to create a premium theme or just a simple explanation on what i need to edit to get these editable link titles.
I do have a few plugin’s installed but none relating to the functionality i am looking at. I am running wordpress 2.7.1.
thanks to wordpress and all the people behind it, havent left the computer for a couple of week now
The topic ‘creating admin options page – array – main top nav’ is closed to new replies.