imath / wp-statuses

WordPress plugin to ease Custom Post Statuses integration
GNU General Public License v2.0
161 stars 27 forks source link

Filter dropdown statuses and labels #21

Closed rowatt closed 5 years ago

rowatt commented 6 years ago

I was wondering if it might be possible to add some filters to wp_statuses. Two in particular would be helpful for me right now.

(1) filter which statuses are displayed in the metabox dropdown. Some of WordPress's built in statuses aren't relevant for me, so it would avoid confusion with editors on the site if they were removed. Although it's possible to achieve the same with javascript, a simple filter seems to be an easier and more robust way to achieve this.

(2) filter the labels used for the built in status types. I'd prefer slightly different wording to what you have used, so a filter would be the simplest way to change the labels.

This commit could probably be improved and if you are willing to add some filters, then there may be other similar things which could also be filtered.

For the record the capitalisation of words isn't consistent in some of the labels, specifically Publicly published and Save as private (lines 206 and 221 of class-wp-statuses-core-status.php).

imath commented 6 years ago

Hi @rowatt

I've just introduced a new function to unregister status for a given list of post types. Here's an example of how to use it :

function test_wp_statuses_unregister_status_for_post_type() {
    // This will remove the Publish status for the page & post post types.
    wp_statuses_unregister_status_for_post_type( 'private', array( 'page', 'post' ) );
}
add_action( 'wp_statuses_registered', 'test_wp_statuses_unregister_status_for_post_type' );

I'm giving myself a few more days to test it doesn't introduce some regressions or bugs before publishing a new major version for it.

Thanks a lot for your contributions to this plugin.

rowatt commented 6 years ago

The unregister function sounds like a fine solution, and thank you for adding the label filter.

Thanks for an awesome plugin!

ibes commented 5 years ago

this might be closed