Making WordPress.org

Ticket #5300: 5300.diff

File 5300.diff, 4.3 KB (added by Ipstenu, 5 years ago)
  • trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

     
    181181                        ) );
    182182                }
    183183
     184                // Plugins need descriptions.
    184185                if ( ! $this->plugin['Description'] ) {
    185186                        $error = __( 'Error: The plugin has no description.', 'wporg-plugins' );
    186187
     
    192193                        ) );
    193194                }
    194195
     196                // Plugins need versions.
    195197                if ( ! $this->plugin['Version'] ) {
    196198                        $error = __( 'Error: The plugin has no version.', 'wporg-plugins' );
    197199
     
    203205                        ) );
    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' );
    208211
     
    214217                }
    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' );
    219223
     
    241245                        }
    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' );
    248252
     
    404408                        'wp-admin',
    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                );
    411417
     
    423429                        'adsense-',
    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-',
    432442                        'easy-digital-downloads-',
     
    453463                        'wa-',
    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-',
    461475                );
     
    462476
    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-' ),
    467484                );
    468485
     486                // Trademarks that are allowed as 'for-whatever' ONLY.
     487                $for_use_exceptions = array(
     488                        'woocommerce',
     489                );
     490
    469491                $has_trademarked_slug = false;
    470492
    471493                foreach ( $trademarked_slugs as $trademark ) {
     
    482504                        }
    483505                }
    484506
     507                // check for 'for-TRADEMARK' exceptions.
     508                if ( false !== $has_trademarked_slug && in_array( $has_trademarked_slug, $for_use_exceptions ) && false !== strpos( $this->plugin_slug, '-for-' . $trademark ) ) {
     509                        // At this point we might be okay, but there's one more check.
     510                        $length  = strlen( '-for-' . $trademark );
     511                        $compare = substr_compare( $this->plugin_slug, '-for-' . $trademark, -$length, $length );
     512
     513                        if ( 0 === $compare ) {
     514                                // Yes the slug ENDS with 'for-TRADEMARK'.
     515                                $has_trademarked_slug = false;
     516                        }
     517                }
     518
    485519                // Get the user email domain.
    486520                $user_email_domain = explode( '@', wp_get_current_user()->user_email, 2 );
    487521
    488522                // 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 ) ) {
     523                if ( false !== $has_trademarked_slug && array_key_exists( $user_email_domain[1], $trademark_exceptions ) ) {
    490524                        // If $has_trademarked_slug is in the array for that domain, they can use the term.
    491525                        if ( in_array( $has_trademarked_slug, $trademark_exceptions[ $user_email_domain[1] ] ) ) {
    492526                                $has_trademarked_slug = false;