I'm troubled with a custom metabox, could someone give me a helping hand? I've got a custom post type which uses it, but unfortunately it's not storing the data into the database.
Any clue?
add_action( 'add_meta_boxes', 'beef_meta_box_add' );
function beef_meta_box_add()
{
add_meta_box( 'beef-metabox', 'Custom Product Settings', 'beef_meta_box_cb', 'product', 'normal', 'high' );}
function beef_meta_box_cb()
{
global $post;
$values = get_post_custom( $post->ID );
$price = isset( $values['beef_meta_box_price'] ) ? $values['beef_meta_box_price'] : '';
wp_nonce_field( 'beef_meta_box_nonce', 'meta_box_nonce' );
?>
<p>
<label for="beef_meta_box_price">price n stuff</label>
<input type="text" name="beef_meta_box_price" id="beef_meta_box_price" value="<?php echo $price; ?>" />
</p>
<?php
}
add_action( 'save_post', 'beef_meta_box_save' );
function beef_meta_box_save( $post_id )
{
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'beef_meta_box_nonce' ) ) return;
if( !current_user_can( 'edit_post' ) ) return;
$allowed = array(
'a' => array(
'href' => array()
)
);
if( isset( $_POST['beef_meta_box_price'] ) )
update_post_meta( $post_id, 'beef_meta_box_price', wp_kses( $_POST['beef_meta_box_price'], $allowed ) );
}