<?php
/*
Plugin Name: Extended Weather
Description: This weather plugin integrates with the OpenWeatherMap API to fetch real-time and forecasted weather data based on a specified city or coordinates. The data is stored in a file, regularly updated at user-defined intervals, and displayed in the latest, forecast, and historical formats.
Version: 1.0
License: GPLv2 or later  
License URI: https://www.gnu.org/licenses/gpl-2.0.en.html  
Author: Stanislav Štajer
Text Domain: extended-weather
Icon: includes/icon-128.png
*/

// Prevent direct access
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

// Add the "Settings" link next to "Disable" in plugin list"
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'wtdp_add_settings_link');
function wtdp_add_settings_link($links) {
    $settings_link = '<a href="options-general.php?page=wtdp-settings">' . __('Settings', 'extended-weather') . '</a>';
    array_unshift($links, $settings_link); 
    return $links;
}

// Include necessary files securely
$files = [
    'admin.php',
    'latest.php',
    'latest-2.php',
    'functions.php'
];

foreach ($files as $file) {
    require_once plugin_dir_path(__FILE__) . $file;
}

// Load plugin text domain for translations
function wtdp_load_textdomain() {
    load_plugin_textdomain('extended-weather', false, dirname(plugin_basename(__FILE__)) . '/languages');
}
add_action('plugins_loaded', 'wtdp_load_textdomain');
