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