admin管理员组文章数量:1391929
This is a question about a plugin.
A form to search the database works. What I am trying to do is have the search term reload into the form input field when returning search results. The problem is strange and appears to be something to do with site_url()
I am setting a variable $search_url = site_url( 'wp-admin/admin.php?page=my-plugin&action=search&searchstringSO=' . $_REQUEST["sigsearch"] );
which is the URL that is loaded with my results. Note the SO
at the end of the key, that is a debug flag so I know I am looking at the right URL - I am.
The resulting URL is .php?page=my-plugin&action=search&searchstringSO&_wpnonce=8664768fcc
notice the =
and the search string are missing.
I am pretty good at trouble shooting and can't find where it is being stripped.
Things I have tried:
- displaying the value of
$_REQUEST["sigsearch"]
right before creating the$search_url
variable - it works - loading the URL string into it's own variable (which works) and then passing that to
site_url()
- adding
&dummy=0
at the end - that also works
For some reason the querystring value (which is nothing more than a text string) plus the =
are stripped out of the URL.
Is this a quirk of site_url()
or am I missing something obvious?
This is a question about a plugin.
A form to search the database works. What I am trying to do is have the search term reload into the form input field when returning search results. The problem is strange and appears to be something to do with site_url()
I am setting a variable $search_url = site_url( 'wp-admin/admin.php?page=my-plugin&action=search&searchstringSO=' . $_REQUEST["sigsearch"] );
which is the URL that is loaded with my results. Note the SO
at the end of the key, that is a debug flag so I know I am looking at the right URL - I am.
The resulting URL is https://example/wp-admin/admin.php?page=my-plugin&action=search&searchstringSO&_wpnonce=8664768fcc
notice the =
and the search string are missing.
I am pretty good at trouble shooting and can't find where it is being stripped.
Things I have tried:
- displaying the value of
$_REQUEST["sigsearch"]
right before creating the$search_url
variable - it works - loading the URL string into it's own variable (which works) and then passing that to
site_url()
- adding
&dummy=0
at the end - that also works
For some reason the querystring value (which is nothing more than a text string) plus the =
are stripped out of the URL.
Is this a quirk of site_url()
or am I missing something obvious?
- How are you performing the search? Why do you even need to build this URL? If you have a search form then won't submitting it lead to the correct URL? I don't really understand why you need to populate the search term into the URL yourself. – Jacob Peattie Commented Feb 14, 2020 at 8:34
- @JacobPeattie I adopted an abandoned plugin so I have no idea why it was done the way it was originally. Adding something like a search function is tricky as I work my way through someone else's code. – Steve Commented Feb 15, 2020 at 5:42
1 Answer
Reset to default 1Could you try using admin_url
instead of site_url
you can call it the same way, but as you are trying to fetch some admin page I think that might be a better idea.
$search_url = admin_url( '/admin.php?page=my-plugin&action=search&searchstringSO=' . $_REQUEST["sigsearch"] );
Note that I removed the wp-admin
prefix from the path.
本文标签: site urlQuerystring value being stripped from siteurl()
版权声明:本文标题:site url - Querystring value being stripped from site_url() 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744748957a2623058.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论