`);
$('#remove_background_button').attr('disabled', false)
$('input[type=radio][name=background_type]').attr('disabled', false)
$('input[type=radio][name=compression_level]').attr('disabled', false)
diff --git a/js/upsell.js b/js/upsell.js
index eba58ca..40bfb88 100644
--- a/js/upsell.js
+++ b/js/upsell.js
@@ -2,7 +2,6 @@ jQuery(document).ready(function($)
{
$('.emr-installer').on('click', function(e){
e.preventDefault();
- // var $this = $(this);
var button = $(this);
var plugin = button.data('plugin');
var nonce = $('#upsell-nonce').val();
diff --git a/readme.txt b/readme.txt
index 819bcd8..c535c3d 100644
--- a/readme.txt
+++ b/readme.txt
@@ -5,13 +5,13 @@ Tags: replace, attachment, media, files, replace image, remove background, repla
Requires at least: 4.9.7
Tested up to: 6.2
Requires PHP: 5.6
-Stable tag: 4.0.3
+Stable tag: 4.1.0
Easily replace any attached image/file by simply uploading a new file in the Media Library edit view - a real time saver!
== Description ==
-**A free, lightweight and easy to use plugin that allows you to seamlessly replace an image or file in your Media Library by uploading a new file in its place. No more deleting, renaming and re-uploading files!
+**A free, lightweight and easy to use plugin that allows you to seamlessly replace an image or file in your Media Library by uploading a new file in its place. No more deleting, renaming and re-uploading files! Now fully compatible with WP Offload Media!
New beta feature! You can now remove the background of your images for better integration with eCommerce solutions!
Supported by the friendly team that created ShortPixel :)**
@@ -34,6 +34,10 @@ This plugin is very powerful and a must-have for all major websites built with W
Similar to replacing media, you can also remove the background of the images from the Media Library! The background removal feature sends the images to ShortPixel's API, removes the background and sends them back in a preview window. If everything looks good, just replace the image with the one that has the background removed! If the source image is a PNG file, you will get a transparent background, while the other images default to a solid white background. You also have the option to choose a different color with an embedded color picker.
The background removal feature is still in beta and will be free of charge for a reasonable usage.
+If you don't want to use the background removal feature, add this line to your theme's functions.php file, or use a plugin like Code Snippets:
+
+```add_filter( 'emr/feature/background', '__return_false' );```
+
#### Show file modification time
There is a shortcode that takes the file modification date and displays it in a post or on a page. The code is:
@@ -61,6 +65,19 @@ If you want more control over the format in which the time is shown, you can use
== Changelog ==
+= 4.1.0 =
+
+Release date: March 28, 2023
+* New: Integration with WP Offload Media; items that are offloaded can now be replaced correctly;
+* New: Switch to a Replacer module that improves the code and makes it more robust;
+* New: Adding an intermediate confirmation page to solve possible redirection issues;
+* Tweak: The new image can now be dragged and dropped directly into the preview area;
+* Tweak: Improved the display of both the original image and the new image on the replacement screen;
+* Tweak: Improved the notification system and added a mechanism for remote notifications;
+* Tweak: Updated the texts and banners to look better on the replacement screen;
+* Fix: Added documentation in the readme to disable the background removal feature (kudos to @jstask82);
+* Fix: Increased the security of the plugin by adding checks for various AJAX calls;
+
= 4.0.3 =
Release date: February 21, 2023
diff --git a/scss/_screens.scss b/scss/_screens.scss
new file mode 100644
index 0000000..aeb1d86
--- /dev/null
+++ b/scss/_screens.scss
@@ -0,0 +1,39 @@
+
+.enable-media-replace.emr-screen
+{
+
+ width: 90%;
+ background: #fff;
+ border: 1px solid #fff;
+ position: relative;
+ margin: 30px 0;
+
+ h3 {
+ font-size: 24px;
+ position: absolute;
+ top: -15px;
+ left: 30px;
+ padding: 16px 8px;
+ border: 1px solid #000;
+ background: #fff;
+ margin: 0;
+ }
+ .content
+ {
+ padding: 32px;
+
+ }
+ h1 {
+ font-weight: 700;
+ }
+
+ p { font-size: 14px; }
+
+
+ .hide { display: none; }
+
+ &.error-screen {
+ h1 { color: #ff0000; }
+ }
+
+}
diff --git a/scss/admin.scss b/scss/admin.scss
index 4c61c45..e64d6a6 100644
--- a/scss/admin.scss
+++ b/scss/admin.scss
@@ -1,5 +1,36 @@
@import 'datepicker';
+@import 'screens';
+#emr-drop-area-active
+{
+// border: 4px dashed #b4b9be;
+// max-width: 600px;
+ position: fixed;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+ z-index: 9999;
+ display: block;
+ background: rgba(0,0,0,0.5);
+ border: 6px dashed #AAA;
+
+ h3 {
+ font-size: 36px;
+ color: #ddd;
+ width: 200px;
+ left: 50%;
+ top: 50%;
+ position:absolute;
+ }
+
+ .drop-wrapper
+ {
+ margin: 0 auto;
+ }
+}
+
+// The main form.
.emr_upload_form
{
form
@@ -15,6 +46,9 @@
{
width: 100%;
}
+ .emr_drop_area {
+ display: none;
+ }
.wrapper
{
@@ -32,52 +66,29 @@
}
}
+ .explainer {
+ font-size: 14px;
+ color: #555;
+ max-width: 800px;
+ margin: 20px 0;
+ .underline {
+ text-decoration-style: dotted;
+ text-decoration-line: underline;
+ }
+
+
+ }
+
.image_chooser.wrapper
{
min-height: 350px;
- .emr_drop_area
- {
- border: 4px dashed #b4b9be;
- max-width: 600px;
- padding: 28px 14px;
- text-align: center;
- position: relative;
- h1 { display: none; }
- .drop-wrapper
- {
- margin: 0 auto;
- }
- &.drop_breakout
- {
- position: fixed;
- left: 0;
- right:0;
- bottom: 0;
- top: 0;
- max-width: none;
- border-color: #83b4d8;
- border-width: 10px;
- z-index: 999999;
- background-color: rgba(#444, 0.7);
- h1 {
- color: #fff;
- position: absolute;
- font-size: 50px;
- line-height: 50px;
- margin-top: -25px;
- top: 50%;
- width: 100%;
- text-align: center;
- display: block;
- }
- .drop-wrapper { display: none; }
- }
- }
.image_previews
{
margin: 15px 0;
+ position: relative;
+
.image_placeholder
{
position: relative;
@@ -86,7 +97,26 @@
margin-bottom: 10px;
border: 1px solid #ddd;
vertical-align: top;
- // max-height: 500px;
+ box-sizing: border-box;
+ background: #fff;
+ max-width: calc(50% - 25px);
+
+ img { object-fit: contain; }
+
+ .upload-title
+ {
+ text-align: center;
+ position: absolute;
+ padding-top: 8px;
+ line-height: 20px;
+ font-weight: 700;
+ width: 100%;
+ left: 0;
+ top: 0;
+ }
+ #upload-file {
+ display: none;
+ }
.textlayer
{
font-size: 25px;
@@ -100,6 +130,7 @@
border: 1px dashed #eee;
background-color: #333;
padding: 8px;
+ z-index: 5;
//max-width: 100%;
}
.dashicons
@@ -120,6 +151,28 @@
bottom: -25px;
width: 100%;
}
+ .drag-and-drop-title
+ {
+ text-align: center;
+ font-weight: 400;
+ font-size: 14px;
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ cursor: pointer;
+ top: 0;
+ left: 0;
+ z-index: 1;
+ span {
+ position: absolute;
+ // left: 46%;
+ top: 50%;
+ transform: translate(-50%,-50%);
+ padding: 5px 10px;
+ width: 100%;
+
+ }
+ }
&.is_image
{
.dashicons::before, .dashicons { display: none }
diff --git a/views/do-replace-background.php b/views/do-replace-background.php
index fb1871e..b40e059 100644
--- a/views/do-replace-background.php
+++ b/views/do-replace-background.php
@@ -5,18 +5,11 @@
use EnableMediaReplace\Notices\NoticeController as Notices;
use \EnableMediaReplace\Replacer as Replacer;
-
if (! defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
-if (! check_admin_referer('do_background_replace'))
-{
- wp_die(esc_html__('Nonce in form failed. Go back, refresh and try again.', 'enable-media-replace'));
-}
-
$key = isset($_POST['key']) ? sanitize_text_field($_POST['key']) : null;
-
if (is_null($key) || strlen($key) == 0)
{
wp_die(esc_html__('Error while sending form (no key). Please try again.', 'enable-media-replace'));
@@ -41,9 +34,6 @@
$datetime = current_time('mysql');
$replacer->setTimeMode( \EnableMediaReplace\Replacer::TIME_UPDATEMODIFIED, $datetime);
-
-
-
$api = new Api();
$result = $api->handleDownload($key);
diff --git a/views/error.php b/views/error.php
new file mode 100644
index 0000000..26986c4
--- /dev/null
+++ b/views/error.php
@@ -0,0 +1,36 @@
+
+
+