Download the PHP package grottopress/wordpress-metaboxes without Composer
On this page you can find all versions of the php package grottopress/wordpress-metaboxes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download grottopress/wordpress-metaboxes
More information about grottopress/wordpress-metaboxes
Files in grottopress/wordpress-metaboxes
Download grottopress/wordpress-metaboxes
More information about grottopress/wordpress-metaboxes
Files in grottopress/wordpress-metaboxes
Vendor grottopress
Package wordpress-metaboxes
Short Description A library to set up metaboxes in WordPress.
License MIT
Package wordpress-metaboxes
Short Description A library to set up metaboxes in WordPress.
License MIT
Keywords wordpress
Please rate this library. Is it a good library?
Informations about the package wordpress-metaboxes
WordPress Metaboxes
Description
A library to set up metaboxes in WordPress.
Usage
Install via composer:
composer require grottopress/wordpress-metaboxes
Use thus:
<?php
use GrottoPress\WordPress\Metaboxes\MetaboxesTrait;
/**
* Define your own metaboxes class
*/
class My_Metaboxes_Class {
/**
* Import the metaboxes trait
*/
use MetaboxesTrait;
/**
* Define your metaboxes with the `metaboxes` method
*/
protected function metaboxes( WP_Post $post ): array {
$boxes = [];
if ( \is_post_type_hierarchical( $post->post_type ) ) {
$boxes[] = [
'id' => 'my-metabox-1',
'title' => \esc_html__( 'My Metabox 1' ),
'context' => 'side',
'priority' => 'default',
'screen' => 'page',
'fields' => [
[
'id' => 'my-metabox-1-field-1',
'type' => 'select',
'choices' => [
'left' => \esc_html__( 'Left' ),
'right' => \esc_html__( 'Right' ),
],
'label' => \esc_html__( 'Select direction' ),
'label_pos' => 'before_field', // or 'after_field'
],
],
'notes' => '<p>' . \esc_html__( 'Just a super cool layout metabox example' ) . '</p>',
];
}
$boxes[] = [
'id' => 'my-metabox-2',
'title' => \esc_html__( 'My Metabox 2' ),
'screen' => 'post',
'fields' => [
[
'id' => 'my-metabox-2-field-1',
'type' => 'text',
'label' => \esc_html__( 'My first field' ),
'label_pos' => 'before_field', // or 'after_field'
'sanitize_callback' => 'sanitize_text_field',
],
[
'id' => 'my-metabox-2-field-2',
'type' => 'email',
'label' => \esc_html__( 'My second field' ),
'label_pos' => 'before_field', // or 'after_field'
'sanitize_callback' => 'sanitize_email',
],
[
'id' => 'my-metabox-2-field-3',
'type' => 'url',
'label' => \esc_html__( 'My third field' ),
'label_pos' => 'before_field', // or 'after_field'
'sanitize_callback' => 'esc_url',
]
],
'notes' => '<p>' . \esc_html__( 'My awesome metabox example.' ) . '</p>',
];
return $boxes;
}
}
// Add your metaboxes to WordPress
$metaboxes = new My_Metaboxes_Class();
$metaboxes->setup();
All versions of wordpress-metaboxes with dependencies
PHP Build Version
Package Version
The package grottopress/wordpress-metaboxes contains the following files
Loading the files please wait ....