Apply coding standards.

This commit is contained in:
Ian Dunn 2020-11-13 12:16:06 -08:00
parent c1ce72d447
commit 13a417ce8e
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB
9 changed files with 50 additions and 52 deletions

View file

@ -46,7 +46,7 @@ add_action( 'wp_head', __NAMESPACE__ . '\prevent_caching_auth_tokens', 99 );
* etc could create situations where they're leaked to others.
*/
function prevent_caching_auth_tokens() {
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce not required, not processing form data.
// phpcs:ignore WordPress.Security.NonceVerification -- Nonce not required, not processing form data.
if ( isset( $_GET['auth_token'] ) || isset( $_POST['auth_token'] ) ) {
nocache_headers();
}

View file

@ -265,7 +265,7 @@ function get_pledge_contributors_data( $pledge_id ) {
$name = $contributor_post->post_title;
$contributor = get_user_by( 'login', $name );
return [
return array(
'pledgeId' => $pledge_id,
'contributorId' => $contributor_post->ID,
'status' => $contributor_status,
@ -277,7 +277,7 @@ function get_pledge_contributors_data( $pledge_id ) {
'resendLabel' => __( 'Resend Confirmation', 'wporg-5ftf' ),
'removeConfirm' => sprintf( __( 'Remove %s from this pledge?', 'wporg-5ftf' ), $name ),
'removeLabel' => sprintf( __( 'Remove %s', 'wporg-5ftf' ), $name ),
];
);
},
$group
);

View file

@ -28,39 +28,39 @@ function manage_contributors_handler() {
$authenticated = Auth\can_manage_pledge( $pledge_id, $token );
if ( is_wp_error( $authenticated ) ) {
wp_die( wp_json_encode( [
wp_die( wp_json_encode( array(
'success' => false,
'message' => __( "Sorry, you don't have permissions to do that.", 'wporg-5ftf' ),
] ) );
) ) );
}
switch ( $action ) {
case 'resend-contributor-confirmation':
$contribution = get_post( $contributor_id );
Email\send_contributor_confirmation_emails( $pledge_id, $contributor_id );
wp_die( wp_json_encode( [
wp_die( wp_json_encode( array(
'success' => true,
'message' => sprintf( __( 'Confirmation email sent to %s.', 'wporg-5ftf' ), $contribution->post_title ),
] ) );
) ) );
break;
case 'remove-contributor':
// Trash contributor.
Contributor\remove_contributor( $contributor_id );
wp_die( wp_json_encode( [
wp_die( wp_json_encode( array(
'success' => true,
'contributors' => Contributor\get_pledge_contributors_data( $pledge_id ),
] ) );
) ) );
break;
case 'add-contributor':
$pledge = get_post( $pledge_id );
$new_contributors = Contributor\parse_contributors( $_POST['contributors'] );
if ( is_wp_error( $new_contributors ) ) {
wp_die( wp_json_encode( [
wp_die( wp_json_encode( array(
'success' => false,
'message' => $new_contributors->get_error_message(),
] ) );
) ) );
}
$contributor_ids = Contributor\add_pledge_contributors( $pledge_id, $new_contributors );
@ -73,10 +73,10 @@ function manage_contributors_handler() {
// Fetch all contributors, now that the new ones have been added.
$contributors = Contributor\get_pledge_contributors_data( $pledge_id );
wp_die( wp_json_encode( [
wp_die( wp_json_encode( array(
'success' => true,
'contributors' => $contributors,
] ) );
) ) );
break;
}
@ -99,15 +99,15 @@ function send_manage_email_handler() {
$message_sent = Email\send_manage_pledge_link( $pledge_id );
if ( $message_sent ) {
$result = [
$result = array(
'success' => true,
'message' => __( 'Thanks! Weve emailed you a link you can open in order to update your pledge.', 'wporg-5ftf' ),
];
);
} else {
$result = [
$result = array(
'success' => false,
'message' => __( 'There was an error while trying to send the email.', 'wporg-5ftf' ),
];
);
}
} else {
$error_message = sprintf(
@ -115,10 +115,10 @@ function send_manage_email_handler() {
get_permalink( get_page_by_path( 'report' ) )
);
$result = [
$result = array(
'success' => false,
'message' => $error_message,
];
);
}
wp_die( wp_json_encode( $result ) );

View file

@ -30,7 +30,7 @@ function render_form_new() {
$is_manage = false;
$pledge_id = 0;
$data = get_form_submission();
$errors = [];
$errors = array();
$pledge = null;
$complete = false;
$directory_url = home_url( 'pledges' );
@ -113,8 +113,8 @@ function render_form_manage() {
return '';
}
$messages = [];
$errors = [];
$messages = array();
$errors = array();
$action = sanitize_text_field( $_REQUEST['action'] ?? '' );
$pledge_id = absint( $_REQUEST['pledge_id'] ?? 0 );

View file

@ -259,7 +259,7 @@ function save_pledge( $pledge_id, $pledge ) {
* This is only intended to run when the front end form and wp-admin forms are submitted, not when posts are
* programmatically updated.
*/
if ( ! in_array( $post_action, [ 'Submit Pledge', 'editpost' ], true ) ) {
if ( ! in_array( $post_action, array( 'Submit Pledge', 'editpost' ), true ) ) {
return;
}

View file

@ -182,7 +182,7 @@ function add_row_action( $actions, $post ) {
*/
function handle_activation_action( $post_id ) {
$action = $_REQUEST['action'];
if ( ! in_array( $action, [ 'deactivate', 'reactivate' ] ) ) {
if ( ! in_array( $action, array( 'deactivate', 'reactivate' ) ) ) {
return;
}
@ -202,7 +202,7 @@ function handle_activation_action( $post_id ) {
}
$sendback = wp_get_referer();
$sendback = remove_query_arg( [ 'deactivated', 'reactivated' ], $sendback );
$sendback = remove_query_arg( array( 'deactivated', 'reactivated' ), $sendback );
if ( 'deactivate' === $action ) {
deactivate( $post_id );

View file

@ -31,13 +31,11 @@ defined( 'WPINC' ) || die();
function get_xprofile_contribution_data( array $user_ids ) {
global $wpdb;
$sql = $wpdb->prepare(
'
$sql = $wpdb->prepare( '
SELECT user_id, field_id, value
FROM bpmain_bp_xprofile_data
WHERE user_id IN ( %1$s )
AND field_id IN ( %2$s )
',
AND field_id IN ( %2$s )',
implode( ', ', array_map( 'absint', $user_ids ) ),
implode( ', ', array_map( 'absint', array_values( FIELD_IDS ) ) )
);