I am trying to display a notice in admin panel when I activate my test plugin.
How can I display that? What's that method?
相关问题
- Display product ACF field value in Woocommerce tra
- Adding a custom button after add to cart button in
- How to add a “active” class to a carousel first el
- Setting custom order statuses as valid for payment
- change the font size in tag cloud
相关文章
- wordpress新增页面如何个性化设置
- Call non-static methods on custom Unity Android Pl
- select query in wordpress
- Get WooCommerce featured products in a WP_Query
- Woocommerce update shipping methods in checkout vi
- How to obtain the enable admission controller list
- Change order status just after payment in WooComme
- Why is my dropzone javascript form not working?
Just use a
<div class='updated'>
. For example -This is so simple to show a notice
But if you want to show a Dismissible Notice then try below
And if you want to show that notice on certain page try below condition.
You can see here
You can use the new admin notices to create what are called admin pointers using
show_wp_pointer_admin_bar
.Linky: http://wpengineer.com/2272/how-to-add-and-deactivate-the-new-feature-pointer-in-wordpress-3-3/
For plugin activations, the 'admin_notices' hook cannot be used directly, because there is a redirect. A workaround is to store your notice in the options table and check for it next time. Also, if you also want to cover plugin upgrades as well as activations, you will need to use another hook, such as 'admin_init' (since WP 3.1, see http://make.wordpress.org/core/2010/10/27/plugin-activation-hooks/).
Here is a complete sample plugin handling both activation and upgrade. I made the deferred notice an array so you can stack them up.
UPDATE: There's also a common way to use
set_transient()
instead ofupdate_option()
, and to direct messages to the correct admin user. This post concerns metaboxes, not plugin activation, but the techniques work the same just about everywhere in Dashboard, as far as I know: https://wordpress.stackexchange.com/questions/15354/passing-error-warning-messages-from-a-meta-box-to-admin-noticesI've developed amarkal-admin-notification - a script that lets you add static/dismissible admin notices and handles the dismissal for you. This script is a module within the Amarkal WordPress framework.
For example:
The proper way to add your notices is to echo it in your hook for
admin_notices
action: