PluginProbe
WP Directory Kit / 1.2.3
WP Directory Kit v1.2.3
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / application / views / wdk / index.php

index.php in WP Directory Kit 1.2.3, at application/views/wdk/index.php

407 lines 24.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The template for Listings Management.
4 *
5 * This is the template that form edit
6 *
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12 ?>
13
14 <!-- This file should primarily consist of HTML with a little bit of PHP. -->
15 <div class="wrap wdk-wrap">
16 <h1 class="wp-heading-inline"><?php echo __('Listings Management', 'wpdirectorykit'); ?> <a href="<?php echo get_admin_url() . "admin.php?page=wdk_listing"; ?>" class="button button-primary" title="<?php echo esc_attr__('Add Listing','wpdirectorykit');?>" id="add_listing_button"><?php echo __('Add Listing', 'wpdirectorykit'); ?></a></h1>
17 <?php
18 if(!get_option('wdk_listing_page') || get_post_status(get_option('wdk_listing_page')) !='publish'
19 || !get_option('wdk_results_page') || get_post_status(get_option('wdk_results_page')) !='publish'
20 ):?>
21 <div class="notice notice-success">
22 <p>
23 <?php echo __('Listing Preview page or Listings Result page missing','wpdirectorykit'); ?>
24 <a href="<?php echo get_admin_url() . "admin.php?page=wdk_settings&function=import_demo"; ?>" class="button button-primary" id="reset_data_field_button">
25 <?php echo __('Import Demo Data','wpdirectorykit'); ?>
26 </a>
27 </p>
28 </div>
29 <?php endif;?>
30
31 <?php
32 if(class_exists('Wdk\DashWidgets\Widgets\WDK_Dashboard_Widget_Stats_Listings')) {
33 $widget = new Wdk\DashWidgets\Widgets\WDK_Dashboard_Widget_Stats_Listings();
34 $widget -> widget();
35 }
36 ?>
37
38 <form method="GET" action="<?php echo wmvc_current_edit_url(); ?>" novalidate="novalidate">
39 <div class="tablenav top">
40 <div class="alignleft actions">
41 <input type="hidden" name="page" value="wdk" />
42
43 <label class="screen-reader-text" for="location_id"><?php echo __('Filter by location', 'wpdirectorykit'); ?></label>
44 <?php echo wmvc_select_option('location_id', $locations, wmvc_show_data('location_id', $db_data, ''), NULL, __('Location', 'wpdirectorykit')); ?>
45
46 <label class="screen-reader-text" for="category_id"><?php echo __('Filter by category', 'wpdirectorykit'); ?></label>
47 <?php echo wmvc_select_option('category_id', $categories, wmvc_show_data('category_id', $db_data, ''), NULL, __('Category', 'wpdirectorykit')); ?>
48
49 <label class="screen-reader-text" for="user_id_editor"><?php echo esc_html__('Filter by user', 'wpdirectorykit'); ?></label>
50 <?php echo wmvc_select_option('user_id_editor', $users, wmvc_show_data('user_id_editor', $db_data, ''), NULL, __('User', 'wpdirectorykit')); ?>
51
52 <label class="screen-reader-text" for="search"><?php echo __('Filter by keyword', 'wpdirectorykit'); ?></label>
53 <input type="text" name="search" id="search" class="postform left" value="<?php echo wmvc_show_data('search', $db_data, ''); ?>" placeholder="<?php echo __('Filter by keyword', 'wpdirectorykit'); ?>" />
54
55 <label class="screen-reader-text" for="order_by"><?php echo __('Order By', 'wpdirectorykit'); ?></label>
56 <?php echo wmvc_select_option('order_by', $order_by, wmvc_show_data('order_by', $db_data, ''), NULL, __('Order by', 'wpdirectorykit')); ?>
57
58 <input type="submit" name="filter_action" id="post-query-submit" class="button" value="<?php echo __('Filter', 'wpdirectorykit'); ?>">
59
60 <input type="hidden" name="is_featured" value="<?php echo esc_attr(wmvc_show_data('is_featured', $db_data, ''));?>">
61 <input type="hidden" name="is_activated" value="<?php echo esc_attr(wmvc_show_data('is_activated', $db_data, ''));?>">
62 </div>
63 <?php echo wmvc_xss_clean($pagination_output); ?>
64 <br class="clear">
65 </div>
66 </form>
67
68 <?php
69 if (function_exists('PLL')){
70 $pll_langs = pll_the_languages( array( 'raw' => 1 ) );
71 }
72 ?>
73
74 <form method="GET" action="<?php echo wmvc_current_edit_url(); ?>" novalidate="novalidate">
75 <table class="wp-list-table widefat fixed striped table-view-list pages">
76 <thead>
77 <tr>
78 <td id="cb" class="manage-column column-cb check-column"><label class="screen-reader-text" for="cb-select-all-1"><?php echo __('Select All', 'wpdirectorykit'); ?></label><input id="cb-select-all-1" type="checkbox"></td>
79 <th style="width:50px;"><?php echo __('#ID', 'wpdirectorykit'); ?></th>
80 <th><?php echo __('Title', 'wpdirectorykit'); ?></th>
81 <th><?php echo __('Category', 'wpdirectorykit'); ?></th>
82 <th style="text-align: center;"><?php echo __('Image', 'wpdirectorykit'); ?></th>
83 <th><?php echo __('Post Date', 'wpdirectorykit'); ?></th>
84 <?php if (function_exists('PLL')): ?>
85 <?php $pll_langs = pll_the_languages( array( 'raw' => 1 ) );
86 foreach($pll_langs as $pll_lang): ?>
87 <th class="manage-column column-language_<?php echo esc_attr($pll_lang['slug']); ?>"><img src="<?php echo esc_html($pll_lang['flag']); ?>" /></th>
88 <?php endforeach; ?>
89 <?php endif; ?>
90 <th class="actions_column"><?php echo __('Actions', 'wpdirectorykit'); ?></th>
91 </tr>
92 </thead>
93 <tbody>
94 <?php if (count($listings) == 0) : ?>
95 <tr class="no-items">
96 <td class="colspanchange" colspan="7"><?php echo __('No Listings found.', 'wpdirectorykit'); ?></td>
97 </tr>
98 <?php endif; ?>
99 <?php foreach ($listings as $listing) : ?>
100 <tr>
101 <th scope="row" class="check-column">
102 <input id="cb-select-<?php echo wmvc_show_data('ID', $listing, '-'); ?>" type="checkbox" name="post[]" value="<?php echo wmvc_show_data('ID', $listing, '-'); ?>">
103 <div class="locked-indicator">
104 <span class="locked-indicator-icon" aria-hidden="true"></span>
105 <span class="screen-reader-text"><?php echo __('Is Locked', 'wpdirectorykit'); ?></span>
106 </div>
107 </th>
108 <td>
109 <?php echo wmvc_show_data('ID', $listing, '-'); ?>
110 </td>
111 <td class="title column-title has-row-actions column-primary page-title" data-colname="Title">
112 <strong>
113 <a class="row-title" href="<?php echo get_admin_url() . "admin.php?page=wdk_listing&id=" . wmvc_show_data('ID', $listing, '-'); ?>"><?php echo wmvc_show_data('post_title', $listing, '-'); ?></a>
114 <?php if(!wmvc_show_data('is_activated', $listing, 0)): ?>
115 <span class="label label-danger"><?php echo __('Not activated', 'wpdirectorykit'); ?></span>
116 <?php endif; ?>
117 <?php if(!wmvc_show_data('is_approved', $listing, 0) && function_exists('run_wdk_membership')): ?>
118 <span class="label label-danger"><?php echo esc_html__('Not approved', 'wpdirectorykit'); ?></span>
119 <?php endif; ?>
120 <?php if(wmvc_show_data('is_featured', $listing, 0)): ?>
121 <span class="label label-info"><?php echo esc_html__('featured', 'wpdirectorykit'); ?></span>
122 <?php endif; ?>
123 </strong>
124 <div class="row-actions">
125 <span class="edit"><a href="<?php echo get_admin_url() . "admin.php?page=wdk_listing&id=" . wmvc_show_data('ID', $listing, '-'); ?>"><?php echo __('Edit', 'wpdirectorykit'); ?></a> | </span>
126 <span class="trash "><a href="<?php echo get_admin_url() . "admin.php?page=wdk&function=delete&paged=".esc_attr($paged)."&id=" . wmvc_show_data('ID', $listing, '-'); ?>&_wpnonce=<?php echo wp_create_nonce( 'wdk-listing-delete_'.wmvc_show_data('ID', $listing, '-'));?>" class="submitdelete question_sure"><?php echo __('Delete', 'wpdirectorykit'); ?></a> | </span>
127 <span class="view"><a href="<?php echo get_permalink($listing); ?>" target="blank"><?php echo __('View', 'wpdirectorykit'); ?></a></span>
128 </div>
129
130
131 <?php if(get_option('wdk_sub_listings_enable')): ?>
132 <?php if(!empty(wmvc_show_data('listing_related_ids', $listing))):?>
133 <div class="">
134 <a href="#" class="laoding_sublistings" data-listing_id = '<?php echo esc_attr(wmvc_show_data('ID', $listing, '-'));?>'><?php echo esc_html__('Show Related','wpdirectorykit');?></a>
135 </div>
136 <?php endif; ?>
137 <?php endif; ?>
138 </td>
139
140 <td>
141
142 <?php echo wmvc_show_data($listing->category_id, $categories, '-'); ?>
143 <?php
144 $other_categories = wdk_generate_other_categories_fast($listing->categories_list);
145
146 if(!empty($other_categories)):?>
147 <br>
148 <span style="display: inline-block;padding-top: 10px;" ><?php echo esc_html(join(', ',$other_categories));?></span>
149 <?php endif;?>
150 </td>
151 <td style="text-align: center;">
152 <a class="img-link" href="<?php echo get_admin_url() . "admin.php?page=wdk_listing&id=" . wmvc_show_data('ID', $listing, '-'); ?>">
153 <img src="<?php echo esc_url(wdk_image_src($listing));?>" alt="thumb" style="height:70px;width:110px;object-fit:cover;text-align: center;"/>
154 </a>
155 </td>
156 <td>
157 <?php echo wdk_get_date($listing->post_date, false); ?>
158 </td>
159 <?php if (function_exists('PLL')): ?>
160 <?php foreach($pll_langs as $pll_lang): ?>
161 <?php if($pll_lang['slug'] == pll_get_post_language($listing->post_id, 'slug' )): ?>
162 <td><img src="<?php echo esc_html($pll_lang['flag']); ?>" /></td>
163 <?php else: ?>
164 <td><a class="pll_icon_edit translation_<?php echo esc_attr($listing->post_id); ?>" href="<?php echo get_admin_url() . "admin.php?page=wdk_listing&id=" . pll_get_post( $listing->post_id, $pll_lang['slug'] ); ?>"></a></td>
165 <?php endif; ?>
166 <?php endforeach; ?>
167 <?php endif; ?>
168 <td class="actions_column">
169 <a href="<?php echo get_permalink($listing); ?>" title="<?php echo esc_attr__('View','wpdirectorykit');?>" target="blank"><span class="dashicons dashicons-visibility"></span></a>
170 <a href="<?php echo get_admin_url() . "admin.php?page=wdk_listing&id=" . wmvc_show_data('ID', $listing, '-'); ?>" title="<?php echo esc_attr__('Edit','wpdirectorykit');?>"><span class="dashicons dashicons-edit"></span></a>
171 <a class="question_sure" href="<?php echo get_admin_url() . "admin.php?page=wdk&function=delete&paged=".esc_attr($paged)."&id=" . wmvc_show_data('ID', $listing, '-'); ?>&_wpnonce=<?php echo wp_create_nonce( 'wdk-listing-delete_'.wmvc_show_data('ID', $listing, '-'));?>" title="<?php echo esc_attr__('Remove','wpdirectorykit');?>"><span class="dashicons dashicons-no"></span></a>
172 </td>
173 </tr>
174
175 <?php if(get_option('wdk_sub_listings_enable')): ?>
176 <?php if(!empty(wmvc_show_data('listing_related_ids', $listing))):?>
177 <?php if(false)foreach (explode(',',wmvc_show_data('listing_related_ids', $listing, '')) as $key => $child_idlisting):?>
178 <tr class="child">
179 <th scope="row"></th>
180 <td scope="row"></td>
181 <td colspan="1">
182 <a target="_blank" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&id='.$child_idlisting));?>"><?php echo esc_html('#'.$child_idlisting.', '.wdk_field_value('post_title', $child_idlisting));?></a>
183 </td>
184 <td>
185 <?php echo wdk_field_value('category_id', $categories); ?>
186 </td>
187 <td style="text-align: center;">
188 <a class="img-link" href="<?php echo get_admin_url() . "admin.php?page=wdk_listing&id=" . $child_idlisting; ?>">
189 <img src="<?php echo esc_url(wdk_image_src(array('listing_images'=>wdk_field_value('listing_images', $child_idlisting))));?>" alt="thumb" style="height:50px;width:65px;object-fit:cover;text-align: center;"/>
190 </a>
191 </td>
192 <td>
193 <?php echo wdk_get_date(wdk_field_value('date', $child_idlisting), false); ?>
194 </td>
195 <td class="actions_column">
196 <a href="<?php echo get_permalink($child_idlisting); ?>" title="<?php echo esc_attr__('View','wpdirectorykit');?>" target="blank"><span class="dashicons dashicons-visibility"></span></a>
197 <a href="<?php echo get_admin_url() . "admin.php?page=wdk_listing&id=" . $child_idlisting; ?>" title="<?php echo esc_attr__('Edit','wpdirectorykit');?>"><span class="dashicons dashicons-edit"></span></a>
198 <a class="question_sure" href="<?php echo get_admin_url() . "admin.php?page=wdk&function=delete&paged=".esc_attr($paged)."&id=" . $child_idlisting; ?>&_wpnonce=<?php echo wp_create_nonce( 'wdk-listing-delete_'.wmvc_show_data('ID', $listing, '-'));?>" title="<?php echo esc_attr__('Remove','wpdirectorykit');?>"><span class="dashicons dashicons-no"></span></a>
199 </td>
200 </tr>
201 <?php endforeach;?>
202 <?php endif;?>
203 <?php endif;?>
204 <?php endforeach;?>
205 </tbody>
206 <tfoot>
207 <tr>
208 <td class="manage-column column-cb check-column"><label class="screen-reader-text" for="cb-select-all-2"><?php echo __('Select All', 'wpdirectorykit'); ?></label><input id="cb-select-all-2" type="checkbox"></td>
209 <th style="width:50px;"><?php echo __('#ID', 'wpdirectorykit'); ?></th>
210 <th><?php echo __('Title', 'wpdirectorykit'); ?></th>
211 <th><?php echo __('Category', 'wpdirectorykit'); ?></th>
212 <th style="text-align: center;"><?php echo __('Image', 'wpdirectorykit'); ?></th>
213 <th><?php echo __('Post Date', 'wpdirectorykit'); ?></th>
214 <?php if (function_exists('PLL')): ?>
215 <?php foreach($pll_langs as $pll_lang): ?>
216 <th><img src="<?php echo esc_html($pll_lang['flag']); ?>" /></th>
217 <?php endforeach; ?>
218 <?php endif; ?>
219 <th class="actions_column"><?php echo __('Actions', 'wpdirectorykit'); ?></th>
220 </tr>
221 </tfoot>
222 </table>
223 <div class="tablenav bottom">
224 <div class="alignleft actions bulkactions">
225 <?php wp_nonce_field( 'wdk-listing-bulk', '_wpnonce'); ?>
226 <label for="bulk-action-selector-bottom" class="screen-reader-text"><?php echo __('Select bulk action', 'wpdirectorykit'); ?></label>
227 <select name="action" id="bulk-action-selector-bottom">
228 <option value="-1"><?php echo __('Bulk actions', 'wpdirectorykit'); ?></option>
229 <option value="delete" class="hide-if-no-js"><?php echo __('Delete', 'wpdirectorykit'); ?></option>
230 <option value="deactivate" class="hide-if-no-js"><?php echo __('Deactivate', 'wpdirectorykit'); ?></option>
231 <option value="activate" class="hide-if-no-js"><?php echo __('Activate', 'wpdirectorykit'); ?></option>
232 <?php if(function_exists('run_wdk_membership')):?>
233 <option value="deapprove" class="hide-if-no-js"><?php echo __('Deapprove', 'wpdirectorykit'); ?></option>
234 <option value="approve" class="hide-if-no-js"><?php echo __('Approve', 'wpdirectorykit'); ?></option>
235 <?php endif;?>
236 </select>
237 <input type="hidden" name="page" value="wdk" />
238 <input type="submit" id="table_action" class="button action" name="table_action" value="<?php echo esc_attr__('Apply', 'wpdirectorykit'); ?>">
239 </div>
240
241 <?php echo wmvc_xss_clean($pagination_output); ?>
242 <br class="clear">
243 </div>
244 </form>
245 </div>
246 <?php
247 wp_enqueue_style('wdk-notify');
248 wp_enqueue_script('wdk-notify');
249 ?>
250 <script>
251 // Generate table
252 jQuery(document).ready(function($) {
253
254 $('.question_sure').on('click', function() {
255 return confirm("<?php echo esc_js(__('Are you sure? Selected item will be completely removed!', 'wpdirectorykit')); ?>");
256 });
257 wdk_loading_sublistings();
258 });
259
260 const wdk_loading_sublistings = ($selector_btn = '.laoding_sublistings') => {
261 var init,action,event, eventRemove;
262
263 event = (elem) => {
264 var listing_id = jQuery(elem).attr('data-listing_id');
265 var self = jQuery(elem);
266
267 if(self.attr('disabled')) {
268 return false;
269 }
270
271 self.addClass('wdk_btn_load_indicator out');
272 self.attr('disabled','disabled');
273
274 var ajax_param = {
275 "page": 'wdk_backendajax',
276 "function": 'loading_sublistings',
277 "action": 'wdk_public_action',
278 "listing_id": listing_id,
279 "_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-backendajax'));?>',
280 };
281
282 jQuery.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param,
283 function(data){
284
285 if(data.popup_text_success)
286 wdk_log_notify(data.popup_text_success);
287
288 if(data.popup_text_error)
289 wdk_log_notify(data.popup_text_error, 'error');
290
291 self.removeClass('wdk_btn_load_indicator out');
292
293 data.results
294 var html = '';
295 jQuery.each(data.results, function(index, value){
296 html += '<tr class="child">\n\
297 <th scope="row"></th>\n\
298 <td scope="row">'+value.post_id+'</td>\n\
299 <td colspan="1">\n\
300 <a target="_blank" href="'+value.listing_edit_url+'">'+value.post_title+'</a>\n\
301 </td>\n\
302 <td>\n\
303 '+value.category+'\n\
304 </td>\n\
305 <td style="text-align: center;">\n\
306 <a class="img-link" href="'+value.listing_edit_url+'">\n\
307 <img src="'+value.image_src+'" alt="thumb" style="height:50px;width:65px;object-fit:cover;text-align: center;"/>\n\
308 </a>\n\
309 </td>\n\
310 <td>\n\
311 '+value.date+'\n\
312 </td>\n\
313 <td class="actions_column">\n\
314 <a href="'+value.listing_view_url+'" title="<?php echo esc_attr__('View','wpdirectorykit');?>" target="blank"><span class="dashicons dashicons-visibility"></span></a>\n\
315 <a href="'+value.listing_edit_url+'" title="<?php echo esc_attr__('Edit','wpdirectorykit');?>"><span class="dashicons dashicons-edit"></span></a>\n\
316 <a class="question_sure remove_event" href="'+value.listing_remove_url+'" data-listing_id ="'+value.post_id+'" title="<?php echo esc_attr__('Remove','wpdirectorykit');?>"><span class="dashicons dashicons-no"></span></a>\n\
317 </td>\n\
318 </tr>'
319 });
320
321 jQuery( html ).insertAfter( self.closest('tr') );
322 jQuery(self).remove();
323
324 }).always(function(data) {
325 if(true) {
326 eventRemove();
327 } else {
328 jQuery('.child .question_sure').off().on('click', function() {
329 return confirm("<?php echo esc_js(__('Are you sure? Selected item will be completely removed!', 'wpdirectorykit')); ?>");
330 });
331 }
332 });
333
334 return false;
335 };
336
337 eventRemove = () => {
338 jQuery('.child .remove_event').off().on('click', function(e) {
339 e.preventDefault();
340 if(!confirm("<?php echo esc_js(__('Are you sure? Selected item will be completely removed!', 'wpdirectorykit')); ?>")) {
341 return false;
342 }
343
344 var self = jQuery(this);
345 var listing_id = self.attr('data-listing_id');
346
347 var ajax_param = {
348 "page": 'wdk_backendajax',
349 "function": 'remove_listing',
350 "action": 'wdk_public_action',
351 "listing_id": listing_id,
352 "_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-backendajax'));?>',
353 };
354
355 var tr = self.closest('tr');
356
357 self.addClass('wdk_btn_load_indicator out');
358
359 jQuery.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param,
360 function(data){
361
362 if(data.popup_text_success)
363 wdk_log_notify(data.popup_text_success);
364
365 if(data.popup_text_error)
366 wdk_log_notify(data.popup_text_error, 'error');
367
368 if(data.success) {
369
370 setTimeout(function() {
371 tr.animate({ opacity: 1/2 }, 500, function(){tr.remove();});
372 }, 200);
373
374 } else {
375 self.removeClass('loading_removing').addClass('loading_removed_error');
376 }
377
378 }).always(function(data) {
379 self.removeClass('wdk_btn_load_indicator out').addClass('wdk_btn_load_success out');
380 });
381 })
382 };
383
384 action = () => {
385 /*
386 jQuery($selector_btn).on('click', function(e){
387 e.preventDefault();
388 event(jQuery(this));
389 });
390 */
391
392 document.querySelectorAll($selector_btn).forEach(elem => elem.addEventListener('click', (e)=>{
393 e.preventDefault();
394 event(e.target);
395 }, false));
396
397 };
398
399 init = () => {
400 action();
401 };
402
403 init();
404 };
405 </script>
406
407 <?php $this->view('general/footer', $data); ?>