[wp-trac] [WordPress Trac] #25279: Use action hooks to add default post publishing actions to post edit screen instead of hardcoding them
WordPress Trac
noreply at wordpress.org
Wed Sep 11 13:39:36 UTC 2013
#25279: Use action hooks to add default post publishing actions to post edit screen
instead of hardcoding them
----------------------------+-----------------------------
Reporter: ragulka | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version:
Severity: normal | Keywords:
----------------------------+-----------------------------
Quite often plugin and theme developers need to remove some of the
publishing actions from the post edit screen. It is more often a real use
case with custom post types of course.
I have written a simple plugin that adds a custom post type, but I do not
need the schedule feature. I also do not need private/public publishing
action.
I could simply remove the default submitdiv meta box and just re-create
the functionality what I need, or hide the actions using CSS or JS, but
that always feels like a hack to me. WordPress usually provides an elegant
way to customize the UI and I think this is one of the areas where it lags
behind...
Re-creating the meta-box code feels just wrong when I simply need to
remove 1 or 2 actions. CSS and JS are not good solutions from usability
perspective.
'''My suggestion is that the default publishing actions should be added
using hooks instead''', because that would allow plugin and theme
developers to simply remove them when not needed.
Namely, we should move all hardcoded minor, misc and major publishing
actions to separate functions that make use of the already existing
`post_submitbox_misc_actions` and `post_submitbox_start` action hooks.
Since there is no action hook for minor publishing actions, we could
create a new action hook for that as well.
If we want to take this one step further, we could rename the actions so
that they follow a similar convetion. For example:
`post_submitbox_minor_actions`, `post_submitbox_misc_actions` and
`post_submitbox_major_actions`
Consider the following code:
Somewhere in core:
{{{
function publish_date_publishing_action() {
// code here...
}
add_action('post_submitbox_misc_actions',
'publish_date_publishing_action');
}}}
Somewhere in a plugin:
{{{
function remove_book_publishing_date_action() {
if ( is_admin() && $typenow == 'book' ) {
remove_action('post_submitbox_misc_actions',
'publish_date_publishing_action');
}
}
add_action('init', 'remove_book_publishing_date_action');
}}}
This is clearly a better approach than replacing the meta box or using CSS
or JS to hide certain parts of it.
I would be happy to provide the code as a patch as well.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25279>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list