Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#56382 new enhancement

Allow filtering excluded directories during theme export via `wp_is_theme_directory_ignored`

Reported by: mat-lipe's profile Mat Lipe Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.0
Component: Themes Keywords: has-patch
Focuses: Cc:

Description

The wp_is_theme_directory_ignored function excludes the majority of common vendor or VCS files by default during theme export via the Site Editor.

There are themes which may need to exclude additional directories on a case by case basis. A few examples include:

  1. Source files for JS tools like Webpack.
  2. Unit test files.
  3. .yarn files for Yarn projects with PNP support.

By offering a filter to theme developers we allow developers to filter as needed without needing to maintain a list of exclusions which covers all cases.

Change History (1)

This ticket was mentioned in PR #3094 on WordPress/wordpress-develop by lipemat.


2 years ago
#1

  • Keywords has-patch added

The wp_is_theme_directory_ignored function excludes the majority of common vendor or VCS files by default during theme export via the Site Editor.

There are themes which may need to exclude additional directories on a case by case basis. A few examples include:

  1. Source files for JS tools like Webpack.
  2. Unit test files.
  3. .yarn files for Yarn projects with PNP support.

By offering a filter to theme developers we allow developers to filter as needed without needing to maintain a list of exclusions which covers all cases.

### Testing
Assuming running the TwentyTwentyTwo theme.
{{{php
add_filter( 'ignored_theme_directory', function( $dirs ) {

$dirs[] = 'inc';
return $dirs;

} );
}}}

  1. Open the Site Editor (FSE)
  2. Click the 3 dot menu.
  3. Click Export.
  4. Notice the "inc" directory is not included in the .zip archive.

https://core.trac.wordpress.org/ticket/56382

Note: See TracTickets for help on using tickets.