2017 © Pedro Peláez
 

library wp-post-status

A library for better integration of custom post statuses with the UI in WordPress.

image

wpscholar/wp-post-status

A library for better integration of custom post statuses with the UI in WordPress.

  • Thursday, November 30, 2017
  • by wpscholar
  • Repository
  • 1 Watchers
  • 1 Stars
  • 204 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 22 % Grown

The README.md

WordPress Post Status

A library for better integration of custom post statuses with the UI in WordPress., (*1)

Getting Started

For the most part, use the same arguments as you would when directly calling register_post_status() in WordPress:, (*2)

<?php 

add_action( 'init', function () {

    \wpscholar\WordPress\PostStatus::register( 'archive', [
        'label'                     => esc_html_x( 'Archive', 'post status', 'text-domain' ),
        'labels'                    => [
            'post_state'    => esc_html_x( 'Archived', 'post status state', 'text-domain' ),
        ],
        'label_count'               => _n_noop( 'Archived <span class="count">(%s)</span>', 'Archived <span class="count">(%s)</span>', 'text-domain' ),
        'post_types'                => [ 'post' ],
        'public'                    => true,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
    ] );

} );

Just be sure to replace text-domain with your actual plugin (or theme) text domain., (*3)

Custom Arguments

The following are custom arguments:, (*4)

  • labels - The post_state label is used when displaying the status next to the title on the post listing page.
  • post_types - Unless one or more post types are defined, the new status won't be assignable via the UI.

It is possible to assign any arguments you want when registering a custom post status. You can then filter by those arguments when calling get_post_stati()., (*5)

Fetching Custom Labels

A custom label can be fetched as follows:, (*6)

<?php

// Label returned will be 'Archived' (given registration code from previous example)
$label = \wpscholar\WordPress\PostStatus::getLabel('archive', 'post_state');

If the requested label doesn't exist, the fallback is the main label property from the post status object., (*7)

The Versions

30/11 2017

dev-master

9999999-dev

A library for better integration of custom post statuses with the UI in WordPress.

  Sources   Download

GPL-2.0+

30/11 2017

1.0

1.0.0.0

A library for better integration of custom post statuses with the UI in WordPress.

  Sources   Download

GPL-2.0+