Skip to content

Library upload post type list excludes private post types even when opted in via filter #517

Description

@codente

Problem

When a post type is registered with show_ui: false and public: false, it cannot appear in the library upload post type picker. There is no way for external plugins to surface their own private post types in this list.

Two things need to change:

1. No filter hook exists on the $known allowlist

PostsRepository::get_types() has a hardcoded $known array for post types with show_ui: false that should still appear in the content browser:

$known = [
    'wp_template',
    'wp_template_part',
    'fl_code',
];

There is no filter hook on this array, so external plugins have no way to opt their own private post types in without patching the assistant plugin directly.

2. The library upload UI filters by canView, which excludes private post types

Even if a post type were added to $known, the library upload UI in cloud-ui applies a second independent filter:

const types = typesData.filter( t => true === t[1].canView )

canView is set in the backend as public || publicly_queryable. Private post types always have canView: false and are silently dropped by the frontend before they can appear in the list.

Use Case

fl-design-system (the BB Design System CPT) is private (show_ui: false, public: false) but should be available in the library upload picker so design systems can be saved to an Assistant library.

Proposed Fix

In PostsRepository::get_types() — wrap $known in a filter so external plugins can opt in, and treat types in $known as viewable so they pass the frontend filter:

$known = apply_filters( 'fl_assistant_post_types_known', [
    'wp_template',
    'wp_template_part',
    'fl_code',
] );

// ...

'canView' => $type->public || $type->publicly_queryable || in_array( $slug, $known ),

bb-design-system can then hook in without the assistant plugin needing to know about it directly:

add_filter( 'fl_assistant_post_types_known', function( $known ) {
    $known[] = 'fl-design-system';
    return $known;
} );

Files

  • backend/src/Data/Repository/PostsRepository.phpget_types(), $known array, canView flag

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions