prepare( " SELECT id, value FROM `$table` WHERE field_id = %d", XProfile\FIELD_IDS['team_names'] ); $rows = $wpdb->get_results( $query, ARRAY_A ); foreach ( $rows as $row ) { $updated = false; $chosen_teams = (array) maybe_unserialize( $row['value'] ); if ( empty( $chosen_teams ) ) { continue; } $original_team_count = count( $chosen_teams ); // Can't do this in the loop because it would be reduced when team are removed. for ( $i = 0; $i < $original_team_count; $i++ ) { /* * Postfix 'Team' to all team names -- e.g., 'Support' => 'Support Team' -- to make it obvious that * we're referring to an official Make team, not supporting a private plugin/theme. */ if ( 'Team' !== substr( $chosen_teams[ $i ], -4 ) ) { $updated = true; $chosen_teams[ $i ] .= ' Team'; } // Clarify name of Theme Review Team to remove ambiguity. if ( 'Themes Team' === $chosen_teams[ $i ] ) { $updated = true; $chosen_teams[ $i ] = 'Theme Review Team'; } // Clarify name of WP-CLI Team to remove ambiguity. if ( 'CLI Team' === $chosen_teams[ $i ] ) { $updated = true; $chosen_teams[ $i ] = 'WP-CLI Team'; } // Remove users from closed groups, because the vast majority of them are not actually members. if ( 'Plugins Team' === $chosen_teams[ $i ] || 'Security Team' === $chosen_teams[ $i ] ) { $updated = true; unset( $chosen_teams[ $i ] ); } } if ( $updated ) { // Reindex the array after `unset()`, otherwise `serialize()` will create blank items. $chosen_teams = array_values( $chosen_teams ); $wpdb->update( $table, array( 'value' => maybe_serialize( $chosen_teams ) ), array( 'id' => $row['id'] ) ); } } } /** * Remove invalid hours values, now that they're prevented from being entered. * * @see https://github.com/WordPress/five-for-the-future/issues/125 */ function update_inaccurate_hours() { global $wpdb; $query = $wpdb->prepare( " UPDATE `bpmain_bp_xprofile_data` SET value = 0 WHERE field_id = %d AND ( value > 60 OR value REGEXP '[a-zA-Z]' ) ", XProfile\FIELD_IDS['hours_per_week'] ); $wpdb->query( $query ); }