I created a custom theme for Wordpress and customized the backend to have a white label look and feel. I am able to load up the options page and save settings (which push to a CSS file) from the Administrator menu.
When I try to access this from the Editor level it attempts to load: http://MYURL.COM/wp-admin/functions.php
rather than http://MYURL.COM/wp-admin/admin.php?page=functions.php
I was originally able to pull up the options menu with the Editor account. When I would attempt to save it, I would receive the error that I couldn't save. While changing access levels the problem seems to have gotten worse.
I read through 3-4 pages of search and couldn't find something that was relavant to my issue, sorry!
Below is the code for my functions.php:
<?php
$themename = "Sleek v0.1";
$shortname = "sleek";
$options = array (
/*Declare the variables needed*/
array( "name" => "General Settings",
"type" => "title"),
array( "type" => "open"),
array( "name" => "Call Analytics Number",
"desc" => "This is the call tracking number for the marketing campaign.",
"id" => $shortname."_phone_number",
"type" => "text",
"std" => "(888) 555-5555"),
array( "name" => "MerchEngines Customer ID",
"desc" => "This is the Customer ID in the MerchEngines dashboard",
"id" => $shortname."_cust_id",
"type" => "text",
"std" => "0000"),
array( "name" => "Navigation",
"type" => "title"),
array( "type" => "open"),
array( "name" => "Navigation Bar Background Color",
"desc" => "This is the background color for the top navigation bar and footer. (Default: #000000)",
"id" => $shortname."_navBarColor",
"type" => "text",
"std" => "#000000"),
array( "name" => "Navigation Bar Text Color",
"desc" => "This is the text for the top navigation bar and footer. (Default: #ffffff)",
"id" => $shortname."_navTextColor",
"type" => "text",
"std" => "#ffffff"),
array( "name" => "Current Tab Color",
"desc" => "This is the tab color for the current page (Default: #920000)",
"id" => $shortname."_currentTabColor",
"type" => "text",
"std" => "#920000"),
array( "name" => "Hover Tab Color",
"desc" => "This is the tab color for the current page. (Default: #920000)",
"id" => $shortname."_hoverTabColor",
"type" => "text",
"std" => "#c00000"),
array( "name" => "Call to Action",
"type" => "title"),
array( "type" => "open"),
array( "name" => "Stand Out Font Color",
"desc" => "This is the contrast color used by the CTA phone numbers and the stand out wording within the inForm. (Default: #c00000)",
"id" => $shortname."_CTAstandOutColor",
"type" => "text",
"std" => "#c00000"),
array( "name" => "Base Color",
"desc" => "This is the base color used by the CTA text and the base wording within the inForm. (Default: #000000)",
"id" => $shortname."_CTAbaseColor",
"type" => "text",
"std" => "#000000"),
array( "name" => "Checkmark Color",
"desc" => "This is the color of the 'Feature' checkmarks. Color options are: red, darkred, blue, darkblue, green, darkgreen, purple, and orange (Default: red)",
"id" => $shortname."_checkMarkColor",
"type" => "text",
"std" => "red"),
array( "name" => "Bottom Call to Action Text",
"desc" => "This is the bottom call to action text following the phone number. (Default: for more information!)",
"id" => $shortname."_bottomCTAText",
"type" => "text",
"std" => "for more information!"),
array( "name" => "Test Drop Down",
"desc" => "Test for a drop down box.",
"id" => $shortname."_test_dropdown",
"type" => "select",
"std" => "red",
"options" => "red, green, blue"),
array( "type" => "close")
);
function mytheme_add_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_menu_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
function mytheme_add_init() {
$file_dir=get_bloginfo('template_directory');
wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
}
function mytheme_admin() {
global $themename, $shortname, $options;
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><?php echo $themename; ?> Settings</h2>
<form method="post">
<?php foreach ($options as $value) {
switch ( $value['type'] ) {
case "open":
?>
<table width="100%" border="0" style="background-color:#cdcdcd; padding:10px;">
<?php break;
case "close":
?>
</table><br />
<?php break;
case "title":
?>
<table width="100%" border="0" style="background-color:#868686; padding:5px 10px;"><tr>
<td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
</tr>
<?php break;
case 'text':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><input style="width:400px;" 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']; } ?>" /></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php
break;
case 'textarea':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:400px; height:200px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?></textarea></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php
break;
case 'select':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><select style="width:240px;" 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"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php
break;
case "checkbox":
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
</td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php break;
}
}
?>
<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>
</div>
<?php
}add_action('admin_menu', 'mytheme_add_admin');
add_action('admin_init', 'mytheme_add_init');
?>
register_setting()
call, and youradd_theme_page()
call?functions.php
referenced in the example URL refer to your theme's functions file, that page should not be called directly like that.. (the page should be loaded via a callback function in that file instead)..