//comenzamos con el panel
add_action('admin_init', 'down_add_custom_box', 1);
function down_add_custom_box() {
add_meta_box(
'id_down', //variable del serv
'Uploaded', //nombre del servidor
'wp_box_down',
'post'
);
}
function wp_box_down($post) {
wp_nonce_field(plugin_basename(__FILE__), 'down_noncename');
if($_GET['action']=='edit'){//edicion
$down=get_post_meta($post->ID,'down',true);
//imprimimos
echo'<input name="down" type="text" value="'.$down.'" class="regular-text" style="width:100%" />';
}else{
echo'<input name="down" type="text" value="" class="regular-text" style="width:100%" />';
}
}
add_action('save_post', 'guardar_down');
function guardar_down($post_id){
if ( !wp_verify_nonce( $_POST['down_noncename'], plugin_basename(__FILE__) ) )
return $post_id;
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return $post_id;
if ( !current_user_can( 'edit_post', $post_id ) )
return $post_id;
delete_post_meta($post_id, 'down');
if(!empty($_POST['down'])){
add_post_meta($post_id, 'down', esc_attr($_POST['down']));
}
}