capsx

CHANGES - TAGDIV NewsPaper 8.11->8.2

Nov 20th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 29.27 KB | None | 0 0
  1. CHANGES: 8.11->8.2
  2.  
  3. Files changed:
  4.  
  5. /style.css
  6. /includes/td-config.php
  7. /includes/wp_booster/td_js_generator.php
  8. /includes/wp_booster/td_weather.php
  9. /includes/wp_booster/wp-admin/css/wp-admin.css
  10. /includes/wp_booster/wp-admin/css/wp-panels/demos.less
  11. /includes/wp_booster/wp-admin/panel/views/td_panel_header.php
  12. /js/tadiv_theme.min.js
  13. /js/tadiv_theme.js
  14. /parts/header/top-menu.php
  15.  
  16. DETAILED CHANGES: see - https://pastebin.com/t1NgGYTs
  17.  
  18. /style.css
  19. 5c5
  20. < Version:      8.1.1
  21. ---
  22. > Version:      8.2
  23. 7141c7141
  24. <   max-width: 100% !important;
  25. ---
  26. >   max-width: 100%;
  27.  
  28. /includes/td-config.php
  29. 7c7
  30. < define("TD_THEME_VERSION", "8.1.1");
  31. ---
  32. > define("TD_THEME_VERSION", "8.2");
  33. 4264a4265,4274
  34. >                             "param_name" => "w_key",
  35. >                             "type" => "textfield",
  36. >                             "value" => '',
  37. >                             "heading" => "Weather api key",
  38. >                             "description" => '<a href="https://forum.tagdiv.com/weather-widget/" target="_blank">How to get an api key</a>',
  39. >                             "holder" => "div",
  40. >                             "class" => "",
  41. >                             'group' => 'Weather'
  42. >                         ),
  43. >                       array(
  44.  
  45. /includes/wp_booster/td_js_generator.php
  46. 59,72d58
  47. <
  48. <         // get months and days
  49. <         global $wp_locale;
  50. <         $monthNames = array_map(array($wp_locale, 'get_month'), range(1, 12));
  51. <         $monthNamesShort = array_map(array($wp_locale, 'get_month_abbrev'), $monthNames);
  52. <         $dayNames = array_map(array($wp_locale, 'get_weekday'), range(0, 6));
  53. <         $dayNamesShort = array_map(array($wp_locale, 'get_weekday_abbrev'), $dayNames);
  54. <
  55. <         td_js_buffer::add_variable('tdDateNamesI18n', array(
  56. <             "month_names" => $monthNames,
  57. <             "month_names_short" => $monthNamesShort,
  58. <             "day_names" => $dayNames,
  59. <             "day_names_short" => $dayNamesShort
  60. <         ));
  61. 73a60,72
  62. >  
  63. >   // global used by tdDatei18n.js
  64. >   global $wp_locale;
  65. >   $monthNames = array_map(array($wp_locale, 'get_month'), range(1, 12));
  66. >   $monthNamesShort = array_map(array($wp_locale, 'get_month_abbrev'), $monthNames);
  67. >   $dayNames = array_map(array($wp_locale, 'get_weekday'), range(0, 6));
  68. >   $dayNamesShort = array_map(array($wp_locale, 'get_weekday_abbrev'), $dayNames);
  69. >   td_js_buffer::add_variable('tdDateNamesI18n', array(
  70. >       "month_names" => $monthNames,
  71. >       "month_names_short" => $monthNamesShort,
  72. >       "day_names" => $dayNames,
  73. >       "day_names_short" => $dayNamesShort
  74. >   ));
  75.  
  76. /includes/wp_booster/td_weather.php
  77. 8c8,9
  78. < class td_weather {
  79. ---
  80. > class td_weather
  81. > {
  82. 11d11
  83. <   private static $caching_overtime = 315360000; // 60 * 60 * 24 * 365 * 10
  84. 14,31c14,16
  85. <   private static $owm_api_keys = array (
  86. <       'e5342a41a77f36d7802f350362aa6725',
  87. <       '5f0e41b16ad3752a1ccb886bceb5ed51',
  88. <       '5893ae71fbc9d28b832691406f6ba39b',
  89. <       '93d95bd6e3378a6cb7c7e3e6f6cb5483',
  90. <       '44458592cde0010a8a963db522bf6be5',
  91. <       '9c252c3f1a0036ea446f45651330701e',
  92. <       '0c3f5c17cf5499acaabff3ff594eec5c',
  93. <       '2b08ac14030ba455470237725275d7f8',
  94. <       'c3075d0842fb57c51faada7fc3cbba6b',
  95. <       'f5dc074e364b4d0bbaacbab0030031a3',
  96. <       '17aa0dd026f22e09f52ad000002991c6',
  97. <       '849339ce83cba73963c74b390cba23dd',
  98. <       '6dc28d5e9e6ef985034b6e9d153e73c7',
  99. <       'f166e0697a8541984a1c4dce5221f592',
  100. <       'd24d6df2a159679a31cf70400e87a26c'
  101. <   );
  102. <
  103. ---
  104. > //    private static $owm_api_keys = array (
  105. > //        //'4d99fdabeab40f86485ab0cdefab561b',
  106. > //    );
  107. 40c25,30
  108. <   static function render_generic($atts, $block_uid, $template = 'block_template') {
  109. ---
  110. >   static function render_generic($atts, $block_uid, $template = 'block_template')
  111. >   {
  112. >
  113. >       if (empty($atts['w_key']) and empty($atts['w_location'])) {
  114. >           return td_util::get_block_error('Weather widget', "Configure this block/widget's settings to get weather");
  115. >       }
  116. 43,44c33,37
  117. <           return td_util::get_block_error('Weather', '<strong>Location field</strong> is empty. Configure this block/widget and enter a location and we\'ll show the weather from that location.');
  118. <           //return self::error('<div class="td-block-missing-settings"><span>weather widget</span> <strong>Location field</strong> is empty. Configure this block/widget and enter a location and we\'ll show the weather from that location.</div>');
  119. ---
  120. >           return td_util::get_block_error('Weather widget', "<strong>Location</strong> is empty. Configure this block/widget and enter a location and we will show the weather from that location :)");
  121. >       }
  122. >
  123. >       if (empty($atts['w_key'])) {
  124. >           return td_util::get_block_error('Weather widget', "<strong>Api key</strong> is empty. Configure this block/widget and enter an api key :)");
  125. 46a40
  126. >
  127. 58c52
  128. <       $weather_data = array (
  129. ---
  130. >       $weather_data = array(
  131. 63c57
  132. <           //'api_key' => self::get_a_owm_key(),
  133. ---
  134. >           'api_key' => $atts['w_key'],
  135. 66c60
  136. <           'today_temp' => array (
  137. ---
  138. >           'today_temp' => array(
  139. 71c65
  140. <           'today_wind_speed' => array (
  141. ---
  142. >           'today_wind_speed' => array(
  143. 75c69
  144. <           'today_min' => array (
  145. ---
  146. >           'today_min' => array(
  147. 79c73
  148. <           'today_max' => array (
  149. ---
  150. >           'today_max' => array(
  151. 90c84
  152. <       // td_remote_cache::_disable_cache();
  153. ---
  154. >       //td_remote_cache::_disable_cache();
  155. 103c97
  156. <       $buffy = '<!-- td weather source: ' . $weather_data_status  . ' -->';
  157. ---
  158. >       $buffy = '<!-- td weather source: ' . $weather_data_status . ' -->';
  159. 122c116
  160. <                   tdWeather.addItem(<?php echo json_encode( $weather_data ) ?>);
  161. ---
  162. >                   tdWeather.addItem(<?php echo json_encode($weather_data) ?>);
  163. 128c122
  164. <           td_js_buffer::add_to_footer( "\n" . td_util::remove_script_tag( ob_get_clean() ) );
  165. ---
  166. >           td_js_buffer::add_to_footer("\n" . td_util::remove_script_tag(ob_get_clean()));
  167. 143c137,138
  168. <   private static function render_top_bar_template($atts, $weather_data, $current_temp_label) {
  169. ---
  170. >   private static function render_top_bar_template($atts, $weather_data, $current_temp_label)
  171. >   {
  172. 171c166,167
  173. <   private static function render_block_template($atts, $weather_data, $current_temp_label, $current_speed_label, $block_uid) {
  174. ---
  175. >   private static function render_block_template($atts, $weather_data, $current_temp_label, $current_speed_label, $block_uid)
  176. >   {
  177. 179c175
  178. <           <i class="td-location-icon td-icons-location"  data-block-uid="<?php echo $weather_data['block_uid'] ?>"></i>
  179. ---
  180. >           <i class="td-location-icon td-icons-location" data-block-uid="<?php echo $weather_data['block_uid'] ?>"></i>
  181. 184c180,181
  182. <               <input id="<?php echo $weather_data['block_uid'] ?>" class="td-location-set-input" type="text" name="location" value="" >
  183. ---
  184. >               <input id="<?php echo $weather_data['block_uid'] ?>" class="td-location-set-input" type="text"
  185. >                      name="location" value="">
  186. 192c189,191
  187. <                   <span class="td_animation_sprite-27-100-80-0-0-1 <?php echo $weather_data['today_icon'] ?> td-w-today-icon" data-td-block-uid="<?php echo $block_uid?>"></span>
  188. ---
  189. >                   <span
  190. >                       class="td_animation_sprite-27-100-80-0-0-1 <?php echo $weather_data['today_icon'] ?> td-w-today-icon"
  191. >                       data-td-block-uid="<?php echo $block_uid ?>"></span>
  192. 202c201,202
  193. <                       <span class="td-small-degrees td-w-high-temp"><?php echo $weather_data['today_max'][$current_unit] ?></span>
  194. ---
  195. >                       <span
  196. >                           class="td-small-degrees td-w-high-temp"><?php echo $weather_data['today_max'][$current_unit] ?></span>
  197. 207c207,208
  198. <                       <span class="td-small-degrees td-w-low-temp"><?php echo $weather_data['today_min'][$current_unit] ?></span>
  199. ---
  200. >                       <span
  201. >                           class="td-small-degrees td-w-low-temp"><?php echo $weather_data['today_min'][$current_unit] ?></span>
  202. 218c219,220
  203. <                   <span class="td-weather-parameter td-w-today-humidity"><?php echo $weather_data['today_humidity'] ?>%</span>
  204. ---
  205. >                   <span class="td-weather-parameter td-w-today-humidity"><?php echo $weather_data['today_humidity'] ?>
  206. >                       %</span>
  207. 222c224,225
  208. <                   <span class="td-weather-parameter td-w-today-wind-speed"><?php echo $weather_data['today_wind_speed'][$current_unit] . $current_speed_label; ?></span>
  209. ---
  210. >                   <span
  211. >                       class="td-weather-parameter td-w-today-wind-speed"><?php echo $weather_data['today_wind_speed'][$current_unit] . $current_speed_label; ?></span>
  212. 226c229,230
  213. <                   <span class="td-weather-parameter td-w-today-clouds"><?php echo $weather_data['today_clouds'] ?>%</span>
  214. ---
  215. >                   <span class="td-weather-parameter td-w-today-clouds"><?php echo $weather_data['today_clouds'] ?>
  216. >                       %</span>
  217. 233c237
  218. <
  219. ---
  220. >               $count = 0;
  221. 234a239,241
  222. >                       if ($count === 5) {
  223. >                           break;
  224. >                       }
  225. 237a245
  226. >
  227. 239c247,248
  228. <                           <span class="td-degrees-<?php echo $forecast_index ?>"><?php echo $day_forecast['day_temp'][$current_unit] ?></span>
  229. ---
  230. >                           <span
  231. >                               class="td-degrees-<?php echo $forecast_index ?>"><?php echo $day_forecast['day_temp'][$current_unit] ?></span>
  232. 243a253
  233. >               $count++;
  234. 247a258
  235. >
  236. 253d263
  237. <
  238. 261c271,272
  239. <   private static function get_weather_data($atts, &$weather_data) {
  240. ---
  241. >   private static function get_weather_data($atts, &$weather_data)
  242. >   {
  243. 265c276
  244. <           $available_locales = array( 'en', 'es', 'sp', 'fr', 'it', 'de', 'pt', 'ro', 'pl', 'ru', 'uk', 'ua', 'fi', 'nl', 'bg', 'sv', 'se', 'ca', 'tr', 'hr', 'zh', 'zh_tw', 'zh_cn', 'hu' );
  245. ---
  246. >           $available_locales = array('en', 'es', 'sp', 'fr', 'it', 'de', 'pt', 'ro', 'pl', 'ru', 'uk', 'ua', 'fi', 'nl', 'bg', 'sv', 'se', 'ca', 'tr', 'hr', 'zh', 'zh_tw', 'zh_cn', 'hu');
  247. 268c279
  248. <           if( in_array( $sytem_locale , $available_locales ) ) {
  249. ---
  250. >           if (in_array($sytem_locale, $available_locales)) {
  251. 272c283
  252. <           if( in_array(substr($sytem_locale, 0, 2), $available_locales ) ) {
  253. ---
  254. >           if (in_array(substr($sytem_locale, 0, 2), $available_locales)) {
  255. 280a292,293
  256. >           $today_api_data = self::owm_get_today_data($atts, $weather_data);
  257. >           $forecast_api_data = self::owm_get_five_days_data($atts, $weather_data);
  258. 283,307c296,300
  259. <
  260. <           // The array of keys that have been checked
  261. <           $avoid_keys = array();
  262. <
  263. <           // The flag marks we need a 'today' check
  264. <           $atts['w_type'] = 'today';
  265. <
  266. <           $response = self::get_weather_data_method($atts, $cache_key, true, $weather_data, $avoid_keys);
  267. <
  268. <           if (isset($response)) {
  269. <               return $response;
  270. <           }
  271. <
  272. <           $remaining_keys = array_diff(self::$owm_api_keys, $avoid_keys);
  273. <
  274. <           // The flag marks we need a 'forecast' check
  275. <           $atts['w_type'] = 'forecast';
  276. <
  277. <           if (empty($remaining_keys)) {
  278. <
  279. <               // It means that just one key was available, so now, we give a try, using again the entire set of keys
  280. <               $response = self::get_weather_data_method($atts, $cache_key, true, $weather_data);
  281. <
  282. <               if (isset($response)) {
  283. <                   return $response;
  284. ---
  285. >           if ($today_api_data !== true or $forecast_api_data !== true) {
  286. >               // we have an error on one of the apis
  287. >               $weather_data = td_remote_cache::get(__CLASS__, $cache_key);
  288. >               if ($weather_data === false) {    // miss and io error... shit / die
  289. >                   return self::error('Weather API error: ' . $today_api_data . ' ' . $forecast_api_data);
  290. 309d301
  291. <           } else {
  292. 311,323c303,304
  293. <               // - First, try to get keys from the $remaining_keys array, and when we finish, get the already used $avoid_keys to reuse them
  294. <               // - The cache is not checked, because we'll do it when we check again using the previously avoided keys
  295. <
  296. <               self::get_weather_data_method($atts, $cache_key, false, $weather_data, $avoid_keys);
  297. <
  298. <               if ($weather_data['api_key'] === null) {
  299. <
  300. <                   // It means that the $remaining_keys array was exhausted, so, as we said, get the already used $avoid_keys to reuse them
  301. <                   $response_using_avoided_keys = self::get_weather_data_method($atts, $cache_key, true, $weather_data, $remaining_keys);
  302. <                   if (isset($response_using_avoided_keys)) {
  303. <                       return $response_using_avoided_keys;
  304. <                   }
  305. <               }
  306. ---
  307. >               td_remote_cache::extend(__CLASS__, $cache_key, self::$caching_time);
  308. >               return 'api_fail_cache';
  309. 332,358c313
  310. <
  311. <           if ( $weather_data === false ) {
  312. <
  313. <               // It means an error has happened at the getting weather data, so an non expired cache value has been set for this $cache_key
  314. <               return '';
  315. <           } else {
  316. <               return 'cache';
  317. <           }
  318. <       }
  319. <   }
  320. <
  321. <
  322. <   private static function get_weather_data_method($atts, $cache_key, $check_the_cache, &$weather_data, &$avoid_keys = array()) {
  323. <
  324. <       // The method used is given by the $atts['w_type'] attribute
  325. <       switch ($atts['w_type']) {
  326. <           case 'today': $method = 'owm_get_today_data'; break;
  327. <           case 'forecast': $method = 'owm_get_five_days_data'; break;
  328. <       }
  329. <
  330. <       $weather_data['api_key'] = self::get_a_owm_key($avoid_keys);
  331. <       $api_data = self::$method($atts, $weather_data);
  332. <
  333. <       while ( $api_data !== true && $weather_data['api_key'] !== null) {
  334. <           $avoid_keys[] = $weather_data['api_key'];
  335. <           $weather_data['api_key'] = self::get_a_owm_key($avoid_keys);
  336. <           $api_data = self::$method($atts, $weather_data);
  337. ---
  338. >           return 'cache';
  339. 361,378d315
  340. <       // - Check will be done only when we didn't get api data and we can check the cache
  341. <       // - We do not allow cache checking when the weather data is obtained using a subset of the available keys
  342. <       // (the cache checking allowed only when all keys were used)
  343. <       if ($api_data !== true && $check_the_cache) {
  344. <
  345. <           $weather_data = td_remote_cache::get(__CLASS__, $cache_key);
  346. <           if ($weather_data === false) {
  347. <
  348. <               // - If we allow cache checking (all api weather keys have been used) and there's nothing in cache, we set non expiring cache time
  349. <               // - Important! This will not allow any further api weather checks for this $cache_key (which represents a location)
  350. <               td_remote_cache::set(__CLASS__, $cache_key, false, self::$caching_overtime);
  351. <
  352. <               return self::error('Weather API error: ' . $api_data);
  353. <           }
  354. <
  355. <           td_remote_cache::extend(__CLASS__, $cache_key, self::$caching_time);
  356. <           return 'api_fail_cache';
  357. <       }
  358. 382d318
  359. <
  360. 392,393c328,330
  361. <   private static function owm_get_today_data($atts, &$weather_data) {
  362. <       $today_weather_url = 'http://api.openweathermap.org/data/2.5/weather?q=' . urlencode($atts['w_location']) . '&lang=' . $atts['w_language'] . '&units=metric&appid=' . $weather_data['api_key'];
  363. ---
  364. >   private static function owm_get_today_data($atts, &$weather_data)
  365. >   {
  366. >       $today_weather_url = 'https://api.openweathermap.org/data/2.5/weather?q=' . urlencode($atts['w_location']) . '&lang=' . $atts['w_language'] . '&units=metric&appid=' . $weather_data['api_key'];
  367. 404c341
  368. <             td_log::log(__FILE__, __FUNCTION__, 'Api call failed', $today_weather_url);
  369. ---
  370. >           td_log::log(__FILE__, __FUNCTION__, 'Api call failed', $today_weather_url);
  371. 411c348
  372. <             td_log::log(__FILE__, __FUNCTION__, 'Error decoding the json', $api_response);
  373. ---
  374. >           td_log::log(__FILE__, __FUNCTION__, 'Error decoding the json', $api_response);
  375. 428d364
  376. <
  377. 474c410
  378. <           $icons = array (
  379. ---
  380. >           $icons = array(
  381. 506,508c442
  382. <
  383. <
  384. <
  385. ---
  386. >  
  387. 518c452,453
  388. <   private static function owm_get_five_days_data ($atts, &$weather_data) {
  389. ---
  390. >   private static function owm_get_five_days_data($atts, &$weather_data)
  391. >   {
  392. 520c455
  393. <       $today_weather_url = 'http://api.openweathermap.org/data/2.5/forecast/daily?q=' . urlencode($atts['w_location']) . '&lang=' . $atts['w_language'] . '&units=metric&cnt=7&appid=' . $weather_data['api_key'];
  394. ---
  395. >       $today_weather_url = 'https://api.openweathermap.org/data/2.5/forecast?q=' . urlencode($atts['w_location']) . '&lang=' . $atts['w_language'] . '&units=metric&cnt=35&appid=' . $weather_data['api_key'];
  396. 531c466
  397. <             td_log::log(__FILE__, __FUNCTION__, 'Api call failed', $today_weather_url);
  398. ---
  399. >           td_log::log(__FILE__, __FUNCTION__, 'Api call failed', $today_weather_url);
  400. 538c473
  401. <             td_log::log(__FILE__, __FUNCTION__, 'Error decoding the json', $api_response);
  402. ---
  403. >           td_log::log(__FILE__, __FUNCTION__, 'Error decoding the json', $api_response);
  404. 541,542c476
  405. <
  406. <
  407. ---
  408. >      
  409. 544,546c478,479
  410. <       $today_date = date( 'Ymd', current_time( 'timestamp', 0 ) );
  411. <
  412. <
  413. ---
  414. >       //$today_date = date('Y-m-d', current_time('timestamp', 0));
  415. >      
  416. 548c481
  417. <           $cnt = 0;
  418. ---
  419. >           $tmp_temps = array();
  420. 554,558c487,508
  421. <                   and !empty($day_forecast['temp']['day'])
  422. <                   and $today_date < date('Ymd', $day_forecast['dt'])  // compare today with the forecast date in the format 20150210, today must be smaller. We have to do this hack
  423. <               ) {                                                     // because the api return UTC time and we may have different timezones on the server. Avoid showing the same day twice
  424. <                   if ($cnt > 4) { // show only 5
  425. <                       break;
  426. ---
  427. >                   and !empty($day_forecast['main']['temp'])
  428. >               ) {// because the api return UTC time and we may have different timezones on the server. Avoid showing the same day twice
  429. >                  
  430. >                   $current_day = date('j', $day_forecast['dt']);
  431. >                  
  432. >                   if (!isset($tmp_temps[$current_day])) {
  433. >                       $tmp_temps[$current_day]= array (
  434. >                           'timestamp' => $day_forecast['dt'],
  435. >                           'day_name' => date_i18n('D', $day_forecast['dt']),
  436. >                           'day_temp' => array(
  437. >                               round($day_forecast['main']['temp_max']),                              // metric
  438. >                               round(self::celsius_to_fahrenheit($day_forecast['main']['temp_max']))  //imperial
  439. >                           ),
  440. >                           'owm_day_index' => $index, // used in js to update only the displayed days when we do api calls from JS
  441. >                       );
  442. >                   } else {
  443. >                      
  444. >                       if ($tmp_temps[$current_day]['day_temp'][0] < round($day_forecast['main']['temp_max'])) {
  445. >
  446. >                           $tmp_temps[$current_day]['day_temp'][0] = round($day_forecast['main']['temp_max']);                               // metric
  447. >                           $tmp_temps[$current_day]['day_temp'][1] = round(self::celsius_to_fahrenheit($day_forecast['main']['temp_max']));  //imperial
  448. >                       }
  449. 560,570d509
  450. <                   $weather_data['forecast'][] = array (
  451. <                       'timestamp' => $day_forecast['dt'],
  452. <                       //'timestamp_readable' => date('Ymd', $day_forecast['dt']),
  453. <                       'day_temp' => array (
  454. <                           round($day_forecast['temp']['day']), // metric
  455. <                           round(self::celsius_to_fahrenheit($day_forecast['temp']['day']))  //imperial
  456. <                       ),
  457. <                       'day_name' => date_i18n('D', $day_forecast['dt']),
  458. <                       'owm_day_index' => $index // used in js to update only the displayed days when we do api calls from JS
  459. <                   );
  460. <                   $cnt++;
  461. 573a513,514
  462. >
  463. >           $weather_data['forecast'] = array_values($tmp_temps);
  464. 580d520
  465. <
  466. 586c526,527
  467. <   private static function celsius_to_fahrenheit ($celsius_degrees) {
  468. ---
  469. >   private static function celsius_to_fahrenheit($celsius_degrees)
  470. >   {
  471. 598d538
  472. <
  473. 604c544,545
  474. <   private static function kmph_to_mph ($kmph) {
  475. ---
  476. >   private static function kmph_to_mph($kmph)
  477. >   {
  478. 609d549
  479. <
  480. 615c555,556
  481. <   private static function error($msg) {
  482. ---
  483. >   private static function error($msg)
  484. >   {
  485. 623,637d563
  486. <
  487. <   private static function get_a_owm_key( $avoid_keys = array() ) {
  488. <
  489. <       if (empty($avoid_keys)) {
  490. <           return self::$owm_api_keys[rand(0, count(self::$owm_api_keys) - 1)];
  491. <       }
  492. <
  493. <       $available_keys = array_values(array_diff(self::$owm_api_keys, $avoid_keys));
  494. <
  495. <       if (empty($available_keys)) {
  496. <           return null;
  497. <       }
  498. <
  499. <       return $available_keys[rand(0, count($available_keys) - 1)];
  500. <   }
  501.  
  502. /includes/wp_booster/wp-admin/css/wp-admin.css
  503. 1318a1319
  504. >   vertical-align: top;
  505. 1320c1321
  506. < .wp-picker-container .button {
  507. ---
  508. > .wp-picker-container input.button {
  509. 1333,1336c1334,1337
  510. < .wp-picker-container .button:hover,
  511. < .wp-picker-container .button:focus,
  512. < .wp-picker-container .button:active,
  513. < .wp-picker-container .button:visited {
  514. ---
  515. > .wp-picker-container input.button:hover,
  516. > .wp-picker-container input.button:focus,
  517. > .wp-picker-container input.button:active,
  518. > .wp-picker-container input.button:visited {
  519. 1341a1343,1344
  520. >   -webkit-transform: none;
  521. >   transform: none;
  522. 1348,1350c1351,1353
  523. <   -webkit-box-shadow: inset 1px 1px 6px -2px rgba(0, 0, 0, 0.4);
  524. <   -moz-box-shadow: inset 1px 1px 6px -2px rgba(0, 0, 0, 0.4);
  525. <   box-shadow: inset 1px 1px 6px -2px rgba(0, 0, 0, 0.4);
  526. ---
  527. >   -webkit-box-shadow: inset 1px 1px 6px -2px rgba(0, 0, 0, 0.4) !important;
  528. >   -moz-box-shadow: inset 1px 1px 6px -2px rgba(0, 0, 0, 0.4) !important;
  529. >   box-shadow: inset 1px 1px 6px -2px rgba(0, 0, 0, 0.4) !important;
  530. 1352c1355,1356
  531. < .wp-picker-container .wp-color-result:after {
  532. ---
  533. > .wp-picker-container .wp-color-result:after,
  534. > .wp-picker-container .wp-color-result .wp-color-result-text {
  535. 1365a1370,1379
  536. > .wp-picker-container .wp-color-result .wp-color-result-text {
  537. >   top: 0;
  538. > }
  539. > .wp-picker-container .wp-color-result.button {
  540. >   height: 32px;
  541. >   padding-left: 35px;
  542. > }
  543. > .wp-picker-container {
  544. >   display: inline-block;
  545. > }
  546. 4186a4201,4202
  547. >   -webkit-transform: none !important;
  548. >   transform: none !important;
  549.  
  550. /includes/wp_booster/wp-admin/css/wp-panels/demos.less
  551. 413a414,415
  552. >   -webkit-transform: none !important;
  553. >     transform: none !important;
  554.  
  555. /includes/wp_booster/wp-admin/panel/views/td_panel_header.php
  556.  
  557. 281a282,296
  558. >   <!-- Weather: api key -->
  559. > <div class="td-box-row td-box-weather">
  560. >     <div class="td-box-description">
  561. >         <span class="td-box-title">Weather api key</span>
  562. >         <p><a href="https://forum.tagdiv.com/weather-widget/" target="_blank">How to get an api key</a></p>
  563. >     </div>
  564. >     <div class="td-box-control-full">
  565. >         <?php
  566. >         echo td_panel_generator::input(array(
  567. >             'ds' => 'td_option',
  568. >             'option_id' => 'tds_weather_key_top_menu'
  569. >         ));
  570. >         ?>
  571. >     </div>
  572. > </div>
  573.  
  574. /js/tadiv_theme.js
  575. 14052c14052
  576. <                 var weather = 'http://api.openweathermap.org/data/2.5/forecast/daily?lat=' + tdWeather._currentLatitude + '&lon=' + tdWeather._currentLongitude + '&units=metric&lang=' + tdWeather._currentItem.api_language + '&appid=' + tdWeather._currentItem.api_key;
  577. ---
  578. >                 var weather = 'http://api.openweathermap.org/data/2.5/forecast?lat=' + tdWeather._currentLatitude + '&lon=' + tdWeather._currentLongitude + '&units=metric&lang=' + tdWeather._currentItem.api_language + '&appid=' + tdWeather._currentItem.api_key;
  579. 14075a14076,14079
  580. >                 //limit forecast to 5 days - api brings 35 x 3 hour intervals and at the end of the day you get 6 days forecast
  581. >                 if (item_index === 5) {
  582. >                     break;
  583. >                 }
  584. 14077c14081
  585. <                 current_forecast.day_temp[0] = tdUtil.round(data.list[current_forecast.owm_day_index].temp.day);        //celsius
  586. ---
  587. >                 current_forecast.day_temp[0] = tdUtil.round(data.list[current_forecast.owm_day_index].main.temp_max);   //celsius
  588. 14150a14155
  589. >                 blockInner.find('.td-day-' + item_index).html(tdWeather._currentItem.forecast[item_index].day_name);
  590. 14281c14286
  591. <                 var weather = 'http://api.openweathermap.org/data/2.5/weather?q=' + encodeURIComponent(location) + '&lang=' + tdWeather._currentItem.api_language + '&units=metric&appid=' + tdWeather._currentItem.api_key;
  592. ---
  593. >                 var weather = 'https://api.openweathermap.org/data/2.5/weather?q=' + encodeURIComponent(location) + '&lang=' + tdWeather._currentItem.api_language + '&units=metric&appid=' + tdWeather._currentItem.api_key;
  594. 14330c14335
  595. <                 var weather = 'http://api.openweathermap.org/data/2.5/forecast/daily?q=' + tdWeather._currentItem.api_location + '&lang=' + tdWeather._currentItem.api_language + '&units=metric&cnt=7&appid=' + tdWeather._currentItem.api_key;
  596. ---
  597. >                 var weather = 'https://api.openweathermap.org/data/2.5/forecast?q=' + tdWeather._currentItem.api_location + '&lang=' + tdWeather._currentItem.api_language + '&units=metric&cnt=35&appid=' + tdWeather._currentItem.api_key;
  598. 14355,14360c14360,14364
  599. <             /**
  600. <              * ---------------------------------------------------------------------------------------------------
  601. <              * go through the api data list and increment the counter when we find a past day or the same as today
  602. <              * ---------------------------------------------------------------------------------------------------
  603. <              */
  604. <             var counter = 0;
  605. ---
  606. >             var newForecast = {},
  607. >                 newForecastIsEmpty = true,
  608. >                 ObjProto = Object.prototype,
  609. >                 hasOwnProperty = ObjProto.hasOwnProperty; //safe reference to the hasOwnProperty function, in case it's been overridden accidentally
  610. >
  611. 14361a14366
  612. >                 if (hasOwnProperty.call(data.list[list_item_index], 'dt')) {
  613. 14363,14364c14368,14369
  614. <                 var timestamp = data.list[list_item_index].dt;
  615. <                 //console.log(timestamp);
  616. ---
  617. >                     var timestamp = data.list[list_item_index].dt,
  618. >                         currentDay = td_date_i18n('Ymd', timestamp);
  619. 14366,14378c14371,14387
  620. <                 //the forecast day in a 'easy to read' format - for testing purposes
  621. <                 var forecast_day_format = td_date_i18n('Y m d, H:i a, T', timestamp);
  622. <                 //console.log(forecast_day_format);
  623. <
  624. <                 var today_date = td_date_i18n('Ymd');
  625. <                 var forecast_day = td_date_i18n('Ymd', timestamp);
  626. <
  627. <                 // compare today with the forecast date in the format 20150210, today must be smaller
  628. <                 if (today_date >= forecast_day){
  629. <                     counter = counter + 1;
  630. <                 }
  631. <
  632. <             }
  633. ---
  634. >                     if (hasOwnProperty.call(newForecast, currentDay) === false) {
  635. >                         newForecast[currentDay] = {
  636. >                             timestamp: timestamp,
  637. >                             day_name: td_date_i18n('D', timestamp),
  638. >                             day_temp: [
  639. >                                 tdUtil.round(data.list[list_item_index].main.temp_max),
  640. >                                 tdUtil.round(tdWeather._celsiusToFahrenheit(data.list[list_item_index].main.temp_max))
  641. >                             ],
  642. >                             owm_day_index: list_item_index
  643. >                         }
  644. >                     } else {
  645. >                         if (newForecast[currentDay].day_temp[0] < tdUtil.round(data.list[list_item_index].main.temp_max)) {
  646. >
  647. >                             newForecast[currentDay].day_temp[0] = tdUtil.round(data.list[list_item_index].main.temp_max);
  648. >                             newForecast[currentDay].day_temp[1] = tdUtil.round(tdWeather._celsiusToFahrenheit(data.list[list_item_index].main.temp_max));
  649. >                         }
  650. >                     }
  651. 14380,14395c14389
  652. <             /**
  653. <              * --------------------------------------------------------------------------------------------------
  654. <              * check the data and set the current forecast day index accordingly
  655. <              * --------------------------------------------------------------------------------------------------
  656. <              */
  657. <             for (var item_index = 0; item_index < tdWeather._currentItem.forecast.length ; item_index++) {
  658. <                 var current_forecast = tdWeather._currentItem.forecast[item_index];
  659. <
  660. <                 //daca indexul ii pe 1 si trebuie trecut pe 2
  661. <                 if (item_index === 0 && counter > 1 && current_forecast.owm_day_index < 2){
  662. <                     var current_forecast_owm_day_index_update_status_2 = true;
  663. <                 }
  664. <
  665. <                 //daca trebuie setat pe 2 actulizeaza indexul curent
  666. <                 if (current_forecast_owm_day_index_update_status_2) {
  667. <                     current_forecast.owm_day_index = current_forecast.owm_day_index + 1;
  668. ---
  669. >                     newForecastIsEmpty = false;
  670. 14396a14391
  671. >             }
  672. 14398,14401d14392
  673. <                 //daca e pe 2 si trebuie trecut pe 1
  674. <                 if (item_index === 0 && counter < 2 && current_forecast.owm_day_index > 1){
  675. <                     var current_forecast_owm_day_index_update_status_1 = true;
  676. <                 }
  677. 14403,14405c14394,14401
  678. <                 //daca trebuie setat pe 1 actulizeaza indexul curent
  679. <                 if (current_forecast_owm_day_index_update_status_1) {
  680. <                     current_forecast.owm_day_index = current_forecast.owm_day_index - 1;
  681. ---
  682. >             if (newForecastIsEmpty === false) {
  683. >                 tdWeather._currentItem.forecast = [];
  684. >                 for (var key in newForecast) {
  685. >                     //limit forecast to 5 days - api brings 35 x 3 hour intervals and at the end of the day you get 6 days forecast
  686. >                     if (tdWeather._currentItem.forecast.length === 5) {
  687. >                         break;
  688. >                     }
  689. >                     tdWeather._currentItem.forecast[tdWeather._currentItem.forecast.length] = newForecast[key];
  690. 14407,14409d14402
  691. <
  692. <                 current_forecast.day_temp[0] = tdUtil.round(data.list[current_forecast.owm_day_index].temp.day);        //celsius
  693. <                 current_forecast.day_temp[1] = tdWeather._celsiusToFahrenheit(current_forecast.day_temp[0]);            //imperial
  694. 14410a14404
  695. >
  696. 14417a14412,14413
  697. >
  698. >
  699.  
  700. /js/tadiv_theme.min.js - see /js/tadiv_theme.js
  701.  
  702. /parts/header/top-menu.php
  703. 7a8
  704. >       $atts['w_key'] = td_util::get_option('tds_weather_key_top_menu');
Advertisement
Add Comment
Please, Sign In to add comment