Make WordPress Core


Ignore:
Timestamp:
03/05/2015 05:34:40 AM (8 years ago)
Author:
wonderboymusic
Message:

Allow attachments to be Detached from their parent in media grid and list modes.

See #6820.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r31220 r31619  
    139139        if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) )
    140140            return 'attach';
     141
     142        if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) )
     143            return 'detach';
    141144
    142145        if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
     
    407410                    echo $title;
    408411                } ?></strong>,
    409                 <?php echo get_the_time( __( 'Y/m/d' ) ); ?>
     412                <?php echo get_the_time( __( 'Y/m/d' ) ); ?><br />
     413                <?php
     414                if ( $user_can_edit ):
     415                    $detach_url = add_query_arg( array(
     416                        'parent_post_id' => $post->post_parent,
     417                        'media[]' => $post->ID,
     418                        '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
     419                    ), 'upload.php' ); ?>
     420                <a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url ?>"><?php _e( 'Detach' ); ?></a>
     421                <?php endif; ?>
    410422            </td>
    411423<?php
Note: See TracChangeset for help on using the changeset viewer.