Tools: Add formatting command, run to fix minor phpcs issues

This commit is contained in:
Kelly Dwan 2024-08-27 13:40:37 -04:00
parent 28b102bc4c
commit bb25e0c78b
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
13 changed files with 55 additions and 53 deletions

View file

@ -181,4 +181,3 @@ function can_manage_pledge( $requested_pledge_id, $auth_token = '' ) {
__( 'Your link has expired.', 'wporg-5ftf' )
);
}

View file

@ -127,9 +127,9 @@ function send_contributor_confirmation_emails( $pledge_id, $contributor_id = nul
* @param WP_Post $contributor
*/
function send_contributor_removed_email( $pledge_id, $contributor ) {
$pledge = get_post( $pledge_id );
$subject = "Removed from {$pledge->post_title} Five for the Future pledge";
$user = get_user_by( 'login', $contributor->post_title );
$pledge = get_post( $pledge_id );
$subject = "Removed from {$pledge->post_title} Five for the Future pledge";
$user = get_user_by( 'login', $contributor->post_title );
$message = sprintf( '
Howdy %1$s,
@ -210,7 +210,7 @@ function send_pledge_deactivation_email( $pledge ) {
/**
* Ask an inactive contributor to update their pledge for accuracy.
*/
function send_contributor_inactive_email( array $contributor ) : bool {
function send_contributor_inactive_email( array $contributor ): bool {
/*
* Their first name is ideal, but their username is the best fallback because `nickname`, `display_name`,
* etc are too formal.
@ -218,7 +218,7 @@ function send_contributor_inactive_email( array $contributor ) : bool {
$name = empty( $contributor['first_name'] ) ? '@' . $contributor['user_nicename'] : $contributor['first_name'];
$subject = 'Please update your Five for the Future pledge';
$short_team_names = array_map( function( $team ) {
$short_team_names = array_map( function ( $team ) {
$team = str_replace( 'Team', '', $team );
return trim( $team );
@ -261,7 +261,7 @@ function send_contributor_inactive_email( array $contributor ) : bool {
/**
* Ask a company to update their pledge for accuracy.
*/
function send_pledge_update_email( WP_Post $pledge ) : bool {
function send_pledge_update_email( WP_Post $pledge ): bool {
$to = $pledge->{'5ftf_org-pledge-email'};
$subject = 'Please review your Five for the Future pledge';
$url = get_permalink( $pledge );
@ -281,7 +281,7 @@ function send_pledge_update_email( WP_Post $pledge ) : bool {
/**
* Ask a company to update their pledge for accuracy.
*/
function send_pledge_inactive_email( WP_Post $pledge ) : bool {
function send_pledge_inactive_email( WP_Post $pledge ): bool {
$to = $pledge->{'5ftf_org-pledge-email'};
$subject = 'Please review your Five for the Future pledge';
$url = get_permalink( $pledge );

View file

@ -2,7 +2,7 @@
namespace WordPressDotOrg\FiveForTheFuture\Miscellaneous;
add_action( 'after_setup_theme', function() {
add_action( 'after_setup_theme', function () {
// These alternate versions don't exist for this subsite, so the links would just lead to 404 errors.
remove_action( 'wp_head', 'WordPressdotorg\Theme\hreflang_link_attributes' );
} );

View file

@ -88,7 +88,7 @@ function get_pledge_log( $pledge_id ) {
return array();
}
usort( $log, function( $a, $b ) {
usort( $log, function ( $a, $b ) {
if ( $a['timestamp'] === $b['timestamp'] ) {
return 0;
}
@ -391,7 +391,7 @@ function capture_email_result( $to, $subject, $message, $headers, $result, $pled
/**
* Capture the results of an attempt to send an email.
*/
function capture_pledge_deactivation( int $pledge_id, bool $notify, string $reason, /* mixed */ $result ) : void {
function capture_pledge_deactivation( int $pledge_id, bool $notify, string $reason, /* mixed */ $result ): void {
add_log_entry(
$pledge_id,
'deactivated_pledge',

View file

@ -352,7 +352,7 @@ function is_active_pledge( $post_id ) {
function create_new_pledge( $name ) {
// Grab the ID of the post we are on before inserting a pledge.
$pledge_form_post_id = get_post()->ID;
$args = array(
$args = array(
'post_type' => CPT_ID,
'post_title' => $name,
'post_status' => 'draft',
@ -585,12 +585,12 @@ function send_update_reminders(): void {
'posts_per_page' => 15, // Limit # of emails to maintain IP reputation.
// New pledges haven't had time to become inaccurate yet.
'date_query' => array(
'date_query' => array(
'column' => 'post_date',
'before' => "$resend_interval seconds ago",
),
'meta_query' => array(
'meta_query' => array(
'relation' => 'AND',
array(

View file

@ -74,11 +74,11 @@ function render_company_report_page() {
}
$pledges = get_posts( array(
'post_type' => '5ftf_pledge',
'post_status' => $status,
'post_type' => '5ftf_pledge',
'post_status' => $status,
'posts_per_page' => $pledge_limit, // set to avoid unexpected memory overuse.
'orderby' => 'post_title',
'order' => 'ASC',
'orderby' => 'post_title',
'order' => 'ASC',
) );
// Add visible warning on page if we hit the upper limit of the query.
@ -122,18 +122,18 @@ function render_company_report_page() {
$export_data = array();
foreach ( $pledges as $pledge ) {
$company_url = get_post_meta( $pledge->ID, '5ftf_org-domain', true );
$email = get_post_meta( $pledge->ID, '5ftf_org-pledge-email', true );
$date_created = substr( $pledge->post_date, 0, 10 );
$date_modified = substr( $pledge->post_modified, 0, 10 );
$company_url = get_post_meta( $pledge->ID, '5ftf_org-domain', true );
$email = get_post_meta( $pledge->ID, '5ftf_org-pledge-email', true );
$date_created = substr( $pledge->post_date, 0, 10 );
$date_modified = substr( $pledge->post_modified, 0, 10 );
$team = XProfile\get_aggregate_contributor_data_for_pledge( $pledge->ID );
$hours = $team['hours'];
$contributors = $team['contributors'];
$team = XProfile\get_aggregate_contributor_data_for_pledge( $pledge->ID );
$hours = $team['hours'];
$contributors = $team['contributors'];
$all_contributors += $contributors;
$users = Contributor\get_pledge_contributors( $pledge->ID, 'publish' );
$wporg_profiles = wp_list_pluck( $users, 'post_title' );
$users = Contributor\get_pledge_contributors( $pledge->ID, 'publish' );
$wporg_profiles = wp_list_pluck( $users, 'post_title' );
$usernames = implode( ', ', $wporg_profiles );
$teams = implode( ', ', str_replace( ' Team', '', $team['teams'] ) );
@ -173,11 +173,11 @@ function render_contributor_report_page() {
}
$contributors = get_posts( array(
'post_type' => '5ftf_contributor',
'post_status' => $status,
'post_type' => '5ftf_contributor',
'post_status' => $status,
'posts_per_page' => $contributor_limit, // set to avoid unexpected memory overuse.
'orderby' => 'post_title',
'order' => 'ASC',
'orderby' => 'post_title',
'order' => 'ASC',
) );
// Add visible warning on page if we hit the upper limit of the query.
@ -221,7 +221,7 @@ function render_contributor_report_page() {
$pledge_company_title = get_the_title( $pledge_company ) ?? 'unattached';
$user_id = get_post_meta( $c->ID, 'wporg_user_id', true );
$xprofile = $all_contributor_data[ $user_id ] ?? [
'team_names' => [],
'team_names' => [],
'hours_per_week' => 0,
];
$xprofile_teams = $xprofile['team_names'] ?? [];

View file

@ -171,9 +171,9 @@ function get_snapshot_data() {
if ( Contributor\is_active( $user['last_logged_in'] ) ) {
if ( $is_company_sponsored ) {
$active_company_sponsored_contributors++;
++$active_company_sponsored_contributors;
} else {
$active_self_sponsored_contributors++;
++$active_self_sponsored_contributors;
}
} else {
$snapshot_data['inactive_contributor_ids'][] = $user['user_id'];
@ -185,7 +185,7 @@ function get_snapshot_data() {
foreach ( $user['team_names'] as $team ) {
if ( isset( $snapshot_data[ $team_contributor_key ][ $team ] ) ) {
$snapshot_data[ $team_contributor_key ][ $team ] ++;
++$snapshot_data[ $team_contributor_key ][ $team ];
} else {
$snapshot_data[ $team_contributor_key ][ $team ] = 1;
}

View file

@ -82,7 +82,7 @@ function get_all_xprofile_contributors_indexed(): array {
foreach ( $all_data as $contributor ) {
$newdata[ $contributor->user_id ] = [
'hours_per_week' => $contributor->hours_per_week,
'team_names' => $contributor->team_names,
'team_names' => $contributor->team_names,
];
}