Download the PHP package devuri/cpt-meta-box without Composer

On this page you can find all versions of the php package devuri/cpt-meta-box. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cpt-meta-box

cpt-meta

The cpt-meta library simplifies the creation, management, and rendering of custom post types, meta boxes, and fields in WordPress. Its modular design makes it easier to build structured content management solutions by providing intuitive APIs for defining and sanitizing metadata, registering post types, generating custom fields, and interacting with WordPress hooks and REST endpoints.

Installation

Install via Composer:

Once installed, ensure that your plugin or theme autoloads dependencies:

Simplified Example

Below is a snippet of how a baisc plugin might set everything up:

When you visit Vehicles > Add New in the admin area, you’ll see a “Vehicle Details” meta box. Any data entered into these fields will automatically save to the post’s metadata. check out the full sample plugin code here: https://github.com/devuri/wp-vehicle-management

Key Features

Example: Vehicle Management

Below is a basic walkthrough on how you might use this library to manage a “Vehicle” custom post type and its metadata.

1. Register a Custom Post Type

First, create a PostType instance and register it:

This will make a new post type called “Vehicle” in the WordPress admin menu with a car dashicon and support for title and thumbnail.

2. Define Metadata Fields in a Settings Class

Next, create a subclass of Settings to define the custom fields (e.g., name, description, type, speed):

Within these methods (input, textarea, select), the library handles rendering, sanitization, and labeling. You can further tailor data sanitization by overriding methods like data() or hooking into form submission processes.

3. Attach the Settings to a Meta Box

Create a MetaBox instance, passing in your VehicleSettings object and any config options, then register it:

When editing a “Vehicle” post, you’ll now see a “Vehicle Details” meta box containing all defined fields.

4. Retrieving Metadata

With the Data class, you can retrieve post data in one place:

Additionally, you can fetch a list of vehicles, generate edit links, or retrieve featured image IDs.

Advanced Usage

1. Custom REST Endpoints

If you’d like to expose a custom endpoint, the PostType class offers a helper method:

Your custom endpoint will be available at /{post_type}/v1/custom-details.

2. Admin Columns

Add or modify admin columns for your post type:

3. Bulk Registration & Autosave

If you maintain multiple custom post types, you can bulk-register them. Or you can rely on the built-in autosave mechanism (by default, MetaBox hooks into save_post_{$post_type}).

4. Extensible Form Rendering

All fields are generated by the Form class, which you can override or extend for specialized needs (e.g., custom JavaScript fields, advanced validation, etc.).
Common methods include input, textarea, select, editor, and more.

Below are two examples demonstrating how to use the urisoft/postmeta package in a plugin context. Both examples register a custom post type called “Vehicle” and create a meta box for managing vehicle data in the WordPress admin.


Example 1: Step-by-Step Setup with PostType and MetaBox

Click to expand code

When you visit Vehicles > Add New in the admin area, you’ll see a “Vehicle Details” meta box. Any data entered into these fields will automatically save to the post’s metadata.

Example 2: Helper Function (createMeta)

Click to expand code

Note: The createMeta function will skip registering the “vehicle” post type if it already exists. If that’s the case, you only get the meta box for the existing post type.

Both approaches result in a “Vehicle Details” meta box when editing the “Vehicle” custom post type in your WordPress admin. Choose whichever method best suits your workflow.

Additional Tips

The cpt-meta library offers a streamlined, powerful set of tools for building and maintaining custom post types in WordPress. By combining classes like PostType, MetaBox, Settings, Form, and Data, developers can organize complex metadata workflows with minimal boilerplate. Whether you’re setting up a single custom post type or crafting a fully-fledged content management system, cpt-meta aims to simplify the entire process—so you can focus on building great features.

For more advanced details on WordPress custom post types and metadata, refer to:


All versions of cpt-meta-box with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package devuri/cpt-meta-box contains the following files

Loading the files please wait ....