Making WordPress.org

Changeset 9670


Ignore:
Timestamp:
04/01/2020 05:15:39 AM (5 years ago)
Author:
dd32
Message:

Plugin Directory: Prevent plugin uploads that use existing popular plugin names.

See #4656.

File:
1 edited

Legend:

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

    r9655 r9670  
    222222                __( 'A plugin URI (Uniform Resource Identifier) is a webpage that provides details about this specific plugin. An author URI is a webpage that provides information about the author of the plugin. Those two URIs must be different. You are not required to provide both, so pick the one that best applies to your situation.', 'wporg-plugins' )
    223223            );
     224        }
     225
     226        // Prevent uploads using popular Plugin names in the wild.
     227        if ( function_exists( 'wporg_stats_get_plugin_name_install_count' ) ) {
     228            $installs = wporg_stats_get_plugin_name_install_count( $this->plugin['Name'] );
     229
     230            if ( $installs && $installs->count >= 100 ) {
     231                $error = __( 'Error: That plugin name is already in use.', 'wporg-plugins' );
     232
     233                return new \WP_Error( 'already_exists_in_the_wild', $error . ' ' . sprintf(
     234                    /* translators: 1: plugin slug, 2: 'Plugin Name:' */
     235                    __( 'There is already a plugin with the name %1$s known to WordPress.org. You must rename your plugin by changing the %2$s line in your main plugin file and in your readme. Once you have done so, you may upload it again.', 'wporg-plugins' ),
     236                    '<code>' . $this->plugin['Name'] . '</code>',
     237                    '<code>Plugin Name:</code>'
     238                ) );
     239            }
    224240        }
    225241
Note: See TracChangeset for help on using the changeset viewer.