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

Mark Duncan wp-t31os at ntlworld.com
Mon Nov 8 18:17:04 UTC 2010


$typenow should be set for post-new, it was last time i checked in 3.0.1 
...

Some data i collected when building an admin menu can be found here 
(only intended as a quick reference for me whilst writing code).
http://wordpress.pastebin.com/uDYDa4BQ

The only time i've found it's not set is when viewing the tag management 
page and it's the "post" post type.. (it was populated for other post 
types - see pastebin data).

I suppose if necessary you could strpos or substr on $parent_file or 
$submenu_file to figure out the current post type if $typenow isn't 
producing the expected output (but i'd consider that quite hacky - and 
your existing approaches are probably better).

As Scribu said, it might be worth a trac ticket if the var isn't getting 
populated as it should be..


On 08/11/2010 16:49, Philip M. Hofer (Frumph) wrote:
> $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
>>
>
>
> _______________________________________________
> 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