Layout Builder v2 block templates carry no hooks of their own. anwpfl/lb/block_content is the extension seam: one filter that lets an add-on replace what a block renders, hide it, or add a block alias the plugin does not ship. Available since Football Leagues Premium 0.18.4.
Signature
apply_filters( 'anwpfl/lb/block_content', null, $alias, $block, $post_id, $context );
| Argument | Type | Description |
|---|---|---|
$content | string|null | Replacement inner HTML. null (the default) means no interference. |
$alias | string | Block alias, e.g. team_roster, player_game_log, competition_standings. |
$block | array | The block instance from the layout. |
$post_id | int | Resolved entity post ID – the club, player or competition being rendered. |
$context | array | Render context: season, competition_id, is_swap and similar. |
The contract
| Return | Result |
|---|---|
null | Leave the block alone. Always the default – return this for every alias you do not handle. |
| a non-empty string | Replaces the block’s inner HTML. The plugin still draws the block wrapper around it. |
'' | Hides the block – the wrapper is dropped too, unless the block opts out with always_show. |
Return null, not an empty string, to opt out
'' and null mean different things here. A callback that falls through to return ''; hides every block on every layout on the site.
Where it runs
After the entity visibility gate and before the render_{alias}() dispatch. Two consequences worth knowing:
- It also fires for aliases that have no render method, so an add-on can introduce its own block into a layout rather than only replacing a built-in one.
- The classic club Roster shortcode section runs through the same filter, so one add-on covers both the classic club page and the v2 team layout. Without this, replacing Roster would leave the same club page showing two different rosters depending on which layout drew it.
Examples
Replace one block
add_filter( 'anwpfl/lb/block_content', function ( $content, $alias, $block, $post_id, $context ) {
if ( 'team_roster' !== $alias ) {
return $content;
}
$season_id = absint( $context['season'] ?? 0 );
return my_addon_render_external_roster( $post_id, $season_id );
}, 10, 5 );
Hide a block conditionally
add_filter( 'anwpfl/lb/block_content', function ( $content, $alias, $block, $post_id ) {
if ( 'player_transfers' === $alias && get_post_meta( $post_id, '_my_hide_transfers', true ) ) {
return '';
}
return $content;
}, 10, 4 );
Add your own block alias
add_filter( 'anwpfl/lb/block_content', function ( $content, $alias, $block, $post_id, $context ) {
if ( 'my_addon_fan_poll' !== $alias ) {
return $content;
}
return my_addon_render_fan_poll( $post_id, $context );
}, 10, 5 );
Caching
Per-block AJAX swap responses are object-cached on entity | post | variant | layout revision | block | context. A filter whose output changes without one of those changing is served stale until that cache expires.
If your replacement depends on data outside that key – an external feed, a user-specific value, an option – either fold the varying part into the block’s context, keep the volatile piece client-side, or accept the cache window. Do not assume the filter runs on every request.
Block aliases
The alias is the render_ method name without the prefix. To confirm the current list for a version, grep the plugin:
grep -rhoP 'function render_\K[a-z0-9_]+' football-leagues-by-anwppro-premium/includes/lb2/
| Entity | Aliases |
|---|---|
| Team | team_header, team_roster, team_squad, team_standings, team_schedule, team_fixtures, team_results, team_season_record, team_season_stats, team_club_stats, team_player_stats, team_form_trends, team_scorelines, team_match_breakdown, team_leaderboards, team_rankings, team_gallery, team_trophies, team_description, team_subteam_schedule, team_subteam_squad, team_subteam_stats |
| Player | player_header, player_season_record, player_career, player_career_chart, player_game_log, player_splits, player_vs_opponents, player_form_trends, player_goal_analysis, player_discipline, player_teammates, player_top_performances, player_stats, player_stats_panel, player_matches, player_next_game, player_missed, player_transfers, player_club_standings, player_gallery, player_description, player_bottom_content |
| Competition | competition_header, competition_standings, competition_bracket, competition_matches, competition_matches_compact, competition_fixtures, competition_results, competition_results_matrix, competition_leaders, competition_club_stats, competition_player_stats, competition_stats_overview, competition_scorelines, competition_matchweek_slides, competition_transfers, competition_bottom_content |