[theme-reviewers] Need help with theme option page
Carla Izumi Bamford
decadent.muse.org at gmail.com
Fri Mar 15 16:36:13 UTC 2013
I'm trying to debug my function.php which is for the option page.
And I need some help figuring this out.
Notice: Undefined index: action in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 187
Notice: Undefined index: saved in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 198
Notice: Undefined index: reset in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 199
I also get another 3 errors when I try to save the option.
I added isset on some area which worked on some bugs and I'm not sure
how to fix the rest.
Notice: Undefined index: simplenotes in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 182
Notice: Undefined index: simplenotes in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 182
Notice: Undefined index: simplenotes in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 182
Notice: Undefined index: simplenotes in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 182
Notice: Undefined index: simplenotes in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 182
Notice: Undefined index: id in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 184
Notice: Undefined index: id in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 184
Notice: Undefined index: id in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 184
Notice: Undefined index: id in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 184
Notice: Undefined index: id in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 184
Notice: Undefined index: id in
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 184
Warning: Cannot modify header information - headers already sent by
(output started at
/home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php:182)
in /home/sites/heteml/users47/0/0/0/000/web/work/wordpress/wp-content/themes/simplenotes/functions.php
on line 185
Here's my function.php
<?php
function theme_styles()
{
wp_register_style( 'simplenotes-style',
get_template_directory_uri() . '/style.css',
array(),
'4.2',
'all' );
// enqueing:
wp_enqueue_style( 'simplenotes-style' );
}
add_action('wp_enqueue_scripts', 'theme_styles');
// ********************************* CALLING SC
*********************************
function simplenotes_load_scripts() {
if ( !is_admin() ) {
wp_register_script('simplenotes_custom_script',
get_template_directory_uri() . '/js/scroll.js', array('jquery') );
wp_enqueue_script('simplenotes_custom_script');
wp_register_script('simplenotes_custom_script2',
get_template_directory_uri() . '/js/custom.js', array('jquery') );
wp_enqueue_script('simplenotes_custom_script2');
wp_register_script('simplenotes_custom_script3',
get_template_directory_uri() . '/js/cufon-yui.js', array('jquery') );
wp_enqueue_script('simplenotes_custom_script3');
wp_register_script('simplenotes_custom_script4',
get_template_directory_uri() . '/js/Vegur_400-Vegur_700.font.js',
array('jquery') );
wp_enqueue_script('simplenotes_custom_script4');
}
}
add_action('init', 'simplenotes_load_scripts');
?>
<?php
add_theme_support('post-thumbnails');
add_theme_support('automatic-feed-links');
if ( ! isset( $content_width ) ) $content_width = 645;
// ********************************* CALLING MN
*********************************
add_action( 'init', 'simplenotes_register_menus' );
function simplenotes_register_menus() {
register_nav_menus( array(
'primary' => __( 'Primary Navigation', 'Simplenotes' ),
) );
}
// ********************************* CALLING RP
*********************************
function simplenotes_randomPosts($numPosts = 5){
query_posts(array('orderby' => 'rand', 'showposts' => $numPosts));
?> <ul> <?php
if (have_posts()) : while (have_posts()) : the_post();
?>
<li><a title="Permanent Link to <?php the_title(); ?>" href="<?php
the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
?> </ul> <?php
endif;
wp_reset_query();
}
// ********************************* CALLING WG
*********************************
register_sidebar(array(
'name' => 'Sidebar',
'before_widget' => '<div class="sidebarWrapper"><div
class="sidebarHeader"></div>',
'after_widget' => '</div><div class="sidebarFooter"></div></div>',
'before_title' => '<h3>',
'after_title' => '</h3><div class="sidebar">',
));
?>
<?php
// ********************************* CALLING TC
*********************************
if ( ! function_exists( 'simplenotes_comment' ) ) :
function simplenotes_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div class="comments" id="comment-<?php comment_ID(); ?>">
<div class="commentsData">
<div class="gravatar"><?php echo get_avatar( $comment, 50 ); ?></a></div>
<div class="author">
<div class="authorName"><?php comment_author_link() ?></div>
<div class="authordate"><a href="<?php echo esc_url(
get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( __(
'%1$s at %2$s', 'Simplenotes' ), get_comment_date(),
get_comment_time() ); ?></a> <?php edit_comment_link( __( '(Edit)',
'Simplenotes' ), ' ' ); ?></div>
</div>
<div class="clear"></div>
</div>
<div class="commentBody"><?php comment_text(); ?>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em>Your comment is awaiting moderation.</em>
<br />
<?php endif; ?>
</div>
<div class="commentReply"><?php comment_reply_link( array_merge(
$args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) )
); ?></div>
<div class="clear"></div>
</div>
<?php
break;
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p>Pingback: <?php comment_author_link(); ?><?php edit_comment_link(
__('(Edit)', 'Simplenotes'), ' ' ); ?></p>
<?php
break;
endswitch;
}
endif;
// ********************************* CALLING BC
*********************************
function simplenotes_get_breadcrumbs()
{
global $wp_query;
if ( !is_home() ){
// Start the UL
echo '<ul>';
// Add the Home link
echo '<li><a href="'. home_url() .'">'. get_bloginfo('name') .'</a></li>';
if ( is_category() )
{
$catTitle = single_cat_title( "", false );
$cat = get_cat_ID( $catTitle );
echo "<li> » ". get_category_parents( $cat, TRUE, "
» " ) ."</li>";
}
elseif ( is_archive() && !is_category() )
{
echo "<li> » Archives</li>";
}
elseif ( is_attachment() ) {
echo "<li> » Media Attachment</li>";
}
elseif ( is_search() ) {
echo "<li> » Search Results</li>";
}
elseif ( is_404() )
{
echo "<li> » 404 Not Found</li>";
}
elseif ( is_single() )
{
$category = get_the_category();
$category_id = get_cat_ID( $category[0]->cat_name );
echo '<li> » '. get_category_parents( $category_id,
TRUE, "</li><li> » " );
echo the_title('','', FALSE) ."</li>";
}
elseif ( is_page() )
{
$post = $wp_query->get_queried_object();
if ( $post->post_parent == 0 ){
echo "<li> » ".the_title('','', FALSE)."</li>";
} else {
$title = the_title('','', FALSE);
$ancestors = array_reverse( get_post_ancestors( $post->ID ) );
array_push($ancestors, $post->ID);
foreach ( $ancestors as $ancestor ){
if( $ancestor != end($ancestors) ){
echo '<li> » <a href="'. get_permalink($ancestor)
.'">'. strip_tags( apply_filters( 'single_post_title', get_the_title(
$ancestor ) ) ) .'</a></li>';
} else {
echo '<li> » '. strip_tags( apply_filters(
'single_post_title', get_the_title( $ancestor ) ) ) .'</li>';
}
}
}
}
// End the UL
echo "</ul>";
}
}
?>
<?php
$themename = "Simplenotes";
$shortname = "simplenotes";
$options = array (
array( "name" => "Theme option page",
"type" => "title"),
array( "type" => "open"),
array( "name" => "Twitter Account",
"desc" => "Enter your Twitter URL.",
"id" => $shortname."_twitter",
"type" => "text"),
array( "name" => "Facebook Account",
"desc" => "Enter your Facebook URL.",
"id" => $shortname."_facebook",
"type" => "text"),
array( "type" => "close")
);
function mytheme_add_admin() {
global $themename, $shortname, $options;
if ( isset($_GET['page']) && $_GET['page'] == basename(__FILE__) ) {
if(isset($_REQUEST['action']) == 'save') {
foreach ($options as $value) {
update_option( $shortname, $_REQUEST[ $shortname ] ); }
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", "".$themename." Options",
'edit_themes', basename(__FILE__), 'mytheme_admin');
}
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:#eef5fb; padding:10px;">
<?php break;
case "close":
?>
</table><br />
<?php break;
case "title":
?>
<table width="100%" border="0" style="background-color:#;
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_option( $value['id'] )
!= "") { echo get_option( $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 solid
#c0c0c0;"> </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_option(
$value['id'] ) != "") { echo get_option( $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 solid
#c0c0c0;"> </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_option(
$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 solid
#c0c0c0;"> </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 solid
#c0c0c0;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php break;
}
}
?>
<!--</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>
<?php
}
add_action('admin_menu', 'mytheme_add_admin');
?>
I know there is a support forum but I thought I'd get a better advise
since this place is specialized for theme developing.
Thanks!
More information about the theme-reviewers
mailing list