views:

25

answers:

2

I want to add some custom jquery code to the Edit Post page, something really simple like showing a div when someone presses Publish.

The only restriction is that I want to achieve this through the use of a plugin, not hacking the admin template files.

I've tried echoing some script tags using some actions but it doesn't seem to be the way.

A: 

you can add javascript to pages inside wpadmin page editor. wrap it in [RAW]...[/RAW] tags

[RAW]
<script type='text'/javascript'>
 // ...
</script>
[/RAW]
Crayon Violent
He wants to add JS to the wp-admin page, not the post itself.
Sean Fisher
ah yeah sorry, misread :/
Crayon Violent
+1  A: 
<?php
function add_jquery_data() {
    global $parent_file;

    if ( isset( $_GET['action'] ) && $_GET['action'] == 'edit' && isset( $_GET['post'] ) && $parent_file == 'edit.php') {
    // Do some stuff.
    }
}

add_filter('admin_head', 'add_jquery_data');

?>
Sean Fisher
Thanks a bunch, this is exactly what I've been looking for. I've used admin_footer anyways. However, is there a way to load the content _only_ on new post/edit post?
ign
Sean Fisher