Created
June 10, 2024 04:41
-
-
Save seothemes/fcc675d3723b38a25505dc309229663e to your computer and use it in GitHub Desktop.
Hide directories from wp file editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Hide 'assets' directory from theme file editor. | |
add_filter( 'theme_scandir_exclusions', static function ( array $exclusions ): array { | |
global $current_screen; | |
if ( ! $current_screen || ! in_array( $current_screen->id, [ 'theme-editor-network', 'theme-editor' ] ) ) { | |
return $exclusions; | |
} | |
$exclusions[] = 'assets'; | |
return $exclusions; | |
} ); | |
// Hide 'assets' directory from plugin file editor. | |
add_filter( 'plugin_files_exclusions', static function ( array $exclusions ): array { | |
global $current_screen; | |
if ( ! $current_screen || ! in_array( $current_screen->id, [ 'plugin-editor-network', 'plugin-editor' ] ) ) { | |
return $exclusions; | |
} | |
$exclusions[] = 'assets'; | |
return $exclusions; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment