| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage mod_vikbooking_currencyconverter |
| 5 |
* @author Alessio Gaggii - E4J s.r.l |
| 6 |
* @copyright Copyright (C) 2018 E4J s.r.l. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// No direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
jimport('adapter.module.widget'); |
| 15 |
|
| 16 |
/** |
| 17 |
* Horizontal Search Module implementation for WP |
| 18 |
* |
| 19 |
* @see JWidget |
| 20 |
* @since 1.0 |
| 21 |
*/ |
| 22 |
class ModVikbookingCurrencyconverter_Widget extends JWidget |
| 23 |
{ |
| 24 |
/** |
| 25 |
* Class constructor. |
| 26 |
*/ |
| 27 |
public function __construct() |
| 28 |
{ |
| 29 |
// attach the absolute path of the module folder |
| 30 |
parent::__construct(dirname(__FILE__)); |
| 31 |
|
| 32 |
try |
| 33 |
{ |
| 34 |
/** |
| 35 |
* Convert this widget into a block. |
| 36 |
* |
| 37 |
* @since 1.6.7 |
| 38 |
*/ |
| 39 |
$this->registerBlockType( |
| 40 |
VIKBOOKING_ADMIN_ASSETS_URI, |
| 41 |
[ |
| 42 |
'icon' => 'money-alt', |
| 43 |
'keywords' => [ |
| 44 |
__('VikBooking', 'vikbooking'), |
| 45 |
__('Currency Converter', 'vikbooking'), |
| 46 |
__('Widget'), |
| 47 |
], |
| 48 |
] |
| 49 |
); |
| 50 |
} |
| 51 |
catch (Throwable $error) |
| 52 |
{ |
| 53 |
// there's a conflict with an outdated plugin |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Sanitize widget form values as they are saved. |
| 59 |
* |
| 60 |
* @param array $new_instance Values just sent to be saved. |
| 61 |
* @param array $old_instance Previously saved values from database. |
| 62 |
* |
| 63 |
* @return array Updated safe values to be saved. |
| 64 |
*/ |
| 65 |
public function update($new_instance, $old_instance) |
| 66 |
{ |
| 67 |
$new_instance['title'] = !empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; |
| 68 |
$new_instance['vbonly'] = intval($new_instance['vbonly']) === 1 ? 1 : 0; |
| 69 |
$new_instance['currencynameformat'] = (int)$new_instance['currencynameformat'] > 0 && (int)$new_instance['currencynameformat'] < 4 ? (int)$new_instance['currencynameformat'] : 3; |
| 70 |
|
| 71 |
return $new_instance; |
| 72 |
} |
| 73 |
} |
| 74 |
|