Changeset 3097742
- Timestamp:
- 06/05/2024 07:27:50 AM (21 months ago)
- Location:
- weather-in-any-city-widget/trunk
- Files:
-
- 1 deleted
- 2 edited
-
README.txt (modified) (1 diff)
-
cache (deleted)
-
weather-in-any-city-widget.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
weather-in-any-city-widget/trunk/README.txt
r3097418 r3097742 4 4 Tested up to: 6.5 5 5 Requires PHP: 5.3 6 Stable tag: 1.1. 366 Stable tag: 1.1.40 7 7 License: GPLv2 or later 8 8 -
weather-in-any-city-widget/trunk/weather-in-any-city-widget.php
r3097418 r3097742 4 4 * Plugin URI: https://weatherin.org 5 5 * Description: Weather Widget Pro provides a complete weather forecast for any location around the world. 6 * Version: 1.1. 366 * Version: 1.1.40 7 7 * Author: El tiempo 8 8 * Author URI: https://eltiempoen.com … … 16 16 defined( 'ABSPATH' ) or die( 'ABSPATH not defined' ); 17 17 18 define ('WIYCW_VERSION', '1.1. 36');18 define ('WIYCW_VERSION', '1.1.40'); 19 19 define ('WIYCW_DEF_PLUGIN', 'weather-in-any-city-widget'); 20 20 define ('WIYCW_DEF_BASEURL', plugins_url('', __FILE__)); … … 921 921 function WIYCW_get_weather(){ 922 922 923 try { 924 $response = array(); 925 $response['error'] = false; 926 927 if(isset($_GET['id'])) { 928 929 $id = intval(sanitize_text_field($_GET['id'])); 930 $cache_file = dirname(__FILE__) .'/cache/' . $id . '.txt'; 931 $cache_minutes = 15; 932 933 if(file_exists($cache_file) && (filemtime($cache_file) > (time() - ($cache_minutes * 60)))) { 934 wp_send_json(json_decode(unserialize(file_get_contents($cache_file)))); 935 die(); 923 $error = array('error' => true, 'message' => ''); 924 925 if(!isset($_GET['id'])){ 926 $error['message'] = 'ID not set'; 927 wp_send_json($error); 928 die(); 929 } 930 931 932 $id = intval(sanitize_text_field($_GET['id'])); 933 $cache_key = substr('wiycw_'.$id, 0, 44); 934 $response = get_transient($cache_key); 935 936 if(empty($response)) { 937 938 $params = array( 939 'id' => $id, 940 's' => get_site_url(), 941 'v' => WIYCW_VERSION, 942 'c' => 'true' 943 ); 944 945 $url = add_query_arg($params, 'https://eltiempoen.com/api/weather/widget'); 946 $arg = array('sslverify' => false, 'timeout' => 10); 947 948 $request = wp_remote_get($url, $arg); 949 950 if(!is_wp_error($request) && ($request['response']['code'] == 200 || $request['response']['code'] == 201)) { 951 $response = wp_remote_retrieve_body($request); 952 set_transient($cache_key, $response, MINUTE_IN_SECONDS * 30); 953 }else{ 954 if(is_wp_error($request)){ 955 $error['message'] = $request->get_error_message(); 956 }else{ 957 $error['message'] = 'Response code: '.$request['response']['code']; 936 958 } 937 938 $params = array( 939 'id' => $id, 940 's' => get_site_url(), 941 'v' => WIYCW_VERSION, 942 'c' => 'true' 943 ); 944 945 $url = add_query_arg($params, 'https://eltiempoen.com/api/weather/widget'); 946 $arg = array('sslverify' => false, 'timeout' => 10); 947 948 $request = wp_remote_get($url, $arg); 949 950 if(!is_wp_error($request) && ($request['response']['code'] == 200 || $request['response']['code'] == 201)) { 951 $response = wp_remote_retrieve_body($request); 952 file_put_contents($cache_file, serialize($response), LOCK_EX); 953 wp_send_json(json_decode($response)); 954 }else{ 955 $response['error'] = true; 956 if(is_wp_error($request)){ 957 $response['message'] = $request->get_error_message(); 958 }else{ 959 $response['message'] = 'Response code: '.$request['response']['code']; 960 } 961 wp_send_json($response); 962 } 963 964 } else { 965 $response['error'] = true; 966 $response['message'] = 'ID not set'; 967 wp_send_json($response); 959 960 wp_send_json($error); 961 die(); 968 962 } 969 970 } catch (Exception $e) { 971 echo 'Caught exception: ', $e->getMessage(), "\n"; 963 972 964 } 973 965 966 wp_send_json(json_decode($response)); 967 974 968 } 975 969
Note: See TracChangeset
for help on using the changeset viewer.