/grid/loaders

DescriptionDescription

This filter allows to add custom loaders to display when a grid is filtered.

ArgumentsArguments

ArgumentTypeDescription
$loadersarrayHolds registered grid loaders

ExampleExample

PHP
functions.php
function prefix_register_grid_loaders( $loaders ) {

	// 'my_loader' corresponds to the loader slug.
	$loaders['my_loader'] = [
		'name' => __( 'Loading...', 'text-domain' ),
		'html' => '<div class="loading-text">' . esc_html__( 'Loading...', 'text-domain' ) . '</div>',
		'css'  => '@keyframes loading-animation{0%{opacity:1}50%{opacity:0}100%{opacity:1}}.my_loader{display:flex;align-items:center;justify-content:center}.loading-text{font-weight:600;font-size:14px;background:0 0!important;animation:loading-animation 1s infinite}',
	];

	return $loaders;

}
add_filter( 'wp_grid_builder/grid/loaders', 'prefix_register_grid_loaders', 10, 1 );