WordPress.org

Making WordPress.org

#3769 closed defect (invalid)

Detection mechanism for theme support incorrectly rejecting theme

Reported by: flixos90 Owned by:
Milestone: Priority: normal
Component: Theme Directory Keywords:
Cc:

Description

After trying to submit a theme, I received numerous errors about missing required calls to add_theme_support( 'title-tag' ) and add_theme_support( 'automatic-feed-links' ), although both were present in the respective theme. This would cause in the theme upload to be automatically rejected.

The thing is that the theme code iterates over an array of boolean-ish features (including the above two) and then adds support for each of them, causing exactly the same effect - support is added for the features. But apparently this is not recognized by the automatic check because it probably looks at the exact code statement.

Here is the code for a more exact idea of what I'm talking about:

$features = array(
    'title-tag',
    'automatic-feed-links',
    ...
);
array_walk( $features, function( $feature ) {
    add_theme_support( $feature );
} );

The above doesn't pass.

It's obviously easy to rewrite the code so that it passes that tool by writing individual statements for each feature, but it's certainly unexpected and feels wrong to do so just to please the automatic check.

I think we should investigate ways to improve this.

Change History (3)

This ticket was mentioned in Slack in #themereview by flixos90. View the logs.


10 months ago

#2 @flixos90
10 months ago

  • Summary changed from Detection mechanism for theme support in to Detection mechanism for theme support incorrectly rejecting theme

#3 @Otto42
10 months ago

  • Resolution set to invalid
  • Status changed from new to closed

The check obviously cannot be perfect and detect all possible ways of doing things. Nor should it need to be so complex that it can literally read and understand code like a human being would do.

The truth is that there is no advantage to doing this code your way, in a loop, vs. simply calling the code the normal way. Your code here makes things more complicated for no real reason.

For that reason, I'm going to say no to this request, and ask that you simplify your theme. While we can't make the checks perfect and capable of understanding your code, we can make the themes simpler and easier to use and modify. Code should be simple, and understandable, and self-documenting. These are basic principles that hold for all good code.

Note: See TracTickets for help on using tickets.