[wp-trac] [WordPress Trac] #44377: add filter to post_submit_meta_box() to conditionally refrain from outputting the "Visibility" fields
WordPress Trac
noreply at wordpress.org
Fri Jun 15 19:07:58 UTC 2018
#44377: add filter to post_submit_meta_box() to conditionally refrain from
outputting the "Visibility" fields
--------------------------------+-----------------------------
Reporter: pbiron | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version:
Severity: normal | Keywords:
Focuses: ui, administration |
--------------------------------+-----------------------------
I have a CPT that, by it's very nature, always has visibility `public`
(not private nor password protected).
Since I don't want users selecting anything other than `public`,
currently, I enqueue some CSS that hides the "Visibility" related fields
in the "Publish" metabox on `/wp-admin/post.php` and `/wp-admin/post-
new.php`, but that just seems kludgy.
**Note:** in case a "sneaky" user finds my CSS, unhides the fields and
sets the post to be private or password protected,
I also hook into
[[https://developer.wordpress.org/reference/hooks/wp_insert_post_data/|wp_insert_post_data]]
to "correct" `post_status` and `post_password`.
It would be helpful if there were a filter in
[[https://developer.wordpress.org/reference/functions/post_submit_meta_box/|post_submit_meta_box()]]
to control whether the "Visibility" related fields are output.
Such a filter would be similar in spirit to the
[[https://developer.wordpress.org/reference/hooks/view_mode_post_types/|view_mode_post_types]]
filter in
[[https://developer.wordpress.org/reference/classes/wp_screen/render_view_mode/|WP_Screen::render_view_mode()]]
that controls whether the "View Mode" related fields are output in "Screen
Options". Prior to `view_mode_post_types` being introduced in 4.4, I used
to hide those fields via CSS when appropriate.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44377>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list