Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect results when run on child theme because of a possible bug in WP_Theme::get_files() #429

Open
pbiron opened this issue Jul 31, 2022 · 0 comments

Comments

@pbiron
Copy link

pbiron commented Jul 31, 2022

I just ran a check on child theme I'm developing for a client. The check reports at least 2 incorrect results:

  • REQUIRED: No reference to add_theme_support( "title-tag" ) was found in the theme.
  • REQUIRED: Could not find add_theme_support( 'automatic-feed-links' ). See: add_theme_support

The parent theme does call add_theme_support( 'title-tag' ) and add_theme_support( 'automatic-feed-links' ).

At first I thought this must a bug in this plugin, but after digging into the code, as far as I can tell, the bug seems to be in WP_Theme::get_files():

public function get_files( $type = null, $depth = 0, $search_parent = false ) {
	$files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth );

	if ( $search_parent && $this->parent() ) {
		$files += (array) self::scandir( $this->get_template_directory(), $type, $depth );
	}

	return array_filter( $files );
}

Notice that when it gets the files from the parent theme, it does not pass the 4th (optional) $relative_path parameter. As a result of the += operator used to combine the child and parent theme files, only the child's functions.php file is included in the returned files (ditto for any file in the parent theme with the same filename relative to its theme_root as one in the child theme relative to its theme_root).

Does my analysis above seem correct? If so, should I open a trac ticket about WP_Theme::get_files()?

p.s. I've seen #143 (comment) and realize that this plugin is not used for child themes submitted to .org, and the theme I ran it will not be submitted to .org but I think it would be good to address these incorrect results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant