Changeset 3096591
- Timestamp:
- 06/03/2024 07:35:48 AM (21 months ago)
- Location:
- weather-in-any-city-widget/trunk
- Files:
-
- 1 added
- 3 edited
-
README.txt (modified) (1 diff)
-
cache (added)
-
resources/js/WIYCW-widget.js (modified) (1 diff)
-
weather-in-any-city-widget.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
weather-in-any-city-widget/trunk/README.txt
r3095101 r3096591 4 4 Tested up to: 6.5 5 5 Requires PHP: 5.3 6 Stable tag: 1.1.3 16 Stable tag: 1.1.33 7 7 License: GPLv2 or later 8 8 -
weather-in-any-city-widget/trunk/resources/js/WIYCW-widget.js
r3039227 r3096591 104 104 105 105 106 fetchJSONFile( "https://eltiempoen.com:9090/api/widget?id="+widget.dataset.cityid+"&r="+r, function(data){106 fetchJSONFile(widget.dataset.url+"?action="+widget.dataset.action+"&nonce="+widget.dataset.nonce+"&id="+widget.dataset.cityid, function(data){ 107 107 108 108 if(data.error){ -
weather-in-any-city-widget/trunk/weather-in-any-city-widget.php
r3062472 r3096591 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.3 16 * Version: 1.1.33 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.3 1');18 define ('WIYCW_VERSION', '1.1.33'); 19 19 define ('WIYCW_DEF_PLUGIN', 'weather-in-any-city-widget'); 20 20 define ('WIYCW_DEF_BASEURL', plugins_url('', __FILE__)); … … 22 22 23 23 add_action('init', 'WIYCW_textdomain'); 24 24 25 25 26 function WIYCW_textdomain() { … … 61 62 $instance['url_es'] = !empty($instance['url_es']) ? $instance['url_es'] : ""; 62 63 $instance['time_format'] = !empty($instance['time_format']) ? $instance['time_format'] : "universal"; 64 $instance['url'] = admin_url('admin-ajax.php'); 65 $instance['action'] = "WIYCW_get_weather"; 63 66 return $instance; 64 67 } … … 806 809 $output .= " data-textcolor='".esc_attr($instance['textColor'])."'"; 807 810 $output .= " data-shadow='".esc_attr($instance['shadow'])."'"; 811 $output .= " data-url='".esc_attr($instance['url'])."'"; 812 $output .= " data-action='".esc_attr($instance['action'])."'"; 813 $output .= " data-nonce='".esc_attr(wp_create_nonce(WIYCW_VERSION))."'"; 808 814 $output .= " data-bordercolor='".esc_attr($instance['borderColor'])."'"; 809 815 $output .= ">"; … … 912 918 add_action( 'init', 'WIYCW_shortcodes_init' ); 913 919 920 function WIYCW_get_weather(){ 921 922 $response = array(); 923 $response['error'] = false; 924 925 if(isset($_GET['id'])) { 926 927 $id = intval(sanitize_text_field($_GET['id'])); 928 $cache_file = dirname(__FILE__) .'/cache/' . $id . '.txt'; 929 $cache_minutes = 15; 930 931 if(file_exists($cache_file) && (filemtime($cache_file) > (time() - ($cache_minutes * 60)))) { 932 wp_send_json(json_decode(unserialize(file_get_contents($cache_file)))); 933 die(); 934 } 935 936 $url = 'https://eltiempoen.com:9090/api/widget?id='.$id.'&r='.base64_encode(get_site_url()); 937 $arg = array('sslverify' => false); 938 939 $request = wp_remote_get($url, $arg); 940 if(is_wp_error($request)) { 941 return false; 942 }else{ 943 $response['error'] = true; 944 } 945 946 $response = wp_remote_retrieve_body($request); 947 file_put_contents($cache_file, serialize($response), LOCK_EX); 948 949 } else { 950 $response['error'] = true; 951 952 } 953 954 955 wp_send_json(json_decode($response)); 956 } 957 958 add_action('wp_ajax_WIYCW_get_weather', 'WIYCW_get_weather'); 959 add_action('wp_ajax_nopriv_WIYCW_get_weather', 'WIYCW_get_weather'); 960 914 961 ?>
Note: See TracChangeset
for help on using the changeset viewer.