1298 | | if ( $send ) |
1299 | | $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); |
1300 | | if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { |
1301 | | if ( !EMPTY_TRASH_DAYS ) { |
1302 | | $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>'; |
1303 | | } elseif ( !MEDIA_TRASH ) { |
1304 | | $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> |
1305 | | <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . " |
1306 | | <a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> |
1307 | | <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> |
1308 | | </div>"; |
1309 | | } else { |
1310 | | $delete = "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a> |
1311 | | <a href='" . wp_nonce_url( "post.php?action=untrash&post=$attachment_id", 'untrash-attachment_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>"; |
| 1298 | if ( !isset( $form_fields['buttons'] ) ) { |
| 1299 | |
| 1300 | $buttons = array(); |
| 1301 | |
| 1302 | if ( $send ) |
| 1303 | $buttons['send'] = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); |
| 1304 | if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { |
| 1305 | if ( !EMPTY_TRASH_DAYS ) { |
| 1306 | $buttons['delete'] = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>'; |
| 1307 | } elseif ( !MEDIA_TRASH ) { |
| 1308 | $buttons['delete'] = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> |
| 1309 | <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . " |
| 1310 | <a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> |
| 1311 | <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> |
| 1312 | </div>"; |
| 1313 | } else { |
| 1314 | $buttons['delete'] = "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a> |
| 1315 | <a href='" . wp_nonce_url( "post.php?action=untrash&post=$attachment_id", 'untrash-attachment_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>"; |
| 1316 | } |
1313 | | } else { |
1314 | | $delete = ''; |
| 1318 | |
| 1319 | if ( 'image' == $type ) { |
| 1320 | $calling_post_id = 0; |
| 1321 | if ( isset( $_GET['post_id'] ) ) |
| 1322 | $calling_post_id = absint( $_GET['post_id'] ); |
| 1323 | elseif ( isset( $_POST ) && count( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set |
| 1324 | $calling_post_id = $post->post_parent; |
| 1325 | if ( $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) { |
| 1326 | $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" ); |
| 1327 | $buttons['thumbnail'] = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>"; |
| 1328 | } |
| 1329 | } |
| 1330 | |
| 1331 | if ( count( $buttons ) ) |
| 1332 | $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>" . |
| 1333 | implode( ' ', apply_filters( 'media_item_buttons', $buttons ) ) . |
| 1334 | "</td></tr>\n" ); |
1317 | | $thumbnail = ''; |
1318 | | $calling_post_id = 0; |
1319 | | if ( isset( $_GET['post_id'] ) ) |
1320 | | $calling_post_id = absint( $_GET['post_id'] ); |
1321 | | elseif ( isset( $_POST ) && count( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set |
1322 | | $calling_post_id = $post->post_parent; |
1323 | | if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) { |
1324 | | $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" ); |
1325 | | $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>"; |
1326 | | } |
1327 | | |
1328 | | if ( ( $send || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) |
1329 | | $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $thumbnail $delete</td></tr>\n" ); |
1330 | | |