<!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>[13216] sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login: Registration: Add bulk block, and add room for a reason to be provided, query by country.</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/13216">13216</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/13216","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-02-16 04:46:29 +0000 (Fri, 16 Feb 2024)</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'>Registration: Add bulk block, and add room for a reason to be provided, query by country.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgloginadminclassuserregistrationslisttablephp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/class-user-registrations-list-table.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgloginadminuiphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/ui.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgloginfunctionsregistrationphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-registration.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgloginadminclassuserregistrationslisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/class-user-registrations-list-table.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/themes/pub/wporg-login/admin/class-user-registrations-list-table.php 2024-02-16 02:39:54 UTC (rev 13215)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/class-user-registrations-list-table.php 2024-02-16 04:46:29 UTC (rev 13216)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,7 +42,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $default = 'all';
</span><span class="cx" style="display: block; padding: 0 10px"> $current_view = $_REQUEST['view'] ?? $default;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $_GET['s'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $_GET['s'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $default = 'search';
</span><span class="cx" style="display: block; padding: 0 10px"> $views[0] = [
</span><span class="cx" style="display: block; padding: 0 10px"> 'search', 'All search results'
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,8 +143,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $join . $where;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function get_columns() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function get_columns() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return [
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'cb' => '<input type="checkbox" />',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'User Login',
</span><span class="cx" style="display: block; padding: 0 10px"> 'meta' => 'Meta',
</span><span class="cx" style="display: block; padding: 0 10px"> 'scores' => 'Anti-spam<br>reCaptcha Akismet',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -158,8 +159,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'scores' => array( 'scores', true ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_registered' => array( 'user_registered', true ),
</span><span class="cx" style="display: block; padding: 0 10px"> ];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function get_bulk_actions() {
+ return array(
+ 'reg_block' => 'Block Reg / Ban user',
+ );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function prepare_items() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -183,7 +190,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $sort_order = 'DESC';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $per_page = $this->get_items_per_page( 'users_per_page', 100 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $per_page = $_GET['per_page'] ?? $this->get_items_per_page( 'users_per_page', 100 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $current_page = $this->get_pagenum();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $join_where = $this->get_join_where_sql();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -216,6 +223,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function bulk_actions( $which = '' ) {
+ parent::bulk_actions( $which );
+
+ if ( 'top' !== $which ) {
+ return;
+ }
+ ?>
+
+ <fieldset class="alignleft actions">
+ <input name="block_reason" id="block_reason" placeholder="Ban/Block reason. Used for bulk + single." style="width: 32em;padding: 0.4em;margin: 0;" value="<?php echo esc_attr( $_REQUEST['block_reason'] ?? '' ); ?>" />
+ </fieldset>
+ <?php
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function single_row( $item ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $classes = $this->get_row_class( $item );
</span><span class="cx" style="display: block; padding: 0 10px"> printf( '<tr class="%s">', esc_attr( implode( ' ', $classes ) ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -248,6 +269,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $classes;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function column_cb( $item ) {
+ return sprintf(
+ '<input type="checkbox" name="pending_ids[]" value="%1$s" />',
+ esc_attr( $item->pending_id ),
+ );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function column_default( $item, $column_name ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo esc_html( $item->$column_name );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -347,20 +375,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<div>';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo implode( ', ',
- array_map(
- function( $ip ) {
- return $this->link_to_search( $ip ) .
- ( is_callable( 'WordPressdotorg\GeoIP\query' ) ?
- ' ' . \WordPressdotorg\GeoIP\query( $ip, 'country_short' ) : '' );
- },
- array_filter( array_unique( [
- $meta->registration_ip ?? false,
- $meta->confirmed_ip ?? false
- ] ) )
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $ips = [];
+ foreach ( [ 'registration', 'confirmed' ] as $field ) {
+ if ( empty( $meta->{$field . '_ip'} ) ) {
+ continue;
+ }
+ $ip = $meta->{$field . '_ip'};
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta->{$field . '_ip_country'} ??= ( is_callable( 'WordPressdotorg\GeoIP\query' ) ? ' ' . \WordPressdotorg\GeoIP\query( $ip, 'country_short' ) : '' );
+
+ $ips[] = $ip . ' ' . $meta->{$field . '_ip_country'};
+ }
+
+ echo implode( ', ', array_map( array( $this, 'link_to_Search' ), array_unique( $ips ) ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> echo '<hr>';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( [ 'url', 'from', 'occ', 'interests' ] as $field ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -445,7 +473,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return implode( '', array_map( function( $s ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( strlen( $s ) >= 3 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( strlen( $s ) >= 3 || preg_match( '/^[A-Z]{2}$/', $s ) /* country */ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return '<a href="' . add_query_arg( 's', urlencode( $s ), admin_url( 'admin.php?page=user-registrations' ) ) . '">' . esc_html( $s ) . '</a>';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return esc_html( $s );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -452,4 +480,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }, $parts ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgloginadminuiphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/ui.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/themes/pub/wporg-login/admin/ui.php 2024-02-16 02:39:54 UTC (rev 13215)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/ui.php 2024-02-16 04:46:29 UTC (rev 13216)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,6 +88,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $tr.append( "<td colspan=" + $tds.length + ">...</td>" );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> var url = $this.prop('href') + '&ajax=1';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( url.indexOf( 'block_account' ) !== -1 ) {
+ if ( ! $('block_reason').val() ) {
+ $('block_reason').val( prompt( 'Reason for blocking?' ) || '' );
+ }
+ url += '&block_reason=' + encodeURIComponent( $('block_reason').val() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $.get( url, function( data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $tr.find('td:last').text( data );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -374,15 +380,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_admin_referer( 'block_' . $email );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = wporg_get_pending_user( $email );
- if ( $user ) {
- $user['cleared'] = 0;
- $user['user_activation_key'] = '';
- $user['user_profile_key'] = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wporg_login_block_registration( $user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wporg_update_pending_user( $user );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_GET['ajax'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> die( wporg_login_admin_action_text( 'blocked' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -395,6 +394,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wporg_login_block_registration( $user ) {
+ $user = wporg_get_pending_user( $user );
+ if ( $user ) {
+ $user['cleared'] = 0;
+ $user['user_activation_key'] = '';
+ $user['user_profile_key'] = '';
+
+ wporg_update_pending_user( $user );
+
+ return true;
+ }
+
+ return false;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_post_login_delete', function() {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'promote_users' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -426,20 +440,49 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $_REQUEST['user'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = $_REQUEST['user'] ?? '';
+ $reason = $_REQUEST['block_reason'] ?? '';
+ if ( empty( $user ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> die();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $pending_user = wporg_get_pending_user( $_REQUEST['user'] );
- if ( ! $pending_user || ! $pending_user['created'] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $pending_user = wporg_get_pending_user( $user );
+ if ( ! $user ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> die();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_by( 'slug', $pending_user['user_login'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $user ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ check_admin_referer( 'block_account_' . $user->ID );
+
+ $result = wporg_login_block_account( $pending_user, $reason );
+ if ( ! $result ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> die();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $_GET['ajax'] ) ) {
+ die( wporg_login_admin_action_text( 'blocked_account' ) );
+ }
+
+ wp_safe_redirect( add_query_arg(
+ 's',
+ urlencode( $user->user_email ),
+ 'https://login.wordpress.org/wp-admin/index.php?page=user-registrations&action=blocked_account'
+ ) );
+ exit;
+} );
+
+function wporg_login_block_account( $user, $reason = '' ) {
+ $pending_user = wporg_get_pending_user( $user );
+ if ( ! $pending_user || ! $pending_user['created'] ) {
+ return false;
+ }
+
+ $user = get_user_by( 'slug', $pending_user['user_login'] );
+ if ( ! $user ) {
+ return false;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $table = new User_Registrations_List_Table();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ob_start();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -453,8 +496,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_column = ob_get_clean();
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_column = wp_strip_all_tags( str_replace( '<br>', "\n", $meta_column ), false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- check_admin_referer( 'block_account_' . $user->ID );
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $user && defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Switch first so that bbPress loads with the correct context.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -470,10 +511,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> restore_current_blog();
</span><span class="cx" style="display: block; padding: 0 10px"> switch_to_blog( WPORG_SUPPORT_FORUMS_BLOGID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'wporg_bbp_forum_role_changed_note_text', function( $text ) use ( $meta_column ) {
- return trim( "{$meta_column}\n\n{$text}" );
- } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Load the Support Forums, for logging and whatnot.
+ WordPressdotorg\Forums\Plugin::get_instance();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $callback = function( $text ) use ( $callback, $reason, $meta_column ) {
+ remove_filter( 'wporg_bbp_forum_role_changed_note_text', $callback );
+
+ return trim( "{$reason}\n{$meta_column}\n\n{$text}" );
+ };
+ add_filter( 'wporg_bbp_forum_role_changed_note_text', $callback );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Set the user to blocked. Support forum hooks will take care of the rest.
</span><span class="cx" style="display: block; padding: 0 10px"> bbp_set_user_role( $user->ID, bbp_get_blocked_role() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -480,15 +527,36 @@
</span><span class="cx" style="display: block; padding: 0 10px"> restore_current_blog();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $_GET['ajax'] ) ) {
- die( wporg_login_admin_action_text( 'blocked_account' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return true;
+}
+
+add_action( 'load-toplevel_page_user-registrations', function() {
+ // Perform bulk actions.
+ $action = $_REQUEST['action'] ?? ( $_REQUEST['action2'] ?? '' );
+ if (
+ empty( $_REQUEST['pending_ids'] ) ||
+ 'reg_block' !== $action ||
+ ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-toplevel_page_user-registrations' )
+ ) {
+ return;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_safe_redirect( add_query_arg(
- 's',
- urlencode( $user->user_email ),
- 'https://login.wordpress.org/wp-admin/index.php?page=user-registrations&action=blocked_account'
- ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $reason = $_REQUEST['block_reason'] ?? '';
+ foreach ( (array) $_REQUEST['pending_ids'] as $pending_id ) {
+ $pending_user = wporg_get_pending_user( $pending_id );
+ if ( ! $pending_user ) {
+ continue;
+ }
+
+ if ( $pending_user['created'] ) {
+ wporg_login_block_account( $pending_user, $reason );
+ } else {
+ wporg_login_block_registration( $pending_user );
+ }
+ }
+
+ $url = remove_query_arg( array( 'pending_ids', 'action', 'action2', '_wpnonce', '_wp_http_referer' ) );
+ $url = add_query_arg( 'action', 'blocked_account', $url );
+ wp_safe_redirect( $url );
</ins><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-} );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+} );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgloginfunctionsregistrationphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-registration.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/themes/pub/wporg-login/functions-registration.php 2024-02-16 02:39:54 UTC (rev 13215)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-registration.php 2024-02-16 04:46:29 UTC (rev 13216)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -82,6 +82,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_profile_key' => $hashed_profile_key,
</span><span class="cx" style="display: block; padding: 0 10px"> 'meta' => $meta + array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'registration_ip' => $_SERVER['REMOTE_ADDR'], // Spam & fraud control. Will be discarded after the account is created.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'registration_ip_country' => ( is_callable( 'WordPressdotorg\GeoIP\query' ) ? ' ' . \WordPressdotorg\GeoIP\query( $_SERVER['REMOTE_ADDR'], 'country_short' ) : '' )
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'scores' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'pending' => 1,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -190,24 +191,34 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Fetches a pending user record from the database by username or Email.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @param string|int $who The username, email address, or user ID.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function wporg_get_pending_user( $login_or_email ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wporg_get_pending_user( $who ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Is it a pending user object already?
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_array( $login_or_email ) && isset( $login_or_email['pending_id'] ) ) {
- return $login_or_email;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_array( $who ) && isset( $who['pending_id'] ) ) {
+ return $who;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $login_or_email = trim( $login_or_email );
- if ( ! $login_or_email ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_numeric( $who ) && (int) $who == $who ) {
+ $field = 'pending_id';
+ } elseif ( str_contains( $who, '@' ) ) {
+ $field = 'user_email';
+ } else {
+ $field = 'user_login';
+ }
+
+ $who = trim( $who );
+ if ( ! $who ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $pending_user = $wpdb->get_row( $wpdb->prepare(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "SELECT * FROM `{$wpdb->base_prefix}user_pending_registrations` WHERE ( `user_login` = %s OR `user_email` = %s ) LIMIT 1",
- $login_or_email,
- $login_or_email
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "SELECT * FROM `{$wpdb->base_prefix}user_pending_registrations` WHERE %i = %s LIMIT 1",
+ $field,
+ $who
</ins><span class="cx" style="display: block; padding: 0 10px"> ), ARRAY_A );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $pending_user ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -322,9 +333,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Update the pending record with the new details.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $pending_user['created'] = 1;
- $pending_user['created_date'] = gmdate( 'Y-m-d H:i:s' );
- $pending_user['meta']['confirmed_ip'] = $_SERVER['REMOTE_ADDR']; // Spam/Fraud purposes, will be deleted once not needed.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $pending_user['created'] = 1;
+ $pending_user['created_date'] = gmdate( 'Y-m-d H:i:s' );
+ $pending_user['meta']['confirmed_ip'] = $_SERVER['REMOTE_ADDR'];
+ $pending_user['meta']['confirmed_ip_country'] = ( is_callable( 'WordPressdotorg\GeoIP\query' ) ? ' ' . \WordPressdotorg\GeoIP\query( $_SERVER['REMOTE_ADDR'], 'country_short' ): '' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // reCaptcha v3 logging.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_POST['_reCaptcha_v3_token'] ) ) {
</span></span></pre>
</div>
</div>
</body>
</html>