Download the PHP package gebruederheitz/wp-meta-fields without Composer

On this page you can find all versions of the php package gebruederheitz/wp-meta-fields. 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 wp-meta-fields

Wordpress Meta Fields

Dependency-less helpers for a faster Wordpress metaboxes setup.


Installation

via composer:

Make sure you have Composer autoload or an alternative class loader present.

Usage

Use these helpers anywhere in the WP administration backend where you want to render "metaboxes", or input fields for editors.

WP-Meta-Fields comes with no frontend dependencies – no extra stylesheets or client-side scripts that could cause trouble with installation. This also means, however, that it doesn't come with fancy features like asnyc search, validation or fancy styles for the various input types. It merely provides an intuitive interface to create DRY code when creating metaboxes.

Label i18n

Labels are automatically translated using Wordpress' __() internationalisation function. By default, the namespace "ghwp" is applied. To customize this text domain, call one of the setter method on the singleton:

Inputs API

All field require at least one name attribute (as noted for each type below) to be set, otherwise an InvalidFieldConfigurationException will be thrown.

TextInput

For rendering a regular text input field.

MetaForms::renderTextInputField(string $name, string $label, $value = '', bool $required = false)
Parameter Type Description
name string Identifier for the field. You will use this value to read the $_POSTed data back from the form. Required.
label string A short description for the site editor about the field's expected content. Auto-translated. Required.
value ?string The current value of this field. Will be escaped with Wordpress' own esc_attr(). Default '' (empty string).
required boolean Whether to mark the field as required. An asterisk will be appended to the label and the <input> element will have a required attribute set. Default false.

NumberInput

For rendering a an <input type="number" />.

MetaForms::renderNumberInputField()

same as TextInput

TextArea

Renders a <textarea>.

MetaForms::renderTextArea()

same as TextInput

MediaPicker

Renders the inputs required for a Wordpress media picker, with a preview of the currently selected medium.

For this to work, make sure the WP media scripts are enqueued. If you're using gebruederheitz/wp-easy-cpt this is easily achieved by setting protected $withMedia = true; on your PostType implementation. Otherwise you will need to add a callback to the appropriate action hook:

MetaForms::renderMediaPicker()
Parameter Type Description
idFieldName string Identifier for the field, storing the attachment ID of the selected media. You will use this value to read the $_POSTed data back from the form. Required.
idFieldValue ?int Attachment ID of the selected media.
urlFieldName Identifier for the field, storing the public URL for the selected media. You will use this value to read the $_POSTed data back from the form. Required.
urlFieldValue ?string Public URL of the selected media.
label string Text content of the associated <label> element. Default 'Image'.
showLabel boolean Whether to display the label or not. Default true.

Using custom templates

You can override the default templates provided by simply putting a template file with the correct name into template-parts/meta/forms/ within your theme's root directory:

Input type Template name
Text / Default input-field-text.php
Number input-field-text.php
Textarea textarea.php
Media picker media-picker.php

Customizing the template override location

If you want to use a custom location (other than template-parts/meta/forms/) you can provide your own override base path using one of the singleton's setter methods. You can not change the names of the template files.

Development

Dependencies


All versions of wp-meta-fields with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
gebruederheitz/simple-singleton Version ^1.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 gebruederheitz/wp-meta-fields contains the following files

Loading the files please wait ....