2 Answers
2

A useful fast way is use javascript in combination with an ajax action that output the box.
Create a small plugin. Create a folder inside plugins directory, naming it 'SubmitReviewConf'. In this folder create a php file named SubmitReviewConf.php.

Hide the wordpress 'Submit for Review' button and replace it with a button that appera equel to the wp one, but that do not trigger the submit action.

When out fake submit button is clicked, we use the ajax url to trigger our function and output the html inside the modal confirmation, using the tb_show function provided by thickbox script.

When the use click for 'Submit for Review' inside the modal box, we simulate a click on the wp standard 'Submit for Review' button and remove the modal window. If the user click on 'Cancel' we simply remove the modal window doing nothing.

That's all. Remember to activate the plugin in WP backend ;)

Note that this plugin require javascript is enabled on user browser. If disabled the user will not see any confirmation, but consider that modal window (thickbox) is a javascript script that cannot work if javascript is disabled.

If this feature was a critical one, you probably wanted to disable publishing at all if js is disabled, but being not-critical feature you can just ignore user that have js disabled (wordpress will take care for your security, in that case) considering they are a very small percentage of users.

Before I praise you for this solution, let us make it work accordingly. Currently upon plugin activation, this error appears: Parse error: syntax error, unexpected '}' in /SubmitReviewConf/SubmitReviewConf.php on line 30
–
Christine CooperAug 28 '13 at 15:51

Sworn that I did that, at least when I pasted it in phpStorm. Nonetheless, this is a stellar answer and works very elegantly. Very well done! I will leave the question open for a few days so the answer receives more attention (upvotes) which I certainly believe that it deserves. With that being said, I do have a final question. Like many other multi-author platforms, I use WyPiekacz wordpress.org/plugins/wypiekacz which is a plugin where you can set conditions that users need to follow when posting.
–
Christine CooperAug 29 '13 at 14:07

Problem is that the broken rule notification appears after the thickbox appears. Making this a very painful task if the user have to see the thickbox several times- which could potentially make this an annoyance rather than a benefit. Is there any way to enforce these rules first and when they are passed, then display the thickbox?
–
Christine CooperAug 29 '13 at 14:08

@ChristineCooper The problem is that your plugin check rules on wp_insert_post_data filter. So if post pass rules, post is saved very soon, and I think there is no chance to show the modal box before post is saved as 'pending'... An easy edit I can make to my plugin is to force modal box appear only one time, but still before rules are passed or after post is already sended for review.
–
gmazzapAug 29 '13 at 15:20

1

@ChristineCooper "Do you have a fix for this?" Is this a challenge? ;D Solve bug was very easy for itself, problem is compatibility with WyPiekacz. Only for that I have to implement additional code handling a meta field. Btw now bug should be fixed in WyPiekacz compatible way. Only check this workflow: (I haven't WyPiekacz to test): create and save post as draft. After saved change it in a way that make WyPiekacz rules fail. Send for review, modal should appear. In modal click 'Submit' this will trigger WyPiekacz error. Correct it and send for review again. Does modal appear again?
–
gmazzapAug 30 '13 at 18:13

It is possible to do so. You have to use the wp_insert_post_data filter hook. I will give you the general idea, hopefully this helps.

An example would be:

function my_filter_handler($data , $postarr) {
// do something with the post data
// You have to check that your post is submitted for review, not the publish post, so you have to have an if statement checking that
// Then, you have to ensure that you use jQuery that comes with WordPress (using enqueue methods), and not a jQuery you supply.
return $data;
}
add_filter('wp_insert_post_data', 'my_filter_handler', '99', 2 );