Title: Plugin Improvements
Last modified: October 10, 2019

---

# Plugin Improvements

 *  Resolved [shnjavi](https://wordpress.org/support/users/shnjavi/)
 * (@shnjavi)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/plugin-improvements-2/)
 * Hi [@mateuszgbiorczyk](https://wordpress.org/support/users/mateuszgbiorczyk/),
 * Nice plugin you have. I personally tried the well-known first (big number of 
   usage per month) but no luck with setting custom permastruct etc.. If I set one
   to work, the other post types would 404.
 * And yes, I’ve flushed permalinks each time.
 * This one works! Good job.
 * However, I have a small improvement request looking at the both `rewirites.php`
   files (post types and terms):
 * As this plugin writes in .htaccess file to 301 redirect by **Custom Post Type
   slug** for Post Types, and **Custom Taxonomy slug** for Terms, wouldn’t it be
   better to just write 1 regex per CPT and 1 regex for Custom Tax instead of going`
   foreach`?
 * **What do I mean?**
 * functions/posttypes/rewrites.php line 55
 * If for example CPT name is _book_, replace foreach statement with:
 * `$content .= ' RewriteRule ^book/$ // [R=301,L]' . PHP_EOL;`
 * It does the same thing as your foreach statement but instead of writing (in my
   case) 11000+ lines (that’s how many posts I have and growing) it would write 
   just 1 line.
 * **Same goes for Custom Taxonomies.**
 * functions/terms/rewrites.php line 59
 * should be:
 * `$content .= ' RewriteRule ^book_category/$ // [R=301,L]' . PHP_EOL;`
 * Writing foreach has other disadvantages such as deployment processes, .htaccess
   on live site being overwritten, websites running on Docker containers etc..
 * Do you think you could make this small improvement on your plugin?
 * Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Mateusz Gbiorczyk](https://wordpress.org/support/users/mateuszgbiorczyk/)
 * (@mateuszgbiorczyk)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/plugin-improvements-2/#post-12020335)
 * Hi [@shnjavi](https://wordpress.org/support/users/shnjavi/),
 * Thank you for your message. Thank you also for your idea.
 * Sorry, but your solution cannot be implemented. Default URLs for posts and categories
   work on a regex basis.
 * This plugin cannot be like this because there are many types of links available,
   e.g.
 *     ```
       /events/post-1
       /events/category-1/
       /events/category-1/post-2
       /events/category-2/category-3/
       /events/category-2/category-3/post-3
       /events/category-4/category-4/category-5/
       /events/category-4/category-5/category-6/post-4
       ```
   
 * No regex will work here.
 *  Thread Starter [shnjavi](https://wordpress.org/support/users/shnjavi/)
 * (@shnjavi)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/plugin-improvements-2/#post-12024862)
 * Hey [@mateuszgbiorczyk](https://wordpress.org/support/users/mateuszgbiorczyk/),
 * Thanks for replying back.
 * I see what you mean, but (depending on CPT’s permalink structure) wouldn’t regex
   like:
 * `events\/(.+?)\/?$`
 * work?
 * I tested it for the above scenario and it seems to be working fine.
 *  Plugin Author [Mateusz Gbiorczyk](https://wordpress.org/support/users/mateuszgbiorczyk/)
 * (@mateuszgbiorczyk)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/plugin-improvements-2/#post-12024875)
 * Look at this case:
 *     ```
       /events/category-1/post-2
       /events/category-2/category-3/
       ```
   
 * How would you like to determine if the last part of link is a term slug or post
   slug?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Plugin Improvements’ is closed to new replies.

 * ![](https://ps.w.org/wp-better-permalinks/assets/icon-256x256.png?rev=2636286)
 * [WP Better Permalinks](https://wordpress.org/plugins/wp-better-permalinks/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-better-permalinks/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-better-permalinks/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-better-permalinks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-better-permalinks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-better-permalinks/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Mateusz Gbiorczyk](https://wordpress.org/support/users/mateuszgbiorczyk/)
 * Last activity: [6 years, 7 months ago](https://wordpress.org/support/topic/plugin-improvements-2/#post-12024875)
 * Status: resolved