// ========================================================================= // SHORTCODE: Rangers Affiliates (Filtered, Paginated, Columned Layout) // ========================================================================= add_shortcode('rangers-affiliates', 'render_custom_rangers_affiliates'); function render_custom_rangers_affiliates() { global $wpdb; $table_name = 'otg_rangers_affiliates'; // 1. Get Filter and Pagination Inputs from GET parameters $filter_start_season = isset($_GET['aff_start']) ? sanitize_text_field($_GET['aff_start']) : ''; $filter_end_season = isset($_GET['aff_end']) ? sanitize_text_field($_GET['aff_end']) : ''; $filter_team = isset($_GET['aff_team']) ? sanitize_text_field($_GET['aff_team']) : ''; $filter_league = isset($_GET['aff_league']) ? sanitize_text_field($_GET['aff_league']) : ''; $paged = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1; $per_page = 25; $offset = ($paged - 1) * $per_page; // Season range validation logic: // If start year is after end year, reset end to start. If end is before start year, reset start/end accordingly. if (!empty($filter_start_season) && !empty($filter_end_season)) { if ($filter_start_season > $filter_end_season) { $filter_end_season = $filter_start_season; } } // Build Dynamic WHERE Clause $where_clauses = []; $params = []; if (!empty($filter_start_season)) { $where_clauses[] = "season >= %s"; $params[] = $filter_start_season; } if (!empty($filter_end_season)) { $where_clauses[] = "season <= %s"; $params[] = $filter_end_season; } if (!empty($filter_team)) { $where_clauses[] = "team_name = %s"; $params[] = $filter_team; } if (!empty($filter_league)) { $where_clauses[] = "league_name = %s"; $params[] = $filter_league; } $where_sql = ''; if (!empty($where_clauses)) { $where_sql = " WHERE " . implode(' AND ', $where_clauses); } // 2. Fetch Unique Teams and Leagues for Dropdown Filter Selects $all_teams = $wpdb->get_col("SELECT DISTINCT team_name FROM $table_name ORDER BY team_name ASC"); $all_leagues = $wpdb->get_col("SELECT DISTINCT league_name FROM $table_name ORDER BY league_name ASC"); // 3. Get Total Records Count for Pagination $count_sql = "SELECT COUNT(*) FROM $table_name" . $where_sql; if (!empty($params)) { $total_records = intval($wpdb->get_var($wpdb->prepare($count_sql, $params))); } else { $total_records = intval($wpdb->get_var($count_sql)); } $total_pages = max(1, ceil($total_records / $per_page)); if ($paged > $total_pages) { $paged = $total_pages; $offset = ($paged - 1) * $per_page; } // 4. Fetch the Paginated Dataset (Sorted by most recent season first) // Using SUBSTRING_INDEX or standard ordering depending on your season format (e.g., "2025-26" or "2025") $sql = "SELECT * FROM $table_name" . $where_sql . " ORDER BY season DESC, id DESC LIMIT %d OFFSET %d"; $query_params = array_merge($params, [$per_page, $offset]); $results = $wpdb->get_results($wpdb->prepare($sql, $query_params)); // Calculate record display range $start_record = ($total_records > 0) ? $offset + 1 : 0; $end_record = min($offset + $per_page, $total_records); $current_url = strtok($_SERVER['URI'] ?? $_SERVER['REQUEST_URI'], '?'); $query_args = $_GET; // Standardized form input style matching your site theme $input_style = 'height: 38px; padding: 0 10px; background: #161616; color: #fff; border: 1px solid #444; border-radius: 4px; box-sizing: border-box; font-size: 0.9em;'; // Start Output Wrapper $output = '
'; // Header Section $output .= '
Affiliate History
'; // Filter Form Layout $output .= '
'; // Preserve non-filter GET variables foreach ($_GET as $key => $val) { if (!in_array($key, ['aff_start', 'aff_end', 'aff_team', 'aff_league', 'paged'])) { $output .= ''; } } // Start Season Input $output .= '
'; // End Season Input $output .= '
'; // Team Filter Dropdown $output .= '
'; // League Filter Dropdown $output .= '
'; // Submit / Clear Buttons $output .= '
'; $output .= ''; $output .= 'Clear'; $output .= '
'; $output .= '
'; // Uniform Table Styles with Column Formatting to Prevent Wrapping $output .= ''; // Table structure broken down into strict, explicit columns to avoid awkward text wrapping $output .= ''; if (empty($results)) { $output .= ''; } else { foreach ($results as $row) { $image_path = $row->team_logo; if (!empty($image_path) && !preg_match('~^(?:f|ht)tps?://~i', $image_path)) { $image_path = site_url('/' . ltrim($image_path, '/')); } $logo_html = ''; if (!empty($image_path)) { $logo_html = '' . esc_attr($row->team_name) . ''; } $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; // Placeholder or extra context if needed per-row $output .= ''; } } $output .= '
Season Team Name League Affiliate Details
No affiliate history found matching your criteria.
' . esc_html($row->season) . '' . $logo_html . '' . esc_html($row->team_name) . '' . esc_html($row->league_name) . '-
'; // Pagination Footer Controls Bar $output .= '
'; $output .= '
Showing ' . $start_record . ' to ' . $end_record . ' of ' . $total_records . ' records
'; $output .= '
'; // Previous Page Button if ($paged > 1) { $prev_args = $query_args; $prev_args['paged'] = $paged - 1; $prev_url = add_query_arg($prev_args, $current_url); $output .= '« Previous'; } else { $output .= '« Previous'; } // Current Page Status Indicator $output .= 'Page ' . $paged . ' of ' . $total_pages . ''; // Next Page Button if ($paged < $total_pages) { $next_args = $query_args; $next_args['paged'] = $paged + 1; $next_url = add_query_arg($next_args, $current_url); $output .= 'Next »'; } else { $output .= 'Next »'; } $output .= '
'; $output .= '
'; // Close main wrapper return $output; } Rangerjunkiekimmie – Activity – OutsideTheGarden Boards – Page 61
OCTOBER
«
Fri
2
6:30PM
Sat
3
Sun
4
6:00PM
Mon
5
Tue
6
7:00PM
Wed
7
Thu
8
»
Rangerjunkiekimmie
Rangerjunkiekimmie
Group: Registered
Joined: 2023-08-26
NHL All Star
2
Follow
Panarin with a pass to no one

In forum Where Smit Hits The Fan

2 years ago
Miller with the swing of a stick

In forum Where Smit Hits The Fan

2 years ago
Would also like Zib and Panarin to get some scoring chances

In forum Where Smit Hits The Fan

2 years ago
Would prefer Cuylle on the 3rd line and Wheeler on the 4th, ...

In forum Where Smit Hits The Fan

2 years ago
Igor has to be on LGR

In forum Where Smit Hits The Fan

2 years ago
So do I

In forum Where Smit Hits The Fan

2 years ago
I do think Fish get's it. I also think he has a good way of ...

In forum Where Smit Hits The Fan

2 years ago
Hahahaha

In forum Where Smit Hits The Fan

2 years ago
TD first in line

In forum Where Smit Hits The Fan

2 years ago
Conference finals

In forum Where Smit Hits The Fan

2 years ago
:30.1

In forum Where Smit Hits The Fan

2 years ago
Goodrow ends it

In forum Where Smit Hits The Fan

2 years ago
Finish this series. Boston take it to game 7

In forum Where Smit Hits The Fan

2 years ago
1:37

In forum Where Smit Hits The Fan

2 years ago
1:46

In forum Where Smit Hits The Fan

2 years ago
Page 61 / 106