• Resolved shnjavi

    (@shnjavi)


    Hi @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

    (@mateuszgbiorczyk)

    Hi @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

    (@shnjavi)

    Hey @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

    (@mateuszgbiorczyk)

    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.