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();