• Resolved shelbybark

    (@shelbybark)


    Selecting the fahrenheit option does not show the temperature in fahrenheit. I noticed in the code that fahrenheit is computed, but never used there either.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter shelbybark

    (@shelbybark)

    I have made some adjustments to fix this issue. Let me know if you can incorporate the changes:

    `
    diff –git a/index.php b/index.php
    index 81ef7a7..c1ee5c9 100755
    — a/index.php
    +++ b/index.php
    @@ -16,7 +16,7 @@ Author URI: https://maennchen1.de
    load_plugin_textdomain(‘m1mw’, false, basename( dirname( __FILE__ ) ) . ‘/languages’ );

    class Wx {
    – public function getWeather($lat = false, $long = false, $api_key = false) {
    + public function getWeather($lat = false, $long = false, $api_key = false, $temp_fmt = ‘C’) {
    $data = new stdClass();
    if($lat && $long && $api_key) {
    try {
    @@ -35,6 +35,11 @@ class Wx {
    $main = $data->main;
    $data->tempC = round(($main->temp -273.15), 0);
    $data->tempF = round(((($data->tempC * 9 ) / 5) + 32) ,0);
    + if($temp_fmt === ‘F’) {
    + $data->tempP = $data->tempF;
    + } else {
    + $data->tempP = $data->tempC;
    + }
    }

    } catch(Exception $ex) {
    @@ -75,7 +80,7 @@ class m1_miniweather_widget extends WP_Widget
    {
    //renew!
    $m1mw = new Wx();
    – $m1mw_data = $m1mw->getWeather($settings[‘m1mw_lat’], $settings[‘m1mw_long’], $settings[‘m1mw_api_key’]);
    + $m1mw_data = $m1mw->getWeather($settings[‘m1mw_lat’], $settings[‘m1mw_long’], $settings[‘m1mw_api_key’], $settings[‘m1mw_value’]);
    if (!$m1mw_data->error)
    {
    update_option( ‘m1_miniweather_renew_last’, time() );
    @@ -99,7 +104,7 @@ class m1_miniweather_widget extends WP_Widget
    echo $args[‘after_title’];
    if ($m1mw_data->error ===false) {
    echo ‘<div class=”wi wi-owm-‘ . $m1mw_data->weather[0]->id .'” title=”‘ . $m1mw_data->weather[0]->description . ‘” style=”font-size: 2em;’ . $m1mw_fontColor . ‘”>
    – <span class=”m1mw_temp”>’ . $m1mw_data->tempC . ‘°</span>
    + <span class=”m1mw_temp”>’ . $m1mw_data->tempP . ‘°</span>
    </div>’;
    } else {
    echo $m1mw_data->error;

    I’m having the same issue. Were you able to fix this?

    • This reply was modified 7 years, 8 months ago by kdardis.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Widget not using Fahrenheit’ is closed to new replies.