name = 'post_type_selector'; $this->label = 'Post Type Selector'; $this->category = 'relational'; } public function render( $field, $value = '', $name = null ) { $name = $name ?: "metaforge[{$field['name']}]"; $appearance = $field['appearance'] ?? 'select'; // Backward compatibility for the old 'multiple' toggle if ( isset( $field['multiple'] ) && empty( $field['appearance'] ) ) { $appearance = ! empty( $field['multiple'] ) ? 'multi_select' : 'select'; } $is_multiple = in_array( $appearance, array( 'checkbox', 'multi_select' ) ); $name_attr = $is_multiple ? $name . '[]' : $name; $val_array = is_array( $value ) ? $value : (array) $value; // Fetch public post types but exclude 'attachment' (Media library) $post_types = get_post_types( array( 'public' => true ), 'objects' ); if ( isset( $post_types['attachment'] ) ) { unset( $post_types['attachment'] ); } echo '