[wp-hackers] custom post type post editor add_actionscript targetting

Philip M. Hofer (Frumph) philip at frumph.net
Mon Nov 8 16:49:38 UTC 2010


$typenow isnt populated on the post.php page, was a great thought though, it 
is however populated on post-new.php and edit.php

See if I wanted to add specific scripts to the post.php and post-new.php 
pages in an meta box on those pages there isnt (so far) a clear way of doing 
that, some vars are being populated on one, but not the other while 
targetting a custom post type.




----- Original Message ----- 
From: "Mark Duncan" <wp-t31os at ntlworld.com>
To: <wp-hackers at lists.automattic.com>
Sent: Monday, November 08, 2010 8:40 AM
Subject: Re: [wp-hackers] custom post type post editor add_actionscript 
targetting


> Action for the edit posts(or whatever type) page..
>
>  Scripts
>  add_action( 'admin_print_scripts-edit.php', 'your_callback' );
>
>  Styles
>  add_action( 'admin_print_styles-edit.php', 'your_callback' );
>
> Assuming you want to target only the post listing page (same hook applies 
> for any post type).
>
> For inside the function:
>
>  global $typenow;
>  if( 'your_post_type' == $typenow )
>  // Do your enqueue
>
> Hope thats what you're after.. ;)
>
> On 08/11/2010 16:05, Philip M. Hofer (Frumph) wrote:
>> I'm trying to target the edit page for a specific post type for
>> add_action('admin_print_scripts-' .<location here>
>>
>> So that the scripts do not load on every admin page, unfortunately i'm
>> just *not* getting it how to target that; I can do it using
>> $_GET['page'] for *other* pages or even the hook for the
>> add_submenu_page, unfortunately specifically the edit page gets
>> generated from within core and no idea the hook.
>>
>> hrm.. should I do if ($post->post_type == '<posttypename>') ? but then
>> it would hit some of the other admin pages when it shouldn't; $post gets
>> generated with some defaults since its blank with the "add new posttype"
>> page; blah.
>>
>> Any ideas?
>>
>> - Phil
>>
>>
>> Also, var_dump($wp_query) of course is coming out null, so what would I
>> use to check the created variables for those edit pages to see what I
>> could use as a specific?
>>
>>
>>
>>
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> 




More information about the wp-hackers mailing list