2021-01-08 14:08:40 +01:00
|
|
|
<?php
|
|
|
|
namespace MobilizonConnector;
|
|
|
|
|
|
|
|
// Exit if this file is called directly.
|
|
|
|
if (!defined('ABSPATH')) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
class EventsListWidget extends \WP_Widget {
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct(
|
|
|
|
NAME . '-events-list',
|
2021-05-06 09:22:13 +02:00
|
|
|
NICE_NAME . ' ' . __('Events List', 'connector-mobilizon'),
|
2021-01-08 14:08:40 +01:00
|
|
|
array(
|
2021-05-06 09:22:13 +02:00
|
|
|
'description' => __('A list of the upcoming events of the connected Mobilizon instance.', 'connector-mobilizon'),
|
2021-01-08 14:08:40 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function widget($args, $options) {
|
|
|
|
echo $args['before_widget'];
|
|
|
|
|
|
|
|
if (!empty($options['title'])) {
|
|
|
|
echo $args['before_title'].apply_filters('widget_title', $options['title']).$args['after_title'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$classNamePrefix = NAME;
|
|
|
|
$eventsCount = $options['eventsCount'];
|
2021-05-04 11:16:18 +02:00
|
|
|
$locale = str_replace('_', '-', get_locale());
|
2021-01-15 20:30:05 +01:00
|
|
|
$groupName = isset($options['groupName']) ? $options['groupName'] : '';
|
2021-01-08 14:08:40 +01:00
|
|
|
$url = Settings::getUrl();
|
2021-08-24 19:23:57 +02:00
|
|
|
$timeZone = wp_timezone_string();
|
2021-05-23 15:37:29 +02:00
|
|
|
$isShortOffsetNameShown = Settings::isShortOffsetNameShown();
|
2021-01-08 14:08:40 +01:00
|
|
|
|
|
|
|
require dirname(__DIR__) . '/view/events-list.php';
|
|
|
|
|
|
|
|
echo $args['after_widget'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function form($options) {
|
2021-05-06 09:22:13 +02:00
|
|
|
$title = !empty($options['title']) ? $options['title'] : __('Events', 'connector-mobilizon');
|
2021-01-08 14:08:40 +01:00
|
|
|
$eventsCount = !empty($options['eventsCount']) ? $options['eventsCount'] : DEFAULT_EVENTS_COUNT;
|
2021-01-15 20:30:05 +01:00
|
|
|
$groupName = !empty($options['groupName']) ? $options['groupName'] : '';
|
2021-01-08 14:08:40 +01:00
|
|
|
|
|
|
|
require dirname(__DIR__) . '/view/events-list-widget/form.php';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update($new_options, $old_options) {
|
|
|
|
if (!current_user_can('edit_theme_options')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$options = array();
|
|
|
|
$options['title'] = !empty($new_options['title']) ? sanitize_text_field($new_options['title']) : '';
|
|
|
|
$options['eventsCount'] = !empty($new_options['eventsCount']) ? sanitize_text_field($new_options['eventsCount']) : 5;
|
2021-01-15 20:30:05 +01:00
|
|
|
$options['groupName'] = !empty($new_options['groupName']) ? sanitize_text_field($new_options['groupName']) : '';
|
2021-01-08 14:08:40 +01:00
|
|
|
return $options;
|
|
|
|
}
|
|
|
|
}
|