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.

The plugin Plugin Maker pastebin is not working and I've narrowed it down to its nonce-mechanism failing.

At one point it checks for

check_admin_referer('$pluginmaker_nonce', $pluginmaker_nonce);

which is where it fails. (it gives an error "Are you sure you want to do this")

I've noticed that if you leave out the second argument ($pluginmaker_nonce) it works. (the default argument value is '_wpnonce'.)

The way $pluginmaker_nonce is defined is

if (!function_exists('wp_nonce_field')){
    function pluginmaker_nonce_field($action = -1){
        return;
        }
    $pluginmaker_nonce = -1;
    }
else {
    function pluginmaker_nonce_field($action = -1){
        wp_nonce_field($action);
        }
    $pluginmaker_nonce = 'pluginmaker-nonce-key';
    }
share|improve this question
    
Have a look here, wordpress.stackexchange.com/questions/60957/… –  Wyck Jun 22 '13 at 18:45
    
@Wyck Tested, it's not because of that (still gives that error). But I think it's more because how pluginmaker-nonce-key is totally different from _wpnonce. $pluginmaker_nonce seems to me is defined ..weird. –  laggingreflex Jun 22 '13 at 18:56

1 Answer 1

PHP variables inside single quotes -- ' -- won't be expanded. So in your first code snippet, unless you literally mean to pass the string $pluginmaker_nonce to the check_admin_referer() function as the action, you should probably rewrite your code as check_admin_referer( 'action_name', $pluginmaker_nonce );.

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.