From c70782b8a850b45f2cfc354eade5cd390aecb9fd Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Thu, 12 Mar 2026 06:05:53 +0100 Subject: [PATCH] Create class-directories-macosx-check.php Add a new check for the __MACOSX directory. --- checks/class-directories-macosx-check.php | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 checks/class-directories-macosx-check.php diff --git a/checks/class-directories-macosx-check.php b/checks/class-directories-macosx-check.php new file mode 100644 index 0000000..2915ecd --- /dev/null +++ b/checks/class-directories-macosx-check.php @@ -0,0 +1,87 @@ +theme = $data['theme']; + } + } + + /** + * Check that return true for good/okay/acceptable, false for bad/not-okay/unacceptable. + * + * @param array $php_files File paths and content for PHP files. + * @param array $css_files File paths and content for CSS files. + * @param array $other_files Folder names, file paths and content for other files. + */ + public function check( $php_files, $css_files, $other_files ) { + + $excluded_directories = array( + '__MACOSX', + ); + + $ret = true; + + $theme_dir = $this->theme->get_stylesheet_directory(); + $directories = scandir( $theme_dir ); + + if ( false === $directories ) { + return true; + } + + foreach ( $directories as $dir ) { + checkcount(); + + if ( in_array( $dir, $excluded_directories, true ) ) { + $this->error[] = sprintf( + '%s: %s', + __( 'REQUIRED', 'theme-check' ), + __( 'Please remove any extraneous directories like __MACOSX from the ZIP file before uploading it.', 'theme-check' ) + ); + $ret = false; + } + } + + return $ret; + } + + /** + * Get error messages from the checks. + * + * @return array Error message. + */ + public function getError() { + return $this->error; + } +} + +$themechecks[] = new Directories_Macosx_Check();