Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: archives.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/archives` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/archives` block on server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 5.0.0
[10] Fix | Delete
*
[11] Fix | Delete
* @see WP_Widget_Archives
[12] Fix | Delete
*
[13] Fix | Delete
* @param array $attributes The block attributes.
[14] Fix | Delete
*
[15] Fix | Delete
* @return string Returns the post content with archives added.
[16] Fix | Delete
*/
[17] Fix | Delete
function render_block_core_archives( $attributes ) {
[18] Fix | Delete
$show_post_count = ! empty( $attributes['showPostCounts'] );
[19] Fix | Delete
$type = isset( $attributes['type'] ) ? $attributes['type'] : 'monthly';
[20] Fix | Delete
[21] Fix | Delete
$class = 'wp-block-archives-list';
[22] Fix | Delete
[23] Fix | Delete
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
[24] Fix | Delete
[25] Fix | Delete
$class = 'wp-block-archives-dropdown';
[26] Fix | Delete
[27] Fix | Delete
$dropdown_id = wp_unique_id( 'wp-block-archives-' );
[28] Fix | Delete
$title = __( 'Archives' );
[29] Fix | Delete
[30] Fix | Delete
/** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
[31] Fix | Delete
$dropdown_args = apply_filters(
[32] Fix | Delete
'widget_archives_dropdown_args',
[33] Fix | Delete
array(
[34] Fix | Delete
'type' => $type,
[35] Fix | Delete
'format' => 'option',
[36] Fix | Delete
'show_post_count' => $show_post_count,
[37] Fix | Delete
)
[38] Fix | Delete
);
[39] Fix | Delete
[40] Fix | Delete
$dropdown_args['echo'] = 0;
[41] Fix | Delete
[42] Fix | Delete
$archives = wp_get_archives( $dropdown_args );
[43] Fix | Delete
[44] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) );
[45] Fix | Delete
[46] Fix | Delete
switch ( $dropdown_args['type'] ) {
[47] Fix | Delete
case 'yearly':
[48] Fix | Delete
$label = __( 'Select Year' );
[49] Fix | Delete
break;
[50] Fix | Delete
case 'monthly':
[51] Fix | Delete
$label = __( 'Select Month' );
[52] Fix | Delete
break;
[53] Fix | Delete
case 'daily':
[54] Fix | Delete
$label = __( 'Select Day' );
[55] Fix | Delete
break;
[56] Fix | Delete
case 'weekly':
[57] Fix | Delete
$label = __( 'Select Week' );
[58] Fix | Delete
break;
[59] Fix | Delete
default:
[60] Fix | Delete
$label = __( 'Select Post' );
[61] Fix | Delete
break;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
$show_label = empty( $attributes['showLabel'] ) ? ' screen-reader-text' : '';
[65] Fix | Delete
[66] Fix | Delete
$block_content = '<label for="' . $dropdown_id . '" class="wp-block-archives__label' . $show_label . '">' . esc_html( $title ) . '</label>
[67] Fix | Delete
<select id="' . $dropdown_id . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
[68] Fix | Delete
<option value="">' . esc_html( $label ) . '</option>' . $archives . '</select>';
[69] Fix | Delete
[70] Fix | Delete
return sprintf(
[71] Fix | Delete
'<div %1$s>%2$s</div>',
[72] Fix | Delete
$wrapper_attributes,
[73] Fix | Delete
$block_content
[74] Fix | Delete
);
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
/** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
[78] Fix | Delete
$archives_args = apply_filters(
[79] Fix | Delete
'widget_archives_args',
[80] Fix | Delete
array(
[81] Fix | Delete
'type' => $type,
[82] Fix | Delete
'show_post_count' => $show_post_count,
[83] Fix | Delete
)
[84] Fix | Delete
);
[85] Fix | Delete
[86] Fix | Delete
$archives_args['echo'] = 0;
[87] Fix | Delete
[88] Fix | Delete
$archives = wp_get_archives( $archives_args );
[89] Fix | Delete
[90] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) );
[91] Fix | Delete
[92] Fix | Delete
if ( empty( $archives ) ) {
[93] Fix | Delete
return sprintf(
[94] Fix | Delete
'<div %1$s>%2$s</div>',
[95] Fix | Delete
$wrapper_attributes,
[96] Fix | Delete
__( 'No archives to show.' )
[97] Fix | Delete
);
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
return sprintf(
[101] Fix | Delete
'<ul %1$s>%2$s</ul>',
[102] Fix | Delete
$wrapper_attributes,
[103] Fix | Delete
$archives
[104] Fix | Delete
);
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Register archives block.
[109] Fix | Delete
*
[110] Fix | Delete
* @since 5.0.0
[111] Fix | Delete
*/
[112] Fix | Delete
function register_block_core_archives() {
[113] Fix | Delete
register_block_type_from_metadata(
[114] Fix | Delete
__DIR__ . '/archives',
[115] Fix | Delete
array(
[116] Fix | Delete
'render_callback' => 'render_block_core_archives',
[117] Fix | Delete
)
[118] Fix | Delete
);
[119] Fix | Delete
}
[120] Fix | Delete
add_action( 'init', 'register_block_core_archives' );
[121] Fix | Delete
[122] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function