Problem with meta box in Links

The hook you are after is edit_link (I couldn’t find any documentation). It’s fired from inside wp_insert_link (itself fired whenever a link is created or updated).

The action only passes one argument, the link’s ID, to the callback. So you would need to change 2 to 1, on your add_action call:

add_action( 'edit_link', 'mytheme_save_data', 10, 1 );

and remove the $post variable from your callback function:

function mytheme_save_data($post_id) {
     //Your function here
}

Other differences….

  1. In your metabox callback function (that displays the upload button etc). you use $object->ID. For links this should be $object->link_id.
  2. In your edit_link callback, you use $post to get the post type. This variable is no longer available to you and in any case links are not post types
  3. Because of the above, you’ll have to alter how you check permissions, I think what you want to check is current_user_can('manage_links')