If you edit your user JS page, change the JS, and click Show preview,
the new JS will be loaded ("previewed"). However, this "preview"
is also engaged when you click Show changes, or click "Save page"
and fail to save. Don't do that: only "preview" JS when the user
has actually chosen to preview it.
Change-Id: Id9bcd235d3414b68de6e5d491b7b0c4f9b16e05f
*/
public function userCanPreview() {
$request = $this->getRequest();
- if ( $request->getVal( 'action' ) !== 'submit' || !$request->wasPosted() ) {
+ if (
+ $request->getVal( 'action' ) !== 'submit' ||
+ !$request->getCheck( 'wpPreview' ) ||
+ !$request->wasPosted()
+ ) {
return false;
}