0

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';
    }
2
  • 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

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 );.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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