Making WordPress.org


Ignore:
Timestamp:
04/05/2024 04:55:33 AM (15 months ago)
Author:
dd32
Message:

Plugin Directory: Expand the trademark checks to match multiple trademarks in the field checked.

Simplifies the error message and centralises the 3 uses of it.

See #5868.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-trademarks.php

    r13460 r13462  
    171171     * @param string $check                     The plugin name to check.
    172172     * @param array|WP_User|WP_Post $exceptions An array of exceptions to the trademark checks, or a WP_User or WP_Post object to fetch their exceptions.
    173      * @return string|false The trademarked slug if found, false otherwise.
     173     * @return array|false The trademarked slug if found, false otherwise.
    174174     */
    175175    public static function check( $check, $exceptions = [] ) {
     
    188188     * @param string                $plugin_slug The slug-like-text to check.
    189189     * @param array|WP_User|WP_Post $exceptions  An array of exceptions to the trademark checks, or a WP_User or WP_Post object to fetch their exceptions.
    190      * @return string|false The trademarked slug if found, false otherwise.
     190     * @return array|false The trademarked slug if found, false otherwise.
    191191     */
    192192    public static function check_slug( $plugin_slug, $exceptions = [] ) {
     
    220220        }
    221221
    222         $has_trademarked_slug = false;
     222        $has_trademarked_slug = [];
    223223
    224224        foreach ( $trademarked_slugs as $trademark ) {
     
    226226                // Trademarks ending in "-" indicate slug cannot begin with that term.
    227227                if ( str_starts_with( $plugin_slug, $trademark ) ) {
    228                     $has_trademarked_slug = $trademark;
    229                     break;
     228                    $has_trademarked_slug[] = $trademark;
    230229                }
    231230
     
    246245
    247246                // The term cannot exist anywhere in the plugin slug, and it's not a for-use exception.
    248                 $has_trademarked_slug = $trademark;
    249                 break;
     247                $has_trademarked_slug[] = $trademark;
    250248            }
    251249        }
     
    254252        foreach ( $portmanteaus as $portmanteau ) {
    255253            if ( str_starts_with( $plugin_slug, $portmanteau ) ) {
    256                 $has_trademarked_slug = $portmanteau;
    257                 break;
     254                $has_trademarked_slug[] = $portmanteau . '-'; // State that the portmanteau cannnot start the text.
    258255            }
    259256        }
    260257
    261         return $has_trademarked_slug;
     258        return array_unique( $has_trademarked_slug ) ?: false;
    262259    }
    263260
Note: See TracChangeset for help on using the changeset viewer.