moderntribe / square1-object-meta
Provides object meta wrappers for square one
Installs: 19 987
Dependents: 5
Suggesters: 0
Security: 0
Stars: 0
Watchers: 21
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- moderntribe/square1-container: ^4.2
- 4.x-dev
- 4.2.0
- dev-master / 4.1.x-dev
- 4.1.0
- 4.0.16
- 4.0.15
- 4.0.13
- 4.0.12
- 4.0.8
- 4.0.7
- 4.0.5
- 4.0.4
- 4.0.3
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.18
- 3.4.17
- 3.4.16
- 3.4.15
- 3.4.14
- 3.4.13
- 3.4.12
- 3.4.11
- 3.4.10
- 3.4.9
- 3.4.8
- 3.4.7
- 3.4.6
- v3.4.4
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.0
- v3.2.0
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.0
- 2.1.2
- v2.1.1
- v2.0.0
- 0.0.2
- 0.0.1
- dev-feature/monorepo
This package is auto-updated.
Last update: 2024-10-25 21:14:19 UTC
README
Adding Meta Groups
Create the Meta_Group
<?php namespace Tribe\Example\Object_Meta; use Tribe\Libs\ACF; class Example extends ACF\ACF_Meta_Group { public const NAME = 'example_meta'; public const ONE = 'example_object_meta_one'; public const TWO = 'example_object_meta_two'; public function get_keys() { return [ self::ONE, self::TWO, ]; } public function get_group_config() { $group = new ACF\Group( self::NAME, $this->object_types ); $group->set( 'title', __( 'Example Object Meta', 'tribe' ) ); $group->add_field( $this->get_field_one() ); $group->add_field( $this->get_field_two() ); return $group->get_attributes(); } private function get_field_one() { $field = new ACF\Field( self::NAME . '_' . self::ONE ); $field->set_attributes( [ 'label' => __( 'Example Object Meta #1', 'tribe' ), 'name' => self::ONE, 'type' => 'text', ] ); return $field; } private function get_field_two() { $field = new ACF\Field( self::NAME . '_' . self::TWO ); $field->set_attributes( [ 'label' => __( 'Example Object Meta #2', 'tribe' ), 'name' => self::TWO, 'type' => 'text', ] ); return $field; } }
Register in the Definer
<?php declare( strict_types=1 ); namespace Tribe\Example\Object_Meta; use DI; use Psr\Container\ContainerInterface; use Tribe\Libs\Container\Definer_Interface; use Tribe\Example\Settings; class Object_Meta_Definer implements Definer_Interface { public const GROUPS = 'meta.groups'; public function define(): array { return [ \Tribe\Libs\Object_Meta\Object_Meta_Definer::GROUPS => DI\add( [ DI\get( Example::class ), ] ), Example::class => static function ( ContainerInterface $container ) { return new Example( [ // use one or more of the following options // can be added to post types 'post_types' => [ 'page', 'post' ], // or can be added to taxonomies 'taxonomies' => [ 'category' ], // or can be added to settings screens 'settings_pages' => [ $container->get( Settings\General::class )->get_slug() ], // or can be added to user profiles 'users' => true, ] ); }, ]; } }