PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/html/wpdash/rss/widget.php +226 -0 1.6.1 → 1.8.16 View file →
@@ -1,0 +1,226 @@
1 +<?php
2 +/**
3 + * @package VikBooking - Libraries
4 + * @subpackage html.wpdash
5 + * @author E4J s.r.l.
6 + * @copyright Copyright (C) 2020 E4J s.r.l. All Rights Reserved.
7 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 + * @link https://vikwp.com
9 + */
10 +
11 +// No direct access
12 +defined('ABSPATH') or die('No script kiddies please!');
13 +
14 +extract($displayData);
15 +
16 +/**
17 + * Layout variables
18 + * -----------------
19 + * @var JRegistry $config The configuration registry
20 + * @var JDashboardWidget $widget The widget instance.
21 + * @var array $feeds A list of feeds.
22 + */
23 +
24 +$document = JFactory::getDocument();
25 +
26 +$internalFilesOptions = array('version' => VIKBOOKING_SOFTWARE_VERSION);
27 +
28 +// system.js must be loaded on both front-end and back-end for tmpl=component support
29 +$document->addScript(VIKBOOKING_ADMIN_ASSETS_URI . 'js/system.js', $internalFilesOptions, array('id' => 'vbo-sys-script'));
30 +$document->addScript(VIKBOOKING_ADMIN_ASSETS_URI . 'js/admin.js', $internalFilesOptions, array('id' => 'vbo-admin-script'));
31 +$document->addScript(VIKBOOKING_ADMIN_ASSETS_URI . 'js/bootstrap.min.js', $internalFilesOptions, array('id' => 'bootstrap-script'));
32 +$document->addStyleSheet(VIKBOOKING_ADMIN_ASSETS_URI . 'css/system.css', $internalFilesOptions, array('id' => 'vbo-sys-style'));
33 +$document->addStyleSheet(VIKBOOKING_ADMIN_ASSETS_URI . 'css/bootstrap.lite.css', $internalFilesOptions, array('id' => 'bootstrap-lite-style'));
34 +
35 +// prepare modal to display opt-in
36 +echo JHtml::fetch(
37 + 'bootstrap.renderModal',
38 + 'jmodal-vbo-rss-feed',
39 + array(
40 + 'title' => '',
41 + 'closeButton' => true,
42 + 'keyboard' => true,
43 + 'top' => true,
44 + 'width' => 70,
45 + 'height' => 80,
46 + ),
47 + '{placeholder}'
48 +);
49 +
50 +?>
51 +
52 +<style>
53 + #vik_booking_rss .inside {
54 + padding: 0 !important;
55 + margin: 0 !important;
56 + }
57 + #vik_booking_rss .modal-header h3 {
58 + margin: 0;
59 + line-height: 50px;
60 + font-weight: normal;
61 + font-size: 22px;
62 + }
63 + #vik_booking_rss .modal-header h3 .dashicons-before:before {
64 + line-height: 50px;
65 + }
66 + #vik_booking_rss img {
67 + max-width: 100%;
68 + }
69 +
70 + .vbo-rss-widget ul {
71 + margin: 0;
72 + padding: 0;
73 + }
74 + .vbo-rss-widget ul li {
75 + list-style: none;
76 + display: flex;
77 + align-items: center;
78 + justify-content: space-between;
79 + flex-wrap: wrap;
80 + margin: 0;
81 + padding: 8px 12px;
82 + border-bottom: 1px solid #eee;
83 + }
84 + .vbo-rss-widget ul li:last-child {
85 + border-bottom: 0;
86 + }
87 + .vbo-rss-widget ul li:nth-child(odd) {
88 + background: #fafafa;
89 + }
90 +
91 + .vbo-rss-widget ul li .feed-icon {
92 + width: 32px;
93 + }
94 + .vbo-rss-widget ul li .feed-details {
95 + flex: 1;
96 + }
97 + .vbo-rss-widget ul li .feed-date-time {
98 + text-align: right;
99 + }
100 +
101 + .vbo-rss-widget .rss-missing-optin {
102 + padding: 10px 10px 0 10px;
103 + }
104 +</style>
105 +
106 +<div class="vbo-rss-widget">
107 +
108 + <?php
109 + // make sure the RSS service is enabled
110 + if (!$config->get('optin'))
111 + {
112 + // service not enabled
113 + ?>
114 + <div class="rss-missing-optin">
115 + <div class="notice notice-error inline">
116 + <p>
117 + <?php _e('<b>You haven\'t opted-in to the RSS service!</b><br />Click the following button to start reading RSS feeds.', 'vikbooking'); ?>
118 + </p>
119 +
120 + <p>
121 + <a href="admin.php?page=vikbooking&task=config#rss" class="button button-primary">
122 + <?php _e('Activate RSS Feeds', 'vikbooking'); ?>
123 + </a>
124 + </p>
125 + </div>
126 + </div>
127 + <?php
128 + }
129 + else
130 + {
131 + ?>
132 + <ul>
133 + <?php
134 + foreach ($feeds as $i => $feed)
135 + {
136 + switch (strtolower($feed->category))
137 + {
138 + case 'promo':
139 + $icon = 'star-filled';
140 + break;
141 +
142 + case 'tips':
143 + $icon = 'welcome-learn-more';
144 + break;
145 +
146 + case 'news':
147 + $icon = 'megaphone';
148 + break;
149 +
150 + default:
151 + $icon = 'rss';
152 + }
153 +
154 + ?>
155 + <li data-id="<?php echo $feed->id; ?>">
156 + <div class="feed-icon">
157 + <span class="dashicons-before dashicons-<?php echo $icon; ?>"></span>
158 + </div>
159 +
160 + <div class="feed-details" data-title="<?php echo $this->escape($feed->title); ?>" data-category="<?php echo $this->escape($feed->category); ?>">
161 + <div class="feed-title">
162 + <a href="javascript: void(0);">
163 + <b><?php echo $feed->title; ?></b>
164 + </a>
165 + </div>
166 + <div class="feed-category"><?php echo $feed->category; ?></div>
167 + </div>
168 +
169 + <div class="feed-date-time">
170 + <div class="feed-date">
171 + <?php echo JHtml::fetch('date', $feed->date, get_option('date_format')); ?>
172 + </div>
173 + <div class="feed-time">
174 + <?php echo JHtml::fetch('date', $feed->date, get_option('time_format')); ?>
175 + </div>
176 + </div>
177 +
178 + <div style="display: none;" class="rss-content">
179 + <?php echo $feed->content; ?>
180 + </div>
181 + </li>
182 + <?php
183 + }
184 + ?>
185 + </ul>
186 + <?php
187 + }
188 + ?>
189 +
190 +</div>
191 +
192 +<script>
193 +
194 + jQuery(function() {
195 +
196 + jQuery('#vik_booking_rss .feed-details a').on('click', function() {
197 + // get parent <li>
198 + var li = jQuery(this).closest('li');
199 + // find feed details
200 + var details = li.find('.feed-details');
201 + // find feed content
202 + var content = li.find('.rss-content').html();
203 +
204 + // get modal
205 + var modal = jQuery('#jmodal-vbo-rss-feed');
206 +
207 + // register feed ID
208 + modal.attr('data-feed-id', li.data('id'));
209 +
210 + // update modal title
211 + modal.find('.modal-header h3').html(
212 + li.find('.feed-icon').html() + ' ' +
213 + details.data('category') + ' - ' +
214 + details.data('title')
215 + );
216 +
217 + // update modal content
218 + modal.find('.modal-body').html(content);
219 +
220 + // display modal
221 + wpOpenJModal('vbo-rss-feed');
222 + });
223 +
224 + });
225 +
226 +</script>