Plugin Directory

Changeset 3653359


Ignore:
Timestamp:
08/18/2026 05:57:28 PM (2 months ago)
Author:
henryp
Message:

Fix PHP warnings for empty values in dashboard widget

Location:
donation-thermometer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • donation-thermometer/trunk/donation_therm.php

    r3596038 r3653359  
    44Plugin URI: https://rhewlif.xyz/thermometer
    55Description: Displays customisable thermometers for tracking donations using the shortcode <code>[thermometer raised=?? target=??]</code>. Shortcodes for raised/target/percentage text values are also available for posts/pages/text widgets: <code>[therm_r]</code> / <code>[therm_t]</code> / <code>[therm_%]</code>.
    6 Version: 2.2.9
     6Version: 2.2.10
    77Author: Henry Patton
    88Text Domain: donation-thermometer
  • donation-thermometer/trunk/includes/therm_widget.php

    r2937808 r3653359  
    11<?php
    2 /**
    3  * This file could be used to catch submitted form data. When using a non-configuration
    4  * view to save form data, remember to use some kind of identifying field in your form.
    5  */
    62
    73if(self::get_thermometer_widget_option('thousands') == ' (space)'){
    … …  
    1612$decsep = (self::get_thermometer_widget_option('decsep') == ', (comma)') ? ',' : '.';
    1713$decimals = intval(self::get_thermometer_widget_option('decimals'));
    18 $raisedA = explode(';',self::get_thermometer_widget_option('raised_string'));
     14
     15$raised_str = (string)(self::get_thermometer_widget_option('raised_string') ?? '');
     16$raisedA = explode(';', $raised_str);
     17
    1918if ($decsep == ','){
    2019    foreach($raisedA as &$item) {
    2120        $item = floatval(str_replace(',', '.', str_replace('.', '', strval($item))));
    2221    }
     22    unset($item);
     23} else {
     24    $raisedA = array_map('floatval', $raisedA);
    2325}
     26
    2427$raised = array_sum($raisedA);
    25 $targetA = explode(';',self::get_thermometer_widget_option('target_string'));
     28
     29$target_str = (string)(self::get_thermometer_widget_option('target_string') ?? '');
     30$targetA = explode(';', $target_str);
     31
    2632if ($decsep == ','){
    2733    foreach($targetA as &$item) {
    2834        $item = floatval(str_replace(',', '.', str_replace('.', '', strval($item))));
    2935    }
     36    unset($item);
     37} else {
     38    $targetA = array_map('floatval', $targetA);
    3039}
    3140
    3241$target = floatval(end($targetA));
     42
    3343$currency = self::get_thermometer_widget_option('currency');
    3444$trailing = self::get_thermometer_widget_option('trailing');
  • donation-thermometer/trunk/readme.txt

    r3596038 r3653359  
    55Requires at least: 4.6
    66Tested up to: 7.0
    7 Stable tag: 2.2.9
     7Stable tag: 2.2.10
    88Requires PHP: 5.2
    99License: GPL3
    … …  
    8080
    8181== Changelog ==
     82
     83= 2.2.10 =
     84* Bug fix on the Dashboard widget.
    8285
    8386= 2.2.9 =
Note: See TracChangeset for help on using the changeset viewer.