Make WordPress Core


Ignore:
Timestamp:
03/10/2022 06:22:57 PM (4 years ago)
Author:
davidbaumwald
Message:

Media: Add a "Copy URL to clipboard" function to the list table view.

Previously, a button was added to the modal view for a single media item in the "grid" view to copy the file URL to the user's clipboard. This change adds a similar function to the "list" view for each media item.

Follow-up to [48232].

Props pbiron, ravipatel, alexstine, afercia.
Fixes #54426.

File:
1 edited

Legend:

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

    r51903 r52842  
    807807                    __( 'View' )
    808808                );
     809
     810                $actions['copy'] = sprintf(
     811                    '<span class="copy-to-clipboard-container"><button type="button" class="button-link copy-attachment-url media-library" data-clipboard-text="%s" aria-label="%s">%s</button><span class="success hidden" aria-hidden="true">%s</span></span>',
     812                    esc_url( wp_get_attachment_url( $post->ID ) ),
     813                    /* translators: %s: Attachment title. */
     814                    esc_attr( sprintf( __( 'Copy &#8220;%s&#8221; URL to clipboard' ), $att_title ) ),
     815                    __( 'Copy URL to clipboard' ),
     816                    __( 'Copied!' )
     817                );
    809818            }
    810819        }
Note: See TracChangeset for help on using the changeset viewer.