wpcodefactory / file-renaming-on-upload

6 stars 0 forks source link

After the latest update spaces are removed from {posttitle}. Previously they were replaced with hyphens #5

Closed vladoa closed 4 years ago

vladoa commented 4 years ago

Hi Pablo! I really like your plugin - but since the last update 8 days ago, I noticed that the {posttitle} pattern started giving results like:

mylovelypicture.jpg

Previously it would give result like:

my-lovely-picture.jpg

I suspect that this is is the commit that started causing the issue

Can you double check if you can reproduce this issue?

Further details:

Wordpress Version: 5.3 Plugin Version: 2.3.7

vladoa commented 4 years ago

I think that the regular expression should be:

$new_post_name = preg_replace( "/[^a-zA-Z0-9-_ .]/", "", $new_post_name );

instead of:

$new_post_name = preg_replace( "/[^a-zA-Z0-9-_.]/", "", $new_post_name );

I think allowing the whitespace in the regular experssion in classes/WordPress/class-post.php:39 should fix it

pablo-sg-pacheco commented 4 years ago

Hi @vladoa , Thanks for letting me know.

I've just updated to version 2.3.8 with a fix for it. I ended up using a solution almost like yours. Please, see https://github.com/pablo-sg-pacheco/file-renaming-on-upload/commit/f90ea0a339924e1f6d1012922e18a254a0e61b43

Please give it a try and let me know ;)

vladoa commented 4 years ago

Thanks Pablo for the fast response! I will update the plugin now.

pablo-sg-pacheco commented 4 years ago

;)