Download the PHP package pollora/metabox without Composer
On this page you can find all versions of the php package pollora/metabox. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pollora/metabox
More information about pollora/metabox
Files in pollora/metabox
Package metabox
Short Description Declare Meta Box meta boxes, fields, blocks and settings pages with a fluent PHP API.
License MIT
Homepage https://github.com/Pollora/metabox
Informations about the package metabox
Metabox declares Meta Box meta boxes, custom fields, Gutenberg blocks and settings pages with chained, type-hinted methods instead of the nested arrays passed to the rwmb_meta_boxes filter. Each field type is a class, each setting a method, enumerated values are checked when they are set, and the configuration is registered with Meta Box for you. It is for WordPress developers who use Meta Box and are tired of looking up array keys.
Part of Pollora, the Laravel framework for WordPress. It works in any WordPress project that uses Composer, with or without Pollora.
Installation
Requires PHP 8.2+, WordPress and the Meta Box plugin. Some features need a Meta Box extension: MB Blocks for blocks, MB Settings Page for settings pages, Meta Box Group for groups and Meta Box Tabs for tabs. They are all included in Meta Box AIO.
Coming from amphibee/metabox-maker? Read the upgrade guide.
Quick start
A field group with two fields in the sidebar of the page editor:
A Gutenberg block with a repeatable group of links:
A settings page, and a field group displayed on it:
Declare them when Meta Box reads its configuration, for instance in a theme's functions.php or on the init hook. Values are read with Meta Box's own functions, such as rwmb_meta( 'venue' ).
Why Metabox
Compared with the arrays passed to the rwmb_meta_boxes filter:
- Each field type is a class and each setting a method: the IDE completes them, and a typo is an error instead of a setting Meta Box silently ignores.
- Enumerated values (contexts, styles, operators, block modes…) are checked when they are set, with a message listing the allowed values.
- Extension settings get readable methods:
visibleWhen(),adminColumn(after: 'title'),include(Rule::template(...)). - Fields can be referenced by instance in conditions, so renaming a field ID updates them too.
- The field group is registered for you: no filter callback to write.
With Metabox
The equivalent Meta Box array
Features
- About 50 field types, from text inputs to files, maps, posts, taxonomies and users, with the settings of each type as methods.
- Field groups (meta boxes on edit screens), Gutenberg blocks (MB Blocks) and settings pages (MB Settings Page), displayed on post types, terms, users, comments or settings pages.
- Groups and tabs, with nested fields.
- Enumerated settings (context, priority, styles…) accept a string or an enum, and an invalid value throws an exception.
- Blocks restricted to, or excluded from, given post types.
- Dedicated methods for the Conditional Logic, Columns, Tooltip, Admin Columns, Text Limiter, Include Exclude and Show Hide extensions, and
setting()for any other Meta Box setting. - Tested with Pest and analysed with PHPStan.
Documentation
- Field groups: creating field groups and choosing where they are displayed.
- Common field settings: the settings shared by every field.
- Field list: every field on one page, with its Meta Box type.
- Basic fields: text, textarea, select, checkbox, radio…
- Advanced fields: autocomplete, color, date and time pickers, maps, sliders, WYSIWYG…
- HTML5 fields: email, number, range, URL.
- WordPress fields: post, taxonomy, user and sidebar selectors.
- Upload fields: files, images and videos.
- Layout fields: headings, dividers, groups and tabs.
- Blocks: Gutenberg blocks with MB Blocks.
- Settings pages: settings pages with MB Settings Page.
- Extensions: conditional logic, columns, tooltips, admin columns, text limits, and rules registering or displaying field groups.
- Relationships: relationships between posts, terms and users with MB Relationships.
- pollora/metabox-bridge adds migrations and Eloquent models.
- Attributes: declaring field groups, blocks and settings pages with attributes, discovered in Pollora by pollora/metabox-bridge.
For every setting, the reference is the Meta Box documentation.
Testing
This runs the Pest tests, PHPStan and Pint. The tests check the configuration arrays generated for Meta Box, with the WordPress hook functions stubbed in tests/Pest.php.
Contributing
Contributions are welcome: see the contributing guide. Report security issues privately, as described in the security policy.
License
Metabox is open-source software licensed under the RuBee group