Version Description
- Add: Better handling of dots and hyphens (especially the non-standard ones).
- Add: Support for WebP.
- Note: If you like it, please review the plugin by clicking here. It's important for us - we need motivation for all the work we want to put in the next version :)
Download this release
Release Info
Developer | TigrouMeow |
Plugin | Media File Renamer |
Version | 4.6.7 |
Comparing to | |
See all releases |
Code changes from version 4.6.5 to 4.6.7
- common/admin.php +136 -85
- common/img/default.png +0 -0
- common/img/kinsta.png +0 -0
- common/img/media-cleaner.jpg +0 -0
- common/img/media-file-renamer.jpg +0 -0
- common/img/meow-gallery.jpg +0 -0
- common/img/meow-lightbox.jpg +0 -0
- common/img/meowapps.png +0 -0
- common/img/stackpath.png +0 -0
- common/img/wp-retina-2x.jpg +0 -0
- common/img/wplr-sync.jpg +0 -0
- core.php +160 -34
- media-file-renamer.php +2 -2
- readme.txt +6 -4
- style.css +4 -4
- ui.php +17 -6
- views/column.php +5 -1
common/admin.php
CHANGED
@@ -7,7 +7,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
7 |
public static $logo = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxIiB2aWV3Qm94PSIwIDAgMTY1IDE2NSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8c3R5bGU+CiAgICAuc3Qye2ZpbGw6IzgwNDYyNX0uc3Qze2ZpbGw6I2ZkYTk2MH0KICA8L3N0eWxlPgogIDxwYXRoIGQ9Ik03MiA3YTc2IDc2IDAgMCAxIDg0IDkxQTc1IDc1IDAgMSAxIDcyIDd6IiBmaWxsPSIjNGE2YjhjIi8+CiAgPHBhdGggZD0iTTQ4IDQ4YzIgNSAyIDEwIDUgMTQgNSA4IDEzIDE3IDIyIDIwbDEtMTBjMS0yIDMtMyA1LTNoMTNjMiAwIDQgMSA1IDNsMyA5IDQtMTBjMi0zIDYtMiA5LTJoMTFjMyAyIDMgNSAzIDhsMiAzN2MwIDMtMSA3LTQgOGgtMTJjLTIgMC0zLTItNS00LTEgMS0yIDMtNCAzLTUgMS05IDEtMTMtMS0zIDItNSAyLTkgMnMtOSAxLTEwLTNjLTItNC0xLTggMC0xMi04LTMtMTUtNy0yMi0xMi03LTctMTUtMTQtMjAtMjMtMy00LTUtOC01LTEzIDEtNCAzLTEwIDYtMTMgNC0zIDEyLTIgMTUgMnoiIGZpbGw9IiMxMDEwMTAiLz4KICA8cGF0aCBjbGFzcz0ic3QyIiBkPSJNNDMgNTFsNCAxMS02IDVoLTZjLTMtNS0zLTExIDAtMTYgMi0yIDYtMyA4IDB6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTQ3IDYybDMgNmMwIDMgMCA0LTIgNnMtNCAyLTcgMmwtNi05aDZsNi01eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik01MCA2OGw4IDljLTMgMy01IDYtOSA4bC04LTljMyAwIDUgMCA3LTJzMy0zIDItNnoiLz4KICA8cGF0aCBkPSJNODIgNzRoMTJsNSAxOCAzIDExIDgtMjloMTNsMiA0MmgtOGwtMS0yLTEtMzEtMTAgMzItNyAxLTktMzMtMSAyOS0xIDRoLThsMy00MnoiIGZpbGw9IiNmZmYiLz4KICA8cGF0aCBjbGFzcz0ic3QzIiBkPSJNNTggNzdsNSA1Yy0xIDQtMiA4LTcgOGwtNy01YzQtMiA2LTUgOS04eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik02MyA4Mmw5IDUtNiA5LTEwLTZjNSAwIDYtNCA3LTh6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTcyIDg3bDMgMS0xIDExLTgtMyA2LTEweiIvPgo8L3N2Zz4K';
|
8 |
|
9 |
public static $loaded = false;
|
10 |
-
public static $admin_version = "2.
|
11 |
|
12 |
public $prefix; // prefix used for actions, filters (mfrh)
|
13 |
public $mainfile; // plugin main file (media-file-renamer.php)
|
@@ -52,18 +52,19 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
52 |
}
|
53 |
}
|
54 |
}
|
55 |
-
|
56 |
add_filter( 'edd_sl_api_request_verify_ssl', array( $this, 'request_verify_ssl' ), 10, 0 );
|
57 |
}
|
58 |
|
59 |
function wp_ajax_meow_perf_load() {
|
60 |
-
return 'Did nothing but a blank request.';
|
61 |
}
|
62 |
|
63 |
function wp_ajax_meow_file_check() {
|
64 |
$tmpfile = wp_tempnam();
|
65 |
unlink( $tmpfile );
|
66 |
-
|
|
|
67 |
}
|
68 |
|
69 |
function request_verify_ssl() {
|
@@ -106,19 +107,28 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
106 |
}
|
107 |
$rating_date = get_option( $this->prefix . '_rating_date' );
|
108 |
echo '<div class="notice notice-success" data-rating-date="' . date( 'Y-m-d', $rating_date ) . '">';
|
109 |
-
echo '<p style="font-size: 100%;">
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
echo '<p>
|
111 |
<form method="post" action="" style="float: right;">
|
112 |
<input type="hidden" name="' . $this->prefix . '_never_remind_me" value="true">
|
113 |
-
<input type="submit" name="submit" id="submit" class="button button-red" value="
|
|
|
114 |
</form>
|
115 |
<form method="post" action="" style="float: right; margin-right: 10px;">
|
116 |
<input type="hidden" name="' . $this->prefix . '_remind_me" value="true">
|
117 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="
|
|
|
118 |
</form>
|
119 |
<form method="post" action="" style="float: right; margin-right: 10px;">
|
120 |
<input type="hidden" name="' . $this->prefix . '_did_it" value="true">
|
121 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="
|
|
|
122 |
</form>
|
123 |
<div style="clear: both;"></div>
|
124 |
</p>
|
@@ -154,11 +164,15 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
154 |
return;
|
155 |
}
|
156 |
echo '<div class="error">';
|
157 |
-
|
|
|
|
|
|
|
158 |
echo '<p>
|
159 |
<form method="post" action="">
|
160 |
<input type="hidden" name="' . $this->prefix . '_reset_sub" value="true">
|
161 |
-
<input type="submit" name="submit" id="submit" class="button" value="
|
|
|
162 |
</form>
|
163 |
</p>
|
164 |
';
|
@@ -208,13 +222,13 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
208 |
}
|
209 |
|
210 |
add_settings_section( 'meowapps_common_settings', null, null, 'meowapps_common_settings-menu' );
|
211 |
-
add_settings_field( 'meowapps_hide_meowapps',
|
212 |
array( $this, 'meowapps_hide_dashboard_callback' ),
|
213 |
'meowapps_common_settings-menu', 'meowapps_common_settings' );
|
214 |
-
add_settings_field( 'meowapps_force_sslverify',
|
215 |
array( $this, 'meowapps_force_sslverify_callback' ),
|
216 |
'meowapps_common_settings-menu', 'meowapps_common_settings' );
|
217 |
-
// add_settings_field( 'meowapps_hide_ads',
|
218 |
// array( $this, 'meowapps_hide_ads_callback' ),
|
219 |
// 'meowapps_common_settings-menu', 'meowapps_common_settings' );
|
220 |
register_setting( 'meowapps_common_settings', 'force_sslverify' );
|
@@ -226,36 +240,42 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
226 |
$value = get_option( 'meowapps_hide_ads', null );
|
227 |
$html = '<input type="checkbox" id="meowapps_hide_ads" name="meowapps_hide_ads" value="1" ' .
|
228 |
checked( 1, get_option( 'meowapps_hide_ads' ), false ) . '/>';
|
229 |
-
|
230 |
-
|
231 |
}
|
232 |
|
233 |
function meowapps_hide_dashboard_callback() {
|
234 |
$value = get_option( 'meowapps_hide_meowapps', null );
|
235 |
$html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
|
236 |
checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
|
237 |
-
|
238 |
-
|
239 |
}
|
240 |
|
241 |
function meowapps_force_sslverify_callback() {
|
242 |
$value = get_option( 'force_sslverify', null );
|
243 |
$html = '<input type="checkbox" id="force_sslverify" name="force_sslverify" value="1" ' .
|
244 |
checked( 1, get_option( 'force_sslverify' ), false ) . '/>';
|
245 |
-
|
246 |
-
|
247 |
}
|
248 |
|
249 |
function display_serialkey_box( $url = "https://meowapps.com/" ) {
|
250 |
$html = '<div class="meow-box">';
|
251 |
-
|
252 |
-
|
253 |
-
|
|
|
|
|
254 |
echo $html;
|
255 |
-
$html = apply_filters(
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
|
|
259 |
echo $html;
|
260 |
}
|
261 |
|
@@ -271,7 +291,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
271 |
$pluginpath = trailingslashit( plugin_dir_path( __FILE__ ) ) . '../../' . $plugin;
|
272 |
if ( !file_exists( $pluginpath ) ) {
|
273 |
$url = wp_nonce_url( "update.php?action=install-plugin&plugin=$plugin", "install-plugin_$plugin" );
|
274 |
-
return "<a href='$url'><small><span class='' style='float: right;'>install</span></small></a>";
|
275 |
}
|
276 |
}
|
277 |
else {
|
@@ -293,12 +313,12 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
293 |
'activate-plugin_' . $plugin_file );
|
294 |
return '<small><span style="color: black; float: right;">off
|
295 |
(<a style="color: rgba(30,140,190,1); text-decoration: none;" href="' .
|
296 |
-
$url . '">enable</a>)</span></small>';
|
297 |
}
|
298 |
}
|
299 |
|
300 |
function common_url( $file ) {
|
301 |
-
die( "Meow Apps: The function common_url( \$file ) needs to be overriden." );
|
302 |
// Normally, this should be used:
|
303 |
// return plugin_dir_url( __FILE__ ) . ( '\/common\/' . $file );
|
304 |
}
|
@@ -309,8 +329,8 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
309 |
|
310 |
function plugins_loaded() {
|
311 |
if ( isset( $_GET[ 'tool' ] ) && $_GET[ 'tool' ] == 'error_log' ) {
|
312 |
-
|
313 |
-
|
314 |
}
|
315 |
}
|
316 |
|
@@ -318,7 +338,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
318 |
|
319 |
echo '<div class="wrap meow-dashboard">';
|
320 |
if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'phpinfo' ) {
|
321 |
-
echo "<a href=\"javascript:history.go(-1)\">< Go back</a><br /><br />";
|
322 |
echo '<div id="phpinfo">';
|
323 |
ob_start();
|
324 |
phpinfo();
|
@@ -329,20 +349,25 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
329 |
echo "</div>";
|
330 |
}
|
331 |
else if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'error_log' ) {
|
332 |
-
$log_msg = '=== MEOW APPS DEBUG (This is not an error) ===';
|
333 |
if ( isset( $_POST['write_logs'] ) ) {
|
334 |
error_log( $log_msg );
|
335 |
}
|
336 |
$errorpath = ini_get( 'error_log' );
|
337 |
-
echo "<a href=\"javascript:history.go(-1)\">< Go back</a><br /><br />";
|
338 |
echo '
|
339 |
<form method="post">
|
340 |
<input type="hidden" name="write_logs" value="true">
|
341 |
-
<input class="button button-primary" type="submit" value="Write in the Error Logs">
|
342 |
</form><br />';
|
343 |
echo '<div id="error_log">';
|
344 |
if ( file_exists( $errorpath ) ) {
|
345 |
-
|
|
|
|
|
|
|
|
|
|
|
346 |
$errors = file_get_contents( $errorpath );
|
347 |
$errors = explode( "\n", $errors );
|
348 |
$errors = array_reverse( $errors );
|
@@ -350,7 +375,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
350 |
echo $errors;
|
351 |
}
|
352 |
else {
|
353 |
-
|
354 |
}
|
355 |
echo "</div>";
|
356 |
|
@@ -363,28 +388,27 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
363 |
<?php _e( 'Meow Apps is run by Jordy Meow, a photographer and software developer living in Japan (and taking <a target="_blank" href="http://offbeatjapan.org">a lot of photos</a>). Meow Apps is a suite of plugins focusing on photography, imaging, optimization and it teams up with the best players in the community (other themes and plugins developers). For more information, please check <a href="http://meowapps.com" target="_blank">Meow Apps</a>.', $this->domain )
|
364 |
?>
|
365 |
</p>
|
366 |
-
|
367 |
-
<h2 style="margin-bottom: 0px; margin-top: 25px;"
|
368 |
<div class="meow-row meow-featured-plugins">
|
369 |
<div class="meow-box meow-col meow-span_1_of_2">
|
370 |
<ul class="">
|
371 |
<li><img src='<?= $this->common_url( 'img/media-cleaner.jpg' ) ?>' />
|
372 |
<a href='https://meowapps.com/plugin/media-cleaner/'><b>Media Cleaner</b></a>
|
373 |
<?php echo $this->check_install( 'media-cleaner' ) ?><br />
|
374 |
-
|
375 |
<li><img src='<?= $this->common_url( 'img/media-file-renamer.jpg' ) ?>' />
|
376 |
<a href='https://meowapps.com/plugin/media-file-renamer/'><b>Media File Renamer</b></a>
|
377 |
-
|
378 |
-
|
379 |
<li><img src='<?= $this->common_url( 'img/default.png' ) ?>' />
|
380 |
<a href='https://meowapps.com/plugin/contact-form-block/'><b>Contact Form Block</b></a>
|
381 |
<?php echo $this->check_install( 'contact-form-block' ) ?><br />
|
382 |
-
A simpler, nicer, prettier contact form
|
383 |
-
|
384 |
-
|
385 |
-
<?php echo $this->check_install( '
|
386 |
-
|
387 |
-
|
388 |
</ul>
|
389 |
</div>
|
390 |
<div class="meow-box meow-col meow-span_1_of_2 ">
|
@@ -392,41 +416,63 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
392 |
<li><img src='<?= $this->common_url( 'img/meow-gallery.jpg' ) ?>' />
|
393 |
<a href='https://meowapps.com/plugin/meow-gallery/'><b>Meow Gallery</b></a>
|
394 |
<?php echo $this->check_install( 'meow-gallery' ) ?><br />
|
395 |
-
Beautiful but lightweight gallery with many layouts. The only one that allows you to uninstall it without losing anything
|
396 |
<li><img src='<?= $this->common_url( 'img/meow-lightbox.jpg' ) ?>' />
|
397 |
<a href='https://meowapps.com/plugin/meow-lightbox/'><b>Meow Lightbox</b></a>
|
398 |
<?php echo $this->check_install( 'meow-lightbox' ) ?><br />
|
399 |
-
|
400 |
<li><img src='<?= $this->common_url( 'img/wplr-sync.jpg' ) ?>' />
|
401 |
<a href='https://meowapps.com/plugin/wplr-sync/'><b>WP/LR Sync</b></a>
|
402 |
<?php echo $this->check_install( 'wplr-sync' ) ?><br />
|
403 |
-
Synchronize your Lightroom to your WordPress. This plugin is loved by
|
|
|
|
|
|
|
|
|
404 |
</ul>
|
405 |
</div>
|
406 |
</div>
|
407 |
|
408 |
-
<h2
|
409 |
<div style="background: white; padding: 5px 15px 5px 15px; box-shadow: 2px 2px 1px rgba(0,0,0,.02); margin-bottom: 15px;">
|
410 |
<p><?php _e( 'The <b>Empty Request Time</b> helps you analyzing the raw performance of your install by giving you the average time it takes to run an empty request to your server. You can try to disable some plugins (or change their options) then and click on Reset to see how it influences the results. With <b>File Operation Time</b>, you will find out if your server is slow with files. An excellent install would have an Empty Request Time of less than 500 ms. Keep it absolutely under 2,000 ms. File Operation Time should take only a few milliseconds more than the Empty Request Time. For more information about this, <a href="https://meowapps.com/clean-optimize-wordpress/#Optimize_your_Empty_Request_Time" target="_blank">click here</a>.', $this->domain ); ?></p>
|
411 |
</div>
|
412 |
|
413 |
-
<div
|
414 |
-
|
415 |
-
<div style=
|
416 |
-
|
417 |
-
<
|
|
|
|
|
|
|
|
|
418 |
</div>
|
419 |
-
<input type='submit' style='text-align: center; width: 100%;' id="meow-perf-reset" value="Reset" class="button button-primary">
|
420 |
-
</div>
|
421 |
-
|
422 |
-
<div style="float: left; margin-right: 10px; text-align: center; padding: 10px; background: white; width: 200px; border: 1px solid #e2e2e2;">
|
423 |
-
<div style='font-size: 14px; line-height: 14px; margin-bottom: 20px;'>File Operation Time</div>
|
424 |
-
<div style='font-size: 32px; line-height: 32px; margin-bottom: 10px;' id='meow-file-check-time'>N/A</div>
|
425 |
-
<div style='font-size: 12px; line-height: 12px; margin-bottom: 20px;'>Create temporary file and delete it.</div>
|
426 |
-
<input type='submit' style='text-align: center; width: 100%;' id="meow-file-check-start" value="Check" class="button button-primary">
|
427 |
-
</div>
|
428 |
|
429 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
|
431 |
<script>
|
432 |
(function ($) {
|
@@ -436,7 +482,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
436 |
$('#meow-perf-reset').on('click', function () {
|
437 |
calls = 0;
|
438 |
times = [];
|
439 |
-
$('#meow-perf-load-average').text('N/A');
|
440 |
$('#meow-perf-load-count').text('0');
|
441 |
});
|
442 |
|
@@ -455,7 +501,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
455 |
times.push(time);
|
456 |
var sum = times.reduce(function(a, b) { return a + b; });
|
457 |
var avg = Math.ceil(sum / times.length);
|
458 |
-
$('#meow-perf-load-average').text(avg + ' ms');
|
459 |
$('#meow-perf-load-count').text(calls);
|
460 |
setTimeout(perfLoad, 5000);
|
461 |
});
|
@@ -472,8 +518,8 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
472 |
}).done(function (response) {
|
473 |
var end = new Date().getTime();
|
474 |
var time = end - start;
|
475 |
-
$('#meow-file-check-time').text(time + ' ms');
|
476 |
-
$('#meow-file-check-start').text('Check');
|
477 |
});
|
478 |
};
|
479 |
|
@@ -483,30 +529,31 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
483 |
});
|
484 |
|
485 |
setTimeout(perfLoad, 1500);
|
486 |
-
|
487 |
})(jQuery);
|
488 |
</script>
|
489 |
|
|
|
490 |
<div style="background: white; padding: 5px 15px 5px 15px; box-shadow: 2px 2px 1px rgba(0,0,0,.02); margin-top: 15px;">
|
491 |
<p>
|
492 |
<?php _e( 'Too many WordPress installs are blown-up with useless and/or huge plugins, and bad practices. But that is because most users are overwhelmed by the diversity and immensity of the WordPress jungle. One rule of thumb is to keep your install the simplest as possible, with the least number of plugins (avoiding heavy ones too) and a good hosting service (avoid VPS except if you know exactly what you are doing). Articles are kept being updated on the Meow Apps website, with all the latest recommendations: ', $this->domain )?>
|
493 |
<a href='https://meowapps.com/debugging-wordpress/' target='_blank'>
|
494 |
-
How To Debug</a>,
|
495 |
<a href='https://meowapps.com/seo-optimization/' target='_blank'>
|
496 |
-
SEO Checklist & Optimization</a>,
|
497 |
<a href='https://meowapps.com/clean-optimize-wordpress/' target='_blank'>
|
498 |
-
Clean Up and Optimize</a>,
|
499 |
<a href='https://meowapps.com/optimize-images-cdn/' target='_blank'>
|
500 |
-
Optimize Images</a>,
|
501 |
<a href='https://meowapps.com/best-hosting-services-wordpress/' target='_blank'>
|
502 |
Best Hosting Services</a>.
|
503 |
</p>
|
504 |
</div>
|
505 |
|
506 |
-
<h2 style="margin-bottom: 0px; margin-top: 25px;"
|
507 |
<div class="meow-row">
|
508 |
<div class="meow-box meow-col meow-span_2_of_3">
|
509 |
-
<h3><span class="dashicons dashicons-admin-tools"></span> Common
|
510 |
<div class="inside">
|
511 |
<form method="post" action="options.php">
|
512 |
<?php settings_fields( 'meowapps_common_settings' ); ?>
|
@@ -517,17 +564,17 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
517 |
</div>
|
518 |
|
519 |
<div class="meow-box meow-col meow-span_1_of_3">
|
520 |
-
<h3><span class="dashicons dashicons-admin-tools"></span> Debug
|
521 |
<div class="inside">
|
522 |
<ul>
|
523 |
-
<li><a href="?page=meowapps-main-menu&tool=error_log"
|
524 |
-
<li><a href="?page=meowapps-main-menu&tool=phpinfo"
|
525 |
</ul>
|
526 |
</div>
|
527 |
</div>
|
528 |
|
529 |
<div class="meow-box meow-col meow-span_1_of_3">
|
530 |
-
<h3><span class="dashicons dashicons-admin-tools"></span> Post Types (used by this install)
|
531 |
<div class="inside">
|
532 |
<?php
|
533 |
global $wpdb;
|
@@ -537,7 +584,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
537 |
$result = array();
|
538 |
foreach( $types as $type )
|
539 |
array_push( $result, "{$type->type} ({$type->count})" );
|
540 |
-
echo implode(
|
541 |
?>
|
542 |
</div>
|
543 |
</div>
|
@@ -548,8 +595,12 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
548 |
}
|
549 |
|
550 |
function admin_footer_text( $current ) {
|
551 |
-
return
|
552 |
-
|
|
|
|
|
|
|
|
|
553 |
}
|
554 |
|
555 |
// HELPERS
|
7 |
public static $logo = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxIiB2aWV3Qm94PSIwIDAgMTY1IDE2NSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8c3R5bGU+CiAgICAuc3Qye2ZpbGw6IzgwNDYyNX0uc3Qze2ZpbGw6I2ZkYTk2MH0KICA8L3N0eWxlPgogIDxwYXRoIGQ9Ik03MiA3YTc2IDc2IDAgMCAxIDg0IDkxQTc1IDc1IDAgMSAxIDcyIDd6IiBmaWxsPSIjNGE2YjhjIi8+CiAgPHBhdGggZD0iTTQ4IDQ4YzIgNSAyIDEwIDUgMTQgNSA4IDEzIDE3IDIyIDIwbDEtMTBjMS0yIDMtMyA1LTNoMTNjMiAwIDQgMSA1IDNsMyA5IDQtMTBjMi0zIDYtMiA5LTJoMTFjMyAyIDMgNSAzIDhsMiAzN2MwIDMtMSA3LTQgOGgtMTJjLTIgMC0zLTItNS00LTEgMS0yIDMtNCAzLTUgMS05IDEtMTMtMS0zIDItNSAyLTkgMnMtOSAxLTEwLTNjLTItNC0xLTggMC0xMi04LTMtMTUtNy0yMi0xMi03LTctMTUtMTQtMjAtMjMtMy00LTUtOC01LTEzIDEtNCAzLTEwIDYtMTMgNC0zIDEyLTIgMTUgMnoiIGZpbGw9IiMxMDEwMTAiLz4KICA8cGF0aCBjbGFzcz0ic3QyIiBkPSJNNDMgNTFsNCAxMS02IDVoLTZjLTMtNS0zLTExIDAtMTYgMi0yIDYtMyA4IDB6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTQ3IDYybDMgNmMwIDMgMCA0LTIgNnMtNCAyLTcgMmwtNi05aDZsNi01eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik01MCA2OGw4IDljLTMgMy01IDYtOSA4bC04LTljMyAwIDUgMCA3LTJzMy0zIDItNnoiLz4KICA8cGF0aCBkPSJNODIgNzRoMTJsNSAxOCAzIDExIDgtMjloMTNsMiA0MmgtOGwtMS0yLTEtMzEtMTAgMzItNyAxLTktMzMtMSAyOS0xIDRoLThsMy00MnoiIGZpbGw9IiNmZmYiLz4KICA8cGF0aCBjbGFzcz0ic3QzIiBkPSJNNTggNzdsNSA1Yy0xIDQtMiA4LTcgOGwtNy01YzQtMiA2LTUgOS04eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik02MyA4Mmw5IDUtNiA5LTEwLTZjNSAwIDYtNCA3LTh6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTcyIDg3bDMgMS0xIDExLTgtMyA2LTEweiIvPgo8L3N2Zz4K';
|
8 |
|
9 |
public static $loaded = false;
|
10 |
+
public static $admin_version = "2.6";
|
11 |
|
12 |
public $prefix; // prefix used for actions, filters (mfrh)
|
13 |
public $mainfile; // plugin main file (media-file-renamer.php)
|
52 |
}
|
53 |
}
|
54 |
}
|
55 |
+
|
56 |
add_filter( 'edd_sl_api_request_verify_ssl', array( $this, 'request_verify_ssl' ), 10, 0 );
|
57 |
}
|
58 |
|
59 |
function wp_ajax_meow_perf_load() {
|
60 |
+
return __( 'Did nothing but a blank request.', $this->domain );
|
61 |
}
|
62 |
|
63 |
function wp_ajax_meow_file_check() {
|
64 |
$tmpfile = wp_tempnam();
|
65 |
unlink( $tmpfile );
|
66 |
+
// translators: %s is a filename of an empty temporary file
|
67 |
+
return sprintf( __( 'Created and deleted %s', $this->domain ), $tmpfile );
|
68 |
}
|
69 |
|
70 |
function request_verify_ssl() {
|
107 |
}
|
108 |
$rating_date = get_option( $this->prefix . '_rating_date' );
|
109 |
echo '<div class="notice notice-success" data-rating-date="' . date( 'Y-m-d', $rating_date ) . '">';
|
110 |
+
echo '<p style="font-size: 100%;">';
|
111 |
+
printf(
|
112 |
+
// translators: %1$s is a plugin nicename, %2$s is a short url (slug)
|
113 |
+
__( 'You have been using <b>%1$s</b> for some time now. Thank you! Could you kindly share your opinion with me, along with, maybe, features you would like to see implemented? Then, please <a style="font-weight: bold; color: #b926ff;" target="_blank" href="https://wordpress.org/support/plugin/%2$s/reviews/?rate=5#new-post">write a little review</a>. That will also bring me joy and motivation, and I will get back to you :) <u>In the case you already have written a review</u>, please check again. Many reviews got removed from WordPress recently.', $this->domain ),
|
114 |
+
$this->nice_name_from_file( $this->mainfile ),
|
115 |
+
$this->nice_short_url_from_file( $this->mainfile )
|
116 |
+
);
|
117 |
echo '<p>
|
118 |
<form method="post" action="" style="float: right;">
|
119 |
<input type="hidden" name="' . $this->prefix . '_never_remind_me" value="true">
|
120 |
+
<input type="submit" name="submit" id="submit" class="button button-red" value="'
|
121 |
+
. __( 'Never remind me!', $this->domain ) . '">
|
122 |
</form>
|
123 |
<form method="post" action="" style="float: right; margin-right: 10px;">
|
124 |
<input type="hidden" name="' . $this->prefix . '_remind_me" value="true">
|
125 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="'
|
126 |
+
. __( 'Remind me in a few weeks...', $this->domain ) . '">
|
127 |
</form>
|
128 |
<form method="post" action="" style="float: right; margin-right: 10px;">
|
129 |
<input type="hidden" name="' . $this->prefix . '_did_it" value="true">
|
130 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="'
|
131 |
+
. __( 'Yes, I did it!', $this->domain ) . '">
|
132 |
</form>
|
133 |
<div style="clear: both;"></div>
|
134 |
</p>
|
164 |
return;
|
165 |
}
|
166 |
echo '<div class="error">';
|
167 |
+
printf(
|
168 |
+
// translators: %s is a plugin nicename
|
169 |
+
__( '<p>It looks like you are using the free version of the plugin (<b>%s</b>) but a license for the Pro version was also found. The Pro version might have been replaced by the Free version during an update (might be caused by a temporarily issue). If it is the case, <b>please download it again</b> from the <a target="_blank" href="https://store.meowapps.com">Meow Store</a>. If you wish to continue using the free version and clear this message, click on this button.', $this->domain ),
|
170 |
+
$this->nice_name_from_file( $this->mainfile ) );
|
171 |
echo '<p>
|
172 |
<form method="post" action="">
|
173 |
<input type="hidden" name="' . $this->prefix . '_reset_sub" value="true">
|
174 |
+
<input type="submit" name="submit" id="submit" class="button" value="'
|
175 |
+
. __( 'Remove the license', $this->domain ) . '">
|
176 |
</form>
|
177 |
</p>
|
178 |
';
|
222 |
}
|
223 |
|
224 |
add_settings_section( 'meowapps_common_settings', null, null, 'meowapps_common_settings-menu' );
|
225 |
+
add_settings_field( 'meowapps_hide_meowapps', __( 'Main Menu', $this->domain ),
|
226 |
array( $this, 'meowapps_hide_dashboard_callback' ),
|
227 |
'meowapps_common_settings-menu', 'meowapps_common_settings' );
|
228 |
+
add_settings_field( 'meowapps_force_sslverify', __( 'SSL Verify', $this->domain ),
|
229 |
array( $this, 'meowapps_force_sslverify_callback' ),
|
230 |
'meowapps_common_settings-menu', 'meowapps_common_settings' );
|
231 |
+
// add_settings_field( 'meowapps_hide_ads', __( 'Ads', $this->domain ),
|
232 |
// array( $this, 'meowapps_hide_ads_callback' ),
|
233 |
// 'meowapps_common_settings-menu', 'meowapps_common_settings' );
|
234 |
register_setting( 'meowapps_common_settings', 'force_sslverify' );
|
240 |
$value = get_option( 'meowapps_hide_ads', null );
|
241 |
$html = '<input type="checkbox" id="meowapps_hide_ads" name="meowapps_hide_ads" value="1" ' .
|
242 |
checked( 1, get_option( 'meowapps_hide_ads' ), false ) . '/>';
|
243 |
+
$html .= __( '<label>Hide</label><br /><small>Doesn\'t display the ads.</small>', $this->domain );
|
244 |
+
echo $html;
|
245 |
}
|
246 |
|
247 |
function meowapps_hide_dashboard_callback() {
|
248 |
$value = get_option( 'meowapps_hide_meowapps', null );
|
249 |
$html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
|
250 |
checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
|
251 |
+
$html .= __( '<label>Hide <b>Meow Apps</b> Menu</label><br /><small>Hide Meow Apps menu and all its components, for a cleaner admin. This option will be reset if a new Meow Apps plugin is installed. <b>Once activated, an option will be added in your General settings to display it again.</b></small>', $this->domain );
|
252 |
+
echo $html;
|
253 |
}
|
254 |
|
255 |
function meowapps_force_sslverify_callback() {
|
256 |
$value = get_option( 'force_sslverify', null );
|
257 |
$html = '<input type="checkbox" id="force_sslverify" name="force_sslverify" value="1" ' .
|
258 |
checked( 1, get_option( 'force_sslverify' ), false ) . '/>';
|
259 |
+
$html .= __( '<label>Force</label><br /><small>Updates and licenses checks are usually made without checking SSL certificates and it is actually fine this way. But if you are intransigent when it comes to SSL matters, this option will force it.</small>', $this->domain );
|
260 |
+
echo $html;
|
261 |
}
|
262 |
|
263 |
function display_serialkey_box( $url = "https://meowapps.com/" ) {
|
264 |
$html = '<div class="meow-box">';
|
265 |
+
$html .= '<h3 class="' . ( $this->is_registered( $this->prefix ) ? 'meow-bk-blue' : 'meow-bk-red' ) . '">'
|
266 |
+
. __( 'Pro Version', $this->domain ) . ' '
|
267 |
+
. ( $this->is_registered( $this->prefix ) ? __( '(enabled)', $this->domain ) : __( '(disabled)', $this->domain ) )
|
268 |
+
. '</h3>';
|
269 |
+
$html .= '<div class="inside">';
|
270 |
echo $html;
|
271 |
+
$html = apply_filters(
|
272 |
+
$this->prefix . '_meowapps_license_input',
|
273 |
+
sprintf(
|
274 |
+
// translators: %1$s is a url attribute, %2$s is a url visible for user
|
275 |
+
__( 'More information about the Pro version here: <a target="_blank" href="%1$s">%2$s</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>.', $this->domain ), $url, $url ),
|
276 |
+
$url );
|
277 |
+
$html .= '</div>';
|
278 |
+
$html .= '</div>';
|
279 |
echo $html;
|
280 |
}
|
281 |
|
291 |
$pluginpath = trailingslashit( plugin_dir_path( __FILE__ ) ) . '../../' . $plugin;
|
292 |
if ( !file_exists( $pluginpath ) ) {
|
293 |
$url = wp_nonce_url( "update.php?action=install-plugin&plugin=$plugin", "install-plugin_$plugin" );
|
294 |
+
return "<a href='$url'><small><span class='' style='float: right;'>" . __( 'install', $this->domain ) . "</span></small></a>";
|
295 |
}
|
296 |
}
|
297 |
else {
|
313 |
'activate-plugin_' . $plugin_file );
|
314 |
return '<small><span style="color: black; float: right;">off
|
315 |
(<a style="color: rgba(30,140,190,1); text-decoration: none;" href="' .
|
316 |
+
$url . '">' . __( 'enable', $this->domain ) . '</a>)</span></small>';
|
317 |
}
|
318 |
}
|
319 |
|
320 |
function common_url( $file ) {
|
321 |
+
die( __( "Meow Apps: The function common_url( \$file ) needs to be overriden.", $this->domain ) );
|
322 |
// Normally, this should be used:
|
323 |
// return plugin_dir_url( __FILE__ ) . ( '\/common\/' . $file );
|
324 |
}
|
329 |
|
330 |
function plugins_loaded() {
|
331 |
if ( isset( $_GET[ 'tool' ] ) && $_GET[ 'tool' ] == 'error_log' ) {
|
332 |
+
$sec = "5";
|
333 |
+
header( "Refresh: $sec;" );
|
334 |
}
|
335 |
}
|
336 |
|
338 |
|
339 |
echo '<div class="wrap meow-dashboard">';
|
340 |
if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'phpinfo' ) {
|
341 |
+
echo "<a href=\"javascript:history.go(-1)\">< ". __( 'Go back', $this->domain ) . "</a><br /><br />";
|
342 |
echo '<div id="phpinfo">';
|
343 |
ob_start();
|
344 |
phpinfo();
|
349 |
echo "</div>";
|
350 |
}
|
351 |
else if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'error_log' ) {
|
352 |
+
$log_msg = __( '=== MEOW APPS DEBUG (This is not an error) ===', $this->domain );
|
353 |
if ( isset( $_POST['write_logs'] ) ) {
|
354 |
error_log( $log_msg );
|
355 |
}
|
356 |
$errorpath = ini_get( 'error_log' );
|
357 |
+
echo "<a href=\"javascript:history.go(-1)\">< ". __( 'Go back', $this->domain ) . "</a><br /><br />";
|
358 |
echo '
|
359 |
<form method="post">
|
360 |
<input type="hidden" name="write_logs" value="true">
|
361 |
+
<input class="button button-primary" type="submit" value=" ' . __( 'Write in the Error Logs', $this->domain ) . '">
|
362 |
</form><br />';
|
363 |
echo '<div id="error_log">';
|
364 |
if ( file_exists( $errorpath ) ) {
|
365 |
+
printf(
|
366 |
+
// translators: %s is a preformatted timestamp
|
367 |
+
__( "Now (auto-reload every 5 seconds): [%s UTC]", $this->domain ),
|
368 |
+
date( "d-M-Y H:i:s", time() )
|
369 |
+
);
|
370 |
+
echo "<br /><br /><h2 style='margin: 0px;'>" . __( 'Errors (order by latest)', $this->domain ) . "</h2>";
|
371 |
$errors = file_get_contents( $errorpath );
|
372 |
$errors = explode( "\n", $errors );
|
373 |
$errors = array_reverse( $errors );
|
375 |
echo $errors;
|
376 |
}
|
377 |
else {
|
378 |
+
_e( "The PHP Error Logs cannot be found. Please ask your hosting service for it.", $this->domain );
|
379 |
}
|
380 |
echo "</div>";
|
381 |
|
388 |
<?php _e( 'Meow Apps is run by Jordy Meow, a photographer and software developer living in Japan (and taking <a target="_blank" href="http://offbeatjapan.org">a lot of photos</a>). Meow Apps is a suite of plugins focusing on photography, imaging, optimization and it teams up with the best players in the community (other themes and plugins developers). For more information, please check <a href="http://meowapps.com" target="_blank">Meow Apps</a>.', $this->domain )
|
389 |
?>
|
390 |
</p>
|
391 |
+
|
392 |
+
<h2 style="margin-bottom: 0px; margin-top: 25px;"><?php _e( 'Recommended Meow Apps Plugins', $this->domain ); ?></h2>
|
393 |
<div class="meow-row meow-featured-plugins">
|
394 |
<div class="meow-box meow-col meow-span_1_of_2">
|
395 |
<ul class="">
|
396 |
<li><img src='<?= $this->common_url( 'img/media-cleaner.jpg' ) ?>' />
|
397 |
<a href='https://meowapps.com/plugin/media-cleaner/'><b>Media Cleaner</b></a>
|
398 |
<?php echo $this->check_install( 'media-cleaner' ) ?><br />
|
399 |
+
<?php _e( 'Very complex plugin which analyzes your WordPress deeply to find out which files are in use, or not. Then you can trash them, before deleting them permanently.', $this->domain ); ?></li>
|
400 |
<li><img src='<?= $this->common_url( 'img/media-file-renamer.jpg' ) ?>' />
|
401 |
<a href='https://meowapps.com/plugin/media-file-renamer/'><b>Media File Renamer</b></a>
|
402 |
+
<?php echo $this->check_install( 'media-file-renamer' ) ?><br />
|
403 |
+
<?php _e( 'The Renamer will help you in getting nicer filenames, a better SEO and well-organized files. Extremely popular.', $this->domain ); ?></li>
|
404 |
<li><img src='<?= $this->common_url( 'img/default.png' ) ?>' />
|
405 |
<a href='https://meowapps.com/plugin/contact-form-block/'><b>Contact Form Block</b></a>
|
406 |
<?php echo $this->check_install( 'contact-form-block' ) ?><br />
|
407 |
+
<?php _e( 'A simpler, nicer, prettier contact form. If you simply want your visitors to get in touch with you, this very light plugin will make your life easier.', $this->domain ); ?></li>
|
408 |
+
<li><img src='<?= $this->common_url( 'img/default.png' ) ?>' />
|
409 |
+
<a href='https://meowapps.com/plugin/meow-analytics/'><b>Meow Analytics</b></a>
|
410 |
+
<?php echo $this->check_install( 'meow-analytics' ) ?><br />
|
411 |
+
<?php _e( 'Tired of those fat plugins which are messing-up with your install? Switch to Meow Analytics, it\'s extremely light and features a cute dashboard.', $this->domain ); ?></li>
|
|
|
412 |
</ul>
|
413 |
</div>
|
414 |
<div class="meow-box meow-col meow-span_1_of_2 ">
|
416 |
<li><img src='<?= $this->common_url( 'img/meow-gallery.jpg' ) ?>' />
|
417 |
<a href='https://meowapps.com/plugin/meow-gallery/'><b>Meow Gallery</b></a>
|
418 |
<?php echo $this->check_install( 'meow-gallery' ) ?><br />
|
419 |
+
<?php _e( 'Beautiful but lightweight gallery with many layouts. The only one that allows you to uninstall it without losing anything.', $this->domain ); ?></li>
|
420 |
<li><img src='<?= $this->common_url( 'img/meow-lightbox.jpg' ) ?>' />
|
421 |
<a href='https://meowapps.com/plugin/meow-lightbox/'><b>Meow Lightbox</b></a>
|
422 |
<?php echo $this->check_install( 'meow-lightbox' ) ?><br />
|
423 |
+
<?php _e( 'A very smooth and fast Lightbox which will also display your EXIF data (camera, lens, etc). Try it, you will love it.', $this->domain ); ?></li>
|
424 |
<li><img src='<?= $this->common_url( 'img/wplr-sync.jpg' ) ?>' />
|
425 |
<a href='https://meowapps.com/plugin/wplr-sync/'><b>WP/LR Sync</b></a>
|
426 |
<?php echo $this->check_install( 'wplr-sync' ) ?><br />
|
427 |
+
<?php _e( 'Synchronize your Lightroom to your WordPress. This plugin is loved by a huge community of photographers.', $this->domain ); ?></li>
|
428 |
+
<li><img src='<?= $this->common_url( 'img/wp-retina-2x.jpg' ) ?>' />
|
429 |
+
<a href='https://meowapps.com/plugin/wp-retina-2x/'><b>WP Retina 2x</b></a>
|
430 |
+
<?php echo $this->check_install( 'wp-retina-2x' ) ?><br />
|
431 |
+
<?php _e( 'Here is the very famous plugin that adds Retina support to any website.', $this->domain ); ?></li>
|
432 |
</ul>
|
433 |
</div>
|
434 |
</div>
|
435 |
|
436 |
+
<h2><?php _e( 'WordPress Performance', $this->domain ); ?></h2>
|
437 |
<div style="background: white; padding: 5px 15px 5px 15px; box-shadow: 2px 2px 1px rgba(0,0,0,.02); margin-bottom: 15px;">
|
438 |
<p><?php _e( 'The <b>Empty Request Time</b> helps you analyzing the raw performance of your install by giving you the average time it takes to run an empty request to your server. You can try to disable some plugins (or change their options) then and click on Reset to see how it influences the results. With <b>File Operation Time</b>, you will find out if your server is slow with files. An excellent install would have an Empty Request Time of less than 500 ms. Keep it absolutely under 2,000 ms. File Operation Time should take only a few milliseconds more than the Empty Request Time. For more information about this, <a href="https://meowapps.com/clean-optimize-wordpress/#Optimize_your_Empty_Request_Time" target="_blank">click here</a>.', $this->domain ); ?></p>
|
439 |
</div>
|
440 |
|
441 |
+
<div>
|
442 |
+
|
443 |
+
<div style="float: left; margin-right: 10px; text-align: center; padding: 10px; background: white; width: 200px; border: 1px solid #e2e2e2;">
|
444 |
+
<div style='font-size: 14px; line-height: 14px; margin-bottom: 20px;'><?php _e( 'Empty Request Time', $this->domain ); ?></div>
|
445 |
+
<div style='font-size: 32px; line-height: 32px; margin-bottom: 10px;' id='meow-perf-load-average'><?php _e( 'N/A', $this->domain ); ?></div>
|
446 |
+
<div style='font-size: 12px; line-height: 12px; margin-bottom: 20px;'><?php _e( 'Based on', $this->domain ); ?>
|
447 |
+
<span id='meow-perf-load-count'>0</span> <?php _e( 'request(s)', $this->domain ); ?>
|
448 |
+
</div>
|
449 |
+
<input type='submit' style='text-align: center; width: 100%;' id="meow-perf-reset" value="Reset" class="button button-primary">
|
450 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
|
452 |
+
<div style="float: left; margin-right: 10px; text-align: center; padding: 10px; background: white; width: 200px; border: 1px solid #e2e2e2;">
|
453 |
+
<div style='font-size: 14px; line-height: 14px; margin-bottom: 20px;'><?php _e( 'File Operation Time', $this->domain ); ?></div>
|
454 |
+
<div style='font-size: 32px; line-height: 32px; margin-bottom: 10px;' id='meow-file-check-time'><?php _e( 'N/A', $this->domain ); ?></div>
|
455 |
+
<div style='font-size: 12px; line-height: 12px; margin-bottom: 20px;'><?php _e( 'Create temporary file and delete it.', $this->domain ); ?></div>
|
456 |
+
<input type='submit' style='text-align: center; width: 100%;' id="meow-file-check-start" value="<?php _e( 'Check', $this->domain ); ?>" class="button button-primary">
|
457 |
+
</div>
|
458 |
+
|
459 |
+
<div style="float: left; margin-right: 10px; text-align: center; padding: 10px; background: white; width: 200px; border: 1px solid #e2e2e2;">
|
460 |
+
<a target='_blank' href='https://kinsta.com/?kaid=MFROFDOOINML'>
|
461 |
+
<img style='height: 116px;' src='<?= $this->common_url( 'img/kinsta.png' ) ?>'>
|
462 |
+
<div>Meow's 2020 Favorite Hosting</div>
|
463 |
+
</a>
|
464 |
+
</div>
|
465 |
+
|
466 |
+
<div style="float: left; margin-right: 10px; text-align: center; padding: 10px; background: white; width: 200px; border: 1px solid #e2e2e2;">
|
467 |
+
<a target='_blank' href='https://tracking.maxcdn.com/rPK13'>
|
468 |
+
<img style='height: 116px;' src='<?= $this->common_url( 'img/stackpath.png' ) ?>'>
|
469 |
+
<div>Meow's 2020 Favorite CDN</div>
|
470 |
+
</a>
|
471 |
+
</div>
|
472 |
+
|
473 |
+
<div style="clear: both;"></div>
|
474 |
+
|
475 |
+
</div>
|
476 |
|
477 |
<script>
|
478 |
(function ($) {
|
482 |
$('#meow-perf-reset').on('click', function () {
|
483 |
calls = 0;
|
484 |
times = [];
|
485 |
+
$('#meow-perf-load-average').text('<?php _e( "N/A", $this->domain ); ?>');
|
486 |
$('#meow-perf-load-count').text('0');
|
487 |
});
|
488 |
|
501 |
times.push(time);
|
502 |
var sum = times.reduce(function(a, b) { return a + b; });
|
503 |
var avg = Math.ceil(sum / times.length);
|
504 |
+
$('#meow-perf-load-average').text(avg + ' <?php _e( "ms", $this->domain ); ?>');
|
505 |
$('#meow-perf-load-count').text(calls);
|
506 |
setTimeout(perfLoad, 5000);
|
507 |
});
|
518 |
}).done(function (response) {
|
519 |
var end = new Date().getTime();
|
520 |
var time = end - start;
|
521 |
+
$('#meow-file-check-time').text(time + ' <?php _e( "ms", $this->domain ); ?>');
|
522 |
+
$('#meow-file-check-start').text('<?php _e( "Check", $this->domain ); ?>');
|
523 |
});
|
524 |
};
|
525 |
|
529 |
});
|
530 |
|
531 |
setTimeout(perfLoad, 1500);
|
532 |
+
|
533 |
})(jQuery);
|
534 |
</script>
|
535 |
|
536 |
+
<h2><?php _e( 'WordPress Recommendations', $this->domain ); ?></h2>
|
537 |
<div style="background: white; padding: 5px 15px 5px 15px; box-shadow: 2px 2px 1px rgba(0,0,0,.02); margin-top: 15px;">
|
538 |
<p>
|
539 |
<?php _e( 'Too many WordPress installs are blown-up with useless and/or huge plugins, and bad practices. But that is because most users are overwhelmed by the diversity and immensity of the WordPress jungle. One rule of thumb is to keep your install the simplest as possible, with the least number of plugins (avoiding heavy ones too) and a good hosting service (avoid VPS except if you know exactly what you are doing). Articles are kept being updated on the Meow Apps website, with all the latest recommendations: ', $this->domain )?>
|
540 |
<a href='https://meowapps.com/debugging-wordpress/' target='_blank'>
|
541 |
+
How To Debug</a>,
|
542 |
<a href='https://meowapps.com/seo-optimization/' target='_blank'>
|
543 |
+
SEO Checklist & Optimization</a>,
|
544 |
<a href='https://meowapps.com/clean-optimize-wordpress/' target='_blank'>
|
545 |
+
Clean Up and Optimize</a>,
|
546 |
<a href='https://meowapps.com/optimize-images-cdn/' target='_blank'>
|
547 |
+
Optimize Images</a>,
|
548 |
<a href='https://meowapps.com/best-hosting-services-wordpress/' target='_blank'>
|
549 |
Best Hosting Services</a>.
|
550 |
</p>
|
551 |
</div>
|
552 |
|
553 |
+
<h2 style="margin-bottom: 0px; margin-top: 25px;"><?php _e( 'Common Options & Tools', $this->domain ); ?></h2>
|
554 |
<div class="meow-row">
|
555 |
<div class="meow-box meow-col meow-span_2_of_3">
|
556 |
+
<h3><span class="dashicons dashicons-admin-tools"></span> <?php _e( 'Common', $this->domain ); ?></h3>
|
557 |
<div class="inside">
|
558 |
<form method="post" action="options.php">
|
559 |
<?php settings_fields( 'meowapps_common_settings' ); ?>
|
564 |
</div>
|
565 |
|
566 |
<div class="meow-box meow-col meow-span_1_of_3">
|
567 |
+
<h3><span class="dashicons dashicons-admin-tools"></span> <?php _e( 'Debug', $this->domain ); ?></h3>
|
568 |
<div class="inside">
|
569 |
<ul>
|
570 |
+
<li><a href="?page=meowapps-main-menu&tool=error_log"><?php _e( 'Display Error Log', $this->domain ); ?></a></li>
|
571 |
+
<li><a href="?page=meowapps-main-menu&tool=phpinfo"><?php _e( 'Display PHP Info', $this->domain ); ?></a></li>
|
572 |
</ul>
|
573 |
</div>
|
574 |
</div>
|
575 |
|
576 |
<div class="meow-box meow-col meow-span_1_of_3">
|
577 |
+
<h3><span class="dashicons dashicons-admin-tools"></span> <?php _e( 'Post Types (used by this install)', $this->domain ); ?></h3>
|
578 |
<div class="inside">
|
579 |
<?php
|
580 |
global $wpdb;
|
584 |
$result = array();
|
585 |
foreach( $types as $type )
|
586 |
array_push( $result, "{$type->type} ({$type->count})" );
|
587 |
+
echo implode( ', ', $result );
|
588 |
?>
|
589 |
</div>
|
590 |
</div>
|
595 |
}
|
596 |
|
597 |
function admin_footer_text( $current ) {
|
598 |
+
return sprintf(
|
599 |
+
// translators: %1$s is the version of the interface; %2$s is a file path.
|
600 |
+
__( 'Thanks for using <a href="https://meowapps.com">Meow Apps</a>! This is the Meow Admin %1$s <br /><i>Loaded from %2$s </i>', $this->domain ),
|
601 |
+
MeowApps_Admin::$admin_version,
|
602 |
+
__FILE__
|
603 |
+
);
|
604 |
}
|
605 |
|
606 |
// HELPERS
|
common/img/default.png
CHANGED
Binary file
|
common/img/kinsta.png
ADDED
Binary file
|
common/img/media-cleaner.jpg
CHANGED
Binary file
|
common/img/media-file-renamer.jpg
CHANGED
Binary file
|
common/img/meow-gallery.jpg
CHANGED
Binary file
|
common/img/meow-lightbox.jpg
CHANGED
Binary file
|
common/img/meowapps.png
CHANGED
Binary file
|
common/img/stackpath.png
ADDED
Binary file
|
common/img/wp-retina-2x.jpg
CHANGED
Binary file
|
common/img/wplr-sync.jpg
CHANGED
Binary file
|
core.php
CHANGED
@@ -211,7 +211,8 @@ SQL;
|
|
211 |
|
212 |
/****************************************************************************/
|
213 |
|
214 |
-
// Return false if everything is fine, otherwise return true with an output
|
|
|
215 |
function check_attachment( $post, &$output = array(), $manual_filename = null ) {
|
216 |
$id = $post['ID'];
|
217 |
$old_filepath = get_attached_file( $id );
|
@@ -278,8 +279,6 @@ SQL;
|
|
278 |
}
|
279 |
$new_filename = $this->new_filename( $post, $base_title );
|
280 |
if ( is_null( $new_filename ) ) return false; // Leave it as it is
|
281 |
-
|
282 |
-
//$this->log( "New title: $base_title, New filename: $new_filename" );
|
283 |
}
|
284 |
|
285 |
// If a filename has a counter, and the ideal is without the counter, let's ignore it
|
@@ -324,10 +323,22 @@ SQL;
|
|
324 |
$output['case_issue'] = $case_issue;
|
325 |
$output['manual'] = !empty( $manual_filename );
|
326 |
$output['locked'] = get_post_meta( $id, '_manual_file_renaming', true );
|
327 |
-
$output['desired_filename_exists'] =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
|
329 |
-
//
|
330 |
-
if ( !get_post_meta( $post['ID'], '_require_file_renaming' ) ) {
|
331 |
add_post_meta( $post['ID'], '_require_file_renaming', true, true );
|
332 |
}
|
333 |
return true;
|
@@ -535,6 +546,32 @@ SQL;
|
|
535 |
return $str;
|
536 |
}
|
537 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
538 |
/**
|
539 |
* Computes the ideal filename based on a text
|
540 |
* @param array $media
|
@@ -575,9 +612,15 @@ SQL;
|
|
575 |
// Filename is generated from $text, without an extension.
|
576 |
$text = str_replace( ".jpg", "", $text );
|
577 |
$text = str_replace( ".png", "", $text );
|
|
|
|
|
578 |
$text = str_replace( "'", "-", $text );
|
579 |
-
$text =
|
580 |
-
|
|
|
|
|
|
|
|
|
581 |
}
|
582 |
|
583 |
// Convert all accent characters to ASCII characters
|
@@ -730,7 +773,7 @@ SQL;
|
|
730 |
&& ( ( !file_exists( $wr2x_new_filepath ) ) || is_writable( $wr2x_new_filepath ) ) ) {
|
731 |
|
732 |
// Rename retina file
|
733 |
-
if ( !$this->rename_file( $wr2x_old_filepath, $wr2x_new_filepath
|
734 |
$this->log( "[!] Retina $wr2x_old_filepath -> $wr2x_new_filepath" );
|
735 |
return $post;
|
736 |
}
|
@@ -822,8 +865,18 @@ SQL;
|
|
822 |
$new_filename = $output['desired_filename'];
|
823 |
$manual = $output['manual'] || !empty( $manual_filename );
|
824 |
$path_parts = mfrh_pathinfo( $old_filepath );
|
825 |
-
$directory = $path_parts['dirname']; // '2011/01'
|
826 |
$old_filename = $path_parts['basename']; // 'whatever.jpeg'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
827 |
|
828 |
$this->log( "** Rename Media: " . $old_filename );
|
829 |
$this->log( "New file should be: " . $new_filename );
|
@@ -833,16 +886,49 @@ SQL;
|
|
833 |
$this->log( "The original file ($old_filepath) cannot be found." );
|
834 |
return $post;
|
835 |
}
|
836 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
837 |
$this->log( "The new file already exists ($new_filepath). It is not a case issue. Renaming cancelled." );
|
838 |
return $post;
|
839 |
}
|
840 |
|
841 |
-
// Keep the original filename
|
842 |
$original_filename = get_post_meta( $id, '_original_filename', true );
|
843 |
if ( empty( $original_filename ) )
|
844 |
add_post_meta( $id, '_original_filename', $old_filename, true );
|
845 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
846 |
// Rename the main media file.
|
847 |
if ( !$this->rename_file( $old_filepath, $new_filepath, $case_issue ) && !$force_rename ) {
|
848 |
$this->log( "[!] File $old_filepath -> $new_filepath" );
|
@@ -851,20 +937,16 @@ SQL;
|
|
851 |
$this->log( "File\t$old_filepath -> $new_filepath" );
|
852 |
do_action( 'mfrh_path_renamed', $post, $old_filepath, $new_filepath );
|
853 |
|
854 |
-
//
|
855 |
-
$
|
856 |
-
|
857 |
-
|
858 |
-
$
|
859 |
-
$new_ext
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
$noext_new_filename = $this->str_replace( '.' . $old_ext, '', $new_filename );
|
865 |
-
|
866 |
-
// Update the attachment meta
|
867 |
-
$meta = wp_get_attachment_metadata( $id );
|
868 |
|
869 |
if ( $meta ) {
|
870 |
if ( isset( $meta['file'] ) && !empty( $meta['file'] ) )
|
@@ -901,14 +983,8 @@ SQL;
|
|
901 |
$orig_image_urls[$size] = $orig_image_data[0];
|
902 |
|
903 |
// Double check files exist before trying to rename.
|
904 |
-
if (
|
905 |
-
|
906 |
-
file_exists( $meta_old_filepath ) && (
|
907 |
-
( !file_exists( $meta_new_filepath ) ) ||
|
908 |
-
is_writable( $meta_new_filepath )
|
909 |
-
)
|
910 |
-
)
|
911 |
-
) {
|
912 |
// WP Retina 2x is detected, let's rename those files as well
|
913 |
if ( function_exists( 'wr2x_get_retina' ) ) {
|
914 |
$wr2x_old_filepath = $this->str_replace( '.' . $old_ext, '@2x.' . $old_ext, $meta_old_filepath );
|
@@ -925,6 +1001,16 @@ SQL;
|
|
925 |
do_action( 'mfrh_path_renamed', $post, $wr2x_old_filepath, $wr2x_new_filepath );
|
926 |
}
|
927 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
928 |
|
929 |
// Rename meta file
|
930 |
if ( !$this->rename_file( $meta_old_filepath, $meta_new_filepath, $case_issue ) && !$force_rename ) {
|
@@ -1010,6 +1096,46 @@ SQL;
|
|
1010 |
return $post;
|
1011 |
}
|
1012 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1013 |
/**
|
1014 |
* Locks a post to be manual-rename only
|
1015 |
* @param int|WP_Post $post The post to lock
|
211 |
|
212 |
/****************************************************************************/
|
213 |
|
214 |
+
// Return false if everything is fine, otherwise return true with an output
|
215 |
+
// which details the conditions and results about the renaming.
|
216 |
function check_attachment( $post, &$output = array(), $manual_filename = null ) {
|
217 |
$id = $post['ID'];
|
218 |
$old_filepath = get_attached_file( $id );
|
279 |
}
|
280 |
$new_filename = $this->new_filename( $post, $base_title );
|
281 |
if ( is_null( $new_filename ) ) return false; // Leave it as it is
|
|
|
|
|
282 |
}
|
283 |
|
284 |
// If a filename has a counter, and the ideal is without the counter, let's ignore it
|
323 |
$output['case_issue'] = $case_issue;
|
324 |
$output['manual'] = !empty( $manual_filename );
|
325 |
$output['locked'] = get_post_meta( $id, '_manual_file_renaming', true );
|
326 |
+
$output['desired_filename_exists'] = !!$existing_file;
|
327 |
+
$output['original_image'] = null;
|
328 |
+
|
329 |
+
// If the ideal filename already exists
|
330 |
+
// Maybe that's the original_image! If yes, we should let it go through
|
331 |
+
// as the original_rename will be renamed into another filename anyway.
|
332 |
+
if ( !!$existing_file ) {
|
333 |
+
$meta = wp_get_attachment_metadata( $id );
|
334 |
+
if ( isset( $meta['original_image'] ) && $new_filename === $meta['original_image'] ) {
|
335 |
+
$output['original_image'] = $meta['original_image'];
|
336 |
+
$output['desired_filename_exists'] = false;
|
337 |
+
}
|
338 |
+
}
|
339 |
|
340 |
+
// Set the '_require_file_renaming', even though it's not really used at this point.
|
341 |
+
if ( !get_post_meta( $post['ID'], '_require_file_renaming' ) && $output['desired_filename_exists'] && !$output['locked']) {
|
342 |
add_post_meta( $post['ID'], '_require_file_renaming', true, true );
|
343 |
}
|
344 |
return true;
|
546 |
return $str;
|
547 |
}
|
548 |
|
549 |
+
/**
|
550 |
+
* Transform full width hyphens and other variety hyphens in half size into simple hyphen,
|
551 |
+
* and avoid consecutive hyphens and also at the beginning and end as well.
|
552 |
+
*/
|
553 |
+
function format_hyphens( $str ) {
|
554 |
+
$hyphen = '-';
|
555 |
+
$hyphens = [
|
556 |
+
'﹣', '-', '−', '⁻', '₋',
|
557 |
+
'‐', '‑', '‒', '–', '—',
|
558 |
+
'―', '﹘', 'ー','ー',
|
559 |
+
];
|
560 |
+
$str = str_replace( $hyphens, $hyphen, $str );
|
561 |
+
// remove at the beginning and end.
|
562 |
+
$beginning = mb_substr( $str, 0, 1 );
|
563 |
+
if ( $beginning === $hyphen ) {
|
564 |
+
$str = mb_substr( $str, 1 );
|
565 |
+
}
|
566 |
+
$end = mb_substr( $str, -1 );
|
567 |
+
if ( $end === $hyphen ) {
|
568 |
+
$str = mb_strcut( $str, 0, mb_strlen( $str ) - 1 );
|
569 |
+
}
|
570 |
+
$str = preg_replace( '/-{2,}/u', '-', $str );
|
571 |
+
$str = trim( $str, implode( '', $hyphens ) );
|
572 |
+
return $str;
|
573 |
+
}
|
574 |
+
|
575 |
/**
|
576 |
* Computes the ideal filename based on a text
|
577 |
* @param array $media
|
612 |
// Filename is generated from $text, without an extension.
|
613 |
$text = str_replace( ".jpg", "", $text );
|
614 |
$text = str_replace( ".png", "", $text );
|
615 |
+
$text = str_replace( ['.','…'], "", $text );
|
616 |
+
$text = str_replace( "'s", "", $text );
|
617 |
$text = str_replace( "'", "-", $text );
|
618 |
+
$text = $this->replace_chars( $text );
|
619 |
+
// Changed strolower to mb_strtolower...
|
620 |
+
$text = mb_strtolower( $text );
|
621 |
+
$text = sanitize_file_name( $text );
|
622 |
+
$new_filename = $this->format_hyphens( $text );
|
623 |
+
$new_filename = trim( $new_filename, '-.' );
|
624 |
}
|
625 |
|
626 |
// Convert all accent characters to ASCII characters
|
773 |
&& ( ( !file_exists( $wr2x_new_filepath ) ) || is_writable( $wr2x_new_filepath ) ) ) {
|
774 |
|
775 |
// Rename retina file
|
776 |
+
if ( !$this->rename_file( $wr2x_old_filepath, $wr2x_new_filepath ) ) {
|
777 |
$this->log( "[!] Retina $wr2x_old_filepath -> $wr2x_new_filepath" );
|
778 |
return $post;
|
779 |
}
|
865 |
$new_filename = $output['desired_filename'];
|
866 |
$manual = $output['manual'] || !empty( $manual_filename );
|
867 |
$path_parts = mfrh_pathinfo( $old_filepath );
|
868 |
+
$directory = $path_parts['dirname']; // Directory where the files are, under 'uploads', such as '2011/01'
|
869 |
$old_filename = $path_parts['basename']; // 'whatever.jpeg'
|
870 |
+
// Get old extension and new extension
|
871 |
+
$old_ext = $path_parts['extension'];
|
872 |
+
$new_ext = $old_ext;
|
873 |
+
if ( $manual_filename ) {
|
874 |
+
$pp = mfrh_pathinfo( $manual_filename );
|
875 |
+
$new_ext = $pp['extension'];
|
876 |
+
}
|
877 |
+
$noext_old_filename = $this->str_replace( '.' . $old_ext, '', $old_filename ); // Old filename without extension
|
878 |
+
$noext_new_filename = $this->str_replace( '.' . $old_ext, '', $new_filename ); // New filename without extension
|
879 |
+
|
880 |
|
881 |
$this->log( "** Rename Media: " . $old_filename );
|
882 |
$this->log( "New file should be: " . $new_filename );
|
886 |
$this->log( "The original file ($old_filepath) cannot be found." );
|
887 |
return $post;
|
888 |
}
|
889 |
+
|
890 |
+
// Get the attachment meta
|
891 |
+
$meta = wp_get_attachment_metadata( $id );
|
892 |
+
|
893 |
+
// Get the information about the original image
|
894 |
+
// (which means the current file is a rescaled version of it)
|
895 |
+
$has_original_image = isset( $meta['original_image'] ) && !empty( $meta['original_image'] );
|
896 |
+
$original_is_ideal = $has_original_image ? $new_filename === $meta['original_image'] : false;
|
897 |
+
|
898 |
+
if ( !$original_is_ideal && !$case_issue && !$force_rename && file_exists( $new_filepath ) ) {
|
899 |
$this->log( "The new file already exists ($new_filepath). It is not a case issue. Renaming cancelled." );
|
900 |
return $post;
|
901 |
}
|
902 |
|
903 |
+
// Keep the original filename (that's for the "Undo" feature)
|
904 |
$original_filename = get_post_meta( $id, '_original_filename', true );
|
905 |
if ( empty( $original_filename ) )
|
906 |
add_post_meta( $id, '_original_filename', $old_filename, true );
|
907 |
|
908 |
+
// Support for the original image if it was "-rescaled".
|
909 |
+
// We should rename the -rescaled image first, as it could cause an issue
|
910 |
+
// if renamed after the main file. In fact, the original file might have already
|
911 |
+
// the best filename and evidently, the "-rescaled" one not.
|
912 |
+
if ( $has_original_image ) {
|
913 |
+
$meta_old_filename = $meta['original_image'];
|
914 |
+
$meta_old_filepath = trailingslashit( $directory ) . $meta_old_filename;
|
915 |
+
// In case of the undo, since we do not have the actual real original filename for that un-scaled image,
|
916 |
+
// we make sure the -scaled part of the original filename is not used (that could bring some confusion otherwise).
|
917 |
+
$meta_new_filename = str_replace( '-scaled', '', $noext_new_filename ) . '-mfrh-original.' . $new_ext;
|
918 |
+
$meta_new_filepath = trailingslashit( $directory ) . $meta_new_filename;
|
919 |
+
if ( !$this->rename_file( $meta_old_filepath, $meta_new_filepath, $case_issue ) && !$force_rename ) {
|
920 |
+
$this->log( "[!] File $meta_old_filepath -> $meta_new_filepath" );
|
921 |
+
return $post;
|
922 |
+
}
|
923 |
+
// Manual Rename also uses the new extension (if it was not stripped to avoid user mistake)
|
924 |
+
if ( $force_rename && !empty( $new_ext ) ) {
|
925 |
+
$meta_new_filename = $this->str_replace( $old_ext, $new_ext, $meta_new_filename );
|
926 |
+
}
|
927 |
+
$this->log( "Original File\t$old_filepath -> $new_filepath" );
|
928 |
+
//do_action( 'mfrh_path_renamed', $post, $old_filepath, $new_filepath );
|
929 |
+
$meta['original_image'] = $meta_new_filename;
|
930 |
+
}
|
931 |
+
|
932 |
// Rename the main media file.
|
933 |
if ( !$this->rename_file( $old_filepath, $new_filepath, $case_issue ) && !$force_rename ) {
|
934 |
$this->log( "[!] File $old_filepath -> $new_filepath" );
|
937 |
$this->log( "File\t$old_filepath -> $new_filepath" );
|
938 |
do_action( 'mfrh_path_renamed', $post, $old_filepath, $new_filepath );
|
939 |
|
940 |
+
// Rename the main media file in WebP if it exists.
|
941 |
+
$this->rename_webp_file_if_exist(
|
942 |
+
$old_filepath,
|
943 |
+
$old_ext,
|
944 |
+
$new_filepath,
|
945 |
+
$new_ext,
|
946 |
+
$case_issue,
|
947 |
+
$force_rename,
|
948 |
+
$post
|
949 |
+
);
|
|
|
|
|
|
|
|
|
950 |
|
951 |
if ( $meta ) {
|
952 |
if ( isset( $meta['file'] ) && !empty( $meta['file'] ) )
|
983 |
$orig_image_urls[$size] = $orig_image_data[0];
|
984 |
|
985 |
// Double check files exist before trying to rename.
|
986 |
+
if ( $force_rename || ( file_exists( $meta_old_filepath ) &&
|
987 |
+
( ( !file_exists( $meta_new_filepath ) ) || is_writable( $meta_new_filepath ) ) ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
988 |
// WP Retina 2x is detected, let's rename those files as well
|
989 |
if ( function_exists( 'wr2x_get_retina' ) ) {
|
990 |
$wr2x_old_filepath = $this->str_replace( '.' . $old_ext, '@2x.' . $old_ext, $meta_old_filepath );
|
1001 |
do_action( 'mfrh_path_renamed', $post, $wr2x_old_filepath, $wr2x_new_filepath );
|
1002 |
}
|
1003 |
}
|
1004 |
+
// If webp file existed, that one as well.
|
1005 |
+
$this->rename_webp_file_if_exist(
|
1006 |
+
$meta_old_filepath,
|
1007 |
+
$old_ext,
|
1008 |
+
$meta_new_filepath,
|
1009 |
+
$new_ext,
|
1010 |
+
$case_issue,
|
1011 |
+
$force_rename,
|
1012 |
+
$post
|
1013 |
+
);
|
1014 |
|
1015 |
// Rename meta file
|
1016 |
if ( !$this->rename_file( $meta_old_filepath, $meta_new_filepath, $case_issue ) && !$force_rename ) {
|
1096 |
return $post;
|
1097 |
}
|
1098 |
|
1099 |
+
/**
|
1100 |
+
* Rename webp file only if existed.
|
1101 |
+
*/
|
1102 |
+
function rename_webp_file_if_exist(
|
1103 |
+
$old_filepath,
|
1104 |
+
$old_ext,
|
1105 |
+
$new_finepath,
|
1106 |
+
$new_ext,
|
1107 |
+
$case_issue,
|
1108 |
+
$force_rename,
|
1109 |
+
$post
|
1110 |
+
) {
|
1111 |
+
// 2 patterns exist.
|
1112 |
+
// - filename.webp
|
1113 |
+
// - filename.ext.webp
|
1114 |
+
$webp_files = [
|
1115 |
+
[
|
1116 |
+
'old' => $this->str_replace( '.' . $old_ext, '.webp', $old_filepath ),
|
1117 |
+
'new' => $this->str_replace( '.' . $new_ext, '.webp', $new_finepath ),
|
1118 |
+
],
|
1119 |
+
[
|
1120 |
+
'old' => $this->str_replace( '.' . $old_ext, '.' . $old_ext . '.webp', $old_filepath ),
|
1121 |
+
'new' => $this->str_replace( '.' . $new_ext, '.' . $new_ext . '.webp', $new_finepath ),
|
1122 |
+
],
|
1123 |
+
];
|
1124 |
+
foreach ($webp_files as $webp_file) {
|
1125 |
+
if ( file_exists( $webp_file['old'] )
|
1126 |
+
&& ( ( !file_exists( $webp_file['new'] ) ) || is_writable( $webp_file['new'] ) ) ) {
|
1127 |
+
|
1128 |
+
// Rename webp file
|
1129 |
+
if ( !$this->rename_file( $webp_file['old'], $webp_file['new'], $case_issue ) && !$force_rename ) {
|
1130 |
+
$this->log( "[!] Retina $webp_file[old] -> $webp_file[new]" );
|
1131 |
+
return $post;
|
1132 |
+
}
|
1133 |
+
$this->log( "Retina\t$webp_file[old] -> $webp_file[new]" );
|
1134 |
+
do_action( 'mfrh_path_renamed', $post, $webp_file['old'], $webp_file['new'] );
|
1135 |
+
}
|
1136 |
+
}
|
1137 |
+
}
|
1138 |
+
|
1139 |
/**
|
1140 |
* Locks a post to be manual-rename only
|
1141 |
* @param int|WP_Post $post The post to lock
|
media-file-renamer.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Media File Renamer (Auto Rename)
|
4 |
Plugin URI: https://meowapps.com
|
5 |
Description: Renames automatically the files depending on Media titles and updates the links.
|
6 |
-
Version: 4.6.
|
7 |
Author: Jordy Meow
|
8 |
Author URI: https://jordymeow.com
|
9 |
Text Domain: media-file-renamer
|
@@ -32,7 +32,7 @@ require( 'helpers.php');
|
|
32 |
if ( is_admin() || is_rest() ) {
|
33 |
|
34 |
global $mfrh_version, $mfrh_core;
|
35 |
-
$mfrh_version = '4.6.
|
36 |
|
37 |
// Admin
|
38 |
require( 'mfrh_admin.php');
|
3 |
Plugin Name: Media File Renamer (Auto Rename)
|
4 |
Plugin URI: https://meowapps.com
|
5 |
Description: Renames automatically the files depending on Media titles and updates the links.
|
6 |
+
Version: 4.6.7
|
7 |
Author: Jordy Meow
|
8 |
Author URI: https://jordymeow.com
|
9 |
Text Domain: media-file-renamer
|
32 |
if ( is_admin() || is_rest() ) {
|
33 |
|
34 |
global $mfrh_version, $mfrh_core;
|
35 |
+
$mfrh_version = '4.6.7';
|
36 |
|
37 |
// Admin
|
38 |
require( 'mfrh_admin.php');
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: https://commerce.coinbase.com/checkout/d047546a-77a8-41c8-9ea9-4a95
|
|
5 |
Requires at least: 4.8
|
6 |
Tested up to: 5.3
|
7 |
Requires PHP: 7.0
|
8 |
-
Stable tag: 4.6.
|
9 |
|
10 |
Physically renames your files nicely for a cleaner system and for a better SEO. Please read the description.
|
11 |
|
@@ -57,11 +57,13 @@ Check the FAQ on the official website, [here](https://meowapps.com/media-file-re
|
|
57 |
|
58 |
== Changelog ==
|
59 |
|
60 |
-
= 4.6.
|
61 |
-
*
|
|
|
62 |
* Note: If you like it, please review the plugin [by clicking here](https://wordpress.org/support/plugin/media-file-renamer/reviews/?rate=5#new-post). It's important for us - we need motivation for all the work we want to put in the next version :)
|
63 |
|
64 |
-
= 4.6.
|
|
|
65 |
* Add: Doesn't show the button to the Dashboard if Auto is disabled.
|
66 |
* Update: Admin refreshed to 2.4.
|
67 |
|
5 |
Requires at least: 4.8
|
6 |
Tested up to: 5.3
|
7 |
Requires PHP: 7.0
|
8 |
+
Stable tag: 4.6.7
|
9 |
|
10 |
Physically renames your files nicely for a cleaner system and for a better SEO. Please read the description.
|
11 |
|
57 |
|
58 |
== Changelog ==
|
59 |
|
60 |
+
= 4.6.7 =
|
61 |
+
* Add: Better handling of dots and hyphens (especially the non-standard ones).
|
62 |
+
* Add: Support for WebP.
|
63 |
* Note: If you like it, please review the plugin [by clicking here](https://wordpress.org/support/plugin/media-file-renamer/reviews/?rate=5#new-post). It's important for us - we need motivation for all the work we want to put in the next version :)
|
64 |
|
65 |
+
= 4.6.5 =
|
66 |
+
* Fix: Little (i18n) fixes in the admin.
|
67 |
* Add: Doesn't show the button to the Dashboard if Auto is disabled.
|
68 |
* Update: Admin refreshed to 2.4.
|
69 |
|
style.css
CHANGED
@@ -19,13 +19,13 @@
|
|
19 |
}
|
20 |
.mfrh_column .button-primary,
|
21 |
.mfrh_column .button-primary .dashicons {
|
22 |
-
line-height:
|
23 |
}
|
24 |
.mfrh_column .button-primary {
|
25 |
-
|
26 |
-
padding-left: 0;
|
27 |
-
padding-right: 0;
|
28 |
text-align: center;
|
|
|
|
|
29 |
}
|
30 |
.mfrh_column .button-primary.updating-message:before {
|
31 |
margin: 3px 0 0 0;
|
19 |
}
|
20 |
.mfrh_column .button-primary,
|
21 |
.mfrh_column .button-primary .dashicons {
|
22 |
+
line-height: 24px;
|
23 |
}
|
24 |
.mfrh_column .button-primary {
|
25 |
+
padding: 4px 8px;
|
|
|
|
|
26 |
text-align: center;
|
27 |
+
min-height: auto;
|
28 |
+
line-height: unset;
|
29 |
}
|
30 |
.mfrh_column .button-primary.updating-message:before {
|
31 |
margin: 3px 0 0 0;
|
ui.php
CHANGED
@@ -136,12 +136,16 @@ class Meow_MFRH_UI {
|
|
136 |
$checkFiles = null;
|
137 |
if ( isset( $_GET ) && isset( $_GET['mfrh_scancheck'] ) )
|
138 |
$checkFiles = $this->core->check_text();
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
145 |
|
146 |
echo $this->render_view( 'menu-screen', array(
|
147 |
'wpdb' => $wpdb,
|
@@ -233,6 +237,11 @@ class Meow_MFRH_UI {
|
|
233 |
sprintf( __( 'Rename in lowercase, to %s. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ),
|
234 |
$file['desired_filename'], $modify_url ) . "</div>";
|
235 |
}
|
|
|
|
|
|
|
|
|
|
|
236 |
else {
|
237 |
echo '<br />' . $smallDiv .
|
238 |
sprintf( __( 'Rename to %s. You can also <a href="%s">EDIT THIS MEDIA</a>.', 'media-file-renamer' ),
|
@@ -423,6 +432,7 @@ class Meow_MFRH_UI {
|
|
423 |
|
424 |
function admin_notices() {
|
425 |
$screen = get_current_screen();
|
|
|
426 |
if ( ( $screen->base == 'post' && $screen->post_type == 'attachment' ) ||
|
427 |
( $screen->base == 'media' && isset( $_GET['attachment_id'] ) ) ) {
|
428 |
$id = isset( $_GET['post'] ) ? $_GET['post'] : $_GET['attachment_id'];
|
@@ -442,6 +452,7 @@ class Meow_MFRH_UI {
|
|
442 |
}
|
443 |
|
444 |
function media_send_to_editor( $html, $id, $attachment ) {
|
|
|
445 |
$this->core->check_attachment( get_post( $id, ARRAY_A ), $output );
|
446 |
return $html;
|
447 |
}
|
136 |
$checkFiles = null;
|
137 |
if ( isset( $_GET ) && isset( $_GET['mfrh_scancheck'] ) )
|
138 |
$checkFiles = $this->core->check_text();
|
139 |
+
|
140 |
+
$all_media = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts p
|
141 |
+
WHERE post_status = 'inherit' AND post_type = 'attachment'" );
|
142 |
+
$manual_media = $wpdb->get_var( "SELECT COUNT(*)
|
143 |
+
FROM $wpdb->postmeta pm, $wpdb->posts p
|
144 |
+
WHERE pm.meta_key = '_manual_file_renaming' AND pm.meta_value = 1 AND p.ID = pm.post_id
|
145 |
+
AND p.post_status = 'inherit' AND p.post_type = 'attachment'" );
|
146 |
+
|
147 |
+
// error_log( 'ALL: ' . $all_media );
|
148 |
+
// error_log( 'RENAMED MANUALLY: ' . $manual_media );
|
149 |
|
150 |
echo $this->render_view( 'menu-screen', array(
|
151 |
'wpdb' => $wpdb,
|
237 |
sprintf( __( 'Rename in lowercase, to %s. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ),
|
238 |
$file['desired_filename'], $modify_url ) . "</div>";
|
239 |
}
|
240 |
+
else if ( $file['original_image'] ) {
|
241 |
+
echo '<br />' . $smallDiv .
|
242 |
+
sprintf( __( 'Rename to %s. The original image will be also be renamed. You can also <a href="%s">EDIT THIS MEDIA</a>.', 'media-file-renamer' ),
|
243 |
+
$file['desired_filename'], $modify_url ) . "</div>";
|
244 |
+
}
|
245 |
else {
|
246 |
echo '<br />' . $smallDiv .
|
247 |
sprintf( __( 'Rename to %s. You can also <a href="%s">EDIT THIS MEDIA</a>.', 'media-file-renamer' ),
|
432 |
|
433 |
function admin_notices() {
|
434 |
$screen = get_current_screen();
|
435 |
+
$output = array();
|
436 |
if ( ( $screen->base == 'post' && $screen->post_type == 'attachment' ) ||
|
437 |
( $screen->base == 'media' && isset( $_GET['attachment_id'] ) ) ) {
|
438 |
$id = isset( $_GET['post'] ) ? $_GET['post'] : $_GET['attachment_id'];
|
452 |
}
|
453 |
|
454 |
function media_send_to_editor( $html, $id, $attachment ) {
|
455 |
+
$output = array();
|
456 |
$this->core->check_attachment( get_post( $id, ARRAY_A ), $output );
|
457 |
return $html;
|
458 |
}
|
views/column.php
CHANGED
@@ -66,9 +66,13 @@ else
|
|
66 |
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
67 |
<?php printf( __( 'Rename in lowercase, to %s. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ), $file['desired_filename'], $modify_url ); ?>
|
68 |
</div>
|
|
|
|
|
|
|
|
|
69 |
<?php else: // iii ?>
|
70 |
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
71 |
-
<?php printf( __( 'Rename to %s. You can also <a href="%s">
|
72 |
</div>
|
73 |
<?php endif; // iii ?>
|
74 |
<?php if ( !$isNew ): // iii ?>
|
66 |
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
67 |
<?php printf( __( 'Rename in lowercase, to %s. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ), $file['desired_filename'], $modify_url ); ?>
|
68 |
</div>
|
69 |
+
<?php elseif ( $file['original_image'] ): // iii ?>
|
70 |
+
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
71 |
+
<?php printf( __( 'Rename in lowercase, to %s. The original image will be also be renamed. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ), $file['desired_filename'], $modify_url ); ?>
|
72 |
+
</div>
|
73 |
<?php else: // iii ?>
|
74 |
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
75 |
+
<?php printf( __( 'Rename to %s. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ), $file['desired_filename'], $modify_url ); ?>
|
76 |
</div>
|
77 |
<?php endif; // iii ?>
|
78 |
<?php if ( !$isNew ): // iii ?>
|