Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
81 views
in Technique[技术] by (71.8m points)

How to check if currently in Wordpress Admin?

I am creating my first plugin and have a single function that controls the output. This function has different output based on whether or not it is being viewed from within the WordPress admin vs. the frontend. Is there any way to easily test whether or not my function is being triggered from within admin vs the frontend?

I've tried conditionally checking the query string against the name of my plugin "page" name but it seems to fail on some servers/installs.

Thanks

question from:https://stackoverflow.com/questions/4128273/how-to-check-if-currently-in-wordpress-admin

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Duh, this was too obvious. For some reason I was thinking this had to do with an admin user. if(is_admin()) { ...output my admin stuff....}

http://codex.wordpress.org/Function_Reference/is_admin


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...