<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14476] sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation: Add the wporg-gp-contributor-moderation plugin</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/14476">14476</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/14476","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>amieiro</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2025-06-26 12:20:09 +0000 (Thu, 26 Jun 2025)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Add the wporg-gp-contributor-moderation plugin</pre>
<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcontributormoderationREADMEmd">sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/README.md</a></li>
<li>sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/assets/</li>
<li>sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/assets/css/</li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcontributormoderationassetscssstylecss">sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/assets/css/style.css</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcontributormoderationwporggpcontributormoderationphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/wporg-gp-contributor-moderation.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcontributormoderationREADMEmd"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/README.md</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/README.md (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/README.md 2025-06-26 12:20:09 UTC (rev 14476)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,15 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+# WordPress.org GP Contributor Moderation
+
+This plugin warns or prevents certain users from submitting new individual and/or bulk translations to the [translation system](https://translate.wordpress.org/) because they repeatedly submitted incorrect translations.
+
+This is the message displayed to the warned user. The translation form is not blocked and the submit button is enabled.
+
+
+
+This is the message displayed to the blocked user. The translation form is blocked and the submit button is disabled.
+
+
+
+When the user tries to access to the URL to upload a translation file (e.g. [this URL](https://translate.wordpress.org/projects/wp-plugins/custom-registration-form-builder-with-submission-manager/stable/gl/default/import-translations/)), he gets this error:
+
+
</ins></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcontributormoderationassetscssstylecss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/assets/css/style.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/assets/css/style.css (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/assets/css/style.css 2025-06-26 12:20:09 UTC (rev 14476)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,41 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.show_banned_message {
+ width: 100%;
+ border: 1px solid #dc3232;
+ background: #dc3232;
+ color: #fff;
+ margin: 1rem 0;
+ padding: 1rem;
+}
+
+.show_banned_message a {
+ color: #fff;
+ text-decoration: underline;
+ font-weight: regular;
+}
+
+.show_banned_message a:hover,
+.show_banned_message a:focus {
+ color: #f0f0f0;
+ text-decoration: underline;
+}
+
+.show_warned_message {
+ width: 100%;
+ border: 1px solid #ffb900;
+ background: #ffb900;
+ color: #000;
+ margin: 1rem 0;
+ padding: 1rem;
+}
+
+.show_warned_message a {
+ color: #000;
+ text-decoration: underline;
+ font-weight: regular;
+}
+
+.show_warned_message a:hover,
+.show_warned_message a:focus {
+ color: #222;
+ text-decoration: underline;
+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/assets/css/style.css
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcontributormoderationwporggpcontributormoderationphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/wporg-gp-contributor-moderation.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/wporg-gp-contributor-moderation.php (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/wporg-gp-contributor-moderation.php 2025-06-26 12:20:09 UTC (rev 14476)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,277 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Plugin Name: WordPress.org GP contributor moderation
+ * Plugin URI: https://wordpress.org
+ * Description: Blocks or warns specific users on the translation system for submitting incorrect translations repeatedly.
+ * Version: 1.0.0
+ * Author: WordPress.org
+ * Text Domain: wporg-gp-contributor-moderation
+ * Requires at least: 5.0
+ * Requires PHP: 7.4
+ *
+ * @package WPORG_GP_Contributor_Moderation
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+define( 'WPORG_GP_CONTRIBUTOR_MODERATION_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
+
+/**
+ * Main plugin class
+ */
+class WPORG_GP_Contributor_Moderation {
+ /**
+ * Array of blocked usernames and the reason URL to ban them.
+ *
+ * Add usernames and the reason URL to this array to block them at translate.wordpress.org.
+ * This is uppercase sensitive, so ensure usernames are added exactly as they appear.
+ *
+ * @var array
+ */
+ private const BLOCKED_USERS = array(
+ // 'jesusamieiro' => 'https://make.wordpress.org/polyglots/2025/04/30/can-users-be-blocked-by-someone/',
+ );
+
+ /**
+ * Array of warned usernames and the reason URL for the warning.
+ *
+ * Add usernames and the reason URL to this array to warn them at translate.wordpress.org.
+ * Users in this list can still submit translations, but will see a warning message.
+ * This is uppercase sensitive, so ensure usernames are added exactly as they appear.
+ * If a user is both in WARNED_USERS and BLOCKED_USERS, the blocked status takes precedence.
+ *
+ * @var array
+ */
+ private const WARNED_USERS = array(
+ // 'jesusamieiro' => 'https://make.wordpress.org/polyglots/2025/04/30/can-users-be-blocked-by-someone/',
+ );
+
+ /**
+ * Target domain to block access to.
+ *
+ * @var string
+ */
+ private const TARGET_DOMAIN = 'translate.wordpress.org';
+
+ /**
+ * Instance of this class.
+ *
+ * @var WPORG_GP_Contributor_Moderation|null
+ */
+ private static $instance = null;
+
+ /**
+ * Get singleton instance.
+ *
+ * @return WPORG_GP_Contributor_Moderation Instance of this class.
+ */
+ public static function get_instance() {
+ if ( null === self::$instance ) {
+ self::$instance = new self();
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Constructor.
+ */
+ private function __construct() {
+ add_action( 'gp_before_translation_table', array( $this, 'show_message' ) );
+ add_filter( 'gp_pre_can_user', array( $this, 'block_translation_contributions' ), 10, 2 );
+ }
+
+ /**
+ * Check if we're on the target domain.
+ *
+ * @return bool True if on target domain, false otherwise.
+ */
+ private function is_target_domain() {
+ $current_host = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
+ return self::TARGET_DOMAIN === $current_host;
+ }
+
+ /**
+ * Check if username is in blocked list.
+ *
+ * @param string $username The username to check.
+ * @return bool True if user is blocked, false otherwise.
+ */
+ private function is_user_blocked( $username ) {
+ $blocked_users = apply_filters( 'wporg_gp_contributor_moderation_block_users', self::BLOCKED_USERS );
+ return array_key_exists( $username, $blocked_users );
+ }
+
+ /**
+ * Check if username is in warned list.
+ *
+ * @param string $username The username to check.
+ * @return bool True if user is warned, false otherwise.
+ */
+ private function is_user_warned( $username ) {
+ $warned_users = apply_filters( 'wporg_gp_contributor_moderation_warn_users', self::WARNED_USERS );
+ return array_key_exists( $username, $warned_users );
+ }
+
+ /**
+ * Get the alert message.
+ *
+ * @return string The alert message.
+ */
+ private function get_alert_message() {
+ $current_user = wp_get_current_user();
+ $username = $current_user->user_login;
+ $reason_url = 'https://make.wordpress.org/polyglots/';
+
+ if ( isset( self::BLOCKED_USERS[ $username ] ) ) {
+ $reason_url = self::BLOCKED_USERS[ $username ];
+ }
+
+ $profile_url = sprintf( 'https://profiles.wordpress.org/%s/', rawurlencode( $username ) );
+ /* translators: 1: User profile URL, 2: Username, 3: Discussion URL, 4: link to translate.wordpress.org, 5: Slack channel URL, 6: Make WordPress.org URL */
+ $message = __( 'Because you (<a href="%1$s" target="_blank">%2$s</a>) have repeatedly submitted translations that <a href="%3$s" target="_blank">violated the expectations</a>, currently you cannot submit new translations to <a href="%4$s" target="_blank">translate.wordpress.org</a>. You can see the full discussion <a href="%5$s" target="_blank">here</a>.<br> If you believe this is a mistake, please request assistance in this <a href="%6$s" target="_blank">Slack channel</a> or submit an appeal at <a href="%7$s" target="_blank">Make WordPress.org</a>.', 'wporg-gp-contributor-moderation' );
+
+ return sprintf(
+ $message,
+ esc_url( $profile_url ),
+ esc_html( $username ),
+ esc_url( 'https://make.wordpress.org/polyglots/handbook/translating/expectations/' ),
+ esc_url( 'https://translate.wordpress.org/' ),
+ esc_url( $reason_url ),
+ esc_url( 'https://wordpress.slack.com/archives/C02RP50LK' ),
+ esc_url( 'https://make.wordpress.org/polyglots/' )
+ );
+ }
+
+ /**
+ * Get the warning message.
+ *
+ * @return string The warning message.
+ */
+ private function get_warning_message() {
+ $current_user = wp_get_current_user();
+ $username = $current_user->user_login;
+ $reason_url = 'https://make.wordpress.org/polyglots/';
+
+ if ( isset( self::WARNED_USERS[ $username ] ) ) {
+ $reason_url = self::WARNED_USERS[ $username ];
+ }
+
+ $profile_url = sprintf( 'https://profiles.wordpress.org/%s/', rawurlencode( $username ) );
+ /* translators: 1: User profile URL, 2: Username, 3: Discussion URL, 4: Slack channel URL, 5: Make WordPress.org URL */
+ $message = __( 'You (<a href="%1$s" target="_blank">%2$s</a>) have submitted translations that <a href="%3$s" target="_blank">may not meet our quality standards</a>. You can continue to submit translations, but please review our <a href="%3$s" target="_blank">translation guidelines</a> carefully. If you keep submitting incorrect translations, you may be suspended from the system. You can see the full discussion <a href="%4$s" target="_blank">here</a>.<br> If you need assistance, please reach out in this <a href="%5$s" target="_blank">Slack channel</a> or at <a href="%6$s" target="_blank">Make WordPress.org</a>.', 'wporg-gp-contributor-moderation' );
+
+ return sprintf(
+ $message,
+ esc_url( $profile_url ),
+ esc_html( $username ),
+ esc_url( 'https://make.wordpress.org/polyglots/handbook/translating/expectations/' ),
+ esc_url( $reason_url ),
+ esc_url( 'https://wordpress.slack.com/archives/C02RP50LK' ),
+ esc_url( 'https://make.wordpress.org/polyglots/' ),
+ );
+ }
+
+ /**
+ * Display a message for banned or warned users in the translation table.
+ *
+ * @return void
+ */
+ public function show_message(): void {
+ if ( ! $this->is_target_domain() ) {
+ return;
+ }
+
+ if ( ! is_user_logged_in() ) {
+ return;
+ }
+
+ $current_user = wp_get_current_user();
+ if ( ! $current_user || ! $current_user->exists() ) {
+ return;
+ }
+
+ $username = $current_user->user_login;
+ $is_blocked = $this->is_user_blocked( $username );
+ $is_warned = $this->is_user_warned( $username );
+
+ if ( ! $is_blocked && ! $is_warned ) {
+ return;
+ }
+
+ wp_enqueue_style(
+ 'wporg-gp-contributor-moderation',
+ WPORG_GP_CONTRIBUTOR_MODERATION_PLUGIN_URL . 'assets/css/style.css',
+ array(),
+ filemtime( plugin_dir_path( __FILE__ ) . 'assets/css/style.css' )
+ );
+
+ // Blocked status takes precedence over warned status.
+ if ( $is_blocked ) {
+ $message = $this->get_alert_message();
+ $css_class = 'show_banned_message';
+ $div_id = 'show_banned_message';
+ } else {
+ $message = $this->get_warning_message();
+ $css_class = 'show_warned_message';
+ $div_id = 'show_warned_message';
+ }
+
+ $content = '<div id="' . $div_id . '" class="' . $css_class . '">';
+ $content .= $message;
+ $content .= '</div>';
+
+ echo wp_kses(
+ $content,
+ array(
+ 'div' => array(
+ 'id' => array(),
+ 'class' => array(),
+ 'style' => array(),
+ ),
+ 'span' => array(
+ 'class' => array(),
+ 'style' => array(),
+ ),
+ 'a' => array(
+ 'href' => array(),
+ 'target' => array(),
+ 'style' => array(),
+ ),
+ 'br' => array(),
+ )
+ );
+ }
+
+ /**
+ * Block users from submitting translations.
+ *
+ * @param bool|null $can Whether the user can perform the action, or null if it hasn't been determined yet.
+ * @param array $action An array with the action the user is trying to perform (edit, approve, etc.).
+ * @return bool|null Whether the user can perform the action.
+ */
+ public function block_translation_contributions( $can, $action ) {
+ if ( ! $this->is_target_domain() ) {
+ return $can;
+ }
+
+ $blocked_actions = array( 'edit', 'write', 'approve', 'import-waiting' );
+ if ( ! in_array( $action['action'], $blocked_actions, true ) ) {
+ return $can;
+ }
+
+ $current_user = wp_get_current_user();
+ if ( ! $current_user || ! $current_user->exists() ) {
+ return $can;
+ }
+
+ if ( $this->is_user_blocked( $current_user->user_login ) ) {
+ return false;
+ }
+
+ return $can;
+ }
+}
+
+add_action( 'plugins_loaded', array( WPORG_GP_Contributor_Moderation::class, 'get_instance' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-contributor-moderation/wporg-gp-contributor-moderation.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>
</body>
</html>