From e8856a3e603619b014e7f65808ff589b2f876c00 Mon Sep 17 00:00:00 2001 From: Timi Wahalahti Date: Thu, 21 Sep 2023 01:18:32 +0300 Subject: [PATCH] phpcs --- .../classes/class-wordcamp-docs.php | 21 +++++++++-------- .../templates/sponsorship-agreement.php | 23 +++++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/public_html/wp-content/plugins/wordcamp-docs/classes/class-wordcamp-docs.php b/public_html/wp-content/plugins/wordcamp-docs/classes/class-wordcamp-docs.php index 6fd00fb84..b21960d5d 100644 --- a/public_html/wp-content/plugins/wordcamp-docs/classes/class-wordcamp-docs.php +++ b/public_html/wp-content/plugins/wordcamp-docs/classes/class-wordcamp-docs.php @@ -87,14 +87,14 @@ public static function form_handler() { // Check selected template on any step. $templates = self::get_templates(); $template_selected = sanitize_text_field( $_POST['wcdocs_template'] ); - if ( ! array_key_exists( $template_selected, $templates ) ) + if ( ! array_key_exists( $template_selected, $templates ) ) { return self::error( __( 'Selected template does not exist', 'wordcamporg' ) ); + } $template = $templates[ $template_selected ]; switch ( $step ) { - case 1: // submitted step 1 - + case 1: // submitted step 1. if ( 'sponsorship-agreement' == $template_selected ) { self::$step = 10; } else { @@ -104,8 +104,7 @@ public static function form_handler() { break; - case 10; // submitted step 10 - // Sanitize input + case 10: // submitted step 10. $data = $template->sanitize( $_POST ); if ( 'sponsorship-agreement' == $template_selected ) { @@ -113,10 +112,10 @@ public static function form_handler() { self::$step = 20; } } - break; - case 20: // submitted step 20 + break; + case 20: // submitted step 20. require_once( WORDCAMP_DOCS__PLUGIN_DIR . 'classes/class-wordcamp-docs-pdf-generator.php' ); $generator = new WordCamp_Docs_PDF_Generator; @@ -149,6 +148,9 @@ private static function error( $message ) { /** * Render the contents of our admin section. + * + * phpcs:disable WordPress.Security.NonceVerification.Missing + * nonce is checked on form_handler function */ public static function render_menu_page() { ?> @@ -182,7 +184,7 @@ public static function render_menu_page() {

- +
@@ -199,7 +201,7 @@ public static function render_menu_page() {

- +
@@ -220,6 +222,7 @@ public static function render_menu_page() { 'wcb_sponsor', - 'post_status' => 'publish', - 'posts_per_page' => 500, + 'post_type' => 'wcb_sponsor', + 'post_status' => 'publish', + 'posts_per_page' => 500, ) ); ?>
- + - + - + - +
meta['Start Date (YYYY-mm-dd)'][0] ) ? date( $date_format, $wordcamp->meta['Start Date (YYYY-mm-dd)'][0] ) : ''; - $end_date = ! empty( $wordcamp->meta['End Date (YYYY-mm-dd)'][0] ) ? date( $date_format, $wordcamp->meta['End Date (YYYY-mm-dd)'][0] ) : $start_date; + $start_date = ! empty( $wordcamp->meta['Start Date (YYYY-mm-dd)'][0] ) ? gmdate( $date_format, $wordcamp->meta['Start Date (YYYY-mm-dd)'][0] ) : ''; + $end_date = ! empty( $wordcamp->meta['End Date (YYYY-mm-dd)'][0] ) ? gmdate( $date_format, $wordcamp->meta['End Date (YYYY-mm-dd)'][0] ) : $start_date; $number_formatter = new NumberFormatter( get_locale(), NumberFormatter::SPELLOUT ); $sponsorship_amount = $number_formatter->format( $sponsor_amount ) . " {$sponsor_currency}"; @@ -67,7 +70,7 @@ public function form( $data ) { $number_formatter = new NumberFormatter( get_locale(), NumberFormatter::CURRENCY ); $sponsorship_amount_num = $number_formatter->formatCurrency( $sponsor_amount, $sponsor_currency ); - $data = wp_parse_args( $data, array( + $data = wp_parse_args( $data, array( // phpcs:ignore PEAR.Functions.FunctionCallSignature.MultipleArguments 'sponsor_name' => get_the_title( $sponsor_id ), 'sponsor_rep_name' => get_post_meta( $sponsor_id, '_wcpt_sponsor_first_name', true ) . ' ' . get_post_meta( $sponsor_id, '_wcpt_sponsor_last_name', true ), 'sponsor_rep_title' => '',