Making WordPress.org

Changeset 10024


Ignore:
Timestamp:
07/07/2020 04:06:13 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Update the list of trademark terms. Allow for some -for-$trademark exceptions.

Props Ipstenu.
Fixes #5300.

File:
1 edited

Legend:

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

    r9806 r10024  
    182182                }
    183183
     184                // Plugins need descriptions.
    184185                if ( ! $this->plugin['Description'] ) {
    185186                        $error = __( 'Error: The plugin has no description.', 'wporg-plugins' );
    … …  
    193194                }
    194195
     196                // Plugins need versions.
    195197                if ( ! $this->plugin['Version'] ) {
    196198                        $error = __( 'Error: The plugin has no version.', 'wporg-plugins' );
    … …  
    204206                }
    205207
     208                // Versions should be NUMBERS.
    206209                if ( preg_match( '|[^\d\.]|', $this->plugin['Version'] ) ) {
    207210                        $error = __( 'Error: Plugin versions are expected to be numbers.', 'wporg-plugins' );
    … …  
    215218
    216219                // Prevent duplicate URLs.
     220                // This is part of how the API looks for updates, so having them different helps prevent conflicts.
    217221                if ( ! empty( $this->plugin['PluginURI'] ) && ! empty( $this->plugin['AuthorURI'] ) && $this->plugin['PluginURI'] == $this->plugin['AuthorURI'] ) {
    218222                        $error = __( 'Error: Your plugin and author URIs are the same.', 'wporg-plugins' );
    … …  
    242246                }
    243247
     248                // Check for a valid readme.
    244249                $readme = $this->find_readme_file();
    245                 // Check for a valid readme.
    246250                if ( empty( $readme ) ) {
    247251                        $error = __( 'Error: The plugin has no readme.', 'wporg-plugins' );
    … …  
    405409                        // Reserved names.
    406410                        'jquery',
     411                        'wordpress',
     412                        // common submissions by people trying to upload locally.
     413                        'akismet-anti-spam',
    407414                        'site-kit-by-google',
    408                         'wordpress',
    409415                        'yoast-seo',
    410416                );
    … …  
    424430                        'advanced-custom-fields-',
    425431                        'adwords-',
     432                        'akismet-',
    426433                        'amazon-',
    427434                        'android-',
    428435                        'apple-',
     436                        'aws-',
     437                        'bbpress-',
    429438                        'bing-',
     439                        'buddypress-',
    430440                        'contact-form-7-',
    431441                        'divi-',
    … …  
    454464                        'whatsapp',
    455465                        'whats-app',
    456                         'woocommerce',
     466                        'watson',
     467                        'windows-',
     468                        'woocommerce', // technically ending with '-for-woocommerce' is allowed.
     469                        'woo-commerce',
    457470                        'woo-',
    458471                        'wordpress',
     472                        'yahoo-',
    459473                        'yoast',
    460474                        'youtube-',
    … …  
    463477                // Domains from which exceptions would be accepted.
    464478                $trademark_exceptions = array(
    465                         'yoast.com'      => array( 'yoast' ),
    466                         'automattic.com' => array( 'wordpress', 'woo', 'woocommerce' ),
     479                        'yoast.com'             => array( 'yoast' ),
     480                        'automattic.com'        => array( 'akismet', 'jetpack', 'wordpress', 'woo', 'woo-', 'woocommerce' ),
     481                        'facebook.com'          => array( 'facebook', 'whatsapp', 'instagram' ),
     482                        'support.microsoft.com' => array( 'bing-', 'microsoft-' ),
     483                        'microsoft.com'         => array( 'bing-', 'microsoft-' ),
     484                );
     485
     486                // Trademarks that are allowed as 'for-whatever' ONLY.
     487                $for_use_exceptions = array(
     488                        'woocommerce',
    467489                );
    468490
    … …  
    483505                }
    484506
     507                // check for 'for-TRADEMARK' exceptions.
     508                if ( $has_trademarked_slug && in_array( $has_trademarked_slug, $for_use_exceptions ) ) {
     509                        $for_trademark = '-for-' . $has_trademarked_slug;
     510                        // At this point we might be okay, but there's one more check.
     511                        if ( $for_trademark === substr( $this->plugin_slug, -1 * strlen( $for_trademark ) ) ) {
     512                                // Yes the slug ENDS with 'for-TRADEMARK'.
     513                                $has_trademarked_slug = false;
     514                        }
     515                }
     516
    485517                // Get the user email domain.
    486                 $user_email_domain = explode( '@', wp_get_current_user()->user_email, 2 );
     518                list( ,$user_email_domain ) = explode( '@', wp_get_current_user()->user_email, 2 );
    487519
    488520                // If email domain is on our list of possible exceptions, we have an extra check.
    489                 if ( array_key_exists( $user_email_domain[1], $trademark_exceptions ) ) {
     521                if ( $has_trademarked_slug && array_key_exists( $user_email_domain, $trademark_exceptions ) ) {
    490522                        // If $has_trademarked_slug is in the array for that domain, they can use the term.
    491                         if ( in_array( $has_trademarked_slug, $trademark_exceptions[ $user_email_domain[1] ] ) ) {
     523                        if ( in_array( $has_trademarked_slug, $trademark_exceptions[ $user_email_domain ] ) ) {
    492524                                $has_trademarked_slug = false;
    493525                        }
Note: See TracChangeset for help on using the changeset viewer.