PluginProbe
WP Directory Kit / 1.3.6
WP Directory Kit v1.3.6
1.5.9 1.5.7 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 All 37 releases
wpdirectorykit / application / views / wdk / index.php

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

488 lines 29.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 esc_url(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 esc_url(wmvc_current_edit_url()); ?>" novalidate="novalidate" class="filters-form">
39 <div class="tablenav top">
40 <div class="alignleft actions">
41 <input type="hidden" name="page" value="wdk" />
42
43
44 <?php if(get_option('wdk_is_location_enabled', FALSE)): ?>
45 <label class="screen-reader-text" for="location_id"><?php echo __('Filter by location', 'wpdirectorykit'); ?></label>
46 <?php echo wmvc_select_option('location_id', $locations, wmvc_show_data('location_id', $db_data, ''), NULL, __('Location', 'wpdirectorykit')); ?>
47 <?php endif;?>
48
49 <?php if(get_option('wdk_is_category_enabled', FALSE)): ?>
50 <label class="screen-reader-text" for="category_id"><?php echo __('Filter by category', 'wpdirectorykit'); ?></label>
51 <?php echo wmvc_select_option('category_id', $categories, wmvc_show_data('category_id', $db_data, ''), NULL, __('Category', 'wpdirectorykit')); ?>
52 <?php endif;?>
53
54 <label class="screen-reader-text" for="user_id_editor"><?php echo esc_html__('Filter by user', 'wpdirectorykit'); ?></label>
55 <?php echo wmvc_select_option('user_id_editor', $users, wmvc_show_data('user_id_editor', $db_data, ''), NULL, __('User', 'wpdirectorykit')); ?>
56
57 <label class="screen-reader-text" for="search"><?php echo __('Filter by keyword', 'wpdirectorykit'); ?></label>
58 <input type="text" name="search" id="search" class="postform left" value="<?php echo esc_attr(wmvc_show_data('search', $db_data, '')); ?>" placeholder="<?php echo __('Filter by keyword', 'wpdirectorykit'); ?>" />
59
60 <label class="screen-reader-text" for="order_by"><?php echo __('Order By', 'wpdirectorykit'); ?></label>
61 <?php echo wmvc_select_option('order_by', $order_by, wmvc_show_data('order_by', $db_data, ''), NULL, __('Order by', 'wpdirectorykit')); ?>
62
63
64 <?php
65 $custom_field_init = false;
66 foreach ($_GET as $key => $value) {
67 if(stripos($key, 'c_field_') !== FALSE && stripos($key, '_field',8) !== FALSE) {
68 $field_id = substr($key, 8, (stripos($key, '_',8) - 8) );
69 ?>
70 <span class="custom_parameter" data-key="<?php echo esc_attr($field_id);?>">
71 <?php echo wmvc_select_option('c_field_'.$field_id.'_field', $fields_list, wmvc_show_data('c_field_'.$field_id.'_field', $_GET, ''), 'class="cus_p_field"', __('Field', 'wpdirectorykit')); ?>
72 <?php echo wmvc_select_option('c_field_'.$field_id.'_like', array('=='=>'=','>'=>'>','<'=>'<'), wmvc_show_data('c_field_'.$field_id.'_like', $_GET, ''), 'class="cus_p_like"'); ?>
73 <input type="text" name="c_field_<?php echo esc_attr($field_id);?>_value" value="<?php echo esc_html(wmvc_show_data('c_field_'.$field_id.'_value', $_GET, '')); ?>" class="cus_p_value" placeholder="<?php echo __('Value', 'wpdirectorykit'); ?>" />
74 </span>
75 <?php
76 $custom_field_init = true;
77 }
78 };
79 ?>
80 <?php if(!$custom_field_init):?>
81 <span class="custom_parameter">
82 <?php echo wmvc_select_option('c_field_1_field', $fields_list, wmvc_show_data('c_field_1_field', $db_data, ''), 'class="cus_p_field"', __('Field', 'wpdirectorykit')); ?>
83 <?php echo wmvc_select_option('c_field_1_like', array('=='=>'=','>'=>'>','<'=>'<'), wmvc_show_data('c_field_1_like', $db_data, ''), 'class="cus_p_like"'); ?>
84 <input type="text" name="c_field_1_value" value="<?php echo esc_html(wmvc_show_data('c_field_1_value', $db_data, '')); ?>" class="cus_p_value" placeholder="<?php echo __('Value', 'wpdirectorykit'); ?>" />
85 </span>
86 <?php endif;?>
87
88 <a href="" class="btn_parameter remove"><span class="dashicons dashicons-minus"></span></a>
89 <a href="" class="btn_parameter add"><span class="dashicons dashicons-plus-alt2"></span></a>
90
91 <input type="submit" name="filter_action" id="post-query-submit" class="button" value="<?php echo __('Filter', 'wpdirectorykit'); ?>">
92
93 <input type="hidden" name="is_featured" value="<?php echo esc_attr(wmvc_show_data('is_featured', $db_data, ''));?>">
94 <input type="hidden" name="is_activated" value="<?php echo esc_attr(wmvc_show_data('is_activated', $db_data, ''));?>">
95 </div>
96 <?php echo wmvc_xss_clean($pagination_output); ?>
97 <br class="clear">
98 </div>
99 </form>
100
101 <?php
102 if (function_exists('PLL')){
103 $pll_langs = pll_the_languages( array( 'raw' => 1 ) );
104 }
105 ?>
106
107 <form method="GET" action="<?php echo esc_url(wmvc_current_edit_url()); ?>" novalidate="novalidate">
108 <table class="wp-list-table widefat fixed striped table-view-list pages">
109 <thead>
110 <tr>
111 <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>
112 <th style="width:50px;"><?php echo __('#ID', 'wpdirectorykit'); ?></th>
113 <th><?php echo __('Title', 'wpdirectorykit'); ?></th>
114 <?php if(get_option('wdk_is_category_enabled', FALSE)): ?>
115 <th><?php echo __('Category', 'wpdirectorykit'); ?></th>
116 <?php endif; ?>
117 <th style="text-align: center;"><?php echo __('Image', 'wpdirectorykit'); ?></th>
118 <th><?php echo __('Post Date', 'wpdirectorykit'); ?></th>
119 <?php if (function_exists('PLL')): ?>
120 <?php $pll_langs = pll_the_languages( array( 'raw' => 1 ) );
121 foreach($pll_langs as $pll_lang): ?>
122 <th class="manage-column column-language_<?php echo esc_attr($pll_lang['slug']); ?>"><img src="<?php echo esc_html($pll_lang['flag']); ?>" /></th>
123 <?php endforeach; ?>
124 <?php endif; ?>
125 <th class="actions_column"><?php echo __('Actions', 'wpdirectorykit'); ?></th>
126 </tr>
127 </thead>
128 <tbody>
129 <?php if (count($listings) == 0) : ?>
130 <tr class="no-items">
131 <td class="colspanchange" colspan="7"><?php echo __('No Listings found.', 'wpdirectorykit'); ?></td>
132 </tr>
133 <?php endif; ?>
134 <?php foreach ($listings as $listing) : ?>
135 <tr>
136 <th scope="row" class="check-column">
137 <input id="cb-select-<?php echo esc_attr(wmvc_show_data('ID', $listing, '-')); ?>" type="checkbox" name="post[]" value="<?php echo esc_attr(wmvc_show_data('ID', $listing, '-')); ?>">
138 <div class="locked-indicator">
139 <span class="locked-indicator-icon" aria-hidden="true"></span>
140 <span class="screen-reader-text"><?php echo __('Is Locked', 'wpdirectorykit'); ?></span>
141 </div>
142 </th>
143 <td>
144 <?php echo wmvc_show_data('ID', $listing, '-'); ?>
145 </td>
146 <td class="title column-title has-row-actions column-primary page-title" data-colname="Title">
147 <strong>
148 <a class="row-title" href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk_listing&id=" . wmvc_show_data('ID', $listing, '-')); ?>"><?php echo wmvc_show_data('post_title', $listing, '-'); ?></a>
149 <?php if(!wmvc_show_data('is_activated', $listing, 0)): ?>
150 <span class="label label-danger"><?php echo __('Not activated', 'wpdirectorykit'); ?></span>
151 <?php endif; ?>
152 <?php if(!wmvc_show_data('is_approved', $listing, 0) && function_exists('run_wdk_membership')): ?>
153 <span class="label label-danger"><?php echo esc_html__('Not approved', 'wpdirectorykit'); ?></span>
154 <?php endif; ?>
155
156 <?php if(wdk_get_option('wdk_is_featured_enabled', FALSE)): ?>
157 <?php if(wmvc_show_data('is_featured', $listing, 0)): ?>
158 <span class="label label-info"><?php echo esc_html__('featured', 'wpdirectorykit'); ?></span>
159 <?php endif; ?>
160 <?php endif; ?>
161
162 </strong>
163 <div class="row-actions">
164 <span class="edit"><a href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk_listing&id=" . wmvc_show_data('ID', $listing, '-')); ?>"><?php echo __('Edit', 'wpdirectorykit'); ?></a> | </span>
165 <span class="trash "><a href="<?php echo esc_url(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>
166 <span class="view"><a href="<?php echo get_permalink($listing); ?>" target="blank"><?php echo __('View', 'wpdirectorykit'); ?></a></span>
167 </div>
168
169
170 <?php if(get_option('wdk_sub_listings_enable')): ?>
171 <?php if(!empty(wmvc_show_data('listing_related_ids', $listing))):?>
172 <div class="">
173 <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>
174 </div>
175 <?php endif; ?>
176 <?php endif; ?>
177 </td>
178
179 <?php if(get_option('wdk_is_category_enabled', FALSE)): ?>
180 <td>
181 <?php echo wmvc_show_data($listing->category_id, $categories, '-'); ?>
182 <?php
183 $other_categories = wdk_generate_other_categories_fast($listing->categories_list);
184
185 if(!empty($other_categories)):?>
186 <br>
187 <span style="display: inline-block;padding-top: 10px;" ><?php echo esc_html(join(', ',$other_categories));?></span>
188 <?php endif;?>
189 </td>
190 <?php endif; ?>
191
192 <td style="text-align: center;">
193 <a class="img-link" href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk_listing&id=" . wmvc_show_data('ID', $listing, '-')); ?>">
194 <img src="<?php echo esc_url(wdk_image_src($listing));?>" alt="thumb" style="height:70px;width:110px;object-fit:cover;text-align: center;"/>
195 </a>
196 </td>
197 <td>
198 <?php echo wdk_get_date($listing->post_date, false); ?>
199 </td>
200 <?php if (function_exists('PLL')): ?>
201
202 <?php foreach($pll_langs as $pll_lang): ?>
203 <?php //var_dump($pll_lang); ?>
204 <?php if($pll_lang['slug'] == pll_get_post_language($listing->ID, 'slug' )): ?>
205 <td><img src="<?php echo esc_html($pll_lang['flag']); ?>" /></td>
206 <?php elseif(empty(pll_get_post( $listing->ID, $pll_lang['slug'] ))): ?>
207 <td><a class="pll_icon_edit translation_<?php echo esc_attr($listing->ID); ?>" href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk_listing&function=copy&from_id=" . $listing->ID . "&to_lang=".$pll_lang['slug']); ?>"></a></td>
208 <?php else: ?>
209 <td><a class="pll_icon_edit translation_<?php echo esc_attr($listing->ID); ?>" href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk_listing&id=" . pll_get_post( $listing->ID, $pll_lang['slug'] )); ?>"></a></td>
210 <?php endif; ?>
211 <?php endforeach; ?>
212
213 <?php endif; ?>
214 <td class="actions_column">
215 <a href="<?php echo get_permalink($listing); ?>" title="<?php echo esc_attr__('View','wpdirectorykit');?>" target="blank"><span class="dashicons dashicons-visibility"></span></a>
216 <a href="<?php echo esc_url(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>
217 <a class="question_sure" href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk&function=delete&paged=".esc_attr($paged)."&id=" . wmvc_show_data('ID', $listing, '-')."&_wpnonce=".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>
218 </td>
219 </tr>
220
221 <?php if(get_option('wdk_sub_listings_enable')): ?>
222 <?php if(!empty(wmvc_show_data('listing_related_ids', $listing))):?>
223 <?php if(false)foreach (explode(',',wmvc_show_data('listing_related_ids', $listing, '')) as $key => $child_idlisting):?>
224 <tr class="child">
225 <th scope="row"></th>
226 <td scope="row"></td>
227 <td colspan="1">
228 <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>
229 </td>
230 <td>
231 <?php echo wdk_field_value('category_id', $categories); ?>
232 </td>
233 <td style="text-align: center;">
234 <a class="img-link" href="<?php echo get_admin_url() . "admin.php?page=wdk_listing&id=" . $child_idlisting; ?>">
235 <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;"/>
236 </a>
237 </td>
238 <td>
239 <?php echo wdk_get_date(wdk_field_value('date', $child_idlisting), false); ?>
240 </td>
241 <td class="actions_column">
242 <a href="<?php echo get_permalink($child_idlisting); ?>" title="<?php echo esc_attr__('View','wpdirectorykit');?>" target="blank"><span class="dashicons dashicons-visibility"></span></a>
243 <a href="<?php echo esc_url(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>
244 <a class="question_sure" href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk&function=delete&paged=".esc_attr($paged)."&id=" . $child_idlisting."&_wpnonce=".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>
245 </td>
246 </tr>
247 <?php endforeach;?>
248 <?php endif;?>
249 <?php endif;?>
250 <?php endforeach;?>
251 </tbody>
252 <tfoot>
253 <tr>
254 <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>
255 <th style="width:50px;"><?php echo __('#ID', 'wpdirectorykit'); ?></th>
256 <th><?php echo __('Title', 'wpdirectorykit'); ?></th>
257 <?php if(get_option('wdk_is_category_enabled', FALSE)): ?>
258 <th><?php echo __('Category', 'wpdirectorykit'); ?></th>
259 <?php endif; ?>
260 <th style="text-align: center;"><?php echo __('Image', 'wpdirectorykit'); ?></th>
261 <th><?php echo __('Post Date', 'wpdirectorykit'); ?></th>
262 <?php if (function_exists('PLL')): ?>
263 <?php foreach($pll_langs as $pll_lang): ?>
264 <th><img src="<?php echo esc_html($pll_lang['flag']); ?>" /></th>
265 <?php endforeach; ?>
266 <?php endif; ?>
267 <th class="actions_column"><?php echo __('Actions', 'wpdirectorykit'); ?></th>
268 </tr>
269 </tfoot>
270 </table>
271 <div class="tablenav bottom">
272 <div class="alignleft actions bulkactions">
273 <?php wp_nonce_field( 'wdk-listing-bulk', '_wpnonce'); ?>
274 <label for="bulk-action-selector-bottom" class="screen-reader-text"><?php echo __('Select bulk action', 'wpdirectorykit'); ?></label>
275 <select name="action" id="bulk-action-selector-bottom">
276 <option value="-1"><?php echo __('Bulk actions', 'wpdirectorykit'); ?></option>
277 <option value="delete" class="hide-if-no-js"><?php echo __('Delete', 'wpdirectorykit'); ?></option>
278 <option value="deactivate" class="hide-if-no-js"><?php echo __('Deactivate', 'wpdirectorykit'); ?></option>
279 <option value="activate" class="hide-if-no-js"><?php echo __('Activate', 'wpdirectorykit'); ?></option>
280 <?php if(function_exists('run_wdk_membership')):?>
281 <option value="deapprove" class="hide-if-no-js"><?php echo __('Deapprove', 'wpdirectorykit'); ?></option>
282 <option value="approve" class="hide-if-no-js"><?php echo __('Approve', 'wpdirectorykit'); ?></option>
283 <?php endif;?>
284 </select>
285 <input type="hidden" name="page" value="wdk" />
286 <input type="submit" id="table_action" class="button action" name="table_action" value="<?php echo esc_attr__('Apply', 'wpdirectorykit'); ?>">
287 </div>
288
289 <?php echo wmvc_xss_clean($pagination_output); ?>
290 <br class="clear">
291 </div>
292 </form>
293 </div>
294 <?php
295 wp_enqueue_style('wdk-notify');
296 wp_enqueue_script('wdk-notify');
297 ?>
298 <script>
299 // Generate table
300 jQuery(document).ready(function($) {
301
302 $('.question_sure').on('click', function() {
303 return confirm("<?php echo esc_js(__('Are you sure? Selected item will be completely removed!', 'wpdirectorykit')); ?>");
304 });
305 wdk_loading_sublistings();
306 wdk_custom_search_parameters();
307 });
308
309 const wdk_loading_sublistings = ($selector_btn = '.laoding_sublistings') => {
310 var init,action,event, eventRemove;
311
312 event = (elem) => {
313 var listing_id = jQuery(elem).attr('data-listing_id');
314 var self = jQuery(elem);
315
316 if(self.attr('disabled')) {
317 return false;
318 }
319
320 self.addClass('wdk_btn_load_indicator out');
321 self.attr('disabled','disabled');
322
323 var ajax_param = {
324 "page": 'wdk_backendajax',
325 "function": 'loading_sublistings',
326 "action": 'wdk_public_action',
327 "listing_id": listing_id,
328 "_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-backendajax'));?>',
329 };
330
331 jQuery.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param,
332 function(data){
333
334 if(data.popup_text_success)
335 wdk_log_notify(data.popup_text_success);
336
337 if(data.popup_text_error)
338 wdk_log_notify(data.popup_text_error, 'error');
339
340 self.removeClass('wdk_btn_load_indicator out');
341
342 data.results
343 var html = '';
344 jQuery.each(data.results, function(index, value){
345 html += '<tr class="child">\n\
346 <th scope="row"></th>\n\
347 <td scope="row">'+value.post_id+'</td>\n\
348 <td colspan="1">\n\
349 <a target="_blank" href="'+value.listing_edit_url+'">'+value.post_title+'</a>\n\
350 </td>\n\
351 <td>\n\
352 '+value.category+'\n\
353 </td>\n\
354 <td style="text-align: center;">\n\
355 <a class="img-link" href="'+value.listing_edit_url+'">\n\
356 <img src="'+value.image_src+'" alt="thumb" style="height:50px;width:65px;object-fit:cover;text-align: center;"/>\n\
357 </a>\n\
358 </td>\n\
359 <td>\n\
360 '+value.date+'\n\
361 </td>\n\
362 <td class="actions_column">\n\
363 <a href="'+value.listing_view_url+'" title="<?php echo esc_attr__('View','wpdirectorykit');?>" target="blank"><span class="dashicons dashicons-visibility"></span></a>\n\
364 <a href="'+value.listing_edit_url+'" title="<?php echo esc_attr__('Edit','wpdirectorykit');?>"><span class="dashicons dashicons-edit"></span></a>\n\
365 <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\
366 </td>\n\
367 </tr>'
368 });
369
370 jQuery( html ).insertAfter( self.closest('tr') );
371 jQuery(self).remove();
372
373 }).always(function(data) {
374 if(true) {
375 eventRemove();
376 } else {
377 jQuery('.child .question_sure').off().on('click', function() {
378 return confirm("<?php echo esc_js(__('Are you sure? Selected item will be completely removed!', 'wpdirectorykit')); ?>");
379 });
380 }
381 });
382
383 return false;
384 };
385
386 eventRemove = () => {
387 jQuery('.child .remove_event').off().on('click', function(e) {
388 e.preventDefault();
389 if(!confirm("<?php echo esc_js(__('Are you sure? Selected item will be completely removed!', 'wpdirectorykit')); ?>")) {
390 return false;
391 }
392
393 var self = jQuery(this);
394 var listing_id = self.attr('data-listing_id');
395
396 var ajax_param = {
397 "page": 'wdk_backendajax',
398 "function": 'remove_listing',
399 "action": 'wdk_public_action',
400 "listing_id": listing_id,
401 "_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-backendajax'));?>',
402 };
403
404 var tr = self.closest('tr');
405
406 self.addClass('wdk_btn_load_indicator out');
407
408 jQuery.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param,
409 function(data){
410
411 if(data.popup_text_success)
412 wdk_log_notify(data.popup_text_success);
413
414 if(data.popup_text_error)
415 wdk_log_notify(data.popup_text_error, 'error');
416
417 if(data.success) {
418
419 setTimeout(function() {
420 tr.animate({ opacity: 1/2 }, 500, function(){tr.remove();});
421 }, 200);
422
423 } else {
424 self.removeClass('loading_removing').addClass('loading_removed_error');
425 }
426
427 }).always(function(data) {
428 self.removeClass('wdk_btn_load_indicator out').addClass('wdk_btn_load_success out');
429 });
430 })
431 };
432
433 action = () => {
434 /*
435 jQuery($selector_btn).on('click', function(e){
436 e.preventDefault();
437 event(jQuery(this));
438 });
439 */
440
441 document.querySelectorAll($selector_btn).forEach(elem => elem.addEventListener('click', (e)=>{
442 e.preventDefault();
443 event(e.target);
444 }, false));
445
446 };
447
448 init = () => {
449 action();
450 };
451
452 init();
453 };
454
455 const wdk_custom_search_parameters = ($selector_customParameter = '.custom_parameter') => {
456 var selector_customParameter = jQuery($selector_customParameter).first();
457
458 var event = () => {
459 jQuery('.btn_parameter.add').off().on('click', function(e){
460 e.preventDefault();
461 var cus_field = selector_customParameter.clone().insertAfter(jQuery($selector_customParameter).last());
462 cus_field.find('input,select').val('');
463
464 var key = 1;
465 while (jQuery('.custom_parameter .cus_p_field[name="c_field_'+key+'_field"]').length) {
466 key++;
467 }
468
469 cus_field.find('.cus_p_field').attr('name', 'c_field_'+key+'_field');
470 cus_field.find('.cus_p_like').attr('name', 'c_field_'+key+'_like');
471 cus_field.find('.cus_p_value').attr('name', 'c_field_'+key+'_value');
472 });
473
474 jQuery('.btn_parameter.remove').off().on('click', function(e){
475 e.preventDefault();
476 if(jQuery($selector_customParameter).length>1) {
477 jQuery($selector_customParameter).last().remove();
478 } else {
479 jQuery($selector_customParameter).last().find('input,select').val('');
480 }
481 });
482 };
483
484 event();
485 };
486 </script>
487
488 <?php $this->view('general/footer', $data); ?>