prefix . 'sota_magic_locations' ); return $wpdb->get_row( $wpdb->prepare( "SELECT lat, lon, label, source FROM $table WHERE cache_key = %s AND (expires_at IS NULL OR expires_at > NOW()) LIMIT 1", $cache_key ) ); // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.InterpolatedNotPrepared,PluginCheck.Security.DirectDB.UnescapedDBParameter } /** * Store a location in the dedicated locations table. * Pass $expires_seconds = 0 for permanent storage. */ function sota_magic_location_write( $cache_key, $lat, $lon, $label, $source, $expires_seconds = 0 ) { global $wpdb; // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter $table = esc_sql( $wpdb->prefix . 'sota_magic_locations' ); $wpdb->replace( $table, [ 'cache_key' => $cache_key, 'lat' => $lat, 'lon' => $lon, 'label' => $label, 'source' => $source, 'expires_at' => $expires_seconds > 0 ? gmdate( 'Y-m-d H:i:s', time() + $expires_seconds ) : null, 'cached_at' => gmdate( 'Y-m-d H:i:s' ), ] ); // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter } // Verify nonce — also checked by the AJAX handler that includes this file, but verified here too for static analysis if ( ! isset( $_GET['_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_nonce'] ) ), 'sota_magic_contact_map' ) ) { exit; } // Get and sanitize parameters $sota_magic_debug_mode = ( isset( $_GET['debug'] ) && $_GET['debug'] === '1' ); $sota_magic_csv_url = isset( $_GET['csv'] ) ? esc_url_raw( wp_unslash( $_GET['csv'] ) ) : ''; if ( ! $sota_magic_csv_url ) { echo '
No CSV file specified
'; exit; } // Get callsign lookup credentials $sota_magic_qrz_user = get_option( 'sota_qrz_username' ); $sota_magic_qrz_pass = sota_magic_decrypt_credential( get_option( 'sota_qrz_password' ) ); $sota_magic_hamqth_user = get_option( 'sota_hamqth_username' ); $sota_magic_hamqth_pass = sota_magic_decrypt_credential( get_option( 'sota_hamqth_password' ) ); // Parse CSV via wp_remote_get $sota_magic_contacts = []; $sota_magic_csv_response = wp_remote_get( $sota_magic_csv_url, [ 'timeout' => 15 ] ); if ( ! is_wp_error( $sota_magic_csv_response ) ) { $sota_magic_csv_body = wp_remote_retrieve_body( $sota_magic_csv_response ); foreach ( explode( "\n", $sota_magic_csv_body ) as $sota_magic_csv_line ) { $sota_magic_row = str_getcsv( trim( $sota_magic_csv_line ) ); if ( ! empty( $sota_magic_row[0] ) && $sota_magic_row[0] === 'V2' ) { $sota_magic_contacts[] = [ 'my_summit' => $sota_magic_row[2] ?? '', 'date' => $sota_magic_row[3] ?? '', 'time' => $sota_magic_row[4] ?? '', 'frequency' => $sota_magic_row[5] ?? '', 'mode' => $sota_magic_row[6] ?? '', 'callsign' => $sota_magic_row[7] ?? '', 'their_summit' => trim( $sota_magic_row[8] ?? '' ), 'comments' => trim( $sota_magic_row[9] ?? '' ), ]; } } } /** * Calculate great-circle distance between two lat/lon points (Haversine formula). * Returns array with 'km' and 'miles', both rounded to 1 decimal place. */ function sota_magic_haversine( $lat1, $lon1, $lat2, $lon2 ) { $R = 6371; $dLat = deg2rad( $lat2 - $lat1 ); $dLon = deg2rad( $lon2 - $lon1 ); $a = sin( $dLat / 2 ) * sin( $dLat / 2 ) + cos( deg2rad( $lat1 ) ) * cos( deg2rad( $lat2 ) ) * sin( $dLon / 2 ) * sin( $dLon / 2 ); $km = $R * 2 * atan2( sqrt( $a ), sqrt( 1 - $a ) ); return [ 'km' => round( $km, 1 ), 'miles' => round( $km * 0.621371, 1 ) ]; } /** * Extract a Maidenhead grid square from free text. */ function sota_magic_extract_grid_square( $sota_magic_text ) { if ( preg_match( '/(?= 6 ) { $lon += ( ord( $g[4] ) - ord( 'A' ) ) * ( 5.0 / 60 ) + ( 5.0 / 60 / 2 ); $lat += ( ord( $g[5] ) - ord( 'A' ) ) * ( 2.5 / 60 ) + ( 2.5 / 60 / 2 ); } else { $lon += 1.0; $lat += 0.5; } return [ 'lat' => round( $lat, 6 ), 'lon' => round( $lon, 6 ) ]; } /** * Get band color from frequency (MHz). */ function sota_magic_get_band_color( $sota_magic_frequency ) { $freq = floatval( $sota_magic_frequency ); if ( $freq >= 1.8 && $freq < 2.0 ) return '#8B4513'; if ( $freq >= 3.5 && $freq < 4.0 ) return '#FFA500'; if ( $freq >= 7.0 && $freq < 7.3 ) return '#FFD700'; if ( $freq >= 10.1 && $freq < 10.15 ) return '#FFFF00'; if ( $freq >= 14.0 && $freq < 14.35 ) return '#00FF00'; if ( $freq >= 18.068 && $freq < 18.168 ) return '#00CED1'; if ( $freq >= 21.0 && $freq < 21.45 ) return '#0000FF'; if ( $freq >= 24.89 && $freq < 24.99 ) return '#4B0082'; if ( $freq >= 28.0 && $freq < 29.7 ) return '#8B00FF'; if ( $freq >= 50.0 && $freq < 54.0 ) return '#FF1493'; if ( $freq >= 144.0 && $freq < 148.0 ) return '#FF69B4'; if ( $freq >= 222.0 && $freq < 225.0 ) return '#FFB6C1'; if ( $freq >= 420.0 && $freq < 450.0 ) return '#FFC0CB'; return '#999999'; } // Get summit location from SOTA API (cached 90 days in locations table) $sota_magic_summit = null; if ( ! empty( $sota_magic_contacts[0]['my_summit'] ) ) { $sota_magic_summit_ref = $sota_magic_contacts[0]['my_summit']; $sota_magic_summit_key = 'summit_' . sanitize_key( $sota_magic_summit_ref ); $sota_magic_summit_row = sota_magic_location_read( $sota_magic_summit_key ); if ( $sota_magic_summit_row ) { $sota_magic_summit = [ 'lat' => floatval( $sota_magic_summit_row->lat ), 'lon' => floatval( $sota_magic_summit_row->lon ), 'name' => $sota_magic_summit_row->label ?: $sota_magic_summit_ref, 'ref' => $sota_magic_summit_ref, ]; } else { $sota_magic_api_url = 'https://api2.sota.org.uk/api/summits/' . $sota_magic_summit_ref; $sota_magic_wp_resp = wp_remote_get( $sota_magic_api_url, [ 'timeout' => 30, 'user-agent' => 'SOTA-Magic-Plugin/1.0' ] ); $sota_magic_response = ! is_wp_error( $sota_magic_wp_resp ) ? wp_remote_retrieve_body( $sota_magic_wp_resp ) : false; if ( $sota_magic_response !== false ) { $sota_magic_summit_data = json_decode( $sota_magic_response, true ); if ( $sota_magic_summit_data && isset( $sota_magic_summit_data['latitude'], $sota_magic_summit_data['longitude'] ) ) { $sota_magic_summit_name = $sota_magic_summit_data['name'] ?? $sota_magic_summit_ref; $sota_magic_summit = [ 'lat' => floatval( $sota_magic_summit_data['latitude'] ), 'lon' => floatval( $sota_magic_summit_data['longitude'] ), 'name' => $sota_magic_summit_name, 'ref' => $sota_magic_summit_ref, ]; sota_magic_location_write( $sota_magic_summit_key, $sota_magic_summit['lat'], $sota_magic_summit['lon'], $sota_magic_summit_name, 'sota', 90 * DAY_IN_SECONDS ); } } } } // Get QRZ session if credentials available $sota_magic_qrz_session = null; if ( $sota_magic_qrz_user && $sota_magic_qrz_pass ) { $sota_magic_login_url = 'https://xmldata.qrz.com/xml/current/?username=' . rawurlencode( $sota_magic_qrz_user ) . '&password=' . rawurlencode( $sota_magic_qrz_pass ); $sota_magic_login_wp = wp_remote_get( $sota_magic_login_url, [ 'timeout' => 15 ] ); $sota_magic_login_response = ! is_wp_error( $sota_magic_login_wp ) ? wp_remote_retrieve_body( $sota_magic_login_wp ) : false; if ( $sota_magic_login_response ) { preg_match( '/([^<]+)<\/Key>/', $sota_magic_login_response, $sota_magic_matches ); if ( ! empty( $sota_magic_matches[1] ) ) { $sota_magic_qrz_session = $sota_magic_matches[1]; } } } // Get HamQTH session if credentials available (sessions valid for 1 hour) $sota_magic_hamqth_session = null; if ( $sota_magic_hamqth_user && $sota_magic_hamqth_pass ) { $sota_magic_hamqth_login_url = 'https://www.hamqth.com/xml.php?u=' . rawurlencode( $sota_magic_hamqth_user ) . '&p=' . rawurlencode( $sota_magic_hamqth_pass ); $sota_magic_hamqth_login_wp = wp_remote_get( $sota_magic_hamqth_login_url, [ 'timeout' => 15, 'user-agent' => 'Activator-Toolkit-for-SOTA/1.0' ] ); $sota_magic_hamqth_login_response = ! is_wp_error( $sota_magic_hamqth_login_wp ) ? wp_remote_retrieve_body( $sota_magic_hamqth_login_wp ) : false; if ( $sota_magic_hamqth_login_response ) { preg_match( '/([^<]+)<\/session_id>/', $sota_magic_hamqth_login_response, $sota_magic_hamqth_matches ); if ( ! empty( $sota_magic_hamqth_matches[1] ) ) { $sota_magic_hamqth_session = $sota_magic_hamqth_matches[1]; } } } // Get locations for all contacts $sota_magic_contact_locations = []; $sota_magic_unresolved = []; $sota_magic_lookup_fail_debug = []; // Only populated in debug mode foreach ( $sota_magic_contacts as $sota_magic_contact ) { $sota_magic_callsign = $sota_magic_contact['callsign']; $sota_magic_comments = $sota_magic_contact['comments']; $sota_magic_is_s2s = ! empty( $sota_magic_contact['their_summit'] ); $sota_magic_band_color = sota_magic_get_band_color( $sota_magic_contact['frequency'] ); // Priority 1: grid square in comments $sota_magic_grid = sota_magic_extract_grid_square( $sota_magic_comments ); if ( $sota_magic_grid ) { $sota_magic_coords = sota_magic_maidenhead_to_latlon( $sota_magic_grid ); $sota_magic_contact_locations[] = [ 'callsign' => $sota_magic_callsign, 'lat' => $sota_magic_coords['lat'], 'lon' => $sota_magic_coords['lon'], 'summit' => $sota_magic_contact['their_summit'], 'mode' => $sota_magic_contact['mode'], 'frequency' => $sota_magic_contact['frequency'], 'is_s2s' => $sota_magic_is_s2s, 'color' => $sota_magic_band_color, 'location_source' => 'grid', 'grid' => $sota_magic_grid, ]; continue; } // Priority 2: S2S — use SOTA API summit coordinates (cached 90 days in locations table) if ( $sota_magic_is_s2s ) { $sota_magic_their_ref = $sota_magic_contact['their_summit']; $sota_magic_s2s_key = 'summit_' . sanitize_key( $sota_magic_their_ref ); $sota_magic_s2s_row = sota_magic_location_read( $sota_magic_s2s_key ); if ( $sota_magic_s2s_row ) { $sota_magic_contact_locations[] = [ 'callsign' => $sota_magic_callsign, 'lat' => floatval( $sota_magic_s2s_row->lat ), 'lon' => floatval( $sota_magic_s2s_row->lon ), 'summit' => $sota_magic_their_ref, 'mode' => $sota_magic_contact['mode'], 'frequency' => $sota_magic_contact['frequency'], 'is_s2s' => true, 'color' => $sota_magic_band_color, 'location_source' => 'sota', 'cached' => true, ]; } else { $sota_magic_their_api_url = 'https://api2.sota.org.uk/api/summits/' . $sota_magic_their_ref; $sota_magic_their_wp = wp_remote_get( $sota_magic_their_api_url, [ 'timeout' => 15, 'user-agent' => 'SOTA-Magic-Plugin/1.0' ] ); $sota_magic_their_response = ! is_wp_error( $sota_magic_their_wp ) ? wp_remote_retrieve_body( $sota_magic_their_wp ) : false; if ( $sota_magic_their_response !== false ) { $sota_magic_their_data = json_decode( $sota_magic_their_response, true ); if ( $sota_magic_their_data && isset( $sota_magic_their_data['latitude'], $sota_magic_their_data['longitude'] ) ) { $sota_magic_s2s_lat = floatval( $sota_magic_their_data['latitude'] ); $sota_magic_s2s_lon = floatval( $sota_magic_their_data['longitude'] ); sota_magic_location_write( $sota_magic_s2s_key, $sota_magic_s2s_lat, $sota_magic_s2s_lon, $sota_magic_their_ref, 'sota', 90 * DAY_IN_SECONDS ); $sota_magic_contact_locations[] = [ 'callsign' => $sota_magic_callsign, 'lat' => $sota_magic_s2s_lat, 'lon' => $sota_magic_s2s_lon, 'summit' => $sota_magic_their_ref, 'mode' => $sota_magic_contact['mode'], 'frequency' => $sota_magic_contact['frequency'], 'is_s2s' => true, 'color' => $sota_magic_band_color, 'location_source' => 'sota', 'cached' => false, ]; } else { $sota_magic_unresolved[] = [ 'callsign' => $sota_magic_callsign, 'reason' => 'SOTA API returned no coordinates for ' . $sota_magic_their_ref ]; } } else { $sota_magic_unresolved[] = [ 'callsign' => $sota_magic_callsign, 'reason' => 'SOTA API unreachable for ' . $sota_magic_their_ref ]; } } continue; } // Priority 3: Check unified cache (any source); also check legacy qrz_ key for existing cached entries $sota_magic_loc_key = 'loc_' . sanitize_key( strtolower( $sota_magic_callsign ) ); $sota_magic_legacy_key = 'qrz_' . sanitize_key( strtolower( $sota_magic_callsign ) ); $sota_magic_cached_row = sota_magic_location_read( $sota_magic_loc_key ) ?? sota_magic_location_read( $sota_magic_legacy_key ); if ( $sota_magic_cached_row ) { $sota_magic_contact_locations[] = [ 'callsign' => $sota_magic_callsign, 'lat' => floatval( $sota_magic_cached_row->lat ), 'lon' => floatval( $sota_magic_cached_row->lon ), 'summit' => '', 'mode' => $sota_magic_contact['mode'], 'frequency' => $sota_magic_contact['frequency'], 'is_s2s' => false, 'color' => $sota_magic_band_color, 'location_source' => $sota_magic_cached_row->source, 'cached' => true, ]; continue; } $sota_magic_fail_reasons = []; // Priority 4: Callook.info — free, US callsigns only (FCC data), no auth required $sota_magic_callook_url = 'https://callook.info/' . rawurlencode( $sota_magic_callsign ) . '/json'; $sota_magic_callook_wp = wp_remote_get( $sota_magic_callook_url, [ 'timeout' => 10, 'user-agent' => 'Activator-Toolkit-for-SOTA/1.0' ] ); $sota_magic_callook_body = ! is_wp_error( $sota_magic_callook_wp ) ? wp_remote_retrieve_body( $sota_magic_callook_wp ) : false; if ( $sota_magic_callook_body ) { $sota_magic_callook_data = json_decode( $sota_magic_callook_body, true ); if ( isset( $sota_magic_callook_data['status'] ) && $sota_magic_callook_data['status'] === 'VALID' && ! empty( $sota_magic_callook_data['location']['latitude'] ) && ! empty( $sota_magic_callook_data['location']['longitude'] ) ) { $sota_magic_callook_lat = floatval( $sota_magic_callook_data['location']['latitude'] ); $sota_magic_callook_lon = floatval( $sota_magic_callook_data['location']['longitude'] ); sota_magic_location_write( $sota_magic_loc_key, $sota_magic_callook_lat, $sota_magic_callook_lon, $sota_magic_callsign, 'callook', 0 ); $sota_magic_contact_locations[] = [ 'callsign' => $sota_magic_callsign, 'lat' => $sota_magic_callook_lat, 'lon' => $sota_magic_callook_lon, 'summit' => '', 'mode' => $sota_magic_contact['mode'], 'frequency' => $sota_magic_contact['frequency'], 'is_s2s' => false, 'color' => $sota_magic_band_color, 'location_source' => 'callook', 'cached' => false, ]; usleep( 250000 ); continue; } $sota_magic_fail_reasons[] = 'Callook: not a US callsign'; } else { $sota_magic_fail_reasons[] = 'Callook: request failed'; } // Priority 5: HamQTH — free account, international if ( $sota_magic_hamqth_session ) { $sota_magic_hamqth_url = 'https://www.hamqth.com/xml.php?id=' . rawurlencode( $sota_magic_hamqth_session ) . '&callsign=' . rawurlencode( $sota_magic_callsign ) . '&prg=Activator-Toolkit-for-SOTA'; $sota_magic_hamqth_wp = wp_remote_get( $sota_magic_hamqth_url, [ 'timeout' => 15, 'user-agent' => 'Activator-Toolkit-for-SOTA/1.0' ] ); $sota_magic_hamqth_response = ! is_wp_error( $sota_magic_hamqth_wp ) ? wp_remote_retrieve_body( $sota_magic_hamqth_wp ) : false; if ( $sota_magic_hamqth_response ) { preg_match( '/([^<]+)<\/latitude>/', $sota_magic_hamqth_response, $sota_magic_hamqth_lat_m ); preg_match( '/([^<]+)<\/longitude>/', $sota_magic_hamqth_response, $sota_magic_hamqth_lon_m ); if ( ! empty( $sota_magic_hamqth_lat_m[1] ) && ! empty( $sota_magic_hamqth_lon_m[1] ) ) { $sota_magic_hamqth_lat = floatval( $sota_magic_hamqth_lat_m[1] ); $sota_magic_hamqth_lon = floatval( $sota_magic_hamqth_lon_m[1] ); sota_magic_location_write( $sota_magic_loc_key, $sota_magic_hamqth_lat, $sota_magic_hamqth_lon, $sota_magic_callsign, 'hamqth', 0 ); $sota_magic_contact_locations[] = [ 'callsign' => $sota_magic_callsign, 'lat' => $sota_magic_hamqth_lat, 'lon' => $sota_magic_hamqth_lon, 'summit' => '', 'mode' => $sota_magic_contact['mode'], 'frequency' => $sota_magic_contact['frequency'], 'is_s2s' => false, 'color' => $sota_magic_band_color, 'location_source' => 'hamqth', 'cached' => false, ]; usleep( 250000 ); continue; } $sota_magic_fail_reasons[] = 'HamQTH: no coordinates in response'; if ( $sota_magic_debug_mode ) { $sota_magic_lookup_fail_debug[ $sota_magic_callsign ] = substr( $sota_magic_hamqth_response, 0, 1000 ); } } else { $sota_magic_fail_reasons[] = 'HamQTH: request failed'; } usleep( 250000 ); } else { $sota_magic_fail_reasons[] = 'HamQTH: not configured'; } // Priority 6: QRZ.com — paid subscription, international if ( $sota_magic_qrz_session ) { $sota_magic_qrz_url = 'https://xmldata.qrz.com/xml/current/?s=' . rawurlencode( $sota_magic_qrz_session ) . '&callsign=' . rawurlencode( $sota_magic_callsign ); $sota_magic_qrz_wp = wp_remote_get( $sota_magic_qrz_url, [ 'timeout' => 15, 'user-agent' => 'Activator-Toolkit-for-SOTA/1.0' ] ); $sota_magic_qrz_response = ! is_wp_error( $sota_magic_qrz_wp ) ? wp_remote_retrieve_body( $sota_magic_qrz_wp ) : false; if ( $sota_magic_qrz_response ) { preg_match( '/([^<]+)<\/lat>/', $sota_magic_qrz_response, $sota_magic_lat_match ); preg_match( '/([^<]+)<\/lon>/', $sota_magic_qrz_response, $sota_magic_lon_match ); if ( ! empty( $sota_magic_lat_match[1] ) && ! empty( $sota_magic_lon_match[1] ) ) { $sota_magic_qrz_lat = floatval( $sota_magic_lat_match[1] ); $sota_magic_qrz_lon = floatval( $sota_magic_lon_match[1] ); sota_magic_location_write( $sota_magic_loc_key, $sota_magic_qrz_lat, $sota_magic_qrz_lon, $sota_magic_callsign, 'qrz', 0 ); $sota_magic_contact_locations[] = [ 'callsign' => $sota_magic_callsign, 'lat' => $sota_magic_qrz_lat, 'lon' => $sota_magic_qrz_lon, 'summit' => '', 'mode' => $sota_magic_contact['mode'], 'frequency' => $sota_magic_contact['frequency'], 'is_s2s' => false, 'color' => $sota_magic_band_color, 'location_source' => 'qrz', 'cached' => false, ]; usleep( 500000 ); continue; } $sota_magic_fail_reasons[] = 'QRZ: no coordinates in response'; if ( $sota_magic_debug_mode ) { $sota_magic_lookup_fail_debug[ $sota_magic_callsign ] = substr( $sota_magic_qrz_response, 0, 1000 ); } } else { $sota_magic_fail_reasons[] = 'QRZ: request failed'; } usleep( 500000 ); } else { $sota_magic_fail_reasons[] = 'QRZ: not configured'; } $sota_magic_unresolved[] = [ 'callsign' => $sota_magic_callsign, 'reason' => implode( '; ', $sota_magic_fail_reasons ) ]; } // Build the map data object that contact-map.js reads from window.sotaContactMapData. // This is a standalone HTML document served via admin-ajax.php; wp_enqueue_script/style // hooks have already fired and cannot be used here. All JS logic lives in the external // contact-map.js file — the only inline script below is this single data assignment, // which is the same pattern WordPress core uses for wp_localize_script(). $sota_magic_map_contacts = []; foreach ( $sota_magic_contact_locations as $sota_magic_loc ) { $sota_magic_dist_miles = null; $sota_magic_dist_km = null; if ( $sota_magic_summit ) { $sota_magic_dist = sota_magic_haversine( $sota_magic_summit['lat'], $sota_magic_summit['lon'], $sota_magic_loc['lat'], $sota_magic_loc['lon'] ); $sota_magic_dist_miles = $sota_magic_dist['miles']; $sota_magic_dist_km = $sota_magic_dist['km']; } $sota_magic_map_contacts[] = [ 'lat' => floatval( $sota_magic_loc['lat'] ), 'lon' => floatval( $sota_magic_loc['lon'] ), 'callsign' => $sota_magic_loc['callsign'], 's2s_summit' => $sota_magic_loc['summit'] ?? null, 'frequency' => $sota_magic_loc['frequency'], 'mode' => $sota_magic_loc['mode'], 'color' => $sota_magic_loc['color'], 'is_s2s' => (bool) $sota_magic_loc['is_s2s'], 'location_source' => $sota_magic_loc['location_source'], 'grid' => $sota_magic_loc['grid'] ?? null, 'dist_miles' => $sota_magic_dist_miles, 'dist_km' => $sota_magic_dist_km, ]; } $sota_magic_map_data = [ 'summit' => $sota_magic_summit ? [ 'lat' => floatval( $sota_magic_summit['lat'] ), 'lon' => floatval( $sota_magic_summit['lon'] ), 'name' => $sota_magic_summit['name'], 'ref' => $sota_magic_summit['ref'], ] : null, 'contacts' => $sota_magic_map_contacts, 'unresolved' => $sota_magic_unresolved, 'debug' => $sota_magic_debug_mode, ]; // Enqueue styles and scripts using WordPress APIs. // This is a standalone HTML document served via wp_ajax_*; wp_head()/wp_footer() are never // called automatically, so we call wp_print_styles() / wp_print_scripts() manually below. wp_enqueue_style( 'sota-cm-leaflet', plugins_url( 'lib/leaflet.css', __FILE__ ), [], '1.9.4' ); wp_enqueue_style( 'sota-cm-css', plugins_url( 'contact-map.css', __FILE__ ), [], '1.0.5' ); wp_enqueue_script( 'sota-cm-leaflet-js', plugins_url( 'lib/leaflet.js', __FILE__ ), [], '1.9.4', false ); wp_enqueue_script( 'sota-cm-js', plugins_url( 'contact-map.js', __FILE__ ), [ 'sota-cm-leaflet-js' ], '1.0.5', true ); wp_add_inline_script( 'sota-cm-js', 'var sotaContactMapData = ' . wp_json_encode( $sota_magic_map_data ) . ';', 'before' ); ?> SOTA Contact Map
Loading contact map...
🔍 Contact Map Debug (admin only)
Summit found:
Raw CSV contacts parsed:
First row my_summit field:
Contact locations resolved:
Lines drawn: 0 ) ? count( $sota_magic_contact_locations ) . ' lines' : 'NONE — summit was null'; ?>
Cache hits:  |  Fresh lookups:  |  Unresolved:
prefix . 'sota_magic_locations' ); $sota_magic_total_rows = (int) $wpdb->get_var( "SELECT COUNT(*) FROM $sota_magic_loc_table" ); // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.InterpolatedNotPrepared,PluginCheck.Security.DirectDB.UnescapedDBParameter $sota_magic_db_error = $wpdb->last_error; ?>
Locations table: — row(s) stored
DB error:

$sota_magic_loc ) : ?> ✓ cached' : ' ⬇ fresh fetch' ) : ''; ?> Contact : → (, ) via

⚠ Unresolved contacts (not shown on map):
 • —

Raw lookup responses (failed):
$sota_magic_raw ) : ?> :