Changeset 55949
- Timestamp:
- 06/20/2023 03:45:23 PM (18 months ago)
- Location:
- trunk/src/wp-admin/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-media-list-table.php
r55911 r55949 749 749 $actions = array(); 750 750 751 if ( $this->detached ) { 752 if ( current_user_can( 'edit_post', $post->ID ) ) { 753 $actions['edit'] = sprintf( 754 '<a href="%s" aria-label="%s">%s</a>', 755 get_edit_post_link( $post->ID ), 751 if ( ! $this->is_trash && current_user_can( 'edit_post', $post->ID ) ) { 752 $actions['edit'] = sprintf( 753 '<a href="%s" aria-label="%s">%s</a>', 754 esc_url( get_edit_post_link( $post->ID ) ), 755 /* translators: %s: Attachment title. */ 756 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), 757 __( 'Edit' ) 758 ); 759 } 760 761 if ( current_user_can( 'delete_post', $post->ID ) ) { 762 if ( $this->is_trash ) { 763 $actions['untrash'] = sprintf( 764 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', 765 esc_url( wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ) ), 756 766 /* translators: %s: Attachment title. */ 757 esc_attr( sprintf( __( ' Edit “%s”' ), $att_title ) ),758 __( ' Edit' )767 esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ), 768 __( 'Restore' ) 759 769 ); 760 } 761 762 if ( current_user_can( 'delete_post', $post->ID ) ) { 763 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { 764 $actions['trash'] = sprintf( 765 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', 766 wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), 767 /* translators: %s: Attachment title. */ 768 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), 769 _x( 'Trash', 'verb' ) 770 ); 771 } else { 772 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; 773 $actions['delete'] = sprintf( 774 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', 775 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), 776 $delete_ays, 777 /* translators: %s: Attachment title. */ 778 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), 779 __( 'Delete Permanently' ) 780 ); 781 } 782 } 783 784 if ( get_permalink( $post->ID ) ) { 770 } elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { 771 $actions['trash'] = sprintf( 772 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', 773 esc_url( wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ) ), 774 /* translators: %s: Attachment title. */ 775 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), 776 _x( 'Trash', 'verb' ) 777 ); 778 } 779 780 if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { 781 $show_confirmation = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; 782 783 $actions['delete'] = sprintf( 784 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', 785 esc_url( wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ) ), 786 $show_confirmation, 787 /* translators: %s: Attachment title. */ 788 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), 789 __( 'Delete Permanently' ) 790 ); 791 } 792 } 793 794 $attachment_url = wp_get_attachment_url( $post->ID ); 795 796 if ( ! $this->is_trash ) { 797 $permalink = get_permalink( $post->ID ); 798 799 if ( $permalink ) { 785 800 $actions['view'] = sprintf( 786 801 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', 787 get_permalink( $post->ID),802 esc_url( $permalink ), 788 803 /* translators: %s: Attachment title. */ 789 804 esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), … … 792 807 } 793 808 794 if ( current_user_can( 'edit_post', $post->ID ) ) { 795 $actions['attach'] = sprintf( 796 '<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', 797 $post->ID, 798 /* translators: %s: Attachment title. */ 799 esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), 800 __( 'Attach' ) 801 ); 802 } 803 } else { 804 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { 805 $actions['edit'] = sprintf( 806 '<a href="%s" aria-label="%s">%s</a>', 807 get_edit_post_link( $post->ID ), 808 /* translators: %s: Attachment title. */ 809 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), 810 __( 'Edit' ) 811 ); 812 } 813 814 if ( current_user_can( 'delete_post', $post->ID ) ) { 815 if ( $this->is_trash ) { 816 $actions['untrash'] = sprintf( 817 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', 818 wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ), 819 /* translators: %s: Attachment title. */ 820 esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ), 821 __( 'Restore' ) 822 ); 823 } elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { 824 $actions['trash'] = sprintf( 825 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', 826 wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), 827 /* translators: %s: Attachment title. */ 828 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), 829 _x( 'Trash', 'verb' ) 830 ); 831 } 832 833 if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { 834 $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; 835 $actions['delete'] = sprintf( 836 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', 837 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), 838 $delete_ays, 839 /* translators: %s: Attachment title. */ 840 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), 841 __( 'Delete Permanently' ) 842 ); 843 } 844 } 845 846 if ( ! $this->is_trash ) { 847 if ( get_permalink( $post->ID ) ) { 848 $actions['view'] = sprintf( 849 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', 850 get_permalink( $post->ID ), 851 /* translators: %s: Attachment title. */ 852 esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), 853 __( 'View' ) 854 ); 855 } 856 857 $actions['copy'] = sprintf( 858 '<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>', 859 esc_url( wp_get_attachment_url( $post->ID ) ), 860 /* translators: %s: Attachment title. */ 861 esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ), 862 __( 'Copy URL' ), 863 __( 'Copied!' ) 864 ); 865 866 $actions['download'] = sprintf( 867 '<a href="%s" aria-label="%s" download>%s</a>', 868 esc_url( wp_get_attachment_url( $post->ID ) ), 869 /* translators: %s: Attachment title. */ 870 esc_attr( sprintf( __( 'Download “%s”' ), $att_title ) ), 871 __( 'Download file' ) 872 ); 873 } 809 $actions['copy'] = sprintf( 810 '<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>', 811 esc_url( $attachment_url ), 812 /* translators: %s: Attachment title. */ 813 esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ), 814 __( 'Copy URL' ), 815 __( 'Copied!' ) 816 ); 817 } 818 819 $actions['download'] = sprintf( 820 '<a href="%s" aria-label="%s" download>%s</a>', 821 esc_url( $attachment_url ), 822 /* translators: %s: Attachment title. */ 823 esc_attr( sprintf( __( 'Download “%s”' ), $att_title ) ), 824 __( 'Download file' ) 825 ); 826 827 if ( $this->detached && current_user_can( 'edit_post', $post->ID ) ) { 828 $actions['attach'] = sprintf( 829 '<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', 830 $post->ID, 831 /* translators: %s: Attachment title. */ 832 esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), 833 __( 'Attach' ) 834 ); 874 835 } 875 836 … … 880 841 * 881 842 * @param string[] $actions An array of action links for each attachment. 882 * Default 'Edit', 'Delete Permanently', 'View'. 843 * Includes 'Edit', 'Delete Permanently', 'View', 844 * 'Copy URL' and 'Download file'. 883 845 * @param WP_Post $post WP_Post object for the current attachment. 884 846 * @param bool $detached Whether the list table contains media not attached -
trunk/src/wp-admin/includes/meta-boxes.php
r55414 r55949 470 470 if ( current_user_can( 'delete_post', $post->ID ) ) { 471 471 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { 472 echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Move to Trash' ) . '</a>'; 472 printf( 473 '<a class="submitdelete deletion" href="%1$s">%2$s</a>', 474 get_delete_post_link( $post->ID ), 475 __( 'Move to Trash' ) 476 ); 473 477 } else { 474 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; 475 echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete permanently' ) . '</a>'; 478 $show_confirmation = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; 479 480 printf( 481 '<a class="submitdelete deletion"%1$s href="%2$s">%3$s</a>', 482 $show_confirmation, 483 get_delete_post_link( $post->ID, '', true ), 484 __( 'Delete permanently' ) 485 ); 476 486 } 477 487 }
Note: See TracChangeset
for help on using the changeset viewer.