Skip to content

Commit 4bdbc35

Browse files
committed
Update Meteostat and Pirateweather to work properly.
1 parent c170053 commit 4bdbc35

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

includes/weather/class-weather-provider-meteostat.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct( $args = array() ) {
3030
$this->name = __( 'Meteostat', 'simple-location' );
3131
$this->slug = 'meteostat';
3232
$this->url = 'https://meteostat.net';
33-
$this->description = __( 'Meteostat is an open and free archive for weather data, and offers bulk historic weather data. It does not offer current weather consistently.', 'simple-location' );
33+
$this->description = __( 'Meteostat is an open archive for weather data, and offers bulk historic weather data. It does not offer current weather consistently. The data is free, but using their JSON API is free for 500 requests a month', 'simple-location' );
3434
if ( ! isset( $args['api'] ) ) {
3535
$args['api'] = get_option( 'sloc_meteostat_api' );
3636
}
@@ -144,8 +144,18 @@ public function get_station_data( $time = null ) {
144144
);
145145

146146
// For historic data.
147-
$url = 'https://api.meteostat.net/v2/stations/hourly.php';
148-
$json = $this->fetch_json( $url, $args, array( 'x-api-key' => $this->api ) );
147+
$url = 'https://meteostat.p.rapidapi.com/stations/hourly';
148+
$json = $this->fetch_json(
149+
$url,
150+
$args,
151+
array(
152+
'x-rapidapi-key' => $this->api,
153+
'x-rapidapi-host' => 'meteostat.p.rapidapi.com',
154+
)
155+
);
156+
if ( is_wp_error( $json ) ) {
157+
return $json;
158+
}
149159
if ( array_key_exists( 'meta', $json ) ) {
150160
$return['meta'] = $json['meta'];
151161
}

includes/weather/class-weather-provider-pirateweather.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ public function get_conditions( $time = null ) {
7070
return array();
7171
}
7272
$return = array();
73+
error_log( get_bloginfo( 'language' ) );
7374
if ( $this->latitude && $this->longitude ) {
7475
$data = array(
7576
'units' => 'si',
7677
'exclude' => 'minutely,hourly,daily,alerts,flags',
77-
'lang' => get_bloginfo( 'language' ),
78+
'lang' => substr( get_bloginfo( 'language' ), 0, 2 ),
7879
);
7980

8081
$datetime = $this->datetime( $time );

0 commit comments

Comments
 (0)