Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Could you please move your solution to the separate answer? It is more in line with site's mechanics. –  Rarst Jul 7 '11 at 20:34
    
@Rarst, I try that now, I moved it to your answer, must be peer reviewed. –  mikkelbreum Jul 7 '11 at 20:42
1  
No, move your solution to a separate answer, don't edit someone else's answer. –  EAMann Jul 7 '11 at 20:47

2 Answers 2

up vote 2 down vote accepted

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.

  1. Check that theme is not running any functionality directly in functions.php.

  2. Check that all of theme's functionality runs on appropriate hooks.

  3. 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.

share|improve this answer
    
thank you, that was all I needed, and I found the problem. –  mikkelbreum Jul 7 '11 at 20:08
    
I was loading some admin related logic on the front end, where I did a check_admin_referer() if $_GET['download'] was defined. That was triggered by the export call, that also sets the same var. See my original question. –  mikkelbreum Jul 7 '11 at 20:10
    
..no I'm babbling here, I wasn't loading on the front nd, it was also the back end it broke, but anyway, I was getting the nonce verification error because I intercepted the request while listening for the $_GET['download'] to be defined. I changed that into $_GET['mytheme_download'] and it was fine. –  mikkelbreum Jul 7 '11 at 20:33

The problem was that I had this code in one of my theme admin pages:

if (isset($_GET['download']))
    check_admin_referer('mytheme_options_storage');

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:

if (isset($_GET['mytheme_download']))
    check_admin_referer('mytheme_options_storage');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.