• Resolved bouncebackdata1

    (@bouncebackdata1)


    Hello,
    There is only one plugin I can find for an airport or flight school to display the current weather conditions and I would love to get it working. The developer seems to not exist anymore, so maybe someone on here can help. I get the following error whenever I try to activate the plugin: “Parse error: syntax error, unexpected T_FUNCTION in /home/content/63/8624163/html/wp-content/plugins/metar-widget/metar-widget.php on line 62” Line 62 is the last line. It’s a very simple plugin that uses a single php page. Here’s the entire code for the plugin:

    <?php
    /*
    Plugin Name: METAR plugin
    Plugin URI: http://wordpress.org/extend/plugins/metar-widget/
    Description: Plugin to include the latest METAR information from NOAA database for any Airport
    Version: 0.1
    Author: Luther Blissett
    Author URI: http://lutherblissett.net
    License: GPL3
    */
    
    class MetarWidget extends WP_Widget
    {
        public function __construct() {
            parent::__construct("metar_widget", "METAR Widget",
                array("description" => "Plugin to inlclude the latest METAR information from NOAA database for any Airport"));
        }
    
        public function form($instance) {
            $icao = "";
            // if instance is defined, populate the fields
            if (!empty($instance)) {
                $icao = $instance["icao"];
            }
    
            $tableId = $this->get_field_id("icao");
            $tableName = $this->get_field_name("icao");
            echo '<label for="' . $tableId . '">ICAO</label>';
            echo '<input id="' . $tableId . '" type="text" name="' .
                $tableName . '" value="' . $icao . '"/>';
        }
    
        public function update($newInstance, $oldInstance) {
            $values = array();
            $values["icao"] = htmlentities($newInstance["icao"]);
            return $values;
        }
    
        public function widget($args, $instance) {
            $icao = $instance["icao"];
    
            $fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/$icao.TXT";
            $metar = '';
            $fileData = @file($fileName) or die('METAR not available');
            if ($fileData != false) {
            	list($i, $date) = each($fileData);
            	$utc = strtotime(trim($date));
            	$time = date("D, F jS Y g:i A",$utc);
    
            	while (list($i, $line) = each($fileData)) {
            		$metar .= ' ' . trim($line);
                	}
            	$metar = trim(str_replace('  ', ' ', $metar));
            }
    
    	echo '<div class="widget widget-wrapper" id="' . $args['widget_id'] . '-container">';
    	echo '<div class="widget-title"><b>Current METAR for ' . $icao . '</b></div>';
    	echo $metar . '</div>';
        }
    }
    
    add_action("widgets_init", function () { register_widget("MetarWidget"); });

    Any help is greatly appreciated,
    Mike

Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Broken Plugin, unexpected T_function’ is closed to new replies.