添加其他“已发布”通知,您可以使用以下内容add 发布帖子后的附加管理通知:
add_action(\'admin_notices\', function(){
$screen = get_current_screen();
$editPostScreen = ($screen->parent_base == \'edit\' && $screen->post_type == \'post\') ? true : false;
$justPublished = (isset($_GET[\'message\']) && $_GET[\'message\'] == \'6\') ? true : false;
if ($editPostScreen && $justPublished) {
$class = \'notice notice-info\';
$message = __( \'Just published a post custom text\', \'myplugin_textdomain\' );
printf( \'<div class="%1$s"><p>%2$s</p></div>\', esc_attr( $class ), esc_html( $message ) );
}
});
($justPublished
依赖于$_GET[\'message\']
. 此URL查询变量在管理地址栏中不可见,实际上是Wordpressremoves it from the URL with Javascript! 我花了很长时间才弄明白,所以虽然你看不到它,但它确实存在!)编辑默认的“已发布”通知,您可以使用以下命令edit 发布帖子后的管理员通知:
add_filter( \'post_updated_messages\', function($messages){
$messages[\'post\'][6] = __( \'Just published a post custom text\', \'myplugin_textdomain\' );
return $messages;
}, 10, 1 );