<?php /** * A registry for storing all fields. * * @link https://designpatternsphp.readthedocs.io/en/latest/Structural/Registry/README.html */ class RWMB_Field_Registry { private $data = []; /** * Add a single field to the registry. * * @param array $field Field configuration. * @param string $type Post type|Taxonomy|'user'|Setting page which the field belongs to. * @param string $object_type Object type which the field belongs to. */ public function add( array $field, string $type, string $object_type = 'post' ) { if ( ! isset( $field['id'] ) ) { return; } if ( empty( $this->data[ $object_type ] ) ) { $this->data[ $object_type ] = []; } if ( empty( $this->data[ $object_type ][ $type ] ) ) { $this->data[ $object_type ][ $type ] = []; } $this->data[ $object_type ][ $type ][ $field['id'] ] = $field; do_action( 'rwmb_field_registered', $field, $type, $object_type ); } /** * Retrieve a field. * * @param string $id A meta box instance id. * @param string $type Post type|Taxonomy|'user'|Setting page which the field belongs to. * @param string $object_type Object type which the field belongs to. * * @return bool|array False or field configuration. */ public function get( $id, $type, $object_type = 'post' ) { return $this->data[ $object_type ][ $type ][ $id ] ?? false; } /** * Retrieve fields by object type. * * @param string $object_type Object type which the field belongs to. * * @return array List of fields. */ public function get_by_object_type( string $object_type = 'post' ) : array { return $this->data[ $object_type ] ?? []; } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
about | Folder | 0755 |
|
|
fields | Folder | 0755 |
|
|
helpers | Folder | 0755 |
|
|
interfaces | Folder | 0755 |
|
|
storages | Folder | 0755 |
|
|
templates | Folder | 0755 |
|
|
walkers | Folder | 0755 |
|
|
autoloader.php | File | 1.49 KB | 0644 |
|
clone.php | File | 3.5 KB | 0644 |
|
core.php | File | 2.53 KB | 0644 |
|
field-registry.php | File | 1.63 KB | 0644 |
|
field.php | File | 17.95 KB | 0644 |
|
functions.php | File | 9.5 KB | 0644 |
|
loader.php | File | 3.97 KB | 0644 |
|
media-modal.php | File | 3.09 KB | 0644 |
|
meta-box-registry.php | File | 1.28 KB | 0644 |
|
meta-box.php | File | 12 KB | 0644 |
|
request.php | File | 2.35 KB | 0644 |
|
sanitizer.php | File | 8.14 KB | 0644 |
|
shortcode.php | File | 2.55 KB | 0644 |
|
storage-registry.php | File | 418 B | 0644 |
|
validation.php | File | 2.59 KB | 0644 |
|
wpml.php | File | 3.48 KB | 0644 |
|