Notice: Undefined variable: checked in ****** line 86

I’ve been going through this for hours now and I can’t figure out what I’m doing wrong.

Im getting this error : Notice: Undefined variable: checked in ******** line 86 of options.php

When attempting to make or update a post, if i tick the meta box, the post updates fine

This is from this code :

<?php }
function rand_stuff_meta_save( $post_id ) {
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST[‘rand_stuff_options_nonce’] ) && wp_verify_nonce( sanitize_key( $_POST[‘rand_stuff_options_nonce’] ), basename( __FILE__ ) ) ) ? true : false;

if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
return;
}

if ( ! current_user_can( ‘edit_post’, $post_id ) ) {
return $post_id;
}

// save template options
if ( isset( $_POST[‘rand_stuff_options’] ) ) {

$checked = array();

// sanitizing
if ( in_array( ‘do-this’, $_POST[‘rand_stuff_options’] ) !== false ) {

$checked[] .= ‘do-this’;

} else {

// if sanitization fails, pass an empty array.
$checked[] = array();
}
}
update_post_meta( $post_id, ‘rand_stuff_options’, $checked );
}

of which line 86 is

update_post_meta( $post_id, ‘rand_stuff_options’, $checked );

Im at a loss as to what it could be.

Read more here:: Notice: Undefined variable: checked in ****** line 86

Leave a Reply

Your email address will not be published. Required fields are marked *