我们有一些流程,团队成员在更改Wordpress状态时必须遵循。正因为如此,我尝试显示一条关于状态更改的消息作为提醒。
我发现后转换功能的可湿性粉剂,并认为这是正确的工作的功能,我尝试设置简单的JS警报作为测试,但似乎不工作。我使用die()测试测试了我的函数是否被调用。
任何建议将不胜感激,不需要是JS,只要我可以显示一条信息的状态变化..
我当前的函数:
function status_change_dtp( $post ) {
echo "<script>alert('Display a message on change')</script>";
}
add_action( 'draft_to_publish', 'status_change_dtp', 10, 3 );发布于 2017-07-07 16:53:18
我想出了一个解决方案,而不是使用转换后钩子,我只是简单地更新了状态消息本身……
add_filter( 'post_updated_messages', 'rw_post_updated_messages' );
function rw_post_updated_messages( $messages ) {
$post = get_post();
$post_type = get_post_type( $post );
$post_type_object = get_post_type_object( $post_type );
$messages['cpt_operator'] = array(
6 => __( "Operator Published - <script>alert('Please Set to Live in Protostar')</script>." ),
10 => __( 'Draft Saved.' )
);
return $messages;
}https://stackoverflow.com/questions/44966007
复制相似问题