| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The template for Listings Management. |
| 5 |
* |
| 6 |
* This is the template that form edit |
| 7 |
* |
| 8 |
*/ |
| 9 |
|
| 10 |
if (! defined('ABSPATH')) { |
| 11 |
exit; // Exit if accessed directly. |
| 12 |
} |
| 13 |
?> |
| 14 |
|
| 15 |
<!-- This file should primarily consist of HTML with a little bit of PHP. --> |
| 16 |
<div class="wrap wdk-wrap"> |
| 17 |
<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> |
| 18 |
<?php |
| 19 |
if ( |
| 20 |
!get_option('wdk_listing_page') || get_post_status(get_option('wdk_listing_page')) != 'publish' |
| 21 |
|| !get_option('wdk_results_page') || get_post_status(get_option('wdk_results_page')) != 'publish' |
| 22 |
): ?> |
| 23 |
<div class="notice notice-success"> |
| 24 |
<p> |
| 25 |
<?php echo __('Listing Preview page or Listings Result page missing', 'wpdirectorykit'); ?> |
| 26 |
<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"> |
| 27 |
<?php echo __('Import Demo Data', 'wpdirectorykit'); ?> |
| 28 |
</a> |
| 29 |
</p> |
| 30 |
</div> |
| 31 |
<?php endif; ?> |
| 32 |
|
| 33 |
<?php if (!function_exists('run_wdk_membership')): ?> |
| 34 |
<div class="notice notice-warning"> |
| 35 |
<p> |
| 36 |
<?php echo __('Do you want that your visitors add own listings and earn money by selling subscription packages?', 'wpdirectorykit'); ?> |
| 37 |
<a href="https://wpdirectorykit.com/plugins/wp-directory-membership.html" target="_blank"> |
| 38 |
<?php echo __('Purchase our premium Membership feature and support our work!', 'wpdirectorykit'); ?> |
| 39 |
</a> |
| 40 |
</p> |
| 41 |
</div> |
| 42 |
<?php endif; ?> |
| 43 |
|
| 44 |
<?php |
| 45 |
if (class_exists('Wdk\DashWidgets\Widgets\WDK_Dashboard_Widget_Stats_Listings')) { |
| 46 |
$widget = new Wdk\DashWidgets\Widgets\WDK_Dashboard_Widget_Stats_Listings(); |
| 47 |
$widget->widget(); |
| 48 |
} |
| 49 |
?> |
| 50 |
|
| 51 |
<?php if (did_action('elementor/loaded') && get_option('wdk_results_page')): ?> |
| 52 |
<?php |
| 53 |
global $Winter_MVC_WDK; |
| 54 |
$Winter_MVC_WDK->load_helper('Get_element_settings'); |
| 55 |
$flag = false; |
| 56 |
|
| 57 |
$get_settings_el_results = new WdkGetElementSettings(get_option('wdk_results_page'), NULL, 'wdk-listings-results', FALSE); |
| 58 |
$results_elements = $get_settings_el_results->get_widgets(); |
| 59 |
foreach ($results_elements as $key => $results_element) { |
| 60 |
if ( |
| 61 |
isset($results_element['settings']['conf_pagination_enable']) && $results_element['settings']['conf_pagination_enable'] == 'yes' |
| 62 |
&& (empty($results_element['settings']['conf_results_type']) || $results_element['settings']['conf_results_type'] != 'conf_results_type') |
| 63 |
) { |
| 64 |
$flag = true; |
| 65 |
} |
| 66 |
} |
| 67 |
?> |
| 68 |
|
| 69 |
<?php if (!$flag): ?> |
| 70 |
<div class="notice notice-success"> |
| 71 |
<p> |
| 72 |
<?php echo __('Result page missing or Results widget for all results not exists on page', 'wpdirectorykit'); ?> |
| 73 |
<a href="#" class="button button-primary ajax_query_rest_pages" data-function="reinstall_page" data-arg="wdk_results_page"> |
| 74 |
<?php echo __('RESET RESULTS PAGE', 'wpdirectorykit'); ?> |
| 75 |
</a> |
| 76 |
</p> |
| 77 |
</div> |
| 78 |
|
| 79 |
<?php wp_enqueue_style('jquery-confirm'); ?> |
| 80 |
<?php wp_enqueue_script('jquery-confirm'); ?> |
| 81 |
|
| 82 |
<script> |
| 83 |
jQuery(document).ready(function($) { |
| 84 |
|
| 85 |
|
| 86 |
$('.ajax_query_rest_pages').on('click', function(e) { |
| 87 |
e.preventDefault(); |
| 88 |
e.stopPropagation(); |
| 89 |
var self = $(this); |
| 90 |
|
| 91 |
if (self.attr('disabled')) { |
| 92 |
return false; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
$.confirm({ |
| 97 |
boxWidth: '400px', |
| 98 |
useBootstrap: false, |
| 99 |
title: '', |
| 100 |
content: '<?php echo esc_js(esc_html__('Are you sure? current layout will be replaced with default plugin version', 'wpdirectorykit')); ?>', |
| 101 |
buttons: { |
| 102 |
cancel: function() { |
| 103 |
return true; |
| 104 |
}, |
| 105 |
confirm: { |
| 106 |
text: '<?php echo esc_js(esc_html__('Confirm', 'wpdirectorykit')); ?>', |
| 107 |
btnClass: 'btn-blue', |
| 108 |
keys: ['enter', 'shift'], |
| 109 |
action: function() { |
| 110 |
var ajax_param = { |
| 111 |
"page": 'wdk_backendajax', |
| 112 |
"function": self.data('function'), |
| 113 |
"action": 'wdk_public_action', |
| 114 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce('wdk-backendajax')); ?>', |
| 115 |
"arg": self.data('arg') ?? '', |
| 116 |
}; |
| 117 |
|
| 118 |
self.addClass('wdk_btn_load_indicator out'); |
| 119 |
self.attr('disabled', 'disabled'); |
| 120 |
$.post("<?php echo admin_url('admin-ajax.php'); ?>", ajax_param, |
| 121 |
function(data) { |
| 122 |
|
| 123 |
if (data.popup_text_success) |
| 124 |
wdk_log_notify(data.popup_text_success); |
| 125 |
|
| 126 |
if (data.popup_text_error) |
| 127 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 128 |
|
| 129 |
if (data.success) { |
| 130 |
self.removeClass('wdk_btn_load_indicator out'); |
| 131 |
self.addClass('wdk_btn_load_success out'); |
| 132 |
|
| 133 |
if (data.page_id && data.page_title) { |
| 134 |
self.closest('.wdk-field-container').find('select option').removeAttr('selected').parent().append('<option selected="selected" value="' + data.page_id + '">' + data.page_title + ' #' + data.page_id + '</option>'); |
| 135 |
} |
| 136 |
} else { |
| 137 |
self.removeClass('wdk_btn_load_indicator out'); |
| 138 |
self.addClass('wdk_btn_load_error out'); |
| 139 |
} |
| 140 |
}).always(function(data) { |
| 141 |
|
| 142 |
}); |
| 143 |
|
| 144 |
return true; |
| 145 |
} |
| 146 |
}, |
| 147 |
} |
| 148 |
}) |
| 149 |
}) |
| 150 |
}) |
| 151 |
</script> |
| 152 |
<?php endif; ?> |
| 153 |
<?php endif; ?> |
| 154 |
|
| 155 |
<form method="GET" action="<?php echo esc_url(wmvc_current_edit_url()); ?>" novalidate="novalidate" class="filters-form"> |
| 156 |
<div class="tablenav top"> |
| 157 |
<div class="alignleft actions"> |
| 158 |
<input type="hidden" name="page" value="wdk" /> |
| 159 |
|
| 160 |
|
| 161 |
<?php if (get_option('wdk_is_location_enabled', FALSE)): ?> |
| 162 |
<label class="screen-reader-text" for="location_id"><?php echo __('Filter by location', 'wpdirectorykit'); ?></label> |
| 163 |
<?php echo wmvc_select_option('location_id', $locations, wmvc_show_data('location_id', $db_data, ''), NULL, __('Location', 'wpdirectorykit')); ?> |
| 164 |
<?php endif; ?> |
| 165 |
|
| 166 |
<?php if (get_option('wdk_is_category_enabled', FALSE)): ?> |
| 167 |
<label class="screen-reader-text" for="category_id"><?php echo __('Filter by category', 'wpdirectorykit'); ?></label> |
| 168 |
<?php echo wmvc_select_option('category_id', $categories, wmvc_show_data('category_id', $db_data, ''), NULL, __('Category', 'wpdirectorykit')); ?> |
| 169 |
<?php endif; ?> |
| 170 |
|
| 171 |
<label class="screen-reader-text" for="user_id_editor"><?php echo esc_html__('Filter by user', 'wpdirectorykit'); ?></label> |
| 172 |
<?php echo wmvc_select_option('user_id_editor', $users, wmvc_show_data('user_id_editor', $db_data, ''), NULL, __('User', 'wpdirectorykit')); ?> |
| 173 |
|
| 174 |
<label class="screen-reader-text" for="search"><?php echo __('Filter by keyword', 'wpdirectorykit'); ?></label> |
| 175 |
<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'); ?>" /> |
| 176 |
|
| 177 |
<label class="screen-reader-text" for="order_by"><?php echo __('Order By', 'wpdirectorykit'); ?></label> |
| 178 |
<?php echo wmvc_select_option('order_by', $order_by, wmvc_show_data('order_by', $db_data, ''), NULL, __('Order by', 'wpdirectorykit')); ?> |
| 179 |
|
| 180 |
|
| 181 |
<?php |
| 182 |
$custom_field_init = false; |
| 183 |
foreach ($_GET as $key => $value) { |
| 184 |
if (stripos($key, 'c_field_') !== FALSE && stripos($key, '_field', 8) !== FALSE) { |
| 185 |
$field_id = substr($key, 8, (stripos($key, '_', 8) - 8)); |
| 186 |
?> |
| 187 |
<span class="custom_parameter" data-key="<?php echo esc_attr($field_id); ?>"> |
| 188 |
<?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')); ?> |
| 189 |
<?php echo wmvc_select_option('c_field_' . $field_id . '_like', array('==' => '=', '>' => '>', '<' => '<'), wmvc_show_data('c_field_' . $field_id . '_like', $_GET, ''), 'class="cus_p_like"'); ?> |
| 190 |
<input type="text" name="c_field_<?php echo esc_attr($field_id); ?>_value" value="<?php echo esc_attr(wmvc_show_data('c_field_' . $field_id . '_value', $_GET, '')); ?>" class="cus_p_value" placeholder="<?php echo __('Value', 'wpdirectorykit'); ?>" /> |
| 191 |
</span> |
| 192 |
<?php |
| 193 |
$custom_field_init = true; |
| 194 |
} |
| 195 |
}; |
| 196 |
?> |
| 197 |
<?php if (!$custom_field_init): ?> |
| 198 |
<span class="custom_parameter"> |
| 199 |
<?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')); ?> |
| 200 |
<?php echo wmvc_select_option('c_field_1_like', array('==' => '=', '>' => '>', '<' => '<'), wmvc_show_data('c_field_1_like', $db_data, ''), 'class="cus_p_like"'); ?> |
| 201 |
<input type="text" name="c_field_1_value" value="<?php echo esc_attr(wmvc_show_data('c_field_1_value', $db_data, '')); ?>" class="cus_p_value" placeholder="<?php echo __('Value', 'wpdirectorykit'); ?>" /> |
| 202 |
</span> |
| 203 |
<?php endif; ?> |
| 204 |
|
| 205 |
<a href="" class="btn_parameter remove"><span class="dashicons dashicons-minus"></span></a> |
| 206 |
<a href="" class="btn_parameter add"><span class="dashicons dashicons-plus-alt2"></span></a> |
| 207 |
|
| 208 |
<input type="submit" name="filter_action" id="post-query-submit" class="button" value="<?php echo __('Filter', 'wpdirectorykit'); ?>"> |
| 209 |
|
| 210 |
<input type="hidden" name="is_featured" value="<?php echo esc_attr(wmvc_show_data('is_featured', $db_data, '')); ?>"> |
| 211 |
<input type="hidden" name="is_activated" value="<?php echo esc_attr(wmvc_show_data('is_activated', $db_data, '')); ?>"> |
| 212 |
</div> |
| 213 |
<?php echo wmvc_xss_clean($pagination_output); ?> |
| 214 |
<br class="clear"> |
| 215 |
</div> |
| 216 |
</form> |
| 217 |
|
| 218 |
<?php |
| 219 |
if (function_exists('PLL')) { |
| 220 |
$pll_langs = pll_the_languages(array('raw' => 1)); |
| 221 |
} |
| 222 |
?> |
| 223 |
|
| 224 |
<form method="GET" action="<?php echo esc_url(wmvc_current_edit_url()); ?>" novalidate="novalidate"> |
| 225 |
<table class="wp-list-table widefat fixed striped table-view-list pages"> |
| 226 |
<thead> |
| 227 |
<tr> |
| 228 |
<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> |
| 229 |
<th style="width:50px;"><?php echo __('#ID', 'wpdirectorykit'); ?></th> |
| 230 |
<th><?php echo __('Title', 'wpdirectorykit'); ?></th> |
| 231 |
<?php if (get_option('wdk_is_category_enabled', FALSE)): ?> |
| 232 |
<th><?php echo __('Category', 'wpdirectorykit'); ?></th> |
| 233 |
<?php endif; ?> |
| 234 |
<th style="text-align: center;"><?php echo __('Image', 'wpdirectorykit'); ?></th> |
| 235 |
<th><?php echo __('Post Date', 'wpdirectorykit'); ?></th> |
| 236 |
<?php if (function_exists('PLL')): ?> |
| 237 |
<?php $pll_langs = pll_the_languages(array('raw' => 1)); |
| 238 |
foreach ($pll_langs as $pll_lang): ?> |
| 239 |
<th class="manage-column column-language_<?php echo esc_attr($pll_lang['slug']); ?>"><img src="<?php echo esc_attr($pll_lang['flag']); ?>" /></th> |
| 240 |
<?php endforeach; ?> |
| 241 |
<?php endif; ?> |
| 242 |
<th class="static"><?php echo __('Views', 'wpdirectorykit'); ?></th> |
| 243 |
<th class="static"><?php echo __('Showed in results', 'wpdirectorykit'); ?></th> |
| 244 |
<th class="actions_column"><?php echo __('Actions', 'wpdirectorykit'); ?></th> |
| 245 |
</tr> |
| 246 |
</thead> |
| 247 |
<tbody> |
| 248 |
<?php if (count($listings) == 0) : ?> |
| 249 |
<tr class="no-items"> |
| 250 |
<td class="colspanchange" colspan="9"><?php echo __('No Listings found.', 'wpdirectorykit'); ?></td> |
| 251 |
</tr> |
| 252 |
<?php endif; ?> |
| 253 |
<?php foreach ($listings as $listing) : ?> |
| 254 |
<tr> |
| 255 |
<th scope="row" class="check-column"> |
| 256 |
<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, '-')); ?>"> |
| 257 |
<div class="locked-indicator"> |
| 258 |
<span class="locked-indicator-icon" aria-hidden="true"></span> |
| 259 |
<span class="screen-reader-text"><?php echo __('Is Locked', 'wpdirectorykit'); ?></span> |
| 260 |
</div> |
| 261 |
</th> |
| 262 |
<td> |
| 263 |
<?php echo esc_html(wmvc_show_data('ID', $listing, '-')); ?> |
| 264 |
</td> |
| 265 |
<td class="title column-title has-row-actions column-primary page-title" data-colname="Title"> |
| 266 |
<strong> |
| 267 |
<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 esc_html(wmvc_show_data('post_title', $listing, '-')); ?></a> |
| 268 |
<?php if (!wmvc_show_data('is_activated', $listing, 0)): ?> |
| 269 |
<span class="label label-danger"><?php echo __('Not activated', 'wpdirectorykit'); ?></span> |
| 270 |
<?php endif; ?> |
| 271 |
<?php if (!wmvc_show_data('is_approved', $listing, 0) && function_exists('run_wdk_membership')): ?> |
| 272 |
<span class="label label-danger"><?php echo esc_html__('Not approved', 'wpdirectorykit'); ?></span> |
| 273 |
<?php endif; ?> |
| 274 |
|
| 275 |
<?php if (wdk_get_option('wdk_is_featured_enabled', FALSE)): ?> |
| 276 |
<?php if (wmvc_show_data('is_featured', $listing, 0)): ?> |
| 277 |
<span class="label label-info"><?php echo esc_html__('featured', 'wpdirectorykit'); ?></span> |
| 278 |
<?php endif; ?> |
| 279 |
<?php endif; ?> |
| 280 |
|
| 281 |
</strong> |
| 282 |
<div class="row-actions"> |
| 283 |
<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> |
| 284 |
<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> |
| 285 |
<span class="view"><a href="<?php echo get_permalink($listing); ?>" target="blank"><?php echo __('View', 'wpdirectorykit'); ?></a></span> |
| 286 |
</div> |
| 287 |
|
| 288 |
|
| 289 |
<?php if (get_option('wdk_sub_listings_enable')): ?> |
| 290 |
<?php if (!empty(wmvc_show_data('listing_related_ids', $listing))): ?> |
| 291 |
<div class=""> |
| 292 |
<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> |
| 293 |
</div> |
| 294 |
<?php endif; ?> |
| 295 |
<?php endif; ?> |
| 296 |
</td> |
| 297 |
|
| 298 |
<?php if (get_option('wdk_is_category_enabled', FALSE)): ?> |
| 299 |
<td> |
| 300 |
<?php echo esc_html(wmvc_show_data($listing->category_id, $categories, '-')); ?> |
| 301 |
<?php |
| 302 |
$other_categories = wdk_generate_other_categories_fast($listing->categories_list); |
| 303 |
|
| 304 |
if (!empty($other_categories)): ?> |
| 305 |
<br> |
| 306 |
<span style="display: inline-block;padding-top: 10px;"><?php echo esc_html(join(', ', $other_categories)); ?></span> |
| 307 |
<?php endif; ?> |
| 308 |
</td> |
| 309 |
<?php endif; ?> |
| 310 |
|
| 311 |
<td style="text-align: center;"> |
| 312 |
<a class="img-link" href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk_listing&id=" . wmvc_show_data('ID', $listing, '-')); ?>"> |
| 313 |
<img src="<?php echo esc_url(wdk_image_src($listing)); ?>" alt="thumb" style="height:70px;width:110px;object-fit:cover;text-align: center;" /> |
| 314 |
</a> |
| 315 |
</td> |
| 316 |
<td> |
| 317 |
<?php echo wdk_get_date($listing->post_date, false); ?> |
| 318 |
</td> |
| 319 |
<?php if (function_exists('PLL')): ?> |
| 320 |
|
| 321 |
<?php foreach ($pll_langs as $pll_lang): ?> |
| 322 |
<?php //var_dump($pll_lang); |
| 323 |
?> |
| 324 |
<?php if ($pll_lang['slug'] == pll_get_post_language($listing->ID, 'slug')): ?> |
| 325 |
<td><img src="<?php echo esc_attr($pll_lang['flag']); ?>" /></td> |
| 326 |
<?php elseif (empty(pll_get_post($listing->ID, $pll_lang['slug']))): ?> |
| 327 |
<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> |
| 328 |
<?php else: ?> |
| 329 |
<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> |
| 330 |
<?php endif; ?> |
| 331 |
<?php endforeach; ?> |
| 332 |
|
| 333 |
<?php endif; ?> |
| 334 |
<td class="static"> |
| 335 |
<?php echo esc_html(wmvc_show_data('counter_views', $listing, '-')); ?> |
| 336 |
</td> |
| 337 |
<td class="static"> |
| 338 |
<?php echo esc_html(wmvc_show_data('counter_results_views', $listing, '-')); ?> |
| 339 |
</td> |
| 340 |
<td class="actions_column"> |
| 341 |
<a href="<?php echo get_permalink($listing); ?>" title="<?php echo esc_attr__('View', 'wpdirectorykit'); ?>" target="blank"><span class="dashicons dashicons-visibility"></span></a> |
| 342 |
<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> |
| 343 |
<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> |
| 344 |
</td> |
| 345 |
</tr> |
| 346 |
|
| 347 |
<?php if (get_option('wdk_sub_listings_enable')): ?> |
| 348 |
<?php if (!empty(wmvc_show_data('listing_related_ids', $listing))): ?> |
| 349 |
<?php if (false) foreach (explode(',', wmvc_show_data('listing_related_ids', $listing, '')) as $key => $child_idlisting): ?> |
| 350 |
<tr class="child"> |
| 351 |
<th scope="row"></th> |
| 352 |
<td scope="row"></td> |
| 353 |
<td colspan="1"> |
| 354 |
<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> |
| 355 |
</td> |
| 356 |
<td> |
| 357 |
<?php echo wdk_field_value('category_id', $categories); ?> |
| 358 |
</td> |
| 359 |
<td style="text-align: center;"> |
| 360 |
<a class="img-link" href="<?php echo get_admin_url() . "admin.php?page=wdk_listing&id=" . $child_idlisting; ?>"> |
| 361 |
<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;" /> |
| 362 |
</a> |
| 363 |
</td> |
| 364 |
<td> |
| 365 |
<?php echo wdk_get_date(wdk_field_value('date', $child_idlisting), false); ?> |
| 366 |
</td> |
| 367 |
<td class="actions_column"> |
| 368 |
<a href="<?php echo get_permalink($child_idlisting); ?>" title="<?php echo esc_attr__('View', 'wpdirectorykit'); ?>" target="blank"><span class="dashicons dashicons-visibility"></span></a> |
| 369 |
<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> |
| 370 |
<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> |
| 371 |
</td> |
| 372 |
</tr> |
| 373 |
<?php endforeach; ?> |
| 374 |
<?php endif; ?> |
| 375 |
<?php endif; ?> |
| 376 |
<?php endforeach; ?> |
| 377 |
</tbody> |
| 378 |
<tfoot> |
| 379 |
<tr> |
| 380 |
<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> |
| 381 |
<th style="width:50px;"><?php echo __('#ID', 'wpdirectorykit'); ?></th> |
| 382 |
<th><?php echo __('Title', 'wpdirectorykit'); ?></th> |
| 383 |
<?php if (get_option('wdk_is_category_enabled', FALSE)): ?> |
| 384 |
<th><?php echo __('Category', 'wpdirectorykit'); ?></th> |
| 385 |
<?php endif; ?> |
| 386 |
<th style="text-align: center;"><?php echo __('Image', 'wpdirectorykit'); ?></th> |
| 387 |
<th><?php echo __('Post Date', 'wpdirectorykit'); ?></th> |
| 388 |
<?php if (function_exists('PLL')): ?> |
| 389 |
<?php foreach ($pll_langs as $pll_lang): ?> |
| 390 |
<th><img src="<?php echo esc_attr($pll_lang['flag']); ?>" /></th> |
| 391 |
<?php endforeach; ?> |
| 392 |
<?php endif; ?> |
| 393 |
<th class=""></th> |
| 394 |
<th class=""></th> |
| 395 |
<th class="actions_column"><?php echo __('Actions', 'wpdirectorykit'); ?></th> |
| 396 |
</tr> |
| 397 |
</tfoot> |
| 398 |
</table> |
| 399 |
<div class="tablenav bottom"> |
| 400 |
<div class="alignleft actions bulkactions"> |
| 401 |
<?php wp_nonce_field('wdk-listing-bulk', '_wpnonce'); ?> |
| 402 |
<label for="bulk-action-selector-bottom" class="screen-reader-text"><?php echo __('Select bulk action', 'wpdirectorykit'); ?></label> |
| 403 |
<select name="action" id="bulk-action-selector-bottom"> |
| 404 |
<option value="-1"><?php echo __('Bulk actions', 'wpdirectorykit'); ?></option> |
| 405 |
<option value="delete" class="hide-if-no-js"><?php echo __('Delete', 'wpdirectorykit'); ?></option> |
| 406 |
<option value="deactivate" class="hide-if-no-js"><?php echo __('Deactivate', 'wpdirectorykit'); ?></option> |
| 407 |
<option value="activate" class="hide-if-no-js"><?php echo __('Activate', 'wpdirectorykit'); ?></option> |
| 408 |
<?php if (function_exists('run_wdk_membership')): ?> |
| 409 |
<option value="deapprove" class="hide-if-no-js"><?php echo __('Deapprove', 'wpdirectorykit'); ?></option> |
| 410 |
<option value="approve" class="hide-if-no-js"><?php echo __('Approve', 'wpdirectorykit'); ?></option> |
| 411 |
<?php endif; ?> |
| 412 |
</select> |
| 413 |
<input type="hidden" name="page" value="wdk" /> |
| 414 |
<input type="submit" id="table_action" class="button action" name="table_action" value="<?php echo esc_attr__('Apply', 'wpdirectorykit'); ?>"> |
| 415 |
</div> |
| 416 |
|
| 417 |
<?php echo wmvc_xss_clean($pagination_output); ?> |
| 418 |
<br class="clear"> |
| 419 |
</div> |
| 420 |
</form> |
| 421 |
</div> |
| 422 |
<?php |
| 423 |
wp_enqueue_style('wdk-notify'); |
| 424 |
wp_enqueue_script('wdk-notify'); |
| 425 |
?> |
| 426 |
<script> |
| 427 |
// Generate table |
| 428 |
jQuery(document).ready(function($) { |
| 429 |
|
| 430 |
$('.question_sure').on('click', function() { |
| 431 |
return confirm("<?php echo esc_js(__('Are you sure? Selected item will be completely removed!', 'wpdirectorykit')); ?>"); |
| 432 |
}); |
| 433 |
wdk_loading_sublistings(); |
| 434 |
wdk_custom_search_parameters(); |
| 435 |
}); |
| 436 |
|
| 437 |
const wdk_loading_sublistings = ($selector_btn = '.laoding_sublistings') => { |
| 438 |
var init, action, event, eventRemove; |
| 439 |
|
| 440 |
event = (elem) => { |
| 441 |
var listing_id = jQuery(elem).attr('data-listing_id'); |
| 442 |
var self = jQuery(elem); |
| 443 |
|
| 444 |
if (self.attr('disabled')) { |
| 445 |
return false; |
| 446 |
} |
| 447 |
|
| 448 |
self.addClass('wdk_btn_load_indicator out'); |
| 449 |
self.attr('disabled', 'disabled'); |
| 450 |
|
| 451 |
var ajax_param = { |
| 452 |
"page": 'wdk_backendajax', |
| 453 |
"function": 'loading_sublistings', |
| 454 |
"action": 'wdk_public_action', |
| 455 |
"listing_id": listing_id, |
| 456 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce('wdk-backendajax')); ?>', |
| 457 |
}; |
| 458 |
|
| 459 |
jQuery.post("<?php echo admin_url('admin-ajax.php'); ?>", ajax_param, |
| 460 |
function(data) { |
| 461 |
|
| 462 |
if (data.popup_text_success) |
| 463 |
wdk_log_notify(data.popup_text_success); |
| 464 |
|
| 465 |
if (data.popup_text_error) |
| 466 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 467 |
|
| 468 |
self.removeClass('wdk_btn_load_indicator out'); |
| 469 |
|
| 470 |
data.results |
| 471 |
var html = ''; |
| 472 |
jQuery.each(data.results, function(index, value) { |
| 473 |
html += '<tr class="child">\n\ |
| 474 |
<th scope="row"></th>\n\ |
| 475 |
<td scope="row">' + value.post_id + '</td>\n\ |
| 476 |
<td colspan="1">\n\ |
| 477 |
<a target="_blank" href="' + value.listing_edit_url + '">' + value.post_title + '</a>\n\ |
| 478 |
</td>\n\ |
| 479 |
<td>\n\ |
| 480 |
' + value.category + '\n\ |
| 481 |
</td>\n\ |
| 482 |
<td style="text-align: center;">\n\ |
| 483 |
<a class="img-link" href="' + value.listing_edit_url + '">\n\ |
| 484 |
<img src="' + value.image_src + '" alt="thumb" style="height:50px;width:65px;object-fit:cover;text-align: center;"/>\n\ |
| 485 |
</a>\n\ |
| 486 |
</td>\n\ |
| 487 |
<td>\n\ |
| 488 |
' + value.date + '\n\ |
| 489 |
</td>\n\ |
| 490 |
<td>\n\ |
| 491 |
' + value.counter_views + '\n\ |
| 492 |
</td>\n\ |
| 493 |
<td>\n\ |
| 494 |
' + value.counter_results_views + '\n\ |
| 495 |
</td>\n\ |
| 496 |
<td class="actions_column">\n\ |
| 497 |
<a href="' + value.listing_view_url + '" title="<?php echo esc_attr__('View', 'wpdirectorykit'); ?>" target="blank"><span class="dashicons dashicons-visibility"></span></a>\n\ |
| 498 |
<a href="' + value.listing_edit_url + '" title="<?php echo esc_attr__('Edit', 'wpdirectorykit'); ?>"><span class="dashicons dashicons-edit"></span></a>\n\ |
| 499 |
<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\ |
| 500 |
</td>\n\ |
| 501 |
</tr>' |
| 502 |
}); |
| 503 |
|
| 504 |
jQuery(html).insertAfter(self.closest('tr')); |
| 505 |
jQuery(self).remove(); |
| 506 |
|
| 507 |
}).always(function(data) { |
| 508 |
if (true) { |
| 509 |
eventRemove(); |
| 510 |
} else { |
| 511 |
jQuery('.child .question_sure').off().on('click', function() { |
| 512 |
return confirm("<?php echo esc_js(__('Are you sure? Selected item will be completely removed!', 'wpdirectorykit')); ?>"); |
| 513 |
}); |
| 514 |
} |
| 515 |
}); |
| 516 |
|
| 517 |
return false; |
| 518 |
}; |
| 519 |
|
| 520 |
eventRemove = () => { |
| 521 |
jQuery('.child .remove_event').off().on('click', function(e) { |
| 522 |
e.preventDefault(); |
| 523 |
if (!confirm("<?php echo esc_js(__('Are you sure? Selected item will be completely removed!', 'wpdirectorykit')); ?>")) { |
| 524 |
return false; |
| 525 |
} |
| 526 |
|
| 527 |
var self = jQuery(this); |
| 528 |
var listing_id = self.attr('data-listing_id'); |
| 529 |
|
| 530 |
var ajax_param = { |
| 531 |
"page": 'wdk_backendajax', |
| 532 |
"function": 'remove_listing', |
| 533 |
"action": 'wdk_public_action', |
| 534 |
"listing_id": listing_id, |
| 535 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce('wdk-backendajax')); ?>', |
| 536 |
}; |
| 537 |
|
| 538 |
var tr = self.closest('tr'); |
| 539 |
|
| 540 |
self.addClass('wdk_btn_load_indicator out'); |
| 541 |
|
| 542 |
jQuery.post("<?php echo admin_url('admin-ajax.php'); ?>", ajax_param, |
| 543 |
function(data) { |
| 544 |
|
| 545 |
if (data.popup_text_success) |
| 546 |
wdk_log_notify(data.popup_text_success); |
| 547 |
|
| 548 |
if (data.popup_text_error) |
| 549 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 550 |
|
| 551 |
if (data.success) { |
| 552 |
|
| 553 |
setTimeout(function() { |
| 554 |
tr.animate({ |
| 555 |
opacity: 1 / 2 |
| 556 |
}, 500, function() { |
| 557 |
tr.remove(); |
| 558 |
}); |
| 559 |
}, 200); |
| 560 |
|
| 561 |
} else { |
| 562 |
self.removeClass('loading_removing').addClass('loading_removed_error'); |
| 563 |
} |
| 564 |
|
| 565 |
}).always(function(data) { |
| 566 |
self.removeClass('wdk_btn_load_indicator out').addClass('wdk_btn_load_success out'); |
| 567 |
}); |
| 568 |
}) |
| 569 |
}; |
| 570 |
|
| 571 |
action = () => { |
| 572 |
/* |
| 573 |
jQuery($selector_btn).on('click', function(e){ |
| 574 |
e.preventDefault(); |
| 575 |
event(jQuery(this)); |
| 576 |
}); |
| 577 |
*/ |
| 578 |
|
| 579 |
document.querySelectorAll($selector_btn).forEach(elem => elem.addEventListener('click', (e) => { |
| 580 |
e.preventDefault(); |
| 581 |
event(e.target); |
| 582 |
}, false)); |
| 583 |
|
| 584 |
}; |
| 585 |
|
| 586 |
init = () => { |
| 587 |
action(); |
| 588 |
}; |
| 589 |
|
| 590 |
init(); |
| 591 |
}; |
| 592 |
|
| 593 |
const wdk_custom_search_parameters = ($selector_customParameter = '.custom_parameter') => { |
| 594 |
var selector_customParameter = jQuery($selector_customParameter).first(); |
| 595 |
|
| 596 |
var event = () => { |
| 597 |
jQuery('.btn_parameter.add').off().on('click', function(e) { |
| 598 |
e.preventDefault(); |
| 599 |
var cus_field = selector_customParameter.clone().insertAfter(jQuery($selector_customParameter).last()); |
| 600 |
cus_field.find('input,select').val(''); |
| 601 |
|
| 602 |
var key = 1; |
| 603 |
while (jQuery('.custom_parameter .cus_p_field[name="c_field_' + key + '_field"]').length) { |
| 604 |
key++; |
| 605 |
} |
| 606 |
|
| 607 |
cus_field.find('.cus_p_field').attr('name', 'c_field_' + key + '_field'); |
| 608 |
cus_field.find('.cus_p_like').attr('name', 'c_field_' + key + '_like'); |
| 609 |
cus_field.find('.cus_p_value').attr('name', 'c_field_' + key + '_value'); |
| 610 |
}); |
| 611 |
|
| 612 |
jQuery('.btn_parameter.remove').off().on('click', function(e) { |
| 613 |
e.preventDefault(); |
| 614 |
if (jQuery($selector_customParameter).length > 1) { |
| 615 |
jQuery($selector_customParameter).last().remove(); |
| 616 |
} else { |
| 617 |
jQuery($selector_customParameter).last().find('input,select').val(''); |
| 618 |
} |
| 619 |
}); |
| 620 |
}; |
| 621 |
|
| 622 |
event(); |
| 623 |
}; |
| 624 |
</script> |
| 625 |
|
| 626 |
<?php $this->view('general/footer', $data); ?> |