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.

Could someone perhaps tell if it would be possible to insert -in this case- a <script></script> directly after <head>, but before:

<script type="text/javascript">
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
var userSettings = {
        'url': '/html5/',
        'uid': '1',
        'time':'1332528635'
    },
    ajaxurl = '/html5/wp-admin/admin-ajax.php',
    pagenow = 'dashboard',
    typenow = '',
    adminpage = 'index-php',
    thousandsSeparator = '.',
    decimalPoint = ',',
    isRtl = 0;
</script>
share|improve this question
    
You can't. There are no hooks there, so short of editing the core (very bad idea), you'll not be able to do it. Why does it need to be right after the <head>? –  chrisguitarguy Oct 3 '12 at 23:27

1 Answer 1

Its Not best practice but you can hook up the wp_head and echo out your script like this:

add_action("wp_head","print_script_46614");
function print_script_46614(){
?>
<script type="text/javascript">
    addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
    var userSettings = {
        'url': '/html5/',
        'uid': '1',
        'time':'1332528635'
    },
    ajaxurl = '/html5/wp-admin/admin-ajax.php',
    pagenow = 'dashboard',
    typenow = '',
    adminpage = 'index-php',
    thousandsSeparator = '.',
    decimalPoint = ',',
    isRtl = 0;
</script>
<?php
}
share|improve this answer
    
Hello @bainternet, probably I didn't explain things that well, but the script above isn't the script I'm trying to insert. (it's located at wp-admin\admin-head.php). My tiny removal script only seems to work when being placed just above that. Being this somewhat bad practice or not, do you know how to accomplish this best perhaps? –  Cor van Noorloos Mar 23 '12 at 20:03
    
@CorvanNoorloos maybe if you edit the question with your code i'll get an idea . –  Bainternet Mar 23 '12 at 20:11

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.