Skip to content

Instantly share code, notes, and snippets.

@jayarjo
Created November 20, 2013 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayarjo/7558816 to your computer and use it in GitHub Desktop.
Save jayarjo/7558816 to your computer and use it in GitHub Desktop.
wp: re-attach images from other posts or pages
function f__manage_upload_columns($columns)
{
unset($columns['parent']);
$columns['better_parent'] = "Parent";
return $columns;
}
function a_0_2__manage_media_custom_column($column_name, $id)
{
$post = get_post($id);
if($column_name != 'better_parent') {
return;
}
if ( $post->post_parent > 0 ) {
if ( get_post($post->post_parent) ) {
$title =_draft_or_post_title($post->post_parent);
}
?>
<strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>, <?php echo get_the_time(__('Y/m/d')); ?>
<br />
<a class="hide-if-no-js" onclick="findPosts.open('media[]','<?php echo $post->ID ?>');return false;" href="#the-list"><?php _e('Re-Attach'); ?></a>
<?php
} else {
?>
<?php _e('(Unattached)'); ?><br />
<a class="hide-if-no-js" onclick="findPosts.open('media[]','<?php echo $post->ID ?>');return false;" href="#the-list"><?php _e('Attach'); ?></a>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment