My suggestion was to delete that line of code entirely. There’s no reason to define a constant if you’re only going to use the value once, and the constant is computed. That’s just making messy code messier. But you’ll have to change the
<?php echo EXT_LINK_PARAMS ?>
section to say
<?php echo $ext_link_param; ?>
Otherwise, I’m not sure why it’s not working. I usually add echo or var_dump() statements throughout my code when I’m debugging to test if various parts are being executed. For example, right under
function ext_link_params_wp_head() {
$current_user = wp_get_current_user();
I’d probably do something like:
echo 'And the current user ID is: '.$current_user->ID.'!';
If nothing gets printed on the screen, then I know my function isn’t getting called. If “And the current user ID is: !” gets printed to the screen, then I know there’s something up with the wp_current_user() call. Actually, replacing the echo statement with
var_dump($current_user);
would be a better test.
It also helps to use your browser’s built-in script debugging capabilities. If the JavaScript is crashing, you need to know about it, and on what line it’s erroring out on. In FireFox, you can use the wonderful FireBug plugin. In Chrome, you can click the wrench on the top-right, then Tools->Developer Tools. Even IE has pretty good script debugging capabilities, but you’ll have to turn them on in the menu.
In fact, right before the last
});
in your jQuery section, add this:
alert('Hello World!');
and then refresh the page. If you don’t see an alert box pop up with “Hello World”, then either your script isn’t getting called or you have an error somewhere in your JavaScript.
Also try changing
add_action( 'wp_footer', 'ext_link_params_wp_head', 10 );
back to
add_action( 'wp_head', 'ext_link_params_wp_head', 10 );
If you still can’t find the error, paste your entire plugin code here, and I’ll see if I can spot any obvious errors.