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

Simple Implemetation for custom meta boxes and fields for WordPress custom post types

This is a PHP Composer package that can help you create WordPress Meta Boxes and Meta Fields. It also includes a Data class that you can use to retrieve the saved meta data.

Installation

To install this package, run the following command in your terminal:

MetaBox and Settings

This is a set of PHP code snippets for creating a WordPress meta box and its related settings using the MetaBox and Settings classes. These classes provide functionality to define and handle custom meta boxes and their settings in WordPress.

MetaBox Class

The MetaBox class allows you to create a custom meta box in WordPress. It provides the following features:

Usage

To use the MetaBox class, follow these steps:

  1. Include the code in your WordPress project.
  2. Create an instance of the Settings subclass, such as the Details class in the provided example, passing the relevant post type as a parameter.
  3. Implement the settings() method in your Settings subclass to define the meta box settings. This method defines the fields to be displayed in the meta box.
  4. Implement the data() method in your Settings subclass to handle the data submitted from the meta box fields. This method sanitizes and prepares the data before saving it.
  5. Customize the settings() and data() methods by adding fields and defining their settings within the settings() method.
  6. Create an instance of the MetaBox class, passing the Settings object and optional arguments. This will automatically create and display the meta box on the relevant post types.
  7. The entered data will be saved when the post is updated.

Settings Class

The Settings abstract class provides a foundation for defining and handling settings related to a specific post type. It works in conjunction with the MetaBox class to define the settings for the meta box.

Usage

To use the Settings class, follow these steps:

  1. Create a subclass that extends the Settings class.
  2. Implement the settings() method to define the meta box settings.
  3. Implement the data() method to handle the data submitted from the meta box fields (be sure to sanitize).
  4. Customize the Settings subclass by adding fields and defining their settings within the settings() method.
  5. Instantiate the Settings subclass and pass it to the MetaBox class constructor to create and display the meta box.

Example Usage

The following example demonstrates the usage of the MetaBox and Settings classes:

This example demonstrates how to create a meta box for the 'vehicle' post type using the MetaBox and Settings classes. The Details class is a subclass of Settings and defines the meta box settings and data handling. The MetaBox class is used to create and display the meta box with various customization options.

Data Class

The Data class provides various utility methods for working with data in WordPress. It includes functions for retrieving and manipulating post-related data such as post meta, post items, and generating custom edit links.

Usage

To use the Data class, follow these steps:

  1. Create an instance of the Data class, optionally passing a post type as a parameter. If no post type is specified, the default post type 'post' will be used.
  2. Utilize the available methods of the Data class to perform data-related operations.

Methods

The Data class provides the following methods:

Example Usage

Here's an example of how you can utilize the Data class:

In this example, we create a Data object for the 'vehicle' post type and use its methods to retrieve post items, post meta data, generate an edit link, get a value from an array, and retrieve the latest posts. You can adapt these examples to suit your specific needs.

Conclusion

This package provides a simple and easy-to-use way to create MetaBoxes and meta fields in WordPress. If you have any questions or issues, please feel free to submit an issue.


All versions of cpt-meta-box with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1 || ^7.4 || ^8.0 || ^8.1
devuri/wp-admin-page Version ^3.3.2
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 ....