PHP code example of layered / wp-helpers

1. Go to this page and download the library: Download layered/wp-helpers 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/ */

    

layered / wp-helpers example snippets


CustomPostType::add('idea', [
	'labels'	=>	[
		'name'	=>	__('Ideas', 'my-theme-or-plugin')
	],
	'rewrite'	=>	[
		'slug'	=>	'my-ideas'
	],
	'supports'	=>	['title', 'editor', 'thumbnail', 'excerpt', 'author']
])
	->addTaxonomy('tag')
	->addColumns(['author'])
;

MetaFields::instance()->addPostMeta('second-heading', [
	'name'				=>	'Second Heading',
	'type'				=>	'text',
	'placeholder'		=>	'Heading for article',
	'show_in_rest'		=>	true,
	'showInMetaBox'		=>	true,
	'showInColumns'		=>	true,
	'showInQuickEdit'	=>	true,
	'showInBulkEdit'	=>	true
]);

// keeps request hanging until action is complete
do_action('resource_hungry_action', 'data', 4, 'action');

// queues the action to be handled in background
queue_action('resource_hungry_action', 'data', 4, 'action');