raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Media management action handler.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** Load WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 $parent_file = 'upload.php';
mp-wp_genesis 13 $submenu_file = 'upload.php';
mp-wp_genesis 14
mp-wp_genesis 15 wp_reset_vars(array('action'));
mp-wp_genesis 16
mp-wp_genesis 17 switch( $action ) :
mp-wp_genesis 18 case 'editattachment' :
mp-wp_genesis 19 $attachment_id = (int) $_POST['attachment_id'];
mp-wp_genesis 20 check_admin_referer('media-form');
mp-wp_genesis 21
mp-wp_genesis 22 if ( !current_user_can('edit_post', $attachment_id) )
mp-wp_genesis 23 wp_die ( __('You are not allowed to edit this attachment.') );
mp-wp_genesis 24
mp-wp_genesis 25 $errors = media_upload_form_handler();
mp-wp_genesis 26
mp-wp_genesis 27 if ( empty($errors) ) {
mp-wp_genesis 28 $location = 'media.php';
mp-wp_genesis 29 if ( $referer = wp_get_original_referer() ) {
mp-wp_genesis 30 if ( false !== strpos($referer, 'upload.php') || ( url_to_postid($referer) == $attachment_id ) )
mp-wp_genesis 31 $location = $referer;
mp-wp_genesis 32 }
mp-wp_genesis 33 if ( false !== strpos($location, 'upload.php') ) {
mp-wp_genesis 34 $location = remove_query_arg('message', $location);
mp-wp_genesis 35 $location = add_query_arg('posted', $attachment_id, $location);
mp-wp_genesis 36 } elseif ( false !== strpos($location, 'media.php') ) {
mp-wp_genesis 37 $location = add_query_arg('message', 'updated', $location);
mp-wp_genesis 38 }
mp-wp_genesis 39 wp_redirect($location);
mp-wp_genesis 40 exit;
mp-wp_genesis 41 }
mp-wp_genesis 42
mp-wp_genesis 43 // no break
mp-wp_genesis 44 case 'edit' :
mp-wp_genesis 45 $title = __('Edit Media');
mp-wp_genesis 46
mp-wp_genesis 47 if ( empty($errors) )
mp-wp_genesis 48 $errors = null;
mp-wp_genesis 49
mp-wp_genesis 50 if ( empty( $_GET['attachment_id'] ) ) {
mp-wp_genesis 51 wp_redirect('upload.php');
mp-wp_genesis 52 exit();
mp-wp_genesis 53 }
mp-wp_genesis 54 $att_id = (int) $_GET['attachment_id'];
mp-wp_genesis 55
mp-wp_genesis 56 if ( !current_user_can('edit_post', $att_id) )
mp-wp_genesis 57 wp_die ( __('You are not allowed to edit this attachment.') );
mp-wp_genesis 58
mp-wp_genesis 59 $att = get_post($att_id);
mp-wp_genesis 60
mp-wp_genesis 61 add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
mp-wp_genesis 62
mp-wp_genesis 63 require( 'admin-header.php' );
mp-wp_genesis 64
mp-wp_genesis 65 $parent_file = 'upload.php';
mp-wp_genesis 66 $message = '';
mp-wp_genesis 67 $class = '';
mp-wp_genesis 68 if ( isset($_GET['message']) ) {
mp-wp_genesis 69 switch ( $_GET['message'] ) :
mp-wp_genesis 70 case 'updated' :
mp-wp_genesis 71 $message = __('Media attachment updated.');
mp-wp_genesis 72 $class = 'updated fade';
mp-wp_genesis 73 break;
mp-wp_genesis 74 endswitch;
mp-wp_genesis 75 }
mp-wp_genesis 76 if ( $message )
mp-wp_genesis 77 echo "<div id='message' class='$class'><p>$message</p></div>\n";
mp-wp_genesis 78
mp-wp_genesis 79 ?>
mp-wp_genesis 80
mp-wp_genesis 81 <div class="wrap">
mp-wp_genesis 82 <?php screen_icon(); ?>
mp-wp_genesis 83 <h2><?php _e( 'Edit Media' ); ?></h2>
mp-wp_genesis 84
mp-wp_genesis 85 <form method="post" action="<?php echo clean_url( remove_query_arg( 'message' ) ); ?>" class="media-upload-form" id="media-single-form">
mp-wp_genesis 86 <div class="media-single">
mp-wp_genesis 87 <div id='media-item-<?php echo $att_id; ?>' class='media-item'>
mp-wp_genesis 88 <?php echo get_media_item( $att_id, array( 'toggle' => false, 'send' => false, 'delete' => false, 'show_title' => false, 'errors' => $errors ) ); ?>
mp-wp_genesis 89 </div>
mp-wp_genesis 90 </div>
mp-wp_genesis 91
mp-wp_genesis 92 <p class="submit">
mp-wp_genesis 93 <input type="submit" class="button-primary" name="save" value="<?php _e('Update Media'); ?>" />
mp-wp_genesis 94 <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
mp-wp_genesis 95 <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $att_id; ?>" />
mp-wp_genesis 96 <input type="hidden" name="action" value="editattachment" />
mp-wp_genesis 97 <?php wp_original_referer_field(true, 'previous'); ?>
mp-wp_genesis 98 <?php wp_nonce_field('media-form'); ?>
mp-wp_genesis 99 </p>
mp-wp_genesis 100 </form>
mp-wp_genesis 101
mp-wp_genesis 102 </div>
mp-wp_genesis 103
mp-wp_genesis 104 <?php
mp-wp_genesis 105
mp-wp_genesis 106 require( 'admin-footer.php' );
mp-wp_genesis 107
mp-wp_genesis 108 exit;
mp-wp_genesis 109
mp-wp_genesis 110 default:
mp-wp_genesis 111 wp_redirect( 'upload.php' );
mp-wp_genesis 112 exit;
mp-wp_genesis 113
mp-wp_genesis 114 endswitch;
mp-wp_genesis 115
mp-wp_genesis 116
mp-wp_genesis 117 ?>