From 9d3292b98a90794914a6a7811bdbb2668f63ca2d Mon Sep 17 00:00:00 2001 From: Sven van Hal Date: Thu, 21 Mar 2019 15:18:18 +0100 Subject: [PATCH] Remove dead / unreachable code in `core/calendar` block renderer. (#14546) ## Description The `core/calendar` block registration file contains variable assignments after a `return` statement (hence dead code). After removing this code, I discovered that the variables in question (`$previous_monthnum` and `$previous_year`) are never used anyway (not in this function, not in `get_calendar` and never in the entire codebase for that matter). This PR removes dead code and unused variables to prevent any future ambiguities or bugs. ## How has this been tested? Tests pass, not sure how to test server side rendering well This change seems safe / harmless, however ## Types of changes Refactor, non-breaking --- packages/block-library/src/calendar/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/calendar/index.php b/packages/block-library/src/calendar/index.php index 8e26626f5f861a..54587a47a9dc3e 100644 --- a/packages/block-library/src/calendar/index.php +++ b/packages/block-library/src/calendar/index.php @@ -34,7 +34,7 @@ function render_block_core_calendar( $attributes ) { $custom_class_name = empty( $attributes['className'] ) ? '' : ' ' . $attributes['className']; $align_class_name = empty( $attributes['align'] ) ? '' : ' ' . "align{$attributes['align']}"; - return sprintf( + $output = sprintf( '
%2$s
', esc_attr( 'wp-block-calendar' . $custom_class_name . $align_class_name ), get_calendar( true, false ) @@ -44,6 +44,8 @@ function render_block_core_calendar( $attributes ) { $monthnum = $previous_monthnum; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited $year = $previous_year; + + return $output; } /**