Nathan Arthur

 The Loop

Where humor doesn’t work.
Jan 29, 2020 15:16
@TomJNowell Thank you for the tip!
Jan 28, 2020 20:53
which handles validation and optional route segments.
Jan 28, 2020 20:53
It also handles routes like { language }/audiobooks/stories/{ entity_id:[0-9]+ }[/{ slug }]
Jan 28, 2020 20:52
But I feel like I've made things much more complex then they perhaps need to be.
Jan 28, 2020 20:52
Basically I have a large part of the plugin dedicated to taking routes like { language }/audiobooks/stories, translating them, and generating the regex needed for add_rewrite_rule.
Jan 28, 2020 20:51
This is all due to a pretty complex home-grown routing system... You wouldn't know of any good examples of other people abstracting routing in a WordPress plugin?
Jan 28, 2020 20:47
Thank you so much for your help, @Howdy_McGee!
Jan 28, 2020 20:47
That was it. I was already filtering the redirect, and I wasn't including the query string in what I returned. I feel like I've overcomplicated my solution. =P
Jan 28, 2020 20:33
I just confirmed that the redirect is happening via redirect_canonical by putting a var_dump on that filter.
Jan 28, 2020 17:49
Right...
Jan 28, 2020 17:47
Oh, hmm. Ok.
Jan 28, 2020 17:36
Except the second entry doesn't say from ServiceWorker =P
Jan 28, 2020 17:35
Maybe this is a PWA issue =P
Jan 28, 2020 17:35
Status Code: 301 Moved Permanently (from ServiceWorker)
Jan 28, 2020 17:34
Jan 28, 2020 17:32
I just looked in the Network panel and I am getting an initial 301. Is that normal for a rewrite rule?
Jan 28, 2020 17:32
Turned everything else off, resaved permalinks, and confirmed I get 404s for everything else. Didn't fix it.
Jan 28, 2020 17:28
I'll try turning the other rewrites off.
Jan 28, 2020 17:28
Ok
Jan 28, 2020 17:28
Do I need to match the query string in the regex for the rewrite rule and then append it to the result query?
Jan 28, 2020 17:26
Would that prevent a query string from getting through?
Jan 28, 2020 17:26
public 'matched_rule' => string '^([\w\-\.]+)\/search\/?$' (length=24)
public 'matched_query' => string 'page_id=38&language=english' (length=27)
Jan 28, 2020 17:26
There is a custom rewrite applied to this page.
Jan 28, 2020 17:25
Hmm, I'll try...
Jan 28, 2020 17:25
matched_rule and matched_query in the dumped query look right.
Jan 28, 2020 17:24
How might that interfere?
Jan 28, 2020 17:24
Yes, a lot. =P
Jan 28, 2020 17:22
And it shows up in the public_query_vars section of the dumped query object.
Jan 28, 2020 17:22
public function registerQueryVar($vars)
{
    $vars[] = 'avorg_query';
    return $vars;
}
Jan 28, 2020 17:22
Using add_filter('query_vars', ...) ? Yes
Jan 28, 2020 17:20
Without the dump, get_query_var returns nothing
Jan 28, 2020 17:20
However, that seems to cancel the redirect (?) and the page doesn't load, just the dumped data.
Jan 28, 2020 17:19
If I dump the query on parse_request, the query param shows up in the data.
Jan 28, 2020 17:18
The var I'm testing with is avorg_query=... so I don't think so...
Jan 28, 2020 17:18
I tried using the query_vars filter and the add_rewrite_tag function to register the query var, but it still gets stripped.
Jan 28, 2020 17:17
Any tips on preventing a rewrite rule from removing a query var? I've got a rewrite rule for /the/page, but visiting /the/page?my_var=value ends up at just /the/page without the query string.
Jun 28, 2019 15:40
I figured out my issue. I had a misbehaving callback that was forcing a 404 to be thrown.
Jun 28, 2019 15:23
I'm using the Query Monitor plugin to try to debug this: wordpress.org/plugins/query-monitor
Jun 28, 2019 15:21
Two different URLs, the correct rewrite rule is matched in both cases, and the correct query strings are generated. But with one URL page_id isn't included in the query, so the page isn't found, while with the other URL it is included and the page loads properly.
Jun 28, 2019 15:20
Jun 28, 2019 15:20
Does anyone have an idea why a query variable would make it into the page query for some rewrite rule matches, and not others?
May 13, 2018 18:46
Ok, thanks, maybe I'll go ahead and ask :)
May 13, 2018 18:25
That'd probably be fine, I'd just like to make as difficult to break the website as I can.
May 13, 2018 18:23
@TomJNowell Either that, or I want to turn them on from the plugin. Either is viable for me since this is a plugin for a single website.
May 13, 2018 17:51
This is a plugin for internal use, so I'm not concerned about forcing pretty permalinks to be on.
May 13, 2018 17:50
My plugin successfully adds the rewrite rule, but it only gets used if I manually turn on pretty permalinks, which I don't want to require.
May 13, 2018 17:50
Anyone know how I can turn on permalinks programmatically so my add_rewrite_rules will work on plugin install?
Apr 2, 2018 10:20
@fuxia Thanks! I'll look into that
Apr 1, 2018 19:50
Quick question: Developing a plugin, and need to know in php whether the plugin is currently in my dev environment or not, so I can toggle Twig caching accordingly. What's the best way to do that?
 

 /dev/chat

General discussion for unix.stackexchange.com. If you have a q...
Jul 4, 2016 20:08
Haha! That's great.