內容簡介
Advanced H2H for SportsPress 是一款專為 SportsPress 外掛設計的擴充工具,提供聯盟管理者更進階的排序標準選項,讓每個聯盟表格都能選擇不同的排序準則,提升聯賽管理的靈活性與精確性。
【主要功能】
• 自訂排序準則
• 設定常規排序順序
• 配置平手排序順序
• 支援 H2H 專用排序
• 直觀的拖放介面
外掛標籤
開發者團隊
② 後台搜尋「Advanced H2H for SportsPress」→ 直接安裝(推薦)
原文外掛簡介
This plugin is an extension for SportsPress.
Give your league managers the option to use more advanced Sorting Criteria for your League Tables.
Now is possible to select different Sorting Criteria for each League Table!
How to Use
Step 1: Create Sorting Criteria
Go to SportsPress -> Teams -> Sorting Criteria in your WordPress admin.
Click “Add New Criterion”.
Give your criterion a descriptive name (e.g., “Premier League Style”, “Champions League Rules”).
Step 2: Configure Regular Order
In the “Regular Order” section:
Drag and drop the columns in the order you want them to be considered for initial sorting.
Toggle the switch to disable criteria you do not want.
Set sort direction (Ascending/Descending) for each column.
This determines the primary sorting order when teams have different points.
Important: The Tiebreak Order is only applied between teams that are equal on every column enabled in the Regular Order. If you want the head-to-head rules to decide between teams that are level on points, keep Points as the only column in the Regular Order and move everything else (including overall Goal Difference and Goals For) to the Tiebreak Order. If you leave Goal Difference in the Regular Order, teams that are level on points but have a different Goal Difference are separated before the head-to-head rules can be applied.
Step 3: Configure Tiebreak Order
In the “Tiebreak Order” section:
Drag and drop columns in the order they should be used for tiebreakers.
Toggle the switch to disable criteria you do not want.
Set sort direction for each column.
Enable the “H2H Only” checkbox for columns that should only consider head-to-head results (matches played between the tied teams). Leave it unchecked for a column that should use full-season stats.
This determines how teams are ranked when they are equal on the Regular Order (for example, when they have the same points).
Step 4: Review the Summary
The “Sorting Criteria Summary” sidebar shows:
Your configured regular order.
Your configured tiebreak order.
A clear overview of your sorting rules.
Step 5: Apply to League Tables
Go to SportsPress -> Tables.
Edit an existing league table or create a new one.
In the sidebar, find the “Advanced Sorting Criteria” meta box.
Select your custom sorting criterion from the dropdown.
Save the league table.
Examples
Premier League Style (overall Goal Difference decides before head-to-head):
Regular Order: Points (DESC), Goal Difference (DESC), Goals For (DESC)
Tiebreak Order: Points (DESC), Goal Difference (DESC), Goals For (DESC), Goals Away (DESC)
Champions League Style (head-to-head decides before overall Goal Difference):
Regular Order: Points (DESC)
Tiebreak Order: Points [H2H Only] (DESC), Goal Difference [H2H Only] (DESC), Goals For [H2H Only] (DESC), Goal Difference (DESC), Goals For (DESC)
Note: for the Champions League style, Points must be the only column in the Regular Order. Overall Goal Difference and Goals For go in the Tiebreak Order (with “H2H Only” unchecked) so they are only used after the head-to-head criteria. Putting Goal Difference in the Regular Order would separate teams that are level on points before the head-to-head rules are applied.
Developer Hooks
The bundled league-table.php template exposes five generic filters so you can extend the output (row/cell highlighting, badges, data-* attributes for JS, inline styles, extra legends, etc.) without editing the template. Defaults produce exactly the same markup as before, so existing sites are unaffected until you hook in.
Note on types: the row data is keyed by team post ID as integers, while get_post_meta( ..., 'sp_team' ) returns strings. Cast before comparing, e.g. in_array( (int) $team_id, array_map( 'intval', $teams ), true ).
sah2h_league_table_rows — ( array $data, int $table_id )
Change the row data just before the loop (reorder, add or remove rows). Keys are team post IDs.
add_filter( 'sah2h_league_table_rows', function ( $data, $table_id ) {
return $data; // e.g. custom re-ordering
}, 10, 2 );
sah2h_league_table_row_attributes — ( array $attr, int $team_id, array $row, int $table_id )
Add any attribute to the
add_filter( 'sah2h_league_table_row_attributes', function ( $attr, $team_id, $row, $table_id ) {
$attr['class'][] = 'highlighted'; // colours the whole row
$attr['data-team'] = $team_id; // custom data-* hook for JS
return $attr;
}, 10, 4 );
sah2h_league_table_cell_attributes — ( array $attr, string $column, int $team_id, array $row, int $table_id )
Add attributes to an individual
add_filter( 'sah2h_league_table_cell_attributes', function ( $attr, $column, $team_id, $row, $table_id ) {
if ( 'name' === $column ) {
$attr['class'][] = 'sp-highlight';
}
return $attr;
}, 10, 5 );
sah2h_league_table_row_html — ( string $html, int $team_id, array $row, int $table_id )
Filter the fully assembled
markup for a single row.
add_filter( 'sah2h_league_table_row_html', function ( $html, $team_id, $row, $table_id ) {
return $html; // e.g. append a sub-row or wrap the markup
}, 10, 4 );
sah2h_league_table_html — ( string $output, int $table_id )
Catch-all filter on the complete table markup before it is echoed.
add_filter( 'sah2h_league_table_html', function ( $output, $table_id ) {
return $output . '
Bold = teams in this match
';
}, 10, 2 );
