[wp-hackers] custom post type post editor add_action scripttargetting
Philip M. Hofer (Frumph)
philip at frumph.net
Mon Nov 8 16:26:00 UTC 2010
Yeah I actually tried that after reading how admin-header.php does it,
unfortunately a var_dump on $current_screen is null at this point in
execution.
I'm running the add_menu_pages and script hooks in the 'admin_menu' action;
so it seems to be previous to when $current_screen is populated, hrm.
I always assumed that using add_action('admin_menu', was the appropriate
hook to execute the plugin's creation of the admin pages ;/ which at that
point $current_screen is empty.
Think I figured out a work around since $current_screen is null
global $pagenow;
if (($pagenow == 'post-new.php') && ($_GET['post_type'] ==
'custom_post_type')) {
add_action('admin_print_scripts', 'function_to_execute');
}
this seems to work, then just add_action to the non-hooked
admin_print_scripts
----- Original Message -----
From: "Mohammad Jangda" <batmoo at gmail.com>
To: <wp-hackers at lists.automattic.com>
Sent: Monday, November 08, 2010 8:16 AM
Subject: Re: [wp-hackers] custom post type post editor add_action
scripttargetting
> On Mon, Nov 8, 2010 at 11:05 AM, Philip M. Hofer (Frumph)
> <philip at frumph.net
>> wrote:
>
>> I'm trying to target the edit page for a specific post type for
>> add_action('admin_print_scripts-' .<location here>
>>
>
> See Otto's answer here:
> http://wordpress.org/support/topic/understanding-admin_print_scripts-page-hook#post-1172659
> and
> within your enqueue function, check current_screen for the post_type:
>
> global $current_screen;
>
> if( $current_screen->post_type == 'my-post-type' ) {
>
> // load scripts
>
> }
>
>
> (also see here for a cascading post type check:
> https://gist.github.com/476964)
> _______________________________________________
> 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