Inventory_Presser_Plugin::register_meta_fields()
Registers all meta fields our custom post type uses to define a vehicle and its attachments.
Return Return
(void)
Source Source
File: inventory-presser.php
public function register_meta_fields() { // Add meta fields to our post type. foreach ( INVP::keys_and_types( true ) as $key_arr ) { if ( empty( $key_arr['name'] ) ) { continue; } $key = apply_filters( 'invp_prefix_meta_key', $key_arr['name'] ); register_post_meta( INVP::POST_TYPE, $key, array( 'show_in_rest' => true, 'single' => 'options_array' !== $key_arr['name'], 'type' => $key_arr['type'] ?? 'string', ) ); } // Add a couple fields that are used on media attachments. $attachment_keys = array(); $attachment_keys[] = array( 'name' => 'hash', 'type' => 'string', ); $attachment_keys[] = array( 'name' => 'photo_number', 'type' => 'integer', ); $attachment_keys[] = array( 'name' => 'vin', 'type' => 'string', ); // Add meta fields to attachments. foreach ( $attachment_keys as $key_arr ) { $key = apply_filters( 'invp_prefix_meta_key', $key_arr['name'] ); register_post_meta( 'attachment', $key, array( 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'single' => true, 'type' => $key_arr['type'], ) ); } }
Expand full source code Collapse full source code View on Github