PHP code example of alexrah / wp-admin-custom-post-types

1. Go to this page and download the library: Download alexrah/wp-admin-custom-post-types 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/ */

    

alexrah / wp-admin-custom-post-types example snippets


use WpAdminCPT\RegisterTypes;
use WpAdminCPT\MetaFieldsManager;
use WpAdminCPT\MetaFieldsAdmin;

const META_BOX_NONCE = 'meta_box_nonce';

new RegisterTypes('user-paid-content',
	[
		'label_singular' => "My Post",
		'label_plural' => "My Posts"
	],
	true,
	[
		'label_singular' => "Categoria Contenuto",
		'label_plural' => "Categorie Contenuto"
	]
);

function vn_fields(): MetaFieldsManager {

	$sPrefix = 'user-paid-';

	$aFields = [
		[
			"Name"        => "type",
			"Label"       => "Tipo Contenuto",
			"LabelPublic" => "",
			"Placeholder" => "Seleziona Tipo",
			"Type"        => "select",
			"Validation"  => '',
			"Value"       => ['job-listing','event'],
			'Group'       => 'global'
		],
		[
			"Name"        => "candidati_comunali",
			"Label"       => "Candidati Consiglieri",
			"LabelPublic" => "",
			"Placeholder" => "",
			"Type"        => "data-grid",
			"Validation"  => '',
			"Group"       => 'global',
			"Value"       => [
				[
					'type' => 'text',
					'name' => 'nome',
					'label' => "Nome"
				],
				[
					'type' => 'text',
					'name' => 'cognome',
					'label' => "Cognome"
				],
				[
					'type' => 'text',
					'name' => 'voti',
					'label' => "Voti"
				],
				[
					'type' => 'checkbox',
					'name' => 'isEletto',
					'label' => "Eletto"
				]
			]

		]
	];

	return new MetaFieldsManager($sPrefix,$aFields);

}

$oUserPaidContent = new MetaFieldsAdmin(vn_fields()->getFields(),META_BOX_NONCE,['user-paid-content'],'Dati');
$oUserPaidContent->init();