Php 将发布按钮添加到wordpress中自定义帖子的管理员快速操作列表中

Php 将发布按钮添加到wordpress中自定义帖子的管理员快速操作列表中,php,wordpress,Php,Wordpress,我想在wordpress管理员帖子列表中的快速操作中添加一个“发布”按钮。 我正在使用自定义帖子类型“FOO” 我有下面的代码 add_filter( 'post_row_actions', function ( $actions, $post ) { if ( get_post_status( $post ) != 'publish' ) { $nonce = wp_create_nonce( 'quick-publish-action' );

我想在wordpress管理员帖子列表中的快速操作中添加一个“发布”按钮。 我正在使用自定义帖子类型“FOO”

我有下面的代码

 add_filter( 'post_row_actions', function ( $actions, $post )
{
    if ( get_post_status( $post ) != 'publish' )
    {
        $nonce = wp_create_nonce( 'quick-publish-action' ); 
        $link = admin_url( "edit.php?update_id={$post->ID}&_wpnonce=$nonce" );
        $actions['publish'] = "<a href='$link'>Publish</a>";
    }   
    return $actions;
},
10, 2 );

add_action( 'load-edit.php', function() 
{
    $nonce = isset( $_REQUEST['_wpnonce'] ) ? $_REQUEST['_wpnonce'] : null;
    if ( wp_verify_nonce( $nonce, 'quick-publish-action' ) && isset( $_REQUEST['update_id'] ) )
    {
        $my_post = array();
        $my_post['ID'] = $_REQUEST['update_id'];
        $my_post['post_status'] = 'publish';
        wp_update_post( $my_post );
    }
});
add_filter('post_row_actions',函数($actions,$post)
{
如果(获取发布状态($post)!=“发布”)
{
$nonce=wp_create_nonce(“快速发布操作”);
$link=admin\u url(“edit.php?update\u id={$post->id}&\u wpnoce=$nonce”);
$actions['publish']=“”;
}   
返回$actions;
},
10, 2 );
添加操作('load edit.php',函数()
{
$nonce=isset($\u请求[''''])?$\u请求[''''']:null;
if(wp\u verify\u nonce($nonce,“快速发布操作”)和&isset($\u请求['update\u id']))
{
$my_post=array();
$my_post['ID']=$_请求['update_ID'];
$my_post['post_status']='publish';
wp_update_post($my_post);
}
});
上面的代码确实将“发布”链接添加到了快速操作中,但当我单击它时,它实际上并没有发布,而是指向“发布”文章类型列表。我似乎不知道如何在点击链接后发布帖子并加载“FOO”帖子列表