Edit File by line
/home/barbar84/www/wp-inclu.../blocks
File: calendar.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/calendar` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/calendar` block on server.
[8] Fix | Delete
*
[9] Fix | Delete
* @param array $attributes The block attributes.
[10] Fix | Delete
*
[11] Fix | Delete
* @return string Returns the block content.
[12] Fix | Delete
*/
[13] Fix | Delete
function render_block_core_calendar( $attributes ) {
[14] Fix | Delete
global $monthnum, $year;
[15] Fix | Delete
[16] Fix | Delete
$previous_monthnum = $monthnum;
[17] Fix | Delete
$previous_year = $year;
[18] Fix | Delete
[19] Fix | Delete
if ( isset( $attributes['month'] ) && isset( $attributes['year'] ) ) {
[20] Fix | Delete
$permalink_structure = get_option( 'permalink_structure' );
[21] Fix | Delete
if (
[22] Fix | Delete
strpos( $permalink_structure, '%monthnum%' ) !== false &&
[23] Fix | Delete
strpos( $permalink_structure, '%year%' ) !== false
[24] Fix | Delete
) {
[25] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
[26] Fix | Delete
$monthnum = $attributes['month'];
[27] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
[28] Fix | Delete
$year = $attributes['year'];
[29] Fix | Delete
}
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes();
[33] Fix | Delete
$output = sprintf(
[34] Fix | Delete
'<div %1$s>%2$s</div>',
[35] Fix | Delete
$wrapper_attributes,
[36] Fix | Delete
get_calendar( true, false )
[37] Fix | Delete
);
[38] Fix | Delete
[39] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
[40] Fix | Delete
$monthnum = $previous_monthnum;
[41] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
[42] Fix | Delete
$year = $previous_year;
[43] Fix | Delete
[44] Fix | Delete
return $output;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Registers the `core/calendar` block on server.
[49] Fix | Delete
*/
[50] Fix | Delete
function register_block_core_calendar() {
[51] Fix | Delete
register_block_type_from_metadata(
[52] Fix | Delete
__DIR__ . '/calendar',
[53] Fix | Delete
array(
[54] Fix | Delete
'render_callback' => 'render_block_core_calendar',
[55] Fix | Delete
)
[56] Fix | Delete
);
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
add_action( 'init', 'register_block_core_calendar' );
[60] Fix | Delete
[61] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function