ID.php
10 years ago
actions.php
10 years ago
alternate-text.php
10 years ago
attached-to.php
10 years ago
available-sizes.php
10 years ago
caption.php
10 years ago
description.php
10 years ago
dimensions.php
10 years ago
exif-data.php
10 years ago
file-name.php
10 years ago
file-size.php
10 years ago
full-path.php
10 years ago
height.php
10 years ago
mime-type.php
10 years ago
width.php
10 years ago
actions.php
72 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * CPAC_Column_Media_Actions |
| 5 | * |
| 6 | * @since 2.0 |
| 7 | */ |
| 8 | class CPAC_Column_Media_Actions extends CPAC_Column_Actions { |
| 9 | |
| 10 | /** |
| 11 | * @see CPAC_Column_Actions::get_actions() |
| 12 | * @since 2.3.4 |
| 13 | */ |
| 14 | public function get_actions( $id ) { |
| 15 | |
| 16 | global $wp_list_table; |
| 17 | |
| 18 | $post = get_post( $id ); |
| 19 | $att_title = _draft_or_post_title( $id ); |
| 20 | |
| 21 | $actions = array(); |
| 22 | |
| 23 | if ( $wp_list_table->detached ) { |
| 24 | if ( current_user_can( 'edit_post', $post->ID ) ) |
| 25 | $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>'; |
| 26 | if ( current_user_can( 'delete_post', $post->ID ) ) |
| 27 | if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
| 28 | $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; |
| 29 | } else { |
| 30 | $delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
| 31 | $actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
| 32 | } |
| 33 | $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>'; |
| 34 | if ( current_user_can( 'edit_post', $post->ID ) ) |
| 35 | $actions['attach'] = '<a href="#the-list" onclick="findPosts.open( \'media[]\',\''.$post->ID.'\' );return false;" class="hide-if-no-js">'.__( 'Attach' ).'</a>'; |
| 36 | } |
| 37 | else { |
| 38 | if ( current_user_can( 'edit_post', $post->ID ) && !$wp_list_table->is_trash ) |
| 39 | $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>'; |
| 40 | if ( current_user_can( 'delete_post', $post->ID ) ) { |
| 41 | if ( $wp_list_table->is_trash ) |
| 42 | $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; |
| 43 | elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) |
| 44 | $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; |
| 45 | if ( $wp_list_table->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { |
| 46 | $delete_ays = ( !$wp_list_table->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; |
| 47 | $actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
| 48 | } |
| 49 | } |
| 50 | if ( !$wp_list_table->is_trash ) { |
| 51 | $title =_draft_or_post_title( $post->post_parent ); |
| 52 | $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>'; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Filter the action links for each attachment in the Media list table. |
| 58 | * |
| 59 | * @since 2.8.0 |
| 60 | * |
| 61 | * @param array $actions An array of action links for each attachment. |
| 62 | * Default 'Edit', 'Delete Permanently', 'View'. |
| 63 | * @param WP_Post $post WP_Post object for the current attachment. |
| 64 | * @param bool $detached Whether the list table contains media not attached |
| 65 | * to any posts. Default true. |
| 66 | */ |
| 67 | $actions = apply_filters( 'media_row_actions', $actions, $post, $wp_list_table->detached ); |
| 68 | |
| 69 | return $actions; |
| 70 | } |
| 71 | } |
| 72 |