Undefined index in debug mode
-
Hi all great people..
Now I have to ask you guys, as I cannot find the cause to my issue..I have a themed wp, and one of the functions is the portfolio.. This portfolio and the files to get this running, I have duplicated it and made the changes needed to get it running.
I think the files is more or less basic files for ‘a portfolio’. These are theme-init.php, theme-portfoliometa.php, single-portfolio.php & page-Portfolio2Cols.php.. These are duplicated and changed accordingly.
Everything look correct, but when i run debug in wp-admin, I see:
Notice: Undefined index: tz_meta_box_nonce in /home2/......./includes/theme-postmeta.php on line 323 Notice: Undefined index: br_meta_box_nonce in /home2/......./includes/theme-repairmeta.php on line 371
The code for theme-repairmeta.php is:
<?php /*----------------------------------------------------------------------------------- Add image upload metaboxes to Repair items -----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/ /* Define Metabox Fields /*-----------------------------------------------------------------------------------*/ $prefix = 'br_'; $meta_box_repair = array( 'id' => 'br-meta-box-repair', 'title' => __('Repair Options', 'theme1741'), 'page' => 'repair', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => __('Format', 'theme1741'), 'desc' => __('Choose post format that most fit your needs. ', 'theme1741'), 'id' => $prefix . 'repair_type', "type" => "select", 'std' => 'Image', 'options' => array('Image', 'Slideshow', 'Grid Gallery', 'Video', 'Audio') ), array( 'name' => __('Date', 'theme1741'), 'desc' => __('Input project end date. ', 'theme1741'), 'id' => $prefix . 'repair_date', 'type' => 'text', 'std' => '' ), array( 'name' => __('Client', 'theme1741'), 'desc' => __('Input project owner name. ', 'theme1741'), 'id' => $prefix . 'repair_client', 'type' => 'text', 'std' => '' ), array( 'name' => __('Info', 'theme1741'), 'desc' => __('Additional info for this repair item.', 'theme1741'), 'id' => $prefix . 'repair_info', 'type' => 'text', 'std' => '' ), array( 'name' => __('URL', 'theme1741'), 'desc' => __('Input the project URL (external link)', 'theme1741'), 'id' => $prefix . 'repair_url', 'type' => 'text', 'std' => '' ) ) ); $meta_box_repair_image = array( 'id' => 'br-meta-box-repair-image', 'title' => __('Image Uploader', 'theme1741'), 'page' => 'repair', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( "name" => '', "desc" => '', "id" => $prefix . "repair_upload_images", "type" => 'button', 'std' => 'Upload Images' ) ) ); $meta_box_repair_video = array( 'id' => 'br-meta-box-repair-video', 'title' => __('Video Settings', 'theme1741'), 'page' => 'repair', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => __('Embedded Code', 'theme1741'), 'desc' => __('Use this field to embed video from various websites (YouTube, Vimeo etc).', 'theme1741'), 'id' => $prefix . 'repair_embed_code', 'type' => 'textarea', 'std' => '' ) ), ); $meta_box_repair_audio = array( 'id' => 'br-meta-box-repair-audio', 'title' => __('Audio Settings', 'theme1741'), 'page' => 'repair', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( "name" => __('MP3 File URL','theme1741'), "desc" => __('The URL to the .mp3 audio file','theme1741'), "id" => $prefix."audio_mp3", "type" => "text", 'std' => '' ) ) ); add_action('admin_menu', 'br_add_box_repair'); /*-----------------------------------------------------------------------------------*/ /* Add metabox to edit page /*-----------------------------------------------------------------------------------*/ function br_add_box_repair() { global $meta_box_repair, $meta_box_repair_image, $meta_box_repair_video, $meta_box_repair_audio; add_meta_box($meta_box_repair['id'], $meta_box_repair['title'], 'br_show_box_repair', $meta_box_repair['page'], $meta_box_repair['context'], $meta_box_repair['priority']); add_meta_box($meta_box_repair_image['id'], $meta_box_repair_image['title'], 'br_show_box_repair_image', $meta_box_repair_image['page'], $meta_box_repair_image['context'], $meta_box_repair_image['priority']); add_meta_box($meta_box_repair_video['id'], $meta_box_repair_video['title'], 'br_show_box_repair_video', $meta_box_repair_video['page'], $meta_box_repair_video['context'], $meta_box_repair_video['priority']); add_meta_box($meta_box_repair_audio['id'], $meta_box_repair_audio['title'], 'br_show_box_repair_audio', $meta_box_repair_audio['page'], $meta_box_repair_audio['context'], $meta_box_repair_audio['priority']); } /*-----------------------------------------------------------------------------------*/ /* Callback function to show fields in meta box /*-----------------------------------------------------------------------------------*/ function br_show_box_repair() { global $meta_box_repair, $post; echo '<p style="padding:10px 0 0 0;">'.__('Please choose desired repair Format and fill additional fields. ', 'theme1741').'</p>'; // Use nonce for verification echo '<input type="hidden" name="br_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; foreach ($meta_box_repair['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); switch ($field['type']) { //If Text case 'text': echo '<tr style="border-top:1px solid #eeeeee;">', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style=" display:block; color:#999; margin:5px 0 0 0; line-height: 18px;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '" size="30" style="width:75%; margin-right: 20px; float:left;" />'; break; //If Button case 'button': echo '<input style="float: left;" type="button" class="button" name="', $field['id'], '" id="', $field['id'], '"value="', $meta ? $meta : $field['std'], '" />'; echo '</td>', '</tr>'; break; //If Select case 'select': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style=" display:block; color:#999; margin:5px 0 0 0; line-height: 18px;">'. $field['desc'].'</span></label></th>', '<td>'; echo'<select id="' . $field['id'] . '" name="'.$field['id'].'">'; foreach ($field['options'] as $option) { echo'<option'; if ($meta == $option ) { echo ' selected="selected"'; } echo'>'. $option .'</option>'; } echo'</select>'; break; } } echo '</table>'; } function br_show_box_repair_image() { global $meta_box_repair_image, $post; echo '<p style="padding:10px 0 0 0;">'.__('Please upload an image using the button below. Your images should be not thess than 620px width. Selecting post type "Slideshow" or "Grid Gallery" you will make the Featured Image to appear among others. ', 'theme1741').'</p>'; // Use nonce for verification echo '<input type="hidden" name="br_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; foreach ($meta_box_repair_image['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); switch ($field['type']) { //If Text case 'text': echo '<tr style="border-top:1px solid #eeeeee;">', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style=" display:block; color:#999; margin:5px 0 0 0; line-height: 18px;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '" size="30" style="width:75%; margin-right: 20px; float:left;" />'; break; //If Button case 'button': echo '<tr><td><input style="float: left;" type="button" class="button" name="', $field['id'], '" id="', $field['id'], '"value="', $meta ? $meta : $field['std'], '" />'; echo '</td>', '</tr>'; break; //If Select case 'select': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style=" display:block; color:#999; margin:5px 0 0 0;">'. $field['desc'].'</span></label></th>', '<td>'; echo'<select name="'.$field['id'].'">'; foreach ($field['options'] as $option) { echo'<option'; if ($meta == $option ) { echo ' selected="selected"'; } echo'>'. $option .'</option>'; } echo'</select>'; break; } } echo '</table>'; } function br_show_box_repair_video() { global $meta_box_repair_video, $post; // Use nonce for verification echo '<input type="hidden" name="br_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; foreach ($meta_box_repair_video['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); switch ($field['type']) { //If Text case 'text': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style="line-height:20px; display:block; color:#999; margin:5px 0 0 0;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'],'" size="30" style="width:75%; margin-right: 20px; float:left;" />'; break; //If textarea case 'textarea': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style="line-height:18px; display:block; color:#999; margin:5px 0 0 0;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<textarea name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" rows="8" cols="5" style="width:100%; margin-right: 20px; float:left;">', $meta ? $meta : $field['std'], '</textarea>'; break; //If Button case 'button': echo '<input style="float: left;" type="button" class="button" name="', $field['id'], '" id="', $field['id'], '"value="', $meta ? $meta : $field['std'], '" />'; echo '</td>', '</tr>'; break; } } echo '</table>'; } function br_show_box_repair_audio() { global $meta_box_repair_audio, $post; // Use nonce for verification echo '<input type="hidden" name="br_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; foreach ($meta_box_repair_audio['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); switch ($field['type']) { //If Text case 'text': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style="line-height:20px; display:block; color:#999; margin:5px 0 0 0;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'],'" size="30" style="width:75%; margin-right: 20px; float:left;" />'; break; //If textarea case 'textarea': echo '<tr style="border-top:1px solid #eeeeee;">', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style="line-height:18px; display:block; color:#999; margin:5px 0 0 0;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<textarea name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" rows="8" cols="5" style="width:100%; margin-right: 20px; float:left;">', $meta ? $meta : $field['std'], '</textarea>'; break; //If Button case 'button': echo '<input style="float: left;" type="button" class="button" name="', $field['id'], '" id="', $field['id'], '"value="', $meta ? $meta : $field['std'], '" />'; echo '</td>', '</tr>'; break; } } echo '</table>'; } add_action('save_post', 'br_save_data_repair'); /*-----------------------------------------------------------------------------------*/ /* Save data when post is edited /*-----------------------------------------------------------------------------------*/ function br_save_data_repair($post_id) { global $meta_box_repair, $meta_box_repair_video, $meta_box_repair_audio, $meta_box_repair_image; // verify nonce if (!wp_verify_nonce($_POST['br_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($meta_box_repair['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } foreach ($meta_box_repair_image['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } foreach ($meta_box_repair_video['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } foreach ($meta_box_repair_audio['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } } /*-----------------------------------------------------------------------------------*/ /* Queue Scripts /*-----------------------------------------------------------------------------------*/ function br_admin_scripts_repair() { wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_register_script('br-upload', get_template_directory_uri() . '/functions/js/upload-button.js', array('jquery','media-upload','thickbox')); wp_enqueue_script('br-upload'); } function br_admin_styles_repair() { wp_enqueue_style('thickbox'); } add_action('admin_print_scripts', 'br_admin_scripts_repair'); add_action('admin_print_styles', 'br_admin_styles_repair');
And theme-init.php is:
<?php add_action( 'after_setup_theme', 'my_setup' ); if ( ! function_exists( 'my_setup' ) ): function my_setup() { // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style(); // This theme uses post thumbnails if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9 add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 280, 185, true ); // Normal post thumbnails add_image_size( 'slider-post-thumbnail', 980, 393, true ); // Slider Thumbnail } // Add default posts and comments RSS feed links to head add_theme_support( 'automatic-feed-links' ); // custom menu support add_theme_support( 'menus' ); if ( function_exists( 'register_nav_menus' ) ) { register_nav_menus( array( 'header_menu' => 'Header Menu', 'footer_menu' => 'Footer Menu' ) ); } } endif; /* Slider */ function my_post_type_slider() { register_post_type( 'slider', array( 'label' => __('Slides'), 'singular_label' => __('Slide', 'theme1741'), '_builtin' => false, 'exclude_from_search' => true, // Exclude from Search Results 'capability_type' => 'page', 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => false, 'rewrite' => array( 'slug' => 'slide-view', 'with_front' => FALSE, ), 'query_var' => "slide", // This goes to the WP_Query schema 'menu_icon' => get_template_directory_uri() . '/includes/images/icon_slides.png', 'supports' => array( 'title', 'custom-fields', 'editor', 'thumbnail') ) ); } add_action('init', 'my_post_type_slider'); /* Portfolio */ function my_post_type_portfolio() { register_post_type( 'portfolio', array( 'label' => __('Portfolio'), 'singular_label' => __('Porfolio Item', 'theme1741'), '_builtin' => false, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, 'hierarchical' => true, 'capability_type' => 'page', 'menu_icon' => get_template_directory_uri() . '/includes/images/icon_portfolio.png', 'rewrite' => array( 'slug' => 'portfolio-view', 'with_front' => FALSE, ), 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments') ) ); register_taxonomy('portfolio_category', 'portfolio', array('hierarchical' => true, 'label' => 'Portfolio Categories', 'singular_name' => 'Category', "rewrite" => true, "query_var" => true)); } add_action('init', 'my_post_type_portfolio'); /* By Kenn Nielsen */ /* Repairs */ function my_post_type_repair() { register_post_type( 'repair', array( 'label' => __('Repairs'), 'singular_label' => __('Repair Item', 'theme1741'), '_builtin' => false, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, 'hierarchical' => true, 'capability_type' => 'page', 'menu_icon' => get_template_directory_uri() . '/includes/images/wrench.png', 'rewrite' => array( 'slug' => 'reparationer', 'with_front' => FALSE, ), 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'custom-fields') ) ); register_taxonomy('repair_category', 'repair', array('hierarchical' => true, 'label' => 'Repair Categories', 'singular_name' => 'Category', "rewrite" => true, "query_var" => true)); } add_action('init', 'my_post_type_repair'); /* Testimonial */ function my_post_type_testi() { register_post_type( 'testi', array( 'label' => __('Testimonial'), 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => false, 'menu_position' => 5, 'rewrite' => array( 'slug' => 'kundeudtalelser', 'with_front' => FALSE, ), 'supports' => array( 'title', 'custom-fields', 'thumbnail', 'editor') ) ); } add_action('init', 'my_post_type_testi'); /* By Kenn Nielsen */ /* Did You Know */ function my_post_type_didu() { register_post_type( 'didu', array( 'label' => __('Did You Know?'), 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => false, 'menu_position' => 5, 'rewrite' => array( 'slug' => 'didu-view', 'with_front' => FALSE, ), 'supports' => array( 'title', 'custom-fields', 'thumbnail', 'editor') ) ); } add_action('init', 'my_post_type_didu'); /* Services */ function my_post_type_services() { register_post_type( 'services', array( 'label' => __('Services'), 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => false, 'menu_position' => 5, 'rewrite' => array( 'slug' => 'services-view', 'with_front' => FALSE, ), 'supports' => array( 'title', 'thumbnail', 'editor') ) ); } add_action('init', 'my_post_type_services'); /* FAQs */ function phi_post_type_faq() { register_post_type('faq', array( 'label' => __('FAQs'), 'singular_label' => __('FAQ'), 'public' => false, 'show_ui' => true, '_builtin' => false, // It's a custom post type, not built in '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array("slug" => "faq"), // Permalinks 'query_var' => "faq", // This goes to the WP_Query schema 'supports' => array('title','author','editor'), 'menu_position' => 5, 'publicly_queryable' => true, 'exclude_from_search' => false, )); } add_action('init', 'phi_post_type_faq'); /* Our Team */ function my_post_type_team() { register_post_type( 'team', array( 'label' => __('Our Team'), 'singular_label' => __('Person', 'theme1741'), '_builtin' => false, 'exclude_from_search' => true, // Exclude from Search Results 'capability_type' => 'page', 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => false, 'menu_position' => 5, 'rewrite' => array( 'slug' => 'team-view', 'with_front' => FALSE, ), 'supports' => array( 'title', 'custom-fields', 'editor', 'excerpt', 'thumbnail') ) ); } add_action('init', 'my_post_type_team'); ?>
Any help will be grateful!
Cheers,
Kenn.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Undefined index in debug mode’ is closed to new replies.