awesomemotive / wpforms-phpcs

PHP Coding Standards used by the WPForms team.
https://wpforms.com
GNU General Public License v2.0
12 stars 1 forks source link

Domain check for i18n function work isn't correctly for multi domain config #23

Closed wppunk closed 2 years ago

wppunk commented 2 years ago

Expected Behavior

i18n functions for the file wpforms-some-addon-name/some-directory/some-file.php should have the wpforms-some-addon domain.

Current Behavior

Config:

<config name="multi_domains" value="true"/>
<rule ref="WPForms.PHP.ValidateDomain">
    <properties>
        <property name="wpforms-lite" value="wpforms"/>
        <property name="wpforms" value="wpforms/pro/,wpforms/src/Pro/"/>
    </properties>
</rule>

i18n functions for the file wpforms-some-addon-name/some-directory/some-file.php have the wpforms-lite domain.

Possible Solution

We should fix the algorithm for detecting rewritten domains. Fix the findDomainByProperty method by adding an additional slash at the end.

Steps to Reproduce

  1. Set up config:
    <config name="multi_domains" value="true"/>
    <rule ref="WPForms.PHP.ValidateDomain">
    <properties>
        <property name="wpforms-lite" value="wpforms"/>
        <property name="wpforms" value="wpforms/pro/,wpforms/src/Pro/"/>
    </properties>
    </rule>
  2. Create a file wpforms-some-addon-name/some-directory/some-file.php
  3. Add in the file a few i18n functions
  4. Run the code sniffer