Question

I'm trying to add a "Publish" link by the quick actions:

enter image description here

but I'm not exactly sure of how implement it.

Here's what I've got so far:

add_filter('post_row_actions', function ( $actions )
{
    global $post;

    // If the post hasn't been published yet
    if ( get_post_status($post) != 'publish' )
    {
        $nonce = wp_create_nonce('quick-publish-action');

        $link = get_admin_url('path to where') . "?id={$post->id}&_wpnonce=$nonce";

        $actions['publish'] = "<a href=\"$link\">Publish</a>";
    }

    return $actions;
});

As you can see, I don't know where to link to in get_admin_url. I think I should be using wp_publish_post(), but I don't know where to put that code, and how to link to it.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top