I know this is a vague question, please just spend time on it if you are in the mood, I don’t need to be flamed for not being more precise.
I’m having a problem with a theme I’m developing, for some reason it breaks the export function of WordPress.
I’m not asking for anyone to solve my problems here, but after having spend some hours on it now, I’d like to ask, if anyone recognizes this problem, and would give me a hint as to in what direction to look for the problem.
Somehow I have a feeling it has to do with a nonce check failure, but not sure..
Anyway the problem is, that if i click the Export button in the page
http://www.myserver.com/wp-admin/export.php
then I get the WP Failure Notice Screen. The url I’m taking to is this:
http://www.myserver.com/wp-admin/export.php?download=true&content=all&cat=0&post_author=0&post_start_date=0&post_end_date=0&post_status=0&page_author=0&page_start_date=0&page_end_date=0&page_status=0&submit=Download+Export+File
and the page says:
Are you sure you want to do this?
Please try again.
I think this must be coming from wp_explain_nonce() inside wp-includes/functions.php
If I switch to the twenty ten theme the problem is gone. Back to my theme, and it’s there, so it must be the theme..
Any advice on where to look or how to approach catching the bug in my theme is welcome.
The basic idea for debug here is that theme apparently influences something it totally should not. Either something is done in a wrong way or in a wrong place.
Check that theme is not running any functionality directly in
functions.php
.Check that all of theme’s functionality runs on appropriate hooks.
For hooks that are used both on front-end and back-end conditionally exclude theme’s functionality that is not supposed to work on back-end.
The problem was that I had this code in one of my theme admin pages:
which got triggered by the export request since that also sets $_GET[‘download’] var.
The solution I came up with was to make sure my check only ran when the relevant page was requested, and also I changed the variable to something unique: