Making WordPress.org

Changeset 13465

Timestamp:
04/05/2024 07:53:57 AM (4 months ago)
Author:
dd32
Message:

Plugin Directory: Trademarks: Assume a plugins trademark exceptions are those of it's owners and committers. Better handling for portmanteaus, and trim - off when displaying in the error messages.

See #5868.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

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

    r13462 r13465  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory;
     3
    34
    45use WP_Post;
     
    120121        'wordpess',
    121122        'wpress',
    122         'wp-',
     123        'wp-',
    123124        'wp-mail-smtp-',
    124125        'yandex-',
     
    252253        foreach ( $portmanteaus as $portmanteau ) {
    253254            if ( str_starts_with( $plugin_slug, $portmanteau ) ) {
    254                 $has_trademarked_slug[] = $portmanteau . '-'; // State that the portmanteau cannnot start the text.
     255                // Check there isn't a longer matching trademark already flagged.
     256                // For example, 'woo' should not flag if 'woocommerce' is already flagged.
     257                if ( ! preg_grep( '!^' . preg_quote( $portmanteau, '!' ) . '!', $has_trademarked_slug ) ) {
     258                    $has_trademarked_slug[] = $portmanteau . '-'; // State that the portmanteau cannnot start the text.
     259                }
    255260            }
    256261        }
     
    270275
    271276        // The users email domain.
    272         if ( $user && $user->exists() ) {
     277        if ( $user && $user->exists() ) {
    273278            $exceptions[] = explode( '@', $user->user_email, 2 )[1];
    274279        }
     
    280285     * Get the exceptions allowed for a plugin.
    281286     *
    282      * @param string $plugin_slug The plugin slug.
     287     * @param .
    283288     * @return array
    284289     */
    285     public static function get_plugin_exceptions( $plugin_slug ) {
    286         return [];
     290    public static function get_plugin_exceptions( $post ) {
     291        // Assume all of the committers (and owner) are exceptions.
     292        $committers = Tools::get_plugin_committers( $post );
     293
     294        $committers = array_map( function( $user_login ) { return get_user_by( 'login', $user_login); }, $committers );
     295        $committers[] = get_user_by( 'id', $post->post_author );
     296
     297        $exceptions = [];
     298        foreach ( $committers as $user ) {
     299            $exceptions = array_merge( $exceptions, self::get_user_exceptions( $user ) );
     300        }
     301
     302        return array_unique( $exceptions );
    287303    }
    288304}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php

    r13462 r13465  
    408408
    409409                if ( $cannot_start_with ) {
     410
     411
     412
    410413                    $messages[] = sprintf(
    411414                        /* translators: 1: plugin slug, 2: trademarked term, 3: 'Plugin Name:', 4: plugin email address */
Note: See TracChangeset for help on using the changeset viewer.