Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion lib/compat/wordpress-7.1/view-config-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,44 @@ function _gutenberg_get_entity_view_config_posttype_page( $data ) {
return $data;
}

/**
* Provides the view configuration for the `attachment` post type.
*
* Adds an "Unused" view on top of the generic "all items" one. The view locks a
* filter on the `used` field (exposed by the media usage detection) so the list
* shows only the attachments that are not referenced anywhere and can be
* cleaned up. The rest of the view configuration is left to the default, as the
* Media Library list already relies on it.
*
* @param Gutenberg_View_Config_Data $data The view configuration container for the entity.
* @return Gutenberg_View_Config_Data The updated view configuration container.
*/
function _gutenberg_get_entity_view_config_posttype_attachment( $data ) {
$data->merge(
array(
'view_list' => array(
array(
'title' => __( 'Unused', 'gutenberg' ),
'slug' => 'unused',
'view' => array(
'filters' => array(
array(
'field' => 'used',
'operator' => 'is',
'value' => false,
'isLocked' => true,
),
),
),
),
),
),
1
);

return $data;
}

/**
* Provides the view configuration for the `wp_block` post type.
*
Expand Down Expand Up @@ -758,7 +796,7 @@ function _gutenberg_get_entity_view_config_posttype_wp_template( $data ) {
* registers them at include time or lazily on a hook.
*/
function gutenberg_register_entity_view_config_filters() {
$post_types = array( 'page', 'post', 'wp_block', 'wp_template_part', 'wp_template' );
$post_types = array( 'page', 'post', 'wp_block', 'wp_template_part', 'wp_template', 'attachment' );

foreach ( $post_types as $post_type ) {
$hook = gutenberg_get_entity_view_config_hook_name( 'postType', $post_type );
Expand Down
3 changes: 3 additions & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ function gutenberg_get_experiment_default( $name ) {
// Client-side media processing.
require_once __DIR__ . '/media/load.php';

// Media usage detection for the Media Library cleanup tools.
require_once __DIR__ . '/media/class-gutenberg-media-usage.php';

// Interactivity API full-page client-side navigation.
if ( gutenberg_is_experiment_enabled( 'gutenberg-full-page-client-side-navigation' ) ) {
require __DIR__ . '/experimental/interactivity-api/class-gutenberg-interactivity-api-full-page-navigation.php';
Expand Down
Loading
Loading