Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-inclu.../blocks
File: categories.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/categories` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/categories` block on server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 5.0.0
[10] Fix | Delete
*
[11] Fix | Delete
* @param array $attributes The block attributes.
[12] Fix | Delete
*
[13] Fix | Delete
* @return string Returns the categories list/dropdown markup.
[14] Fix | Delete
*/
[15] Fix | Delete
function render_block_core_categories( $attributes ) {
[16] Fix | Delete
static $block_id = 0;
[17] Fix | Delete
++$block_id;
[18] Fix | Delete
[19] Fix | Delete
$args = array(
[20] Fix | Delete
'echo' => false,
[21] Fix | Delete
'hierarchical' => ! empty( $attributes['showHierarchy'] ),
[22] Fix | Delete
'orderby' => 'name',
[23] Fix | Delete
'show_count' => ! empty( $attributes['showPostCounts'] ),
[24] Fix | Delete
'title_li' => '',
[25] Fix | Delete
'hide_empty' => empty( $attributes['showEmpty'] ),
[26] Fix | Delete
);
[27] Fix | Delete
if ( ! empty( $attributes['showOnlyTopLevel'] ) && $attributes['showOnlyTopLevel'] ) {
[28] Fix | Delete
$args['parent'] = 0;
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
[32] Fix | Delete
$id = 'wp-block-categories-' . $block_id;
[33] Fix | Delete
$args['id'] = $id;
[34] Fix | Delete
$args['show_option_none'] = __( 'Select Category' );
[35] Fix | Delete
$wrapper_markup = '<div %1$s><label class="screen-reader-text" for="' . esc_attr( $id ) . '">' . __( 'Categories' ) . '</label>%2$s</div>';
[36] Fix | Delete
$items_markup = wp_dropdown_categories( $args );
[37] Fix | Delete
$type = 'dropdown';
[38] Fix | Delete
[39] Fix | Delete
if ( ! is_admin() ) {
[40] Fix | Delete
// Inject the dropdown script immediately after the select dropdown.
[41] Fix | Delete
$items_markup = preg_replace(
[42] Fix | Delete
'#(?<=</select>)#',
[43] Fix | Delete
build_dropdown_script_block_core_categories( $id ),
[44] Fix | Delete
$items_markup,
[45] Fix | Delete
1
[46] Fix | Delete
);
[47] Fix | Delete
}
[48] Fix | Delete
} else {
[49] Fix | Delete
$wrapper_markup = '<ul %1$s>%2$s</ul>';
[50] Fix | Delete
$items_markup = wp_list_categories( $args );
[51] Fix | Delete
$type = 'list';
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => "wp-block-categories-{$type}" ) );
[55] Fix | Delete
[56] Fix | Delete
return sprintf(
[57] Fix | Delete
$wrapper_markup,
[58] Fix | Delete
$wrapper_attributes,
[59] Fix | Delete
$items_markup
[60] Fix | Delete
);
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Generates the inline script for a categories dropdown field.
[65] Fix | Delete
*
[66] Fix | Delete
* @since 5.0.0
[67] Fix | Delete
*
[68] Fix | Delete
* @param string $dropdown_id ID of the dropdown field.
[69] Fix | Delete
*
[70] Fix | Delete
* @return string Returns the dropdown onChange redirection script.
[71] Fix | Delete
*/
[72] Fix | Delete
function build_dropdown_script_block_core_categories( $dropdown_id ) {
[73] Fix | Delete
ob_start();
[74] Fix | Delete
?>
[75] Fix | Delete
<script>
[76] Fix | Delete
( function() {
[77] Fix | Delete
var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' );
[78] Fix | Delete
function onCatChange() {
[79] Fix | Delete
if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
[80] Fix | Delete
location.href = "<?php echo esc_url( home_url() ); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;
[81] Fix | Delete
}
[82] Fix | Delete
}
[83] Fix | Delete
dropdown.onchange = onCatChange;
[84] Fix | Delete
})();
[85] Fix | Delete
</script>
[86] Fix | Delete
<?php
[87] Fix | Delete
return wp_get_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Registers the `core/categories` block on server.
[92] Fix | Delete
*
[93] Fix | Delete
* @since 5.0.0
[94] Fix | Delete
*/
[95] Fix | Delete
function register_block_core_categories() {
[96] Fix | Delete
register_block_type_from_metadata(
[97] Fix | Delete
__DIR__ . '/categories',
[98] Fix | Delete
array(
[99] Fix | Delete
'render_callback' => 'render_block_core_categories',
[100] Fix | Delete
)
[101] Fix | Delete
);
[102] Fix | Delete
}
[103] Fix | Delete
add_action( 'init', 'register_block_core_categories' );
[104] Fix | Delete
[105] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function