我想提醒我的插件用户,插件已启用,但仅在product
页面(仪表板),我发现$pagenow
全局变量:
global $pagenow;
$pagenow != \'post.php\'; // This will be shown on "normal posts" too
如何仅在产品页面上添加通知警报?这就是我目前所拥有的:
add_action(\'admin_notices\', function () {
if (!is_admin()) {
return;
}
$title = __e(\'Your plugin is enabled\');
$div = \'<div class="notice notice-info is-dismissible"><p>%s</p></div>\';
$pluginPath = \'path-to/my-plugin.php\';
if (is_plugin_active($pluginPath)) {
echo sprintf($div, $title);
}
});