Erro de índice indefinido na metabox de postagem personalizada

Estou recebendo esse erro com minha metabox de postagem personalizada. A postagem personalizada e a metaboxa funcionam bem, mas se eu tiver uma debugging e quando eu tento salvar qualquer outra página ou publicação, recebo um erro:

Notice: Undefined index: iam_video_select in C:\xampp\htdocs\Iam\wp-content\themes\Iam\inc\classs\Custom_Meta_Boxes.class.php on line 149 Notice: Undefined index: iam_video_url in C:\xampp\htdocs\Iam\wp-content\themes\Iam\inc\classs\Custom_Meta_Boxes.class.php on line 149 Notice: Undefined index: iam_link in C:\xampp\htdocs\Iam\wp-content\themes\Iam\inc\classs\Custom_Meta_Boxes.class.php on line 149 

Meu código:

  'video-meta-box', 'title' => __( 'Video', 'iamtheme' ), 'pages' => 'post', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => 'Select Video Host', 'id' => PTHEME . '_video_select', 'type' => 'select', 'options' => array( 'Youtube', 'Vimeo', 'Self hosted' ) ), array( 'name' => 'URL', 'desc' => 'Enter video url here.', 'id' => PTHEME . '_video_url', 'std' => 'Default value here.', 'type' => 'text' ) ) ); //Link meta box $meta_boxes[] = array( 'id' => 'link-meta-box', 'title' => __( 'Link', 'iamtheme' ), 'pages' => 'post', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => 'Link', 'desc' => 'Enter your url here.', 'id' => PTHEME . '_link', 'std' => 'Default value here.', 'type' => 'text' ) ) ); /** * */ class Custom_Meta_Boxes{ public $_meta_box; public function __construct( $meta_box ){ $this->_meta_box = $meta_box; add_action( 'add_meta_boxes', array( $this, 'iam_add_meta_box' ) ); add_action( 'save_post', array( $this, 'iam_save_meta_box_data' ) ); } /** * Adds a meta box to the post editing screen */ public function iam_add_meta_box(){ add_meta_box( $this->_meta_box['id'], $this->_meta_box['title'], array( &$this, 'iam_display_custom_meta_box' ), $this->_meta_box['pages'], $this->_meta_box['context'], $this->_meta_box['priority'] ); } /** * Render Meta Box content. */ public function iam_display_custom_meta_box() { global $post; // Add an nonce field so we can check for it later. wp_nonce_field( 'iam_nonce_check', 'iam_nonce_check_value' ); echo '
'; foreach ( $this->_meta_box['fields'] as $field) { // get current post meta data $meta = get_post_meta( $post->ID, $field['id'], true ); echo '
'; echo ''; switch ( $field['type'] ) { case 'text': echo ''; echo '

' , $field['desc'] , '

'; break; case 'textarea': echo ''; echo '

' , $field['desc'] , '

'; break; case 'select': echo ''; foreach ( $field['options'] as $option ) { echo '', $option, ''; } echo ''; break; case 'radio': foreach ( $field['options'] as $option ) { echo '', $option['name']; } break; case 'checkbox': echo ''; break; } echo '
'; } echo '
'; } /** * Save the meta when the post is saved. */ public function iam_save_meta_box_data( $post_id ){ if( $this->iam_user_can_save( $post_id, 'iam_nonce_check_value' ) ) { // Checks for input and sanitizes/saves if needed foreach ( $this->_meta_box['fields'] as $field ) { $old = get_post_meta( $post_id, $field['id'], true ); $new = sanitize_text_field( $_POST[ $field['id'] ] ); if ( $new && $new != $old ) { update_post_meta( $post_id, $field['id'], $new ); } elseif ( '' == $new && $old ) { delete_post_meta( $post_id, $field['id'], $old ); } } } } /** * Determines whether or not the current user has the ability to save meta * data associated with this post. * * @param int $post_id The ID of the post being save * @param bool Whether or not the user has the ability to save this post. */ public function iam_user_can_save( $post_id, $nonce ){ // Checks save status $is_autosave = wp_is_post_autosave( $post_id ); $is_revision = wp_is_post_revision( $post_id ); $is_valid_nonce = ( isset( $_POST[ $nonce ] ) && wp_verify_nonce( $_POST[ $nonce ], 'iam_nonce_check' ) ) ? 'true' : 'false'; // Return true if the user is able to save; otherwise, false. return ! ( $is_autosave || $is_revision ) && $is_valid_nonce; } } // Instantiate theme if ( class_exists( 'Custom_Meta_Boxes' ) ){ foreach ( $meta_boxes as $meta_box ) { $my_box = new Custom_Meta_Boxes( $meta_box ); } } ?>

Solutions Collecting From Web of "Erro de índice indefinido na metabox de postagem personalizada"