Support » Plugin: Theme Check » Theme Check expects _n() to have at most three parameters, but it has four

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    No, theme-check only looks at “string” parameters. It doesn’t see the variable $count parameter because of the particular way that check works.

    The _n() function has three parameters that must all be plain strings. If you’re getting this error message, you’re calling _n() incorrectly, somehow.

    OK, so it turns out that this results in an error:

    _n( 'one', '%d', (int)$foo['bar'], 'textdomain' ) );

    But this doesn’t:

    $foobar = (int)$foo['bar'];
    _n( 'one', '%d', $foobar, 'textdomain' ) );

    Is this the expected behaviour?

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Right. Theme check is not perfect, and it’s not meant to be. The extra string in there (‘bar’) is throwing it off. It can’t read code like a person can, because it’s not that sophisticated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Theme Check expects _n() to have at most three parameters, but it has four’ is closed to new replies.