[wp-hackers] admin menu equivalent of template_redirect?

Glenn Ansley glenn at glennansley.com
Mon Oct 20 06:06:20 GMT 2008


What about something like this:

add_action('admin_print_scripts', 'testers');
function testers(){
	global $the_current_page;
	if ( 'post.php' == $the_current_page || 'page.php' == $the_current_page ){
		update_post_meta($_GET['post'],'foo','bar');
		$test = get_post_meta($_GET['post'],'foo',true);
		if ( $test == 'bar' ){
			wp_enqueue_script('cropper');
		}
	}
}

On Sat, Oct 18, 2008 at 12:33 AM, DD32 <wordpress at dd32.id.au> wrote:
>
> I have a feeling that you wont be able to achieve that.
> AFAIK, The headers included before the post is queried, And the admin interface doesnt use the same Query functions like the front end does.
>
> Your best bet is probably going to be enqueue them for all posts/pages, and hook onto the footer to echo <script>$myscript.enable()</script> possibly.  you might also want to check if $post_id is set on the admin_init hook, I doubt it is, but if it is, you can base it off that.
>
> On Sat, 18 Oct 2008 15:24:49 +1100, Casey Bisson <casey.bisson at gmail.com> wrote:
>
>>
>> The template_redirect hook works wonders on the public side, allowing
>> my plugins to evaluate the found posts and execute conditional code
>> based on the results. Is there any equivalent to that inside the
>> dashboard?
>>
>> Reason: I'm manipulating the post and page editor screens via jQuery,
>> but only if the page/post has certain post_meta. How can I check for
>> the existence of that post_meta in time to queue the appropriate js
>> and css?
>>
>> --Casey
>>
>> http://about.Scriblio.net/
>> http://MaisonBisson.com/
>>
>> _______________________________________________
>> 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