Skip to content

Commit

Permalink
PHPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
renintw committed May 20, 2024
1 parent ba7061a commit 11be950
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ function save_request( $post_id, $post ) {
}

verify_metabox_nonces();

// phpcs:ignore is added because verify_metabox_nonces(); already checks that.
// phpcs:ignore WordPress.Security.NonceVerification.Missing
validate_and_save_notes( $post, $_POST['wcbrr_new_note'] );

/*
Expand Down Expand Up @@ -753,10 +756,11 @@ function validate_and_save_expenses( $post_id, $expenses ) {
function validate_and_save_notes( $post, $new_note_message ) {

// Save incomplete message.
if ( isset( $_POST['wcp_mark_incomplete_notes'] ) ) {
// phpcs:ignore is used because verify_metabox_nonces(); already checks that.
if ( isset( $_POST['wcp_mark_incomplete_notes'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
$safe_value = '';
if ( $post->post_status == 'wcb-incomplete' ) {
$safe_value = wp_kses( $_POST['wcp_mark_incomplete_notes'], wp_kses_allowed_html( 'strip' ) );
if ( 'wcb-incomplete' == $post->post_status ) {
$safe_value = wp_kses( $_POST['wcp_mark_incomplete_notes'], wp_kses_allowed_html( 'strip' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
}

update_post_meta( $post->ID, '_wcp_incomplete_notes', $safe_value );
Expand Down Expand Up @@ -784,9 +788,14 @@ function validate_and_save_notes( $post, $new_note_message ) {
update_post_meta( $post->ID, '_wcbrr_notes', $notes );
notify_parties_of_new_note( $post, $new_note );

\WordCamp_Budgets::log( $post->ID, get_current_user_id(), sprintf( 'Note: %s', $new_note_message ), array(
'action' => 'note-added',
) );
\WordCamp_Budgets::log(
$post->ID,
get_current_user_id(),
sprintf( 'Note: %s', $new_note_message ),
array(
'action' => 'note-added',
)
);
}

/**
Expand Down Expand Up @@ -1624,4 +1633,4 @@ function _generate_payment_report_jpm_wires( $args ) {
// JPM chokes on accents and non-latin characters.
$results = remove_accents( $results );
return $results;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,93 +27,117 @@ public function __construct() {
public static function register_post_statuses() {
// Uses core's draft status too.

register_post_status( 'wcb-incomplete', array(
'label' => esc_html_x( 'Incomplete', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Incomplete <span class="count">(%s)</span>',
'Incomplete <span class="count">(%s)</span>',
'wordcamporg'
),
) );
register_post_status(
'wcb-incomplete',
array(
'label' => esc_html_x( 'Incomplete', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Incomplete <span class="count">(%s)</span>',
'Incomplete <span class="count">(%s)</span>',
'wordcamporg'
),
)
);

register_post_status( 'wcb-pending-approval', array(
'label' => esc_html_x( 'Pending Approval', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Pending Approval <span class="count">(%s)</span>',
'Pending Approval <span class="count">(%s)</span>',
'wordcamporg'
),
) );
register_post_status(
'wcb-pending-approval',
array(
'label' => esc_html_x( 'Pending Approval', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Pending Approval <span class="count">(%s)</span>',
'Pending Approval <span class="count">(%s)</span>',
'wordcamporg'
),
)
);

register_post_status( 'wcb-needs-followup', array(
'label' => esc_html_x( 'Needs Follow-up', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Needs Follow-up <span class="count">(%s)</span>',
'Needs Follow-up <span class="count">(%s)</span>',
'wordcamporg'
),
) );
register_post_status(
'wcb-needs-followup',
array(
'label' => esc_html_x( 'Needs Follow-up', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Needs Follow-up <span class="count">(%s)</span>',
'Needs Follow-up <span class="count">(%s)</span>',
'wordcamporg'
),
)
);

register_post_status( 'wcb-approved', array(
'label' => esc_html_x( 'Approved', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Approved <span class="count">(%s)</span>',
'Approved <span class="count">(%s)</span>',
'wordcamporg'
),
) );
register_post_status(
'wcb-approved',
array(
'label' => esc_html_x( 'Approved', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Approved <span class="count">(%s)</span>',
'Approved <span class="count">(%s)</span>',
'wordcamporg'
),
)
);

register_post_status( 'wcb-pending-payment', array(
'label' => esc_html_x( 'Payment Sent', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Payment Sent <span class="count">(%s)</span>',
'Payment Sent <span class="count">(%s)</span>',
'wordcamporg'
),
) );
register_post_status(
'wcb-pending-payment',
array(
'label' => esc_html_x( 'Payment Sent', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Payment Sent <span class="count">(%s)</span>',
'Payment Sent <span class="count">(%s)</span>',
'wordcamporg'
),
)
);

register_post_status( 'wcb-paid', array(
'label' => esc_html_x( 'Paid', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Paid <span class="count">(%s)</span>',
'Paid <span class="count">(%s)</span>',
'wordcamporg'
),
) );
register_post_status(
'wcb-paid',
array(
'label' => esc_html_x( 'Paid', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Paid <span class="count">(%s)</span>',
'Paid <span class="count">(%s)</span>',
'wordcamporg'
),
)
);

register_post_status( 'wcb-failed', array(
'label' => esc_html_x( 'Failed', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Failed <span class="count">(%s)</span>',
'Failed <span class="count">(%s)</span>',
'wordcamporg'
),
) );
register_post_status(
'wcb-failed',
array(
'label' => esc_html_x( 'Failed', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Failed <span class="count">(%s)</span>',
'Failed <span class="count">(%s)</span>',
'wordcamporg'
),
)
);

register_post_status( 'wcb-cancelled', array(
'label' => esc_html_x( 'Cancelled', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Cancelled <span class="count">(%s)</span>',
'Cancelled <span class="count">(%s)</span>',
'wordcamporg'
),
) );
register_post_status(
'wcb-cancelled',
array(
'label' => esc_html_x( 'Cancelled', 'payment request', 'wordcamporg' ),
'public' => false,
'protected' => true,
'label_count' => _nx_noop(
'Cancelled <span class="count">(%s)</span>',
'Cancelled <span class="count">(%s)</span>',
'wordcamporg'
),
)
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
<?php

namespace WordCamp\Budgets\Reimbursement_Requests;
defined( 'WPINC' ) or die();

?>

<?php if ( empty ( $existing_notes ) ) : ?>

<?php _e( 'There are no notes yet.', 'wordcamporg' ); ?>

<?php else : ?>

<?php foreach ( $existing_notes as $note ) : ?>
if ( ! defined( 'WPINC' ) ) {
die();
}

if ( empty( $existing_notes ) ) :
esc_html_e( 'There are no private notes yet.', 'wordcamporg' );
else :
foreach ( $existing_notes as $note ) : ?>
<div class="wcbrr-note">
<span class="wcbrr-note-meta">
<?php echo esc_html( date( 'Y-m-d', $note['timestamp'] ) ); ?>
<?php echo esc_html( \WordCamp_Budgets::get_requester_name( $note['author_id'] ) ); ?>:
<?php echo esc_html( gmdate( 'Y-m-d', $note['timestamp'] ) ); ?>
<?php echo esc_html( WordCamp_Budgets::get_requester_name( $note['author_id'] ) ); ?>:
</span>

<?php echo esc_html( $note['message'] ); ?>
</div>
<?php endforeach; ?>

<?php endif; ?>
<?php endforeach;
endif; ?>

<div>
<h3>
<label for="wcbrr_new_note">
<?php _e( 'Add a Note', 'wordcamporg' ); ?>
<?php esc_html_e( 'Add a Note', 'wordcamporg' ); ?>
</label>

<?php if ( current_user_can( 'manage_network' ) ) : ?>
Expand Down

0 comments on commit 11be950

Please sign in to comment.