[wp-trac] [WordPress Trac] #36462: Updating or publishing a (custom) post that hasn't loaded completely closes comments
WordPress Trac
noreply at wordpress.org
Thu May 26 03:45:53 UTC 2016
#36462: Updating or publishing a (custom) post that hasn't loaded completely closes
comments
-----------------------------------+-----------------------------
Reporter: SeBsZ | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Posts, Post Types | Version: 4.4.2
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion | Focuses: administration
-----------------------------------+-----------------------------
Changes (by boonebgorges):
* keywords: needs-patch => has-patch 2nd-opinion
Comment:
> Yeah, I would definitely want to see a more generic solution than one
that applies only to those 2 checkboxes and not any that could be added by
some plugin.
Not sure there's much we can do for plugins, at least if the plugins are
building their own markup. But yeah, if we are going to adopt a technique
for core checkboxes, we should probably do it consistently throughout.
> I've added two hidden fields in meta-boxes.php, one for comment_status
and the other for ping_status. Then I removed the code in post.php where
it closes the comments and ping_status if the POST data is missing.
This is pretty clever. I'd been imagining something less clever but more
straightforward:
{{{
<input name="comment_status_loaded" type="hidden" value="1">
<input name="comment_status" type="checkbox" id="comment_status"
value="open" <?php checked($post->comment_status, 'open'); ?> />
}}}
and then the submission handler would check `isset(
$_POST['comment_status_loaded'] )` before saving a value. Your solution is
a lot more elegant.
It feels sorta like cheating to have more than one input element on a page
with the same 'name', and then to take advantage of the fact that PHP's
behavior with respect to POST (ie, an array) will cause the second one to
overwrite the first. But I can't find anything in the HTML spec that
suggests that it's invalid markup, and I can't find anything that suggests
that we shouldn't trust PHP's behavior here.
What do others think? Would be curious to hear a take from someone like
@helen.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36462#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list