Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
- function your_prefix_function_name( $meta_boxes ) {
- $prefix = '';
- $meta_boxes[] = [
- 'title' => __( 'Post Meta', 'your-text-domain' ),
- 'id' => 'post-meta',
- 'post_types' => ['post'],
- 'fields' => [
- [
- 'name' => __( 'API version', 'your-text-domain' ),
- 'id' => $prefix . 'api_version',
- 'type' => 'select',
- 'options' => [
- 'ver1' => __( 'Version 1', 'your-text-domain' ),
- 'ver2' => __( 'Version 2', 'your-text-domain' ),
- 'ver3' => __( 'Version 3', 'your-text-domain' ),
- ],
- ]
- ],
- ];
- $meta_boxes[] = [
- 'title' => __( 'Version 2', 'your-text-domain' ),
- 'id' => 'version-2',
- 'post_types' => ['post'],
- 'visible' => [
- 'when' => [['api_version', '=', 'ver2']],
- 'relation' => 'or',
- ],
- 'fields' => [
- [
- 'name' => __( 'Button', 'your-text-domain' ),
- 'id' => $prefix . 'button_1x23b7ksihm',
- 'type' => 'button',
- ],
- [
- 'name' => __( 'Textarea', 'your-text-domain' ),
- 'id' => $prefix . 'textarea_b0zkrtrtzei',
- 'type' => 'textarea',
- ],
- ],
- ];
- $meta_boxes[] = [
- 'title' => __( 'Version 3', 'your-text-domain' ),
- 'id' => 'version-3',
- 'post_types' => ['post'],
- 'visible' => [
- 'when' => [['api_version', '=', 'ver3']],
- 'relation' => 'or',
- ],
- 'fields' => [
- [
- 'name' => __( 'Text', 'your-text-domain' ),
- 'id' => $prefix . 'text_vwrjp72xk2q',
- 'type' => 'text',
- ],
- ],
- ];
- return $meta_boxes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement