Version Description
- Add: Table with the filenames before and after renaming + CSV Export (works with Redirection plugin).
Download this release
Release Info
Developer | TigrouMeow |
Plugin | Media File Renamer |
Version | 3.6.6 |
Comparing to | |
See all releases |
Code changes from version 3.6.4 to 3.6.6
- common/admin.php +1 -1
- core.php +114 -36
- media-file-renamer.php +10 -2
- readme.txt +4 -1
common/admin.php
CHANGED
@@ -134,7 +134,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
134 |
$html .= '<div class="inside">';
|
135 |
echo $html;
|
136 |
$html = apply_filters( $this->prefix . '_meowapps_license_input', ( 'More information about the Pro version here:
|
137 |
-
<a target="_blank" href="' . $url . '">' . $url . '</a>.' ), $url );
|
138 |
$html .= '</div>';
|
139 |
$html .= '</div>';
|
140 |
echo $html;
|
134 |
$html .= '<div class="inside">';
|
135 |
echo $html;
|
136 |
$html = apply_filters( $this->prefix . '_meowapps_license_input', ( 'More information about the Pro version here:
|
137 |
+
<a target="_blank" href="' . $url . '">' . $url . '</a>. If you actually bought the Pro version already, please remove the current plugin and download the Pro version from your account at the <a target="_blank" href="https://store.meowapps.com/account/downloads/">Meow Apps Store</a>.' ), $url );
|
138 |
$html .= '</div>';
|
139 |
$html .= '</div>';
|
140 |
echo $html;
|
core.php
CHANGED
@@ -233,6 +233,40 @@ class Meow_MFRH_Core {
|
|
233 |
});
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
</script>
|
237 |
<?php
|
238 |
}
|
@@ -274,29 +308,29 @@ class Meow_MFRH_Core {
|
|
274 |
die();
|
275 |
}
|
276 |
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
die();
|
296 |
-
}
|
297 |
-
echo 0;
|
298 |
die();
|
299 |
}
|
|
|
|
|
|
|
300 |
|
301 |
function admin_menu() {
|
302 |
$method = apply_filters( 'mfrh_method', 'media_title' );
|
@@ -521,6 +555,10 @@ class Meow_MFRH_Core {
|
|
521 |
echo '</p></div>';
|
522 |
}
|
523 |
|
|
|
|
|
|
|
|
|
524 |
$checkFiles = null;
|
525 |
if ( isset( $_GET ) && isset( $_GET['mfrh_scancheck'] ) )
|
526 |
$checkFiles = $this->check_text();
|
@@ -562,10 +600,15 @@ class Meow_MFRH_Core {
|
|
562 |
style='margin-right: 0px;'><span class="dashicons dashicons-controls-play" style="position: relative; top: 3px; left: -2px;"></span>
|
563 |
<?php echo sprintf( __( "Unlock ALL & Rename [%d]", 'media-file-renamer' ), $all_media ); ?>
|
564 |
</a>
|
|
|
565 |
<a href="?page=rename_media_files&mfrh_lockall" id='mfrh_lock_all_images' class='button-primary'
|
566 |
-
style='margin-right:
|
567 |
<?php echo sprintf( __( "Lock ALL [%d]", 'media-file-renamer' ), $all_media ); ?>
|
568 |
</a>
|
|
|
|
|
|
|
|
|
569 |
<a onclick='mfrh_undo_media()' id='mfrh_undo_all_images' class='button button-red'
|
570 |
style='margin-right: 0px; float: right;'><span class="dashicons dashicons-undo" style="position: relative; top: 3px; left: -2px;"></span>
|
571 |
<?php echo sprintf( __( "Undo ALL [%d]", 'media-file-renamer' ), $all_media ); ?>
|
@@ -615,27 +658,62 @@ class Meow_MFRH_Core {
|
|
615 |
else if ( $checkFiles == null ) {
|
616 |
?><tr><td colspan='4'><div style='width: 100%; text-align: center;'>
|
617 |
<a class='button-primary' href="?page=rename_media_files&mfrh_scancheck" style='margin-top: 15px; margin-bottom: 15px;'><span class="dashicons dashicons-admin-generic" style="position: relative; top: 3px; left: -2px;"></span>
|
618 |
-
<?php
|
619 |
</a>
|
620 |
</div></td><?php
|
621 |
}
|
622 |
?>
|
623 |
</tbody>
|
624 |
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
625 |
</div>
|
626 |
-
<?php
|
627 |
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
638 |
|
|
|
639 |
}
|
640 |
|
641 |
/**
|
@@ -663,7 +741,7 @@ class Meow_MFRH_Core {
|
|
663 |
|
664 |
function save_post( $post_id ) {
|
665 |
$status = get_post_status( $post_id );
|
666 |
-
if ( !in_array( $status, array( 'publish', 'future', 'private' ) ) )
|
667 |
return;
|
668 |
$this->rename_media_on_publish( $post_id );
|
669 |
}
|
@@ -737,7 +815,7 @@ class Meow_MFRH_Core {
|
|
737 |
error_log( $data );
|
738 |
if ( !get_option( 'mfrh_log' ) )
|
739 |
return;
|
740 |
-
$fh = fopen( trailingslashit(
|
741 |
$date = date( "Y-m-d H:i:s" );
|
742 |
fwrite( $fh, "$date: {$data}\n" );
|
743 |
fclose( $fh );
|
233 |
});
|
234 |
}
|
235 |
|
236 |
+
function mfrh_export_table(table) {
|
237 |
+
var table = jQuery(table);
|
238 |
+
var data = [];
|
239 |
+
// Header
|
240 |
+
table.find('thead tr').each(function(i, tr) {
|
241 |
+
var row = [];
|
242 |
+
jQuery(tr).find('th').each(function(i, td) {
|
243 |
+
var text = jQuery(td).text();
|
244 |
+
row.push(text);
|
245 |
+
});
|
246 |
+
data.push(row);
|
247 |
+
});
|
248 |
+
// Body
|
249 |
+
table.find('tbody tr').each(function(i, tr) {
|
250 |
+
var row = [];
|
251 |
+
jQuery(tr).find('td').each(function(i, td) {
|
252 |
+
var text = jQuery(td).text();
|
253 |
+
row.push(text);
|
254 |
+
});
|
255 |
+
data.push(row);
|
256 |
+
});
|
257 |
+
var csvContent = "data:text/csv;charset=utf-8,";
|
258 |
+
data.forEach(function(infoArray, index){
|
259 |
+
dataString = infoArray.join(",");
|
260 |
+
csvContent += index < data.length ? dataString+ "\n" : dataString;
|
261 |
+
});
|
262 |
+
var encodedUri = encodeURI(csvContent);
|
263 |
+
var link = document.createElement("a");
|
264 |
+
link.setAttribute("href", encodedUri);
|
265 |
+
link.setAttribute("download", "media-file-renamer.csv");
|
266 |
+
document.body.appendChild(link);
|
267 |
+
link.click();
|
268 |
+
}
|
269 |
+
|
270 |
</script>
|
271 |
<?php
|
272 |
}
|
308 |
die();
|
309 |
}
|
310 |
|
311 |
+
function wp_ajax_mfrh_undo_media() {
|
312 |
+
$subaction = $_POST['subaction'];
|
313 |
+
if ( $subaction == 'getMediaIds' ) {
|
314 |
+
global $wpdb;
|
315 |
+
$ids = $wpdb->get_col( "
|
316 |
+
SELECT p.ID FROM $wpdb->posts p
|
317 |
+
WHERE post_status = 'inherit' AND post_type = 'attachment'" );
|
318 |
+
$reply = array();
|
319 |
+
$reply['ids'] = $ids;
|
320 |
+
$reply['total'] = count( $ids );
|
321 |
+
echo json_encode( $reply );
|
322 |
+
die;
|
323 |
+
}
|
324 |
+
else if ( $subaction == 'undoMediaId' ) {
|
325 |
+
$id = intval( $_POST['id'] );
|
326 |
+
$original_filename = get_post_meta( $id, '_original_filename', true );
|
327 |
+
$this->rename_media( get_post( $id, ARRAY_A ), null, false, $original_filename );
|
328 |
+
echo 1;
|
|
|
|
|
|
|
329 |
die();
|
330 |
}
|
331 |
+
echo 0;
|
332 |
+
die();
|
333 |
+
}
|
334 |
|
335 |
function admin_menu() {
|
336 |
$method = apply_filters( 'mfrh_method', 'media_title' );
|
555 |
echo '</p></div>';
|
556 |
}
|
557 |
|
558 |
+
if ( isset( $_GET ) && isset( $_GET['mfrh_unlockall'] ) ) {
|
559 |
+
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_manual_file_renaming'" );
|
560 |
+
}
|
561 |
+
|
562 |
$checkFiles = null;
|
563 |
if ( isset( $_GET ) && isset( $_GET['mfrh_scancheck'] ) )
|
564 |
$checkFiles = $this->check_text();
|
600 |
style='margin-right: 0px;'><span class="dashicons dashicons-controls-play" style="position: relative; top: 3px; left: -2px;"></span>
|
601 |
<?php echo sprintf( __( "Unlock ALL & Rename [%d]", 'media-file-renamer' ), $all_media ); ?>
|
602 |
</a>
|
603 |
+
<span style='margin-right: 5px; margin-left: 5px;'>|</span>
|
604 |
<a href="?page=rename_media_files&mfrh_lockall" id='mfrh_lock_all_images' class='button-primary'
|
605 |
+
style='margin-right: 0px;'><span class="dashicons dashicons-controls-play" style="position: relative; top: 3px; left: -2px;"></span>
|
606 |
<?php echo sprintf( __( "Lock ALL [%d]", 'media-file-renamer' ), $all_media ); ?>
|
607 |
</a>
|
608 |
+
<a href="?page=rename_media_files&mfrh_unlockall" id='mfrh_unblock_all_images' class='button-primary'
|
609 |
+
style='margin-right: 0px;'><span class="dashicons dashicons-controls-play" style="position: relative; top: 3px; left: -2px;"></span>
|
610 |
+
<?php echo sprintf( __( "Unlock ALL [%d]", 'media-file-renamer' ), $all_media ); ?>
|
611 |
+
</a>
|
612 |
<a onclick='mfrh_undo_media()' id='mfrh_undo_all_images' class='button button-red'
|
613 |
style='margin-right: 0px; float: right;'><span class="dashicons dashicons-undo" style="position: relative; top: 3px; left: -2px;"></span>
|
614 |
<?php echo sprintf( __( "Undo ALL [%d]", 'media-file-renamer' ), $all_media ); ?>
|
658 |
else if ( $checkFiles == null ) {
|
659 |
?><tr><td colspan='4'><div style='width: 100%; text-align: center;'>
|
660 |
<a class='button-primary' href="?page=rename_media_files&mfrh_scancheck" style='margin-top: 15px; margin-bottom: 15px;'><span class="dashicons dashicons-admin-generic" style="position: relative; top: 3px; left: -2px;"></span>
|
661 |
+
<?php _e( "Scan All & Show Issues", 'media-file-renamer' ); ?>
|
662 |
</a>
|
663 |
</div></td><?php
|
664 |
}
|
665 |
?>
|
666 |
</tbody>
|
667 |
</table>
|
668 |
+
|
669 |
+
<h2>Before / After</h2>
|
670 |
+
<p>This is useful if you wish to create redirections from your old filenames to your new ones. The CSV file generated by Media File Renamer is compatible with the import function of the <a href="https://wordpress.org/plugins/redirection/" target="_blank">Redirection</a> plugin. The redirections with slugs are already automatically and natively handled by WordPress.</p>
|
671 |
+
|
672 |
+
<div style='margin-top: 12px; background: #FFF; padding: 5px; border-radius: 4px; height: 28px; box-shadow: 0px 0px 6px #C2C2C2;'>
|
673 |
+
|
674 |
+
<a href="?page=rename_media_files&mfrh_beforeafter_filenames" class='button-primary' style='margin-right: 0px;'>
|
675 |
+
<span class="dashicons dashicons-media-spreadsheet" style="position: relative; top: 3px; left: -2px;"></span>
|
676 |
+
<?php echo _e( "Display Filenames", 'media-file-renamer' ); ?>
|
677 |
+
</a>
|
678 |
+
|
679 |
+
<a onclick="mfrh_export_table('#mfrh-before-after')" class='button-primary' style='margin-right: 0px; float: right;'>
|
680 |
+
<span class="dashicons dashicons-arrow-down-alt" style="position: relative; top: 3px; left: -2px;"></span>
|
681 |
+
<?php echo _e( "Export as CSV", 'media-file-renamer' ); ?>
|
682 |
+
</a>
|
683 |
+
|
684 |
</div>
|
|
|
685 |
|
686 |
+
<table id='mfrh-before-after' class='wp-list-table widefat fixed media' style='margin-top: 15px;'>
|
687 |
+
<thead>
|
688 |
+
<tr><th><?php _e( 'Before', 'media-file-renamer' ); ?></th><th><?php _e( 'After', 'media-file-renamer' ); ?></th></tr>
|
689 |
+
</thead>
|
690 |
+
<tfoot>
|
691 |
+
<tr><th><?php _e( 'Before', 'media-file-renamer' ); ?></th><th><?php _e( 'After', 'media-file-renamer' ); ?></th></tr>
|
692 |
+
</tfoot>
|
693 |
+
<tbody>
|
694 |
+
<?php
|
695 |
+
if ( isset( $_GET['mfrh_beforeafter_filenames'] ) || isset( $_GET['mfrh_beforeafter_slugs'] ) ) {
|
696 |
+
global $wpdb;
|
697 |
+
$results = $wpdb->get_results( "
|
698 |
+
SELECT m.post_id as ID, m.meta_value as original_filename, m2.meta_value as current_filename
|
699 |
+
FROM {$wpdb->postmeta} m
|
700 |
+
JOIN {$wpdb->postmeta} m2 on m2.post_id = m.post_id AND m2.meta_key = '_wp_attached_file'
|
701 |
+
WHERE m.meta_key = '_original_filename'" );
|
702 |
+
foreach ( $results as $row ) {
|
703 |
+
$fullsize_path = wp_get_attachment_url( $row->ID );
|
704 |
+
$parts = pathinfo( $fullsize_path );
|
705 |
+
$shorten_url = trailingslashit( $parts['dirname'] ) . $row->original_filename;
|
706 |
+
if ( isset( $_GET['mfrh_beforeafter_filenames'] ) )
|
707 |
+
echo "<tr><td>{$shorten_url}</td><td>$fullsize_path</td></tr>";
|
708 |
+
else
|
709 |
+
echo "<tr><td>{$row->original_slug}</td><td>{$row->current_slug}</td></tr>";
|
710 |
+
}
|
711 |
+
}
|
712 |
+
?>
|
713 |
+
</tbody>
|
714 |
+
</table>
|
715 |
|
716 |
+
<?php
|
717 |
}
|
718 |
|
719 |
/**
|
741 |
|
742 |
function save_post( $post_id ) {
|
743 |
$status = get_post_status( $post_id );
|
744 |
+
if ( !in_array( $status, array( 'publish', 'draft', 'future', 'private' ) ) )
|
745 |
return;
|
746 |
$this->rename_media_on_publish( $post_id );
|
747 |
}
|
815 |
error_log( $data );
|
816 |
if ( !get_option( 'mfrh_log' ) )
|
817 |
return;
|
818 |
+
$fh = fopen( trailingslashit( dirname(__FILE__) ) . 'media-file-renamer.log', 'a' );
|
819 |
$date = date( "Y-m-d H:i:s" );
|
820 |
fwrite( $fh, "$date: {$data}\n" );
|
821 |
fclose( $fh );
|
media-file-renamer.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Media File Renamer
|
4 |
Plugin URI: http://meowapps.com
|
5 |
Description: Auto-rename the files when titles are modified and update and the references (links). Manual Rename is a Pro option. Please read the description.
|
6 |
-
Version: 3.6.
|
7 |
Author: Jordy Meow
|
8 |
Author URI: http://meowapps.com
|
9 |
Text Domain: media-file-renamer
|
@@ -18,10 +18,18 @@ Originally developed for two of my websites:
|
|
18 |
- Haikyo (http://haikyo.org)
|
19 |
*/
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
if ( is_admin() ) {
|
22 |
|
23 |
global $mfrh_version;
|
24 |
-
$mfrh_version = '3.6.
|
25 |
|
26 |
// Admin
|
27 |
require( 'mfrh_admin.php');
|
3 |
Plugin Name: Media File Renamer
|
4 |
Plugin URI: http://meowapps.com
|
5 |
Description: Auto-rename the files when titles are modified and update and the references (links). Manual Rename is a Pro option. Please read the description.
|
6 |
+
Version: 3.6.6
|
7 |
Author: Jordy Meow
|
8 |
Author URI: http://meowapps.com
|
9 |
Text Domain: media-file-renamer
|
18 |
- Haikyo (http://haikyo.org)
|
19 |
*/
|
20 |
|
21 |
+
if ( class_exists( 'Meow_MFRH_Core' ) ) {
|
22 |
+
function mfrh_admin_notices() {
|
23 |
+
echo '<div class="error"><p>Thanks for installing the Pro version of Media File Renamer :) However, the free version is still enabled. Please disable or uninstall it.</p></div>';
|
24 |
+
}
|
25 |
+
add_action( 'admin_notices', 'mfrh_admin_notices' );
|
26 |
+
return;
|
27 |
+
}
|
28 |
+
|
29 |
if ( is_admin() ) {
|
30 |
|
31 |
global $mfrh_version;
|
32 |
+
$mfrh_version = '3.6.6';
|
33 |
|
34 |
// Admin
|
35 |
require( 'mfrh_admin.php');
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: TigrouMeow
|
|
3 |
Tags: rename, file, media, management, image, renamer, wpml, wp-retina-2x
|
4 |
Requires at least: 4.2
|
5 |
Tested up to: 4.8
|
6 |
-
Stable tag: 3.6.
|
7 |
|
8 |
Automatically rename files depending on Media titles dynamically + update links. Pro version has many more options. Check the description :)
|
9 |
|
@@ -100,6 +100,9 @@ You are welcome to create plugins using Media File Renamer using special rules f
|
|
100 |
|
101 |
== Changelog ==
|
102 |
|
|
|
|
|
|
|
103 |
= 3.6.4 =
|
104 |
* Add: Button "Undo All" to restore all the original filenames.
|
105 |
* Fix: Avoid the Numbered Files and Force Renamed options to be activated at the same time.
|
3 |
Tags: rename, file, media, management, image, renamer, wpml, wp-retina-2x
|
4 |
Requires at least: 4.2
|
5 |
Tested up to: 4.8
|
6 |
+
Stable tag: 3.6.6
|
7 |
|
8 |
Automatically rename files depending on Media titles dynamically + update links. Pro version has many more options. Check the description :)
|
9 |
|
100 |
|
101 |
== Changelog ==
|
102 |
|
103 |
+
= 3.6.6 =
|
104 |
+
* Add: Table with the filenames before and after renaming + CSV Export (works with Redirection plugin).
|
105 |
+
|
106 |
= 3.6.4 =
|
107 |
* Add: Button "Undo All" to restore all the original filenames.
|
108 |
* Fix: Avoid the Numbered Files and Force Renamed options to be activated at the same time.
|