* @copyright Måns Jonasson 13 sep 2010 * @version $Revision: 2303 $ | $Date: 2010-09-13 11:12:35 +0200 (ma, 13 sep 2010) $ * @package wordpress * @subpackage enable-media-replace * */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. if (!current_user_can('upload_files')) wp_die( esc_html__('You do not have permission to upload files.', 'enable-media-replace') ); global $wpdb; //$emr = EnableMediaReplacePlugin::get(); $table_name = $wpdb->prefix . "posts"; $attachment_id = intval($_GET['attachment_id']); $attachment = get_post($attachment_id); if (! emr()->checkImagePermission($attachment)) { wp_die( esc_html__('You do not have permission to upload files for this author.', 'enable-media-replace') ); } $replacer = new Replacer($attachment_id); $file = $replacer->getSourceFile(); $filepath = $file->getFullPath(); $filename = $file->getFileName(); $filetype = $file->getExtension(); $source_mime = get_post_mime_type($attachment_id); $uiHelper = emr()->uiHelper(); $uiHelper->setPreviewSizes(); $uiHelper->setSourceSizes($attachment_id); $defaults = array( 'replace_type' => 'replace', 'timestamp_replace' => \EnableMediaReplace\Replacer::TIME_UPDATEMODIFIED, 'custom_date' => date("Y-m-d H:i:s"), 'new_location' => false, 'new_location_dir' => false, ); $settings = get_option('enable_media_replace', $defaults); $settings = array_merge($defaults, $settings); // might miss some ?>