admin-content.php
5 years ago
folder-deactivate-form.php
6 years ago
folder-popup.php
5 years ago
general-settings.php
5 years ago
help.php
6 years ago
media-replace.php
5 years ago
recommended-plugins.php
5 years ago
update.php
6 years ago
upgrade-table.php
5 years ago
upgrade-to-pro.php
5 years ago
media-replace.php
93 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | |
| 4 | if (!current_user_can('upload_files')) |
| 5 | wp_die(esc_html__('You do not have permission to upload files.', 'enable-media-replace')); |
| 6 | |
| 7 | global $wpdb; |
| 8 | |
| 9 | $attachment_id = intval($_GET['attachment_id']); |
| 10 | $attachment = get_post($attachment_id); |
| 11 | |
| 12 | $size = 0; |
| 13 | if(isset($attachment->guid)) { |
| 14 | $size = $this->getFileSize($attachment_id); |
| 15 | } |
| 16 | //$url = wp_get_attachment_url($attachment_id); die; |
| 17 | $guid = $attachment->guid; |
| 18 | $url = wp_get_attachment_url($attachment_id); |
| 19 | if(!empty($url)) { |
| 20 | $guid = $url; |
| 21 | } |
| 22 | $guid = explode(".", $guid); |
| 23 | $ext = array_pop($guid); |
| 24 | $image_meta = wp_get_attachment_metadata($attachment_id); |
| 25 | $thumb = wp_get_attachment_image_src($attachment_id, 'thumbnail'); |
| 26 | $source_type = get_post_mime_type($attachment_id); |
| 27 | $url = ""; |
| 28 | if(isset($thumb[0])) { |
| 29 | $url = $thumb[0]; |
| 30 | } |
| 31 | $file_parts = pathinfo($attachment->guid); |
| 32 | $file_name = $file_parts['basename']; |
| 33 | ?> |
| 34 | <div class="wrap"> |
| 35 | <h2><?php esc_html_e("Replace Media"); ?></h2> |
| 36 | <div class="file-type warning replace-message"> |
| 37 | <?php esc_html_e("Replacement file is not the same filetype. This might cause unexpected issues", "folders"); ?> |
| 38 | </div> |
| 39 | <form enctype="multipart/form-data" method="POST" action="<?php echo esc_url($form_action) ?>"> |
| 40 | <div class="replace-media-page"> |
| 41 | <p><b><?php esc_html_e("Current File", "folders") ?></b>: <?php echo esc_attr($file_name) ?></p> |
| 42 | <p><?php esc_html_e("Upload a new file instead of the current one", "folders") ?></p> |
| 43 | <p><?php printf(__('Maximum file size: <strong>%s</strong>', 'enable-media-replace'), size_format(wp_max_upload_size())) ?></p> |
| 44 | <input type="hidden" name="attachment_id" value="<?php echo esc_attr__($attachment_id) ?>"/> |
| 45 | <input type="hidden" name="ext" id="file_ext" value="<?php echo esc_attr__($ext) ?>"/> |
| 46 | <div class="upload-media-box"> |
| 47 | |
| 48 | </div> |
| 49 | <div class=""> |
| 50 | <div class="current-image-box"> |
| 51 | <div class="file-option"><?php esc_html_e("Current File", "folders") ?></div> |
| 52 | <div class="preview-box"> |
| 53 | <?php if (wp_attachment_is('image', $attachment_id)) { ?> |
| 54 | <?php if(!empty($url)) { ?> |
| 55 | <img src="<?php echo esc_url($url) ?>" /> |
| 56 | <span class="image-size"><?php echo esc_attr($image_meta['width']." x ".$image_meta['height']) ?></span> |
| 57 | <?php } ?> |
| 58 | <?php } else { ?> |
| 59 | <span class="dashicons dashicons-media-document"></span> |
| 60 | <?php } ?> |
| 61 | </div> |
| 62 | <?php if(!empty($size)) { ?> |
| 63 | <div class="file-size"><?php echo esc_attr($size) ?></div> |
| 64 | <?php } ?> |
| 65 | </div> |
| 66 | <div class="new-image-box"> |
| 67 | <div class="file-option"><?php esc_html_e("New File", "folders") ?></div> |
| 68 | <div class="preview-box"> |
| 69 | <div class="container" > |
| 70 | <div class="container" > |
| 71 | <input type="file" name="new_media_file" id="media_file"> |
| 72 | |
| 73 | <!-- Drag and Drop container--> |
| 74 | <div class="upload-area" id="upload-file"> |
| 75 | <div class="drag-and-drop-title"> |
| 76 | <span>Click here to upload file</span> |
| 77 | </div> |
| 78 | </div> |
| 79 | </div> |
| 80 | </div> |
| 81 | </div> |
| 82 | <div class="file-size"></div> |
| 83 | </div> |
| 84 | <div class="clearfix"></div> |
| 85 | </div> |
| 86 | <div class="replace-media-buttons"> |
| 87 | <button type="submit" class="button button-primary" disabled><?php echo esc_html_e("Change File", "bolders") ?></button> |
| 88 | <button type="button" class="button button-secondary" onclick="history.back();"><?php echo esc_html_e("Cancel", "bolders") ?></button> |
| 89 | </div> |
| 90 | </div> |
| 91 | </form> |
| 92 | </div> |
| 93 |