• Resolved Imagegonzalesc

    (@gonzalesc)


    Hi.

    I have an error: “Global variables defined by a theme/plugin should start with the theme/plugin prefix. Found: “$installmentItem”.”

    and this is my code:

    <ul>

    <?php foreach ( $installments['items'] as $installmentItem ) : ?>

    <li><?php echo \esc_html( $installmentItem ); ?></li>

    <?php endforeach; ?>

    </ul>

    Why does that point to a loop?

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ImageDavid Perez

    (@davidperez)

    Where is that function? is it global? You need to share all context.

    Thread Starter Imagegonzalesc

    (@gonzalesc)

    It is a template and it is all the content, because it is called from other function, but if you see, $installmentItem is not a global variable, only is part of a loop.

    I solved it add a prefix, $icalculator_installmentItem, because “icalculator” is my plugin name, but I think this is unnecessary the prefix in a loop.

    Thanks

    Plugin Author ImageDavid Perez

    (@davidperez)

    It’s nice to hear that you managed to solve it.

    Hello,

    I have the same issue.

    Plugin Check is giving a lot of WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound warnings, even in cases where the variables are not global.

    I suggest checking this, as it appears to be a bug.

    Why should variables be prefixed if they aren’t global variables?

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.