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. * etc could create situations where they're leaked to others.
*/ */
function prevent_caching_auth_tokens() { 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'] ) ) { if ( isset( $_GET['auth_token'] ) || isset( $_POST['auth_token'] ) ) {
nocache_headers(); nocache_headers();
} }

View file

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

View file

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

View file

@ -30,7 +30,7 @@ function render_form_new() {
$is_manage = false; $is_manage = false;
$pledge_id = 0; $pledge_id = 0;
$data = get_form_submission(); $data = get_form_submission();
$errors = []; $errors = array();
$pledge = null; $pledge = null;
$complete = false; $complete = false;
$directory_url = home_url( 'pledges' ); $directory_url = home_url( 'pledges' );
@ -113,8 +113,8 @@ function render_form_manage() {
return ''; return '';
} }
$messages = []; $messages = array();
$errors = []; $errors = array();
$action = sanitize_text_field( $_REQUEST['action'] ?? '' ); $action = sanitize_text_field( $_REQUEST['action'] ?? '' );
$pledge_id = absint( $_REQUEST['pledge_id'] ?? 0 ); $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 * This is only intended to run when the front end form and wp-admin forms are submitted, not when posts are
* programmatically updated. * programmatically updated.
*/ */
if ( ! in_array( $post_action, [ 'Submit Pledge', 'editpost' ], true ) ) { if ( ! in_array( $post_action, array( 'Submit Pledge', 'editpost' ), true ) ) {
return; return;
} }

View file

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

View file

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