Edit-Flow icon indicating copy to clipboard operation
Edit-Flow copied to clipboard

Submit for Review button not showing

Open slobodan opened this issue 12 years ago • 7 comments

I thought this was due to "Pending Review" status being deleted and replaced by a similarly named status, but I'm getting the same problem at fresh WP install.

In /modules/custom-status/custom-status.php there's no_js_notice function, it embeds some CSS to hide #publish (same ID used for Submit for Review) button if a user has JS disabled.

The button is made visible again by JS code, but only if this condition is met:

if ( current_user_can_publish_posts || ( current_status == 'publish' && current_user_can_edit_published_posts ) ) {
    // show publish button if allowed to publish
    jQuery('#publish').show();

These two variables are set in custom-status.php and they are:

var current_user_can_publish_posts = <?php echo current_user_can( $post_type_obj->cap->publish_posts ) ? 1 : 0; ?>;
var current_user_can_edit_published_posts = <?php echo current_user_can( $post_type_obj->cap->edit_published_posts ) ? 1 : 0; ?>;

So, when a contributor is trying to submit a post for review, both should be false and Submit for Review button remains hidden, right?

slobodan avatar Nov 13 '13 15:11 slobodan

Hey, you can probably accomplish this by emulating the following functionality: http://editflow.org/extend/hide-the-publish-button-for-certain-custom-statuses/. Rather than

<style>
    #publishing-action { display: none; }
</style>

You could use something like:

<style>
    #publishing-action #publish { display: block; }
</style>

In conjunction with that, you'll probably want to hide or limit the custom statuses a user can select based on their role, so check out http://editflow.org/extend/limit-custom-statuses-based-on-user-role/.

If this doesn't make sense, I can put up a more thorough example/I can go more into depth on how Edit Flow handles custom statuses and why this is a weird issue.

cojennin avatar Nov 18 '13 03:11 cojennin

Thanks @cojennin

Got this to work, but I'm still surprised the button is hidden in the first place. No need for a more thorough example (although I really appreciate it).

Looked at the code and I guess this could kind of make sense because not all publishers want to force contributors' posts to go from Draft to Pending Review, but I still think 90% of them do, so maybe hiding the button programmatically rather than bringing it back would make more sense. Or maybe add a true/false filter hook to allow check if CSS that hides the button is needed, cause this way both "hide CSS" and "show CSS" are used. Just my thoughts, but wondering if you think any of that makes sense :)

slobodan avatar Nov 18 '13 09:11 slobodan

You're asking a lot of good questions and unfortunately I only have subpar answers, but if you're interested in learning more, you should definitely check out a few interesting spots in WordPress core, as it looks like you've already done, you can browse the Edit Flow Custom Status module, and something I think that's also pretty important is to take a quick look at this core ticket.

The real problem with WordPress and custom statuses is that there exists a Custom Status API but it's poorly implemented and supported for a few good/bad reasons, some you've touched on here. The first thing that really needs to be solved is "what do custom statuses represent?" Do they deal with permissions? Are they used to display posts differently? What do you do about statuses like "Trash," "Published" and "Scheduled"? To be truly "custom," should a user be able to alter the concept or function of these statuses? Should a user be able to remove them entirely?

The custom statuses in Edit Flow are more about adding some conceptual (and a little concrete) structure to a user(s) workflow. In order to begin to advance the idea of truly "custom" statuses, you have to begin by getting rid of the structure WordPress imposes on them. Edit Flow takes a stab at this by attempting to level the playing field of statuses. For the most part, statuses that are not "Published," "Scheduled" or "Trash" should hold the same wait and it's up to the developer to graft on to each status their notion of what each represents.

If this seems pretty interesting we're always looking for folks to help out with developing Edit Flow. Patches, suggestions and ideas are always welcome! Feel free to check out editflow.org or dev.editflow.org for some more info.

*Edits were made for clarification and spelling.

cojennin avatar Nov 18 '13 15:11 cojennin

The original thinking behind hiding the button was that, because you can remove the "Pending Review" status in Edit Flow or change it's position in the workflow, the "Submit for Review" may or may not be applicable for your use case. Generally to keep users from shooting themselves in the foot, but also to promote more status-agnostic workflows.

The real problem with WordPress and custom statuses is that there exists a Custom Status API but it's poorly implemented and supported for a few good/bad reasons, some you've touched on here.

Yeah... we should fix that :)

cc @nacin

danielbachhuber avatar Nov 18 '13 18:11 danielbachhuber

Sorry about delayed response and thank you both.

@danielbachhuber I see what you mean with the button, although I was confused by this at first. The only thing I think could be better is to insert a filter that would disable the CSS that hides it because this way Edit Flow hides it, then if you need it you need to override Edit Flow's CSS. So basically instead of:

if( $this->is_whitelisted_page() ) :

it would be

if( $this->is_whitelisted_page() && apply_filters( 'ef_hide_publish_button', true ) ) :

If this makes sense I can submit a pull request.

@cojennin I'm relatively new to Edit Flow, but have been using it extensively and will keep an eye on its development and try to contribute.

slobodan avatar Nov 29 '13 09:11 slobodan

Adding a filter seems fine to me.

danielbachhuber avatar Dec 01 '13 04:12 danielbachhuber

I'm not sure I follow all the reasoning here, but as an editor of a group blog, basically the only thing I want contributors to be able to do (besides draft a post) is submit the post for review. I was surprised to hear from our writers that this option had disappeared after we turned on Edit Flow.

Here's what I added to functions.php to turn it back on:

/*------------------------------
Edit Flow
Show Submit for Review Button
------------------------------*/

add_action( 'admin_head', 'edit_flow_show_publish_button' );

function edit_flow_show_publish_button() {

    if ( ! function_exists( 'EditFlow' ) )
        return;

    if ( ! EditFlow()->custom_status->is_whitelisted_page() )
        return;

    if ( get_post_status() == 'draft' ) { ?>
        <style>
            #publishing-action #publish { display: block; }
        </style>
    <?php }
}

So it works now, but it doesn't seem like the default should be to hide the button.

samglover avatar Feb 20 '15 19:02 samglover