WordPress / theme-check

Theme Check plugin
https://wordpress.org/plugins/theme-check/
333 stars 108 forks source link

class-copyright-notice-check.php failing for child theme #420

Open EvanHerman opened 2 years ago

EvanHerman commented 2 years ago

Parent Theme: https://wordpress.org/themes/primer/ Child Theme: https://wordpress.org/themes/ascension/

When running the theme check we're seeing errors saying a copyright notice could not be found for the theme. image

I'm not sure why it's returning an error, as we do have a copyright notice inside of the readme.txt file and the style.css file.

https://github.com/godaddy-wordpress/primer-child-ascension/blob/develop/readme.txt#L62-L82 https://github.com/godaddy-wordpress/primer-child-ascension/blob/develop/style.css#L19

There are also copyright notices in the parent Primer theme readme.txt, and that passes the theme check without issue. https://github.com/godaddy-wordpress/primer/blob/develop/readme.txt#L41-L64

When digging through the code it looks like the $paths var doesn't contain any paths to the child theme, but only paths to the parent theme. image

Inside of the copyright-notice-check class file it looks like it's searching for a path to the child theme file, which isn't found and in turn returns a false error. https://github.com/WordPress/theme-check/blob/master/checks/class-copyright-notice-check.php#L39-L46

// Get the contents of themeslug/filename:
foreach ( $combined_files as $path => $contents ) {
    if ( stripos( $path, $this->slug . '/readme.txt' ) ||
        stripos( $path, $this->slug . '/readme.md' ) ||
        stripos( $path, $this->slug . '/style.css' ) ||
        stripos( $path, $this->slug . '/licence.txt' ) !== false ) {
            $content .= $contents;
    }
}
pattonwebz commented 2 years ago

You would be correct here - nearly all the checks are geared up to test the parent theme and child theme is barely (if at all) checked with the current code. We would have to refactor it pretty significantly to account for child themes in a good way.

Sorry for the confusion! If the theme allows you to upload it to the wordpress.org directory you should be ok.

EvanHerman commented 2 years ago

Thanks @pattonwebz I appreciate the speedy response