tombenner / wp-mvc

An MVC framework for WordPress
http://wpmvc.org
MIT License
624 stars 172 forks source link

Routes not reloading? #252

Closed neilabdev closed 4 years ago

neilabdev commented 4 years ago

Thanks for bringing sanity to WordPress for those coming from the MVC world! This may not be an MVC issue, but despite how advanced a dev I thought I was, WordPress is humbling my soul. Basically, when I get my controllers to invoke, by merely changing the url it doesn't seem to take effect. E.g.

MvcRouter::public_connect('wizard', array('controller' => 'brand_wizards', 'action' => 'index'));

Will work, but if I add and "x" to the end:

MvcRouter::public_connect('wizardx', array('controller' => 'brand_wizards', 'action' => 'index'));

It doesn't load, but the old route before the change does, though it doesn't exists anymore. I presume there is some caching someplace, and have added:

define('WP_CACHE', false);

to my config, restarted server, etc, but to no avail. Further, the reason I was doing this was to check that another route would work, which it doesn't, so thought to change one that was working, only to find out it wasn't loading, so maybe the new route would work, if the old one would work under a new path. Hope that makes sense. Finally, can you override a standard wordpress route, or to put another way, does wp-mvc routes take precedence? Thanks in advance :)

cyberscribe commented 4 years ago

Flush permalinks

On Sat, 16 May 2020 at 16:35, ghost notifications@github.com wrote:

Thanks for bringing sanity to WordPress for those coming from the MVC world! This may not be an MVC issue, but despite how advanced a dev I thought I was, WordPress is humbling my soul. Basically, when I get my controllers to invoke, by merely changing the url it doesn't seem to take effect. E.g.

MvcRouter::public_connect('wizard', array('controller' => 'brand_wizards', 'action' => 'index'));

Will work, but if I add and "x" to the end:

MvcRouter::public_connect('wizardx', array('controller' => 'brand_wizards', 'action' => 'index'));

It doesn't load, but the old route before the change does, though it doesn't exists anymore. I presume there is some caching someplace, and have added:

define('WP_CACHE', false);

to my config, restarted server, etc, but to no avail. Further, the reason I was doing this was to check that another route would work, which it doesn't, so thought to change one that was working, only to find out it wasn't loading, so maybe the new route would work, if the old one would work under a new path. Hope that makes sense. Finally, can you override a standard wordpress route, or to put another way, does wp-mvc routes take precedence? Thanks in advance :)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tombenner/wp-mvc/issues/252, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFJLZKJ5YU5SR24VGDWAALRR2XFXANCNFSM4NC63Z4A .

-- Sent from Gmail Mobile

neilabdev commented 4 years ago

Wow, thank you for saving my day!

https://typerocket.com/flushing-permalinks-in-wordpress/

Flushing like this doesn't seem to work:

<?php
flush_rewrite_rules(); //FOR DEV DEBUG ONLY
MvcRouter::public_connect('wizard', array('controller' => 'brand_wizards', 'action' => 'index'));
MvcRouter::public_connect('brand-quizx', array('controller' => 'brandquizzes', 'action' => 'index')); 
?>

But going to admin "Settings > Permalinks" "Save Changes" does. So, since I won't be changing all that much, I' think the admin method works fine. Much Appreciated :)