Media: Allow hiding of ‘View attachment page’ link in media modal.

If an empty string is supplied to the `attachment_link` filter the ‘View attachment page’ link will be hidden in the media modal.
Props limera1n, garrett-eclipse, joemcgill, Mista-Flo, hellofromTonya.
Fixes #48325.


git-svn-id: https://develop.svn.wordpress.org/trunk@49222 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Anthony Burchell 2020-10-20 02:27:39 +00:00
parent 16468a23ac
commit b95d64f62a
2 changed files with 13 additions and 3 deletions

View File

@ -452,6 +452,8 @@ function get_attachment_link( $post = null, $leavename = false ) {
* Filters the permalink for an attachment.
*
* @since 2.0.0
* @since 5.6.0 Providing an empty string will now disable
* the view attachment page link on the media modal.
*
* @param string $link The attachment's permalink.
* @param int $post_id Attachment ID.

View File

@ -514,11 +514,19 @@ function wp_print_media_templates() {
</div>
<div class="actions">
<a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a>
<# if ( data.can.save ) { #> |
<# if ( data.link ) { #>
<a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a>
<# } #>
<# if ( data.can.save ) { #>
<# if ( data.link ) { #>
<span class="links-separator">|</span>
<# } #>
<a href="{{ data.editLink }}"><?php _e( 'Edit more details' ); ?></a>
<# } #>
<# if ( ! data.uploading && data.can.remove ) { #> |
<# if ( ! data.uploading && data.can.remove ) { #>
<# if ( data.link || data.can.save ) { #>
<span class="links-separator">|</span>
<# } #>
<?php if ( MEDIA_TRASH ) : ?>
<# if ( 'trash' === data.status ) { #>
<button type="button" class="button-link untrash-attachment"><?php _e( 'Restore from Trash' ); ?></button>