PHP code example of wpscholar / wp-post-status

1. Go to this page and download the library: Download wpscholar/wp-post-status library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wpscholar / wp-post-status example snippets


 

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,
	] );

} );



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