Hallo zusammen,
kurze Frage,
ich bastel gerade an dem Theme Scarlett. Ich hätte gerne, dass der Optionsbereich im Backend nicht unter der Rubrik "DESIGN" gelistet wird, sondern die Optionen sollen unter "BENUTZER" laufen.
Könntet Ihr mir bitte helfen - was muss im Code dafür geändert werden?
PHP
<?php
function scar_options(){
$themename = "OSS V3";
$shortname = "scar";
$zm_categories_obj = get_categories('hide_empty=0');
$zm_categories = array();
foreach ($zm_categories_obj as $zm_cat) {
$zm_categories[$zm_cat->cat_ID] = $zm_cat->category_nicename;
}
$categories_tmp = array_unshift($zm_categories, "Select a category:");
$number_entries = array("Select a Number:","1","2","3","4","5","6","7","8","9","10", "12","14", "16", "18", "20" );
$options = array (
array( "name" => "Sliding Panel Settings",
"type" => "heading",
"desc" => "This section customizes the sliding panel area and the number of panels to be displayed.",
),
array( "name" => "Sliding Panel category",
"desc" => "Select the category that you would like to have displayed on the sliding.",
"id" => $shortname."_gldcat",
"std" => "Select a category:",
"type" => "select",
"options" => $zm_categories),
array( "name" => "Number of sliding panels",
"desc" => "Select the number of panels to display .",
"id" => $shortname."_gldct",
"std" => "Select a Number:",
"type" => "select",
"options" => $number_entries),
array( "name" => "125 x 125 banner Settings",
"type" => "heading",
"desc" => "You can setup three 125 x 125 banners on your sidebar from here",
),
array("name" => "Banner-1 Image",
"desc" => "Enter your 125 x 125 banner image url here.",
"id" => $shortname."_banner1",
"std" => "[URL]http://web2feel.com/images/TF.jpg[/URL]",
"type" => "text"),
array("name" => "Banner-1 Url",
"desc" => "Enter the banner-1 url here.",
"id" => $shortname."_url1",
"std" => "Banner-1 url",
"type" => "text"),
array("name" => "Banner-2 Image",
"desc" => "Enter your 125 x 125 banner image url here.",
"id" => $shortname."_banner2",
"std" => "[URL]http://web2feel.com/images/TF.jpg[/URL]",
"type" => "text"),
array("name" => "Banner-2 Url",
"desc" => "Enter the banner-2 url here.",
"id" => $shortname."_url2",
"std" => "Banner-2 url",
"type" => "text"),
array("name" => "Banner-3 Image",
"desc" => "Enter your 125 x 125 banner image url here.",
"id" => $shortname."_banner3",
"std" => "[URL]http://web2feel.com/images/TF.jpg[/URL]",
"type" => "text"),
array("name" => "Banner-3 Url",
"desc" => "Enter the banner-3 url here.",
"id" => $shortname."_url3",
"std" => "Banner-3 url",
"type" => "text"),
array("name" => "Banner-4 Image",
"desc" => "Enter your 125 x 125 banner image url here.",
"id" => $shortname."_banner4",
"std" => "[URL]http://web2feel.com/images/TF.jpg[/URL]",
"type" => "text"),
array("name" => "Banner-4 Url",
"desc" => "Enter the banner-4 url here.",
"id" => $shortname."_url4",
"std" => "Banner-4 url",
"type" => "text"),
);
update_option('scar_template',$options);update_option('scar_themename',$themename);update_option('scar_shortname',$shortname);
}
add_action('init','scar_options');
function mytheme_add_admin() {
$options = get_option('scar_template'); $themename = get_option('scar_themename');$shortname = get_option('scar_shortname');
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=controlpanel.php&saved=true");
die;
} else if( 'reset' == $_REQUEST['action'] ) {
foreach ($options as $value) {
delete_option( $value['id'] );
update_option( $value['id'], $value['std'] );}
header("Location: themes.php?page=controlpanel.php&reset=true");
die;
}
}
add_theme_page($themename." Options", "$themename Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
function mytheme_admin() {
$options = get_option('scar_template');$themename = get_option('scar_themename');$shortname = get_option('scar_shortname');
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
?>
<div class="wrap">
<h2><b><?php echo $themename; ?> theme options</b></h2>
<form method="post">
<table class="optiontable">
<?php foreach ($options as $value) {
if ($value['type'] == "text") { ?>
<tr align="left">
<th scope="row"><?php echo $value['name']; ?>:</th>
<td>
<input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" size="40" />
</td>
</tr>
<tr><td colspan=2> <small><?php echo $value['desc']; ?> </small> <hr /></td></tr>
<?php } elseif ($value['type'] == "textarea") { ?>
<tr align="left">
<th scope="row"><?php echo $value['name']; ?>:</th>
<td>
<textarea name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" cols="50" rows="8"/>
<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes (get_settings( $value['id'] )); }
else { echo $value['std'];
} ?>
</textarea>
</td>
</tr>
<tr><td colspan=2> <small><?php echo $value['desc']; ?> </small> <hr /></td></tr>
<?php } elseif ($value['type'] == "select") { ?>
<tr align="left">
<th scope="top"><?php echo $value['name']; ?>:</th>
<td>
<select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
<option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; }?>><?php echo $option; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr><td colspan=2> <small><?php echo $value['desc']; ?> </small> <hr /></td></tr>
<?php } elseif ($value['type'] == "heading") { ?>
<tr valign="top">
<td colspan="2" style="text-align: left;"><h2 style="color:green;"><?php echo $value['name']; ?></h2></td>
</tr>
<tr><td colspan=2> <small> <p style="color:red; margin:0 0;" > <?php echo $value['desc']; ?> </P> </small> <hr /></td></tr>
<?php } ?>
<?php
}
?>
</table>
<p class="submit">
<input name="save" type="submit" value="Save changes" />
<input type="hidden" name="action" value="save" />
</p>
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>
<p> For more <a href="[URL]http://www.web2feel.com[/URL]" >wordpress themes </a>and support, contact the <a href="[URL]http://web2feel.com/forum/[/URL]" > support forums </a> </p>
<?php
}
add_action('admin_menu', 'mytheme_add_admin'); ?>
Alles anzeigen