Version Description
- Fix PDF thumbnails not replaced when replacing a PDF
- Fix not replacing text files with .dat extension
Download this release
Release Info
Developer | ShortPixel |
Plugin | Enable Media Replace |
Version | 3.2.4 |
Comparing to | |
See all releases |
Code changes from version 3.2.3 to 3.2.4
- class-emr-smart-notification.php +327 -0
- enable-media-replace.php +31 -42
- img/shortpixel.png +0 -0
- img/wp-modula.jpg +0 -0
- readme.txt +4 -0
- upload.php +9 -2
class-emr-smart-notification.php
ADDED
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EMR_Smart_Notification {
|
4 |
+
|
5 |
+
private static $_instance = null;
|
6 |
+
private $plugins;
|
7 |
+
private $options;
|
8 |
+
private $plugin_dir;
|
9 |
+
|
10 |
+
function __construct( $args ) {
|
11 |
+
|
12 |
+
if ( defined( WP_PLUGIN_DIR ) ) {
|
13 |
+
$this->plugin_dir = WP_PLUGIN_DIR . '/';
|
14 |
+
}else{
|
15 |
+
$this->plugin_dir = WP_CONTENT_DIR . '/plugins/';
|
16 |
+
}
|
17 |
+
|
18 |
+
$this->container_id = 'emr-smart-notification';
|
19 |
+
$this->options = get_option( 'sp-recommended-plugin', array() );
|
20 |
+
$this->plugins = $this->parse_plugins( $args['plugins'] );
|
21 |
+
|
22 |
+
if ( is_admin() && $this->show_notice() ) {
|
23 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
|
24 |
+
add_action( 'admin_notices', array( $this, 'notification' ) );
|
25 |
+
add_action( 'wp_ajax_emr_smart_notitification', array( $this, 'ajax' ) );
|
26 |
+
add_action('admin_footer', array( $this, 'emr_script' ) );
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
private function parse_plugins( $need_check ) {
|
32 |
+
$plugins = array();
|
33 |
+
|
34 |
+
$shortpixel_extra_check = get_option( 'emr_news', false );
|
35 |
+
if ( $shortpixel_extra_check ) {
|
36 |
+
$this->options[] = 'shortpixel-image-optimiser';
|
37 |
+
}
|
38 |
+
|
39 |
+
foreach ( $need_check as $slug => $plugin ) {
|
40 |
+
|
41 |
+
if ( in_array( $slug, $this->options ) ) {
|
42 |
+
continue;
|
43 |
+
}
|
44 |
+
|
45 |
+
$plugin_info = $this->check_plugin( $slug );
|
46 |
+
if ( 'deactivate' == $plugin_info['needs'] ) {
|
47 |
+
continue;
|
48 |
+
}
|
49 |
+
|
50 |
+
$plugins[ $slug ] = array_merge( $plugin, $plugin_info );
|
51 |
+
}
|
52 |
+
|
53 |
+
return $plugins;
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
private function show_notice() {
|
58 |
+
|
59 |
+
if ( ! empty( $this->plugins ) ) {
|
60 |
+
return true;
|
61 |
+
}
|
62 |
+
|
63 |
+
return false;
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @since 1.0.0
|
69 |
+
* @return emr_Smart_Notification
|
70 |
+
*/
|
71 |
+
public static function get_instance( $args ) {
|
72 |
+
if ( is_null( self::$_instance ) ) {
|
73 |
+
self::$_instance = new self( $args );
|
74 |
+
}
|
75 |
+
return self::$_instance;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function notification() {
|
79 |
+
$notice_html = '';
|
80 |
+
|
81 |
+
foreach ( $this->plugins as $slug => $plugin ) {
|
82 |
+
$notice_html .= '<div class="emr-plugin-card">';
|
83 |
+
$url = $this->create_plugin_link( $plugin['needs'], $slug );
|
84 |
+
if ( '' != $plugin['image'] ) {
|
85 |
+
$notice_html .= '<div style="padding-right: 10px;">';
|
86 |
+
$notice_html .= '<img src="' . esc_url( $plugin['image'] ) . '" width="75" height="75">';
|
87 |
+
$notice_html .= '</div>';
|
88 |
+
}
|
89 |
+
$notice_html .= '<div style="align-self: center;flex-grow: 1;">';
|
90 |
+
$notice_html .= '<h3 style="margin:0;">' . $plugin['name'] . '</h3>';
|
91 |
+
$notice_html .= '<p>' . $plugin['description'] . '</p>';
|
92 |
+
$notice_html .= '</div>';
|
93 |
+
$notice_html .= '<div>';
|
94 |
+
$notice_html .= '<a href="#" class="emr-dismiss" data-dismiss="' . esc_attr( $slug ) . '"><span class="screen-reader-text">Dismiss this notice.</span></a>';
|
95 |
+
$notice_html .= '<span class="plugin-card-' . esc_attr( $slug ) . ' action_button ' . $plugin['needs'] . '">';
|
96 |
+
$notice_html .= '<a data-slug="' . esc_attr( $slug ) . '" data-action="' . esc_attr( $plugin['needs'] ) . '" class="emr-plugin-button ' . esc_attr( $plugin['class'] ) . '" href="' . esc_url( $url ) . '">' . esc_attr( $plugin['label'] ) . '</a>';
|
97 |
+
$notice_html .= '</span>';
|
98 |
+
$notice_html .= '</div>';
|
99 |
+
$notice_html .= '</div>';
|
100 |
+
}
|
101 |
+
|
102 |
+
$class = "emr-one-column";
|
103 |
+
if ( count( $this->plugins ) > 1 ) {
|
104 |
+
$class = "emr-two-column";
|
105 |
+
}
|
106 |
+
echo '<div id="' . $this->container_id . '" class="emr-custom-notice notice ' . $class . '" style="background:transparent;border: 0 none;box-shadow: none;padding: 0;display: flex;">';
|
107 |
+
echo $notice_html;
|
108 |
+
echo '<style>.emr-plugin-card {display: flex;background: #fff;border-left: 4px solid #46b450;padding: .5em 12px;box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);position:relative;align-items:center;}.emr-one-column .emr-plugin-card{ width:100%; }.emr-two-column .emr-plugin-card{width:49%;}.emr-two-column .emr-plugin-card:nth-child( 2n + 1 ){margin-right:2%;}.emr-dismiss { position: absolute;top: 0;right: 1px;border: none;margin: 0;padding: 9px;background: 0 0;color: #72777c;cursor: pointer;text-decoration:none; }.emr-dismiss:before { background: 0 0;color: #72777c;content: "\f153";display: block;font: 400 16px/20px dashicons; speak: none;height: 20px;text-align: center;width: 20px;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale; }.emr-dismiss:active:before, .emr-dismiss:focus:before, .emr-dismiss:hover:before { color: #c00; }</style>';
|
109 |
+
echo '</div>';
|
110 |
+
|
111 |
+
|
112 |
+
}
|
113 |
+
|
114 |
+
public function ajax() {
|
115 |
+
|
116 |
+
check_ajax_referer( 'emr-smart-notitification', 'security' );
|
117 |
+
|
118 |
+
if ( isset( $_POST['slug'] ) ) {
|
119 |
+
$this->options[] = sanitize_text_field( $_POST['slug'] );
|
120 |
+
update_option( 'sp-recommended-plugin', $this->options );
|
121 |
+
}
|
122 |
+
|
123 |
+
wp_die( 'ok' );
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
public function enqueue() {
|
128 |
+
wp_enqueue_script( 'updates' );
|
129 |
+
wp_enqueue_script( 'jquery' );
|
130 |
+
}
|
131 |
+
|
132 |
+
private function get_plugins( $plugin_folder = '' ) {
|
133 |
+
if ( ! function_exists( 'get_plugins' ) ) {
|
134 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
135 |
+
}
|
136 |
+
|
137 |
+
return get_plugins( $plugin_folder );
|
138 |
+
}
|
139 |
+
|
140 |
+
private function _get_plugin_basename_from_slug( $slug ) {
|
141 |
+
$keys = array_keys( $this->get_plugins() );
|
142 |
+
|
143 |
+
foreach ( $keys as $key ) {
|
144 |
+
if ( preg_match( '|^' . $slug . '/|', $key ) ) {
|
145 |
+
return $key;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
return $slug;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @return bool
|
154 |
+
*/
|
155 |
+
private function check_plugin_is_installed( $slug ) {
|
156 |
+
|
157 |
+
$plugin_path = $this->_get_plugin_basename_from_slug( $slug );
|
158 |
+
|
159 |
+
if ( file_exists( $this->plugin_dir . $plugin_path ) ) {
|
160 |
+
return true;
|
161 |
+
}
|
162 |
+
|
163 |
+
return false;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* @return bool
|
168 |
+
*/
|
169 |
+
private function check_plugin_is_active( $slug ) {
|
170 |
+
$plugin_path = $this->_get_plugin_basename_from_slug( $slug );
|
171 |
+
if ( file_exists( $this->plugin_dir . $plugin_path ) ) {
|
172 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
173 |
+
|
174 |
+
return is_plugin_active( $plugin_path );
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
private function create_plugin_link( $state, $slug ) {
|
179 |
+
$string = '';
|
180 |
+
|
181 |
+
switch ( $state ) {
|
182 |
+
case 'install':
|
183 |
+
$string = wp_nonce_url(
|
184 |
+
add_query_arg(
|
185 |
+
array(
|
186 |
+
'action' => 'install-plugin',
|
187 |
+
'plugin' => $this->_get_plugin_basename_from_slug( $slug ),
|
188 |
+
),
|
189 |
+
network_admin_url( 'update.php' )
|
190 |
+
),
|
191 |
+
'install-plugin_' . $slug
|
192 |
+
);
|
193 |
+
break;
|
194 |
+
case 'deactivate':
|
195 |
+
$string = add_query_arg(
|
196 |
+
array(
|
197 |
+
'action' => 'deactivate',
|
198 |
+
'plugin' => rawurlencode( $this->_get_plugin_basename_from_slug( $slug ) ),
|
199 |
+
'plugin_status' => 'all',
|
200 |
+
'paged' => '1',
|
201 |
+
'_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $this->_get_plugin_basename_from_slug( $slug ) ),
|
202 |
+
),
|
203 |
+
admin_url( 'plugins.php' )
|
204 |
+
);
|
205 |
+
break;
|
206 |
+
case 'activate':
|
207 |
+
$string = add_query_arg(
|
208 |
+
array(
|
209 |
+
'action' => 'activate',
|
210 |
+
'plugin' => rawurlencode( $this->_get_plugin_basename_from_slug( $slug ) ),
|
211 |
+
'plugin_status' => 'all',
|
212 |
+
'paged' => '1',
|
213 |
+
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $this->_get_plugin_basename_from_slug( $slug ) ),
|
214 |
+
),
|
215 |
+
admin_url( 'plugins.php' )
|
216 |
+
);
|
217 |
+
break;
|
218 |
+
default:
|
219 |
+
$string = '';
|
220 |
+
break;
|
221 |
+
}// End switch().
|
222 |
+
|
223 |
+
return $string;
|
224 |
+
}
|
225 |
+
|
226 |
+
private function check_plugin( $slug = '' ) {
|
227 |
+
$arr = array(
|
228 |
+
'installed' => $this->check_plugin_is_installed( $slug ),
|
229 |
+
'active' => $this->check_plugin_is_active( $slug ),
|
230 |
+
'needs' => 'install',
|
231 |
+
'class' => 'button button-primary',
|
232 |
+
'label' => __( 'Install and Activate', 'enable-media-replace' ),
|
233 |
+
);
|
234 |
+
|
235 |
+
if ( $arr['installed'] ) {
|
236 |
+
$arr['needs'] = 'activate';
|
237 |
+
$arr['class'] = 'button button-primary';
|
238 |
+
$arr['label'] = __( 'Activate now', 'enable-media-replace' );
|
239 |
+
}
|
240 |
+
|
241 |
+
if ( $arr['active'] ) {
|
242 |
+
$arr['needs'] = 'deactivate';
|
243 |
+
$arr['class'] = 'deactivate-now button';
|
244 |
+
$arr['label'] = __( 'Deactivate now', 'enable-media-replace' );
|
245 |
+
}
|
246 |
+
|
247 |
+
return $arr;
|
248 |
+
}
|
249 |
+
|
250 |
+
public function emr_script() {
|
251 |
+
|
252 |
+
$ajax_nonce = wp_create_nonce( 'emr-smart-notitification' );
|
253 |
+
|
254 |
+
?>
|
255 |
+
<script type="text/javascript">
|
256 |
+
|
257 |
+
|
258 |
+
function emrActivatePlugin( url, el ) {
|
259 |
+
|
260 |
+
jQuery.ajax( {
|
261 |
+
async: true,
|
262 |
+
type: 'GET',
|
263 |
+
dataType: 'html',
|
264 |
+
url: url,
|
265 |
+
success: function() {
|
266 |
+
location.reload();
|
267 |
+
}
|
268 |
+
} );
|
269 |
+
}
|
270 |
+
|
271 |
+
var emrContainer = jQuery( '#<?php echo $this->container_id ?>' );
|
272 |
+
emrContainer.on( 'click', '.emr-plugin-button', function( event ) {
|
273 |
+
var action = jQuery( this ).data( 'action' ),
|
274 |
+
url = jQuery( this ).attr( 'href' ),
|
275 |
+
slug = jQuery( this ).data( 'slug' );
|
276 |
+
|
277 |
+
jQuery(this).addClass( 'updating-message' );
|
278 |
+
jQuery(this).attr( 'disabled', 'disabled' );
|
279 |
+
|
280 |
+
event.preventDefault();
|
281 |
+
|
282 |
+
if ( 'install' === action ) {
|
283 |
+
|
284 |
+
wp.updates.installPlugin( {
|
285 |
+
slug: slug
|
286 |
+
} );
|
287 |
+
|
288 |
+
} else if ( 'activate' === action ) {
|
289 |
+
|
290 |
+
emrActivatePlugin( url, jQuery( this ) );
|
291 |
+
|
292 |
+
}
|
293 |
+
|
294 |
+
} );
|
295 |
+
|
296 |
+
emrContainer.on( 'click', '.emr-dismiss', function( event ) {
|
297 |
+
var container = jQuery(this).parents( '.emr-plugin-card' ),
|
298 |
+
data = jQuery(this).data(),
|
299 |
+
ajaxData = {
|
300 |
+
action: 'emr_smart_notitification',
|
301 |
+
security: '<?php echo $ajax_nonce; ?>',
|
302 |
+
};
|
303 |
+
|
304 |
+
event.preventDefault();
|
305 |
+
|
306 |
+
ajaxData.slug = data.dismiss;
|
307 |
+
|
308 |
+
jQuery.post( '<?php echo admin_url( 'admin-ajax.php' ) ?>', ajaxData, function( response ) {
|
309 |
+
container.slideUp( 'fast', function() {
|
310 |
+
jQuery( this ).remove();
|
311 |
+
} );
|
312 |
+
});
|
313 |
+
|
314 |
+
});
|
315 |
+
|
316 |
+
jQuery( document ).on( 'wp-plugin-install-success', function( response, data ) {
|
317 |
+
var el = emrContainer.find( '.emr-plugin-button[data-slug="' + data.slug + '"]' );
|
318 |
+
event.preventDefault();
|
319 |
+
emrActivatePlugin( data.activateUrl, el );
|
320 |
+
} );
|
321 |
+
|
322 |
+
</script>
|
323 |
+
|
324 |
+
<?php
|
325 |
+
}
|
326 |
+
|
327 |
+
}
|
enable-media-replace.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Enable Media Replace
|
4 |
Plugin URI: http://www.mansjonasson.se/enable-media-replace
|
5 |
Description: Enable replacing media files by uploading a new file in the "Edit Media" section of the WordPress Media Library.
|
6 |
-
Version: 3.2.
|
7 |
Author: ShortPixel
|
8 |
Author URI: https://shortpixel.com
|
9 |
|
@@ -26,18 +26,24 @@ add_action('admin_init', 'enable_media_replace_init');
|
|
26 |
add_action('admin_menu', 'emr_menu');
|
27 |
add_filter('attachment_fields_to_edit', 'enable_media_replace', 10, 2);
|
28 |
add_filter('media_row_actions', 'add_media_action', 10, 2);
|
29 |
-
|
30 |
-
add_action('admin_notices', 'emr_display_notices');
|
31 |
-
add_action('network_admin_notices', 'emr_display_network_notices');
|
32 |
-
add_action('wp_ajax_emr_dismiss_notices', 'emr_dismiss_notices');
|
33 |
-
add_action('wp_ajax_emr_install_plugin', 'emr_install_plugin');
|
34 |
-
add_action( 'admin_enqueue_scripts', 'emr_add_js' );
|
35 |
|
36 |
add_shortcode('file_modified', 'emr_get_modified_date');
|
37 |
|
38 |
if(!defined("SHORTPIXEL_AFFILIATE_CODE")) {
|
39 |
define("SHORTPIXEL_AFFILIATE_CODE", 'VKG6LYN28044');
|
40 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
/**
|
42 |
* Register this file in WordPress so we can call it with a ?page= GET var.
|
43 |
* To suppress it in the menu we give it an empty menu title.
|
@@ -167,41 +173,6 @@ function ua_admin_date_replaced_media_on_edit_media_screen() {
|
|
167 |
}
|
168 |
add_action( 'attachment_submitbox_misc_actions', 'ua_admin_date_replaced_media_on_edit_media_screen', 91 );
|
169 |
|
170 |
-
/*----------------------------------------------------------------------------------------------------------
|
171 |
-
Display/dismiss admin notices if needed
|
172 |
-
-----------------------------------------------------------------------------------------------------------*/
|
173 |
-
|
174 |
-
function emr_display_notices() {
|
175 |
-
$current_screen = get_current_screen();
|
176 |
-
|
177 |
-
$crtScreen = function_exists("get_current_screen") ? get_current_screen() : (object)array("base" => false);
|
178 |
-
|
179 |
-
if(current_user_can( 'activate_plugins' ) && !get_option( 'emr_news') && !is_plugin_active('shortpixel-image-optimiser/wp-shortpixel.php')
|
180 |
-
&& $crtScreen->base != "media_page_enable-media-replace/enable-media-replace"
|
181 |
-
//for network installed plugins, don't display the message on subsites.
|
182 |
-
&& !(function_exists('is_multisite') && is_multisite() && is_plugin_active_for_network('enable-media-replace/enable-media-replace.php') && !is_main_site()))
|
183 |
-
{
|
184 |
-
require_once( str_replace("enable-media-replace.php", "notice.php", __FILE__) );
|
185 |
-
}
|
186 |
-
}
|
187 |
-
|
188 |
-
function emr_display_network_notices() {
|
189 |
-
if(current_user_can( 'activate_plugins' ) && !get_option( 'emr_news') && !is_plugin_active_for_network('shortpixel-image-optimiser/wp-shortpixel.php')) {
|
190 |
-
require_once( str_replace("enable-media-replace.php", "notice.php", __FILE__) );
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
function emr_dismiss_notices() {
|
195 |
-
update_option( 'emr_news', true);
|
196 |
-
exit(json_encode(array("Status" => 0)));
|
197 |
-
}
|
198 |
-
|
199 |
-
function emr_add_js($hook) {
|
200 |
-
if("media_page_enable-media-replace/enable-media-replace" == $hook) {
|
201 |
-
wp_enqueue_script('emr-plugin-install', plugins_url('/js/plugin-install.js',__FILE__), array( 'jquery', 'updates' ), '1.0.0', 'all' );
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
function emr_install_plugin() {
|
206 |
$slug = isset($_GET['slug']) ? trim($_GET['slug']) : null;
|
207 |
if($slug == 'shortpixel-image-optimiser') {
|
@@ -228,3 +199,21 @@ function emr_install_plugin() {
|
|
228 |
exit(json_encode(array("Status" => 2)));
|
229 |
}
|
230 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
Plugin Name: Enable Media Replace
|
4 |
Plugin URI: http://www.mansjonasson.se/enable-media-replace
|
5 |
Description: Enable replacing media files by uploading a new file in the "Edit Media" section of the WordPress Media Library.
|
6 |
+
Version: 3.2.4
|
7 |
Author: ShortPixel
|
8 |
Author URI: https://shortpixel.com
|
9 |
|
26 |
add_action('admin_menu', 'emr_menu');
|
27 |
add_filter('attachment_fields_to_edit', 'enable_media_replace', 10, 2);
|
28 |
add_filter('media_row_actions', 'add_media_action', 10, 2);
|
29 |
+
add_filter('upload_mimes', 'dat_mime_types', 1, 1);
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
add_shortcode('file_modified', 'emr_get_modified_date');
|
32 |
|
33 |
if(!defined("SHORTPIXEL_AFFILIATE_CODE")) {
|
34 |
define("SHORTPIXEL_AFFILIATE_CODE", 'VKG6LYN28044');
|
35 |
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param array $mime_types
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
function dat_mime_types($mime_types) {
|
42 |
+
$mime_types['dat'] = 'text/plain'; // Adding .dat extension
|
43 |
+
|
44 |
+
return $mime_types;
|
45 |
+
}
|
46 |
+
|
47 |
/**
|
48 |
* Register this file in WordPress so we can call it with a ?page= GET var.
|
49 |
* To suppress it in the menu we give it an empty menu title.
|
173 |
}
|
174 |
add_action( 'attachment_submitbox_misc_actions', 'ua_admin_date_replaced_media_on_edit_media_screen', 91 );
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
function emr_install_plugin() {
|
177 |
$slug = isset($_GET['slug']) ? trim($_GET['slug']) : null;
|
178 |
if($slug == 'shortpixel-image-optimiser') {
|
199 |
exit(json_encode(array("Status" => 2)));
|
200 |
}
|
201 |
}
|
202 |
+
|
203 |
+
// Add Epsilon Smart Notification
|
204 |
+
require_once 'class-emr-smart-notification.php';
|
205 |
+
EMR_Smart_Notification::get_instance( array(
|
206 |
+
'plugins' => array(
|
207 |
+
'shortpixel-image-optimiser' => array(
|
208 |
+
'name' => __( 'ShortPixel Image Optimizer', 'enable-media-replace' ),
|
209 |
+
'description' => __( 'A freemium easy to use, comprehensive, stable and frequently updated image compression plugin supported by the friendly team that created it.', 'enable-media-replace' ),
|
210 |
+
'image' => plugins_url('/img/shortpixel.png',__FILE__),
|
211 |
+
),
|
212 |
+
'modula-best-grid-gallery' => array(
|
213 |
+
'name' => __( 'Modula WordPress Photo Gallery', 'enable-media-replace' ),
|
214 |
+
'description' => __( 'Modula is currently the easiest and fastest photo gallery plugin for WordPress. With its wizard you are able to build an image gallery in a few seconds, unlike many other WordPress gallery plugins.', 'enable-media-replace' ),
|
215 |
+
'image' => plugins_url('/img/wp-modula.jpg',__FILE__),
|
216 |
+
),
|
217 |
+
),
|
218 |
+
|
219 |
+
) );
|
img/shortpixel.png
ADDED
Binary file
|
img/wp-modula.jpg
ADDED
Binary file
|
readme.txt
CHANGED
@@ -42,6 +42,10 @@ If you want more control over the format used to display the time, you can use t
|
|
42 |
|
43 |
== Changelog ==
|
44 |
|
|
|
|
|
|
|
|
|
45 |
= 3.2.3 =
|
46 |
* disable ShortPixel recommendation on secondary sites of a multisite install when it was network activated.
|
47 |
|
42 |
|
43 |
== Changelog ==
|
44 |
|
45 |
+
= 3.2.4 =
|
46 |
+
* Fix PDF thumbnails not replaced when replacing a PDF
|
47 |
+
* Fix not replacing text files with .dat extension
|
48 |
+
|
49 |
= 3.2.3 =
|
50 |
* disable ShortPixel recommendation on secondary sites of a multisite install when it was network activated.
|
51 |
|
upload.php
CHANGED
@@ -37,6 +37,12 @@ function emr_delete_current_files( $current_file, $metadta = null ) {
|
|
37 |
// Delete old resized versions if this was an image
|
38 |
$suffix = substr($current_file, (strlen($current_file)-4));
|
39 |
$prefix = substr($current_file, 0, (strlen($current_file)-4));
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
$imgAr = array(".png", ".gif", ".jpg");
|
41 |
if (in_array($suffix, $imgAr)) {
|
42 |
// It's a png/gif/jpg based on file name
|
@@ -194,8 +200,9 @@ function emr_normalize_file_urls( $old, $new ) {
|
|
194 |
}
|
195 |
|
196 |
// Get old guid and filetype from DB
|
197 |
-
$sql = "SELECT
|
198 |
-
list($
|
|
|
199 |
|
200 |
// Massage a bunch of vars
|
201 |
$current_guid = $current_filename;
|
37 |
// Delete old resized versions if this was an image
|
38 |
$suffix = substr($current_file, (strlen($current_file)-4));
|
39 |
$prefix = substr($current_file, 0, (strlen($current_file)-4));
|
40 |
+
|
41 |
+
if (strtolower($suffix) === ".pdf") {
|
42 |
+
$prefix .= "-pdf";
|
43 |
+
$suffix = ".jpg";
|
44 |
+
}
|
45 |
+
|
46 |
$imgAr = array(".png", ".gif", ".jpg");
|
47 |
if (in_array($suffix, $imgAr)) {
|
48 |
// It's a png/gif/jpg based on file name
|
200 |
}
|
201 |
|
202 |
// Get old guid and filetype from DB
|
203 |
+
$sql = "SELECT post_mime_type FROM $table_name WHERE ID = '" . (int) $_POST["ID"] . "'";
|
204 |
+
list($current_filetype) = $wpdb->get_row($sql, ARRAY_N);
|
205 |
+
$current_filename = wp_get_attachment_url($_POST['ID']);
|
206 |
|
207 |
// Massage a bunch of vars
|
208 |
$current_guid = $current_filename;
|