PluginProbe
WP Directory Kit / 1.5.6
WP Directory Kit v1.5.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_listing / index.php

index.php in WP Directory Kit 1.5.6, at application/views/wdk_listing/index.php

993 lines 70.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The template for Edit Listing.
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 __('Add/Edit Listing', 'wpdirectorykit'); ?></h1>
18 <br />
19
20 <?php if (!function_exists('run_wdk_membership')): ?>
21 <div class="notice notice-success">
22 <p>
23 <?php echo __('Do you need to add listing on frontend or allow visitors to add own listings?', 'wpdirectorykit'); ?>
24 <a href="https://wpdirectorykit.com/plugins/wp-directory-membership.html" target="_blank">
25 <?php echo __('Purchase our premium Membership feature and support our work!', 'wpdirectorykit'); ?>
26 </a>
27 </p>
28 </div>
29 <?php endif; ?>
30
31 <?php $this->view('wdk_listing/inc/quick-nav-listings',$data); ?>
32
33 <div class="wdk-body">
34 <form method="post" class="form_listing form_listing_ai" action="<?php echo esc_url(wmvc_current_edit_url()); ?>" enctype="multipart/form-data" novalidate="novalidate">
35 <?php wp_nonce_field('wdk-listing-edit_' . wmvc_show_data('ID', $db_data, 0), '_wpnonce'); ?>
36
37 <div class="postbox" style="display: block;">
38 <div class="postbox-header">
39 <h3 class="wide wdk-gap-15 wdk-d-flex wdk-align-items-start wdk-align-items-center">
40 <?php echo __('Main Data', 'wpdirectorykit'); ?> <?php if (function_exists('PLL')): ?>[<?php echo pll_get_post_language(wmvc_show_data('ID', $db_data, 0), 'slug'); ?>]<?php endif; ?>
41
42 <a href="#"
43 <?php if (!file_exists(ABSPATH . 'wp-content/plugins/wdk-geo/wdk-geo.php')): ?>
44 class="wdk-mr-5 button button-primary alignright wdk-pro"
45 data-button-succuss="<?php echo esc_attr__('Purchase Now', 'wpdirectorykit'); ?>"
46 data-title="<?php echo esc_attr__('Your version doesn\'t support this functionality, please upgrade', 'wpdirectorykit'); ?>"
47 data-content="<?php echo esc_attr__('We constantly maintain compatibility and improving this plugin for living, please support us and purchase, we provide very reasonable prices and will always do our best to help you!', 'wpdirectorykit'); ?>"
48 data-action="https://wpdirectorykit.com/plugin/wp-directory-geo-coding/"
49 <?php elseif (file_exists(ABSPATH . 'wp-content/plugins/wdk-geo/wdk-geo.php') && !function_exists('run_wdk_geo')): ?>
50 class="wdk-mr-5 button button-primary alignright wdk-pro"
51 data-button-succuss="<?php echo esc_attr__('Activate addon WDK Geo', 'wpdirectorykit'); ?>"
52 data-title="<?php echo esc_attr__('Your version doesn\'t support this functionality, please upgrade', 'wpdirectorykit'); ?>"
53 data-content="<?php echo esc_attr__('We constantly maintain compatibility and improving this plugin for living, please support us and purchase, we provide very reasonable prices and will always do our best to help you!', 'wpdirectorykit'); ?>"
54
55 data-action="<?php echo esc_url(get_admin_url() . "plugins.php?plugin_status=all#activate-wdk-geo"); ?>"
56 <?php else: ?>
57 class="wdk-mr-5 button button-primary alignright wdk-geo-listing-google-places-search-btn"
58 <?php endif; ?>>
59 <?php echo __('Google Maps Search', 'wpdirectorykit') ?>
60 </a>
61
62 <?php if (get_option('wdk_sub_listings_enable')): ?>
63 <?php if (!empty(wmvc_show_data('listing_parent_post_id', $db_data))): ?>
64 <?php echo __('Child Listing of', 'wpdirectorykit'); ?> <a target="_blank" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&id=' . wmvc_show_data('listing_parent_post_id', $db_data))); ?>"><?php echo esc_html(wdk_field_value('post_title', wmvc_show_data('listing_parent_post_id', $db_data))); ?></a>
65 <?php elseif (isset($_GET['parent_post_id']) && !empty($_GET['parent_post_id'])): ?>
66 <?php echo __('Child Listing of', 'wpdirectorykit'); ?> <a target="_blank" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&id=' . intval($_GET['parent_post_id']))); ?>"><?php echo esc_html(wdk_field_value('post_title', intval($_GET['parent_post_id']))); ?></a>
67 <?php endif; ?>
68 <?php endif; ?>
69 </h3>
70
71 <?php do_action('wdk/listing/edit/top/buttons/before', wmvc_show_data('ID', $db_data)); ?>
72 <?php if (!empty(wmvc_show_data('ID', $db_data))): ?>
73
74 <?php if ($calendar_id): ?>
75 <a href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk-bookings-calendar&function=edit&id=" . esc_attr($calendar_id)); ?>"
76 class="wdk-mr-5 button button-secondary alignright">
77 <span class="dashicons dashicons-calendar"></span> <?php echo __('Edit Calendar', 'wpdirectorykit') ?>
78 </a>
79 <?php endif; ?>
80
81 <a href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk-duplicate-listing&function=duplicate&listing_post_id=" . wmvc_show_data('ID', $db_data)); ?>"
82 <?php if (!file_exists(ABSPATH . 'wp-content/plugins/wdk-duplicate-listing/wdk-duplicate-listing.php')): ?>
83 class="wdk-mr-5 button button-secondary alignright wdk-pro"
84 data-button-succuss="<?php echo esc_attr__('Purchase Now', 'wpdirectorykit'); ?>"
85 data-title="<?php echo esc_attr__('Your version doesn\'t support this functionality, please upgrade', 'wpdirectorykit'); ?>"
86 data-content="<?php echo esc_attr__('We constantly maintain compatibility and improving this plugin for living, please support us and purchase, we provide very reasonable prices and will always do our best to help you!', 'wpdirectorykit'); ?>"
87 data-action="https://www.wpdirectorykit.com/plugins/wp-directory-duplicate-listing.html"
88 <?php elseif (file_exists(ABSPATH . 'wp-content/plugins/wdk-duplicate-listing/wdk-duplicate-listing.php') && !function_exists('run_wdk_duplicate_listing')): ?>
89 class="wdk-mr-5 button button-secondary alignright wdk-pro"
90 data-button-succuss="<?php echo esc_attr__('Activate addon WDK Duplicate Listing', 'wpdirectorykit'); ?>"
91 data-title="<?php echo esc_attr__('Your version doesn\'t support this functionality, please upgrade', 'wpdirectorykit'); ?>"
92 data-content="<?php echo esc_attr__('We constantly maintain compatibility and improving this plugin for living, please support us and purchase, we provide very reasonable prices and will always do our best to help you!', 'wpdirectorykit'); ?>"
93
94 data-action="<?php echo esc_url(get_admin_url() . "plugins.php?plugin_status=all#activate-wdk-duplicate-listing"); ?>"
95 <?php else: ?>
96 class="wdk-mr-5 button button-secondary alignright"
97 <?php endif; ?>>
98 <span class="dashicons dashicons-admin-page"></span> <?php echo __('Duplicate Listing', 'wpdirectorykit') ?>
99 </a>
100 <a href="<?php echo get_permalink(wmvc_show_data('ID', $db_data)); ?>" title="<?php echo esc_attr__('View', 'wpdirectorykit'); ?>" class="button button-secondary alignright" target="_blank" style="margin-right:15px;"><span class="dashicons dashicons-visibility" ></span> <?php echo __('View listing', 'wpdirectorykit'); ?></a>
101 <?php endif; ?>
102 </div>
103 <div class="inside">
104 <?php
105
106 $success_message = NULL;
107 if (isset($_GET['custom_message']))
108 $success_message = esc_html(urldecode($_GET['custom_message']));
109
110 if (function_exists('run_wdk_bookings')) {
111 /* if booking addon exists, show custom message with link to edit calendar */
112 $success_message .= esc_html__('Successfully saved', 'wpdirectorykit') . '. <a target="_blank" href="' . admin_url('admin.php?page=wdk-bookings-calendar&function=edit&id=' . $calendar_id . '&post_id=' . wmvc_show_data('ID', $db_data)) . '">' . esc_html__('To define calendar availability dates please click here', 'wpdirectorykit') . '</a>';
113 }
114 $form->messages('class="alert alert-danger"', $success_message);
115 ?>
116
117 <div class="wdk-side-content">
118 <div class="wdk-col main">
119 <table class="form-table" role="presentation">
120 <tbody>
121 <tr class="<?php if (method_exists($form, 'hasError') && $form->hasError('post_title')): ?> field-error <?php endif; ?>">
122 <th scope="row"><label for="post_title"><?php echo __('Title', 'wpdirectorykit'); ?>*</label></th>
123 <td>
124 <input name="post_title" type="text" id="post_title" value="<?php echo esc_attr(wmvc_show_data('post_title', $db_data, '')); ?>" placeholder="<?php echo esc_html__('Title', 'wpdirectorykit'); ?>" class="regular-text">
125 <?php if (method_exists($form, 'hasError') && $form->getError('post_title')): ?>
126 <p class="wdk-hint wdk-error">
127 <?php echo wp_kses_post($form->getError('post_title')); ?>
128 </p>
129 <?php endif; ?>
130 </td>
131 </tr>
132 <?php if (get_option('wdk_is_address_enabled', FALSE)): ?>
133 <tr>
134 <th scope="row"><label for="input_address"><?php echo __('Address', 'wpdirectorykit'); ?></label></th>
135 <td>
136 <input name="address" type="text" id="input_address" value="<?php echo esc_attr(wmvc_show_data('address', $db_data, '')); ?>" placeholder="<?php echo esc_html__('Address', 'wpdirectorykit'); ?>" class="regular-text">
137 <p class="description" id="input_address-description"><?php echo __('After you enter address system will try to autodetect and pin location on map, then you can drag and drop pin on map to fine tune location', 'wpdirectorykit'); ?></p>
138 </td>
139 </tr>
140 <?php endif; ?>
141
142 <?php if (get_option('wdk_sub_listings_enable')): ?>
143
144 <?php if (!empty(wmvc_show_data('listing_parent_post_id', $db_data)) || (isset($_GET['parent_post_id']) && !empty($_GET['parent_post_id']))): ?>
145 <tr class="<?php echo (defined('WP_DEBUG') && WP_DEBUG) ? '' : 'hidden'; ?>">
146 <th scope="row"><label for="listing_parent_post_id"><?php echo __('Parent ID', 'wpdirectorykit'); ?>*</label></th>
147 <td>
148 <?php if (!empty(wmvc_show_data('listing_parent_post_id', $db_data))): ?>
149 <input readonly name="listing_parent_post_id" type="text" id="listing_parent_post_id" value="<?php echo esc_attr(wmvc_show_data('listing_parent_post_id', $db_data, '')); ?>" placeholder="<?php echo esc_html__('listing_parent_post_id', 'wpdirectorykit'); ?>" class="regular-text">
150 <?php elseif (isset($_GET['parent_post_id']) && !empty($_GET['parent_post_id'])): ?>
151 <input readonly name="listing_parent_post_id" type="text" id="listing_parent_post_id" value="<?php echo esc_attr(intval($_GET['parent_post_id'])); ?>" placeholder="<?php echo esc_html__('listing_parent_post_id', 'wpdirectorykit'); ?>" class="regular-text">
152 <?php endif; ?>
153 </td>
154 </tr>
155 <?php else: ?>
156 <?php if (!empty(wmvc_show_data('ID', $db_data)) && empty(wmvc_show_data('parent_post_id', $db_data))): ?>
157 <tr>
158 <th scope="row"><label for="listing_related_ids"><?php echo __('Related', 'wpdirectorykit'); ?></label></th>
159 <td>
160 <div class="wdk-listing-childs-wrap">
161
162 <div class="wdk-listing-childs-drop">
163 <?php $related_ids = wmvc_show_data('listing_related_ids', $db_data, ''); ?>
164 <?php if (!empty(wmvc_show_data('listing_related_ids', $db_data, ''))): ?>
165 <?php foreach (explode(',', wmvc_show_data('listing_related_ids', $db_data, '')) as $key => $child_idlisting): ?>
166
167 <?php
168 if (empty(wdk_field_value('post_id', $child_idlisting))) {
169 $related_ids = trim(str_replace(',' . $child_idlisting . '', '', ',' . $related_ids . ','), ',');
170 continue;
171 }
172 ?>
173
174 <div class="drop-listing-item" data-idlisting="<?php echo esc_attr($child_idlisting); ?>">
175 <h3 class="handle">
176 <a target="_blank" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&id=' . $child_idlisting)); ?>" class="title"><?php echo esc_html('#' . $child_idlisting . ', ' . wdk_field_value('post_title', $child_idlisting)); ?></a>
177 <a target="_blank" class="btn" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&id=' . $child_idlisting)); ?>" target="_blank" title="Edit"><span class="dashicons dashicons-edit"></span></a>
178 <a class="question_sure btn remove" href="#" title="Remove"><span class="dashicons dashicons-no"></span></a>
179 </h3>
180 </div>
181 <?php endforeach; ?>
182 <?php endif; ?>
183 </div>
184 <input readonly name="listing_related_ids" type="hidden" id="listing_related_ids" value="<?php echo esc_attr($related_ids); ?>" class="regular-text">
185
186 <div class="wdk-field-edit">
187 <div class="wdk-field-container" style="padding: 0;">
188 <?php echo wdk_treefield_option('new_listing_id', 'listing_m', NULL, 'post_title', '', __('Not Selected', 'wpdirectorykit'), '', FALSE, 'only_nochilds'); ?>
189 <a class="button button-primary add_new_listing" style="margin-left: 5px" href="#"><?php echo __('Add', 'wpdirectorykit'); ?></a>
190 </div>
191 </div>
192 <a target="_blank" class="button button-secondary" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&parent_post_id=' . wmvc_show_data('ID', $db_data))); ?>"><?php echo __('Add New Related Listing', 'wpdirectorykit'); ?></a>
193 </div>
194 </td>
195 </tr>
196 <?php else: ?>
197 <tr>
198 <th scope="row"><label for="listing_related_ids"><?php echo __('Related', 'wpdirectorykit'); ?></label></th>
199 <td>
200 <div class="wdk-listing-childs-wrap">
201 <p class="alert alert-info"><?php echo __('Feature will be available after listing is saved', 'wpdirectorykit'); ?></p>
202 </div>
203 </td>
204 </tr>
205 <?php endif; ?>
206
207 <?php endif; ?>
208
209 <?php endif; ?>
210
211 <?php if (get_option('wdk_is_category_enabled', FALSE)): ?>
212 <?php if (wdk_get_option('wdk_multi_categories_edit_field_type') == 'wdk_treefield_dropdown'): ?>
213 <tr>
214 <th scope="row"><label for="category_id"><?php echo __('Category', 'wpdirectorykit'); ?><?php if (wdk_get_option('wdk_listing_category_required')): ?>*<?php endif; ?></label></th>
215 <td class="wdk_multi_treefield_dropdown_container">
216 <?php
217 global $Winter_MVC_WDK;
218 $Winter_MVC_WDK->load_helper('listing');
219 $Winter_MVC_WDK->model('category_m');
220 $field_value = wmvc_show_data('category_id', $db_data, '');
221 $field_key = 'category_id';
222
223 $categories = array();
224 if (!empty($field_value)) {
225 $categories[] = $field_value;
226 $category = $Winter_MVC_WDK->category_m->get($field_value, TRUE);
227
228 while (!empty($category->parent_id)) {
229 $category = $Winter_MVC_WDK->category_m->get($category->parent_id, TRUE);
230 $categories[] = $category->idcategory;
231 }
232 krsort($categories);
233 } else {
234 $categories[] = 0;
235 }
236
237 wp_enqueue_style('wdk-treefield-dropdown');
238 wp_enqueue_script('wdk-treefield-dropdown');
239 wp_enqueue_style('dashicons');
240
241
242 $level_max = $Winter_MVC_WDK->category_m->get_max_level();
243
244 $placeholder = [
245 0 => esc_html__('Select Categories', 'wpdirectorykit'),
246 1 => esc_html__('Select Sub Categories', 'wpdirectorykit'),
247 2 => esc_html__('Select Sub Categories', 'wpdirectorykit'),
248 3 => esc_html__('Select Sub Categories', 'wpdirectorykit'),
249 4 => esc_html__('Select Sub Categories', 'wpdirectorykit'),
250 5 => esc_html__('Select Sub Categories', 'wpdirectorykit'),
251 ];
252 ?>
253
254 <input name="<?php echo esc_attr($field_key); ?>" type="hidden" value="<?php echo esc_attr($field_value); ?>">
255 <?php
256 $level = 0;
257 $current = NULL;
258
259 foreach ($categories as $category) {
260 $current = $Winter_MVC_WDK->category_m->get($category, TRUE);
261 if (!$current)
262 break;
263 $list = $Winter_MVC_WDK->category_m->get_by(array('parent_id = ' . $current->parent_id => NULL));
264
265 if (isset($placeholder[$level])) {
266 $values_list = array('' => $placeholder[$level]);
267 } else {
268 $values_list = array('' => esc_html__('Select Sub Categories', 'wpdirectorykit'));
269 }
270
271 foreach ($list as $list_value) {
272 $values_list[$list_value->idcategory] = $list_value->category_title;
273 }
274 ?>
275
276 <div data-level="<?php echo esc_attr($level); ?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk_multi_treefield_dropdown wdk_treefield_dropdown">
277 <div class="wdk-field-group">
278 <?php echo wmvc_select_option('category_' . $level, $values_list, $category, 'class="wdk-control"'); ?>
279 </div>
280 </div>
281
282 <?php
283 $level++;
284 }
285
286 if ($level < $level_max) {
287 for (; $level < $level_max;) {
288
289 if (isset($placeholder[$level])) {
290 $values_list = array('' => $placeholder[$level]);
291 } else {
292 $values_list = array('' => esc_html__('Select Sub Categories', 'wpdirectorykit'));
293 }
294
295 if ($category) {
296 $list = $Winter_MVC_WDK->category_m->get_by(array('parent_id = ' . $category => NULL));
297 foreach ($list as $list_value) {
298 $values_list[$list_value->idcategory] = $list_value->category_title;
299 }
300 $category = NULL;
301 }
302
303 ?>
304 <div data-level="<?php echo esc_attr($level); ?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk_multi_treefield_dropdown wdk_treefield_dropdown">
305 <div class="wdk-field-group">
306 <?php echo wmvc_select_option('category_' . $level, $values_list, NULL, 'class="wdk-control"'); ?>
307 </div>
308 </div>
309
310 <?php
311 $level++;
312 }
313 }
314 ?>
315 </td>
316 </tr>
317 <?php else: ?>
318 <tr>
319 <th scope="row"><label for="category_id"><?php echo __('Category', 'wpdirectorykit'); ?><?php if (wdk_get_option('wdk_listing_category_required')): ?>*<?php endif; ?></label></th>
320 <td>
321 <div class="wdk-field-edit edittable">
322 <div class="wdk-field-container">
323 <?php echo wdk_treefield_option('category_id', 'category_m', wmvc_show_data('category_id', $db_data, ''), 'category_title', '', __('Not Selected', 'wpdirectorykit')); ?>
324 </div>
325 </div>
326 </td>
327 </tr>
328 <?php endif; ?>
329 <?php endif; ?>
330
331 <?php if (get_option('wdk_is_category_enabled', FALSE) && get_option('wdk_multi_categories_other_enable', FALSE)): ?>
332 <tr>
333 <th scope="row"><label for="listing_categories"><?php echo __('More Categories', 'wpdirectorykit'); ?></label></th>
334 <td class="">
335 <?php echo wdk_treefield_select_ajax('listing_sub_categories[]', 'category_m', wmvc_show_data('listing_sub_categories', $db_data, '', TRUE, TRUE), 'category_title', 'idcategory', '', __('All Categories', 'wpdirectorykit'), '', 'data-limit="10"'); ?>
336 </td>
337 </tr>
338 <?php endif; ?>
339
340 <?php if (get_option('wdk_is_location_enabled', FALSE)): ?>
341 <?php if (wdk_get_option('wdk_multi_categories_edit_field_type') == 'wdk_treefield_dropdown'): ?>
342 <tr>
343 <th scope="row"><label for="location_id"><?php echo __('Location', 'wpdirectorykit'); ?><?php if (wdk_get_option('wdk_listing_category_required')): ?>*<?php endif; ?></label></th>
344 <td class="wdk_multi_treefield_dropdown_container">
345 <?php
346 global $Winter_MVC_WDK;
347 $Winter_MVC_WDK->load_helper('listing');
348 $Winter_MVC_WDK->model('location_m');
349 $field_value = wmvc_show_data('location_id', $db_data, '');
350 $field_key = 'location_id';
351
352 $locations = array();
353 if (!empty($field_value)) {
354 $locations[] = $field_value;
355 $location = $Winter_MVC_WDK->location_m->get($field_value, TRUE);
356
357 while (!empty($location->parent_id)) {
358 $location = $Winter_MVC_WDK->location_m->get($location->parent_id, TRUE);
359 $locations[] = $location->idlocation;
360 }
361 krsort($locations);
362 } else {
363 $locations[] = 0;
364 }
365
366 wp_enqueue_style('wdk-treefield-dropdown');
367 wp_enqueue_script('wdk-treefield-dropdown');
368 wp_enqueue_style('dashicons');
369
370 $level_max = $Winter_MVC_WDK->location_m->get_max_level();
371
372 $placeholder = [
373 0 => esc_html__('Select Country', 'wpdirectorykit'),
374 1 => esc_html__('Select City', 'wpdirectorykit'),
375 2 => esc_html__('Select Neighborhood', 'wpdirectorykit'),
376 3 => esc_html__('Select Sub Area', 'wpdirectorykit'),
377 4 => esc_html__('Select Sub Area', 'wpdirectorykit'),
378 5 => esc_html__('Select Sub Area', 'wpdirectorykit'),
379 ];
380 ?>
381
382 <input name="<?php echo esc_attr($field_key); ?>" type="hidden" value="<?php echo esc_attr($field_value); ?>">
383 <?php
384 $level = 0;
385 $current = NULL;
386
387 foreach ($locations as $location) {
388 $current = $Winter_MVC_WDK->location_m->get($location, TRUE);
389 if (!$current)
390 break;
391 $list = $Winter_MVC_WDK->location_m->get_by(array('parent_id = ' . $current->parent_id => NULL));
392
393 if (isset($placeholder[$level])) {
394 $values_list = array('' => $placeholder[$level]);
395 } else {
396 $values_list = array('' => esc_html__('Select Sub Area', 'wpdirectorykit'));
397 }
398
399 foreach ($list as $list_value) {
400 $values_list[$list_value->idlocation] = $list_value->location_title;
401 }
402 ?>
403
404 <div data-level="<?php echo esc_attr($level); ?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk_multi_treefield_dropdown wdk_treefield_dropdown">
405 <div class="wdk-field-group">
406 <?php echo wmvc_select_option('location_' . $level, $values_list, $location, 'class="wdk-control"'); ?>
407 </div>
408 </div>
409
410 <?php
411 $level++;
412 }
413
414 if ($level < $level_max) {
415 for (; $level < $level_max;) {
416
417 if (isset($placeholder[$level])) {
418 $values_list = array('' => $placeholder[$level]);
419 } else {
420 $values_list = array('' => esc_html__('Select Sub Area', 'wpdirectorykit'));
421 }
422
423
424 if (isset($placeholder[$level])) {
425 $values_list = array('' => $placeholder[$level]);
426 } else {
427 $values_list = array('' => esc_html__('Select Sub Area', 'wpdirectorykit'));
428 }
429
430 if ($location) {
431 $list = $Winter_MVC_WDK->location_m->get_by(array('parent_id = ' . $location => NULL));
432 foreach ($list as $list_value) {
433 $values_list[$list_value->idlocation] = $list_value->location_title;
434 }
435 $location = NULL;
436 }
437
438 ?>
439 <div data-level="<?php echo esc_attr($level); ?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk_multi_treefield_dropdown wdk_treefield_dropdown">
440 <div class="wdk-field-group">
441 <?php echo wmvc_select_option('location_' . $level, $values_list, NULL, 'class="wdk-control"'); ?>
442 </div>
443 </div>
444
445 <?php
446 $level++;
447 }
448 }
449 ?>
450 </td>
451 </tr>
452 <?php else: ?>
453 <tr>
454 <th scope="row"><label for="location_id"><?php echo __('Location', 'wpdirectorykit'); ?><?php if (wdk_get_option('wdk_listing_category_required')): ?>*<?php endif; ?></label></th>
455 <td>
456 <div class="wdk-field-edit edittable">
457 <div class="wdk-field-container">
458 <?php echo wdk_treefield_option('location_id', 'location_m', wmvc_show_data('location_id', $db_data, ''), 'location_title', '', __('Not Selected', 'wpdirectorykit')); ?>
459 </div>
460 </div>
461 </td>
462 </tr>
463 <?php endif; ?>
464 <?php endif; ?>
465
466 <?php if (get_option('wdk_is_location_enabled', FALSE) && get_option('wdk_multi_locations_other_enable', FALSE)): ?>
467 <tr>
468 <th scope="row"><label for="listing_agents"><?php echo __('More Locations', 'wpdirectorykit'); ?></label></th>
469 <td class="">
470 <?php echo wdk_treefield_select_ajax('listing_sub_locations[]', 'location_m', wmvc_show_data('listing_sub_locations', $db_data, '', TRUE, TRUE), 'location_title', 'idlocation', '', __('All Locations', 'wpdirectorykit'), '', 'data-limit="10"'); ?>
471 </td>
472 </tr>
473 <?php endif; ?>
474 <?php if (wdk_get_option('wdk_is_user_editor_enabled', FALSE)): ?>
475 <tr>
476 <th scope="row"><label for="user_id_editor"><?php echo __('Agent Editor', 'wpdirectorykit'); ?></label></th>
477 <td>
478 <div class="wdk-field-edit edittable">
479 <div class="wdk-field-container">
480 <?php echo wdk_treefield_option('user_id_editor', 'user_m', wmvc_show_data('user_id_editor', $db_data, ''), 'display_name', '', __('Not Selected', 'wpdirectorykit')); ?>
481 </div>
482 </div>
483 </td>
484 </tr>
485 <?php endif; ?>
486 <?php if (wdk_get_option('wdk_is_alt_agent_enabled', FALSE)): ?>
487 <?php if (function_exists('run_wdk_membership')): ?>
488 <tr>
489 <th scope="row"><label for="listing_agents"><?php echo __('Alternative Agents', 'wpdirectorykit'); ?></label></th>
490 <td class="">
491 <?php echo wdk_user_select_ajax('listing_agents[]', array_keys(wmvc_show_data('listing_agents', $db_data, '', TRUE, TRUE)), __('Add Agents', 'wpdirectorykit')); ?>
492 </td>
493 <?php if (false): ?>
494 <td class="agents_group">
495 <?php echo wdk_select_multi_option('listing_agents[]', wmvc_show_data('listing_agents', $db_data, '', TRUE, TRUE), array_keys(wmvc_show_data('listing_agents', $db_data, '', TRUE, TRUE)), "id='listing_agents'"); ?>
496 <div class="agent_add form-inline">
497 <div class="wdk-field-edit">
498 <div class="wdk-field-container">
499 <?php echo wdk_treefield_option('agent_id', 'user_m', '', 'display_name', '', __('Not Selected', 'wpdirectorykit')); ?>
500 </div>
501 </div>
502 <button type="button" class="button button-primary add_button"><?php echo __('Add agent', 'wpdirectorykit'); ?></button>
503 <button type="button" title="<?php echo __('Remove latest on list', 'wpdirectorykit'); ?>" class="button button-secondary rem_button"><?php echo __('X', 'wpdirectorykit'); ?></button>
504 </div>
505 </td>
506 <?php endif; ?>
507 </tr>
508 <?php endif; ?>
509 <?php endif; ?>
510
511 <?php if (wdk_get_option('wdk_membership_is_enable_subscriptions') && function_exists('run_wdk_membership')): ?>
512 <tr>
513 <th scope="row"><label for="subscription_id"><?php echo __('Membership Subscription', 'wpdirectorykit'); ?></label></th>
514 <td>
515 <?php
516 echo wmvc_select_option('subscription_id', $subscriptions, wmvc_show_data('subscription_id', $db_data, ''), "id='subscription_id' class='regular-text'", __('Not Selected', 'wpdirectorykit'));
517 ?>
518 </td>
519 </tr>
520 <?php endif; ?>
521
522 <?php if (function_exists('run_wdk_payments') && isset($packages)): ?>
523 <tr>
524 <th scope="row"><label for="packages"><?php echo __('Package', 'wpdirectorykit'); ?></label></th>
525 <td>
526 <?php
527 echo wmvc_select_option('package_id', $packages, wmvc_show_data('package_id', $db_data, ''), "id='packages'", __('Not Selected', 'wpdirectorykit'));
528 ?>
529 </td>
530 </tr>
531 <?php endif; ?>
532
533 <?php if (wdk_get_option('wdk_is_rank_enabled', FALSE)): ?>
534 <tr>
535 <th scope="row"><label for="rank"><?php echo __('Rank', 'wpdirectorykit'); ?></label></th>
536 <td>
537 <input <?php if (!wmvc_user_in_role('administrator') && !current_user_can('wdk_listings_manage')): ?> readonly="readonly" <?php endif; ?> name="rank" type="number" id="rank" value="<?php echo esc_attr(wmvc_show_data('rank', $db_data, '')); ?>" placeholder="<?php echo esc_html__('Rank', 'wpdirectorykit'); ?>" class="regular-text">
538 <p class="description" id="input_rank-description"><b><?php echo __('Rank', 'wpdirectorykit'); ?></b> <?php echo esc_html__('is number, higher number means a better position/rank in results.', 'wpdirectorykit'); ?></p>
539 </td>
540 </tr>
541 <?php endif; ?>
542
543 <?php if (wdk_get_option('wdk_is_featured_enabled', FALSE)): ?>
544 <tr>
545 <th scope="row"><label for="is_featured"><?php echo __('Is Featured', 'wpdirectorykit'); ?></label></th>
546 <td>
547 <input name="is_featured" type="checkbox" id="is_featured" value="1" <?php echo !empty(wmvc_show_data('is_featured', $db_data, '')) ? 'checked' : ''; ?>><label for="is_featured"><?php echo __('Make it featured', 'wpdirectorykit'); ?></label>
548 <p class="description" id="is_featured-description"><?php echo __('Featured/Highlighted listing in results', 'wpdirectorykit'); ?></p>
549 </td>
550 </tr>
551 <?php endif; ?>
552
553 <tr>
554 <th scope="row"><label for="is_activated"><?php echo __('Is Activated', 'wpdirectorykit'); ?></label></th>
555 <td>
556 <input name="is_activated" type="checkbox" id="is_activated" value="1" <?php echo !empty(wmvc_show_data('is_activated', $db_data, '')) ? 'checked' : ''; ?>><label for="is_activated"><?php echo __('Make it available for public', 'wpdirectorykit'); ?></label>
557 <p class="description" id="is_activated-description"><?php echo __('When enabled, the listing becomes visible on the frontend. The listing owner can activate or deactivate the listing at any time.', 'wpdirectorykit'); ?></p>
558 </td>
559 </tr>
560 <?php if (function_exists('run_wdk_membership')): ?>
561 <tr>
562 <th scope="row"><label for="is_approved"><?php echo __('Is Approved', 'wpdirectorykit'); ?></label></th>
563 <td>
564 <input name="is_approved" type="checkbox" id="is_approved" value="1" <?php echo !empty(wmvc_show_data('is_approved', $db_data, '')) ? 'checked' : ''; ?>><label for="is_approved"><?php echo __('Make it approved for public', 'wpdirectorykit'); ?></label>
565 <p class="description" id="is_approved-description"><?php echo __('When approved, the listing is eligible to be shown on the frontend, but it must also be activated. Approval can be granted by an admin, and for certain membership packages, listings may be auto-approved if configured.', 'wpdirectorykit'); ?> (<?php echo __('only admin can approve', 'wpdirectorykit'); ?>)</p>
566 </td>
567 </tr>
568 <?php endif; ?>
569 <tr>
570 <th scope="row"><label for="slug"><?php echo __('Slug', 'wpdirectorykit'); ?></label></th>
571 <td>
572 <input <?php if (!wmvc_user_in_role('administrator') && !current_user_can('wdk_listings_manage')): ?> readonly="readonly" <?php endif; ?> name="slug" type="text" id="slug" value="<?php echo esc_attr(wmvc_show_data('post_name', $db_data, '')); ?>" placeholder="<?php echo esc_html__('Slug', 'wpdirectorykit'); ?>" class="regular-text">
573 </td>
574 </tr>
575 </tbody>
576 </table>
577 </div>
578 <div class="wdk-col sidebar">
579 <?php if (get_option('wdk_is_address_enabled', FALSE)): ?>
580 <div class="clearfix">
581 <a href="#" class="button button-secondary alignright wdk_action_clear_gps_reset_map"><?php echo esc_html__('Clear Gps coordinates', 'wpdirectorykit'); ?></a>
582 </div>
583 <br />
584 <div id="map" class="listing_edit_map"></div>
585 <br />
586 <p class="alert alert-info"><?php echo esc_html__('Drag and drop pin to desired location', 'wpdirectorykit'); ?></p>
587 <div class="wdk-field-edit inline">
588 <label for="listing_gps"><?php echo esc_html__('GPS', 'wpdirectorykit'); ?>:</label>
589 <div class="wdk-field-container">
590 <input name="lat" readonly="readonly" type="text" id="input_lat" value="<?php echo esc_attr(wmvc_show_data('lat', $db_data, '')); ?>" class="regular-text" placeholder="<?php echo esc_html__('lat', 'wpdirectorykit'); ?>">
591 <input name="lng" readonly="readonly" type="text" id="input_lng" value="<?php echo esc_attr(wmvc_show_data('lng', $db_data, '')); ?>" class="regular-text" placeholder="<?php echo esc_html__('lng', 'wpdirectorykit'); ?>">
592 </div>
593 </div>
594 <?php endif; ?>
595 <?php if (!empty($edit_log)): ?>
596 <div class="wdk_editlog">
597 <table class="table table-bordered">
598 <caption><?php echo esc_html__('Edit History', 'wpdirectorykit'); ?></caption>
599 <thead>
600 <tr>
601 <th><?php echo esc_html__('User', 'wpdirectorykit'); ?></th>
602 <th><?php echo esc_html__('Date', 'wpdirectorykit'); ?></th>
603 <th><?php echo esc_html__('IP', 'wpdirectorykit'); ?></th>
604 </tr>
605 </thead>
606 <tbody>
607 <?php foreach ($edit_log as $log_row): ?>
608 <tr>
609 <td><?php echo esc_html($log_row->display_name); ?></td>
610 <td><?php echo esc_html(wdk_get_date($log_row->date)); ?></td>
611 <td><?php echo esc_html($log_row->ip); ?></td>
612 </tr>
613 <?php endforeach; ?>
614
615 </tbody>
616 </table>
617 </div>
618
619 <?php endif; ?>
620
621 </div>
622 </div>
623
624 <?php if (wdk_get_option('wdk_is_post_content_enable', FALSE)): ?>
625 <table class="form-table <?php if (method_exists($form, 'hasError') && $form->hasError('post_content')): ?> field-error <?php endif; ?>" role="presentation">
626 <tbody>
627 <tr>
628 <th scope="row"><label for="post_content"><?php echo __('Content', 'wpdirectorykit'); ?>*</label></th>
629 <td><?php wp_editor(
630 wmvc_show_data('post_content', $db_data, ''),
631 'post_content',
632 apply_filters('wpdirectorykit/listing_edit/textarea_wysiwyg/config', array(
633 'media_buttons' => TRUE,
634 ))
635 ); ?>
636 <?php if (method_exists($form, 'hasError') && $form->getError('post_content')): ?>
637 <p class="wdk-hint wdk-error">
638 <?php echo wp_kses_post($form->getError('post_content')); ?>
639 </p>
640 <?php endif; ?>
641 </td>
642 </tr>
643 </tbody>
644 </table>
645 <?php endif; ?>
646 </div>
647 </div>
648 <div class="postbox listing_custom_fields" style="display: block;">
649 <div class="inside wdk-row">
650 <?php if (count($fields) == 0): ?>
651 <div class="wdk-col-12">
652 <div class="alert alert-success mb0">
653 <p><?php echo __('Fields doesn\'t exists', 'wpdirectorykit'); ?> <a href="<?php echo esc_url(get_admin_url() . "admin.php?page=wdk_fields"); ?>" class="button button-primary" id="add_field_button"><?php echo __('Manage Fields', 'wpdirectorykit'); ?></a></p>
654 </div>
655 </div>
656 <?php endif; ?>
657
658 <?php echo wdk_generate_fields($fields, $db_data, $form); ?>
659 </div>
660 </div>
661 <?php if (!wdk_get_option('wdk_listing_plangs_documents_disable')): ?>
662 <div class="postbox" style="display: block;">
663 <div class="postbox-header">
664 <h3><?php echo __('Listing plans and documents', 'wpdirectorykit'); ?></h3>
665 </div>
666 <div class="inside">
667 <p class="alert alert-info"><?php echo __('Drag and drop files to change order', 'wpdirectorykit'); ?></p>
668 <?php
669 echo wdk_upload_multi_files('listing_plans_documents', wmvc_show_data('listing_plans_documents', $db_data, ''));
670 ?>
671 </div>
672 </div>
673 <?php endif; ?>
674 <?php if (!wdk_get_option('wdk_listing_images_disable')): ?>
675 <div class="postbox" style="display: block;">
676 <div class="postbox-header">
677 <h3><?php echo __('Listing Images/Videos', 'wpdirectorykit'); ?></h3>
678 </div>
679 <div class="inside">
680 <p class="alert alert-info"><?php echo __('Drag and drop image to change order', 'wpdirectorykit'); ?></p>
681 <?php
682 echo wmvc_upload_multiple('listing_images', wmvc_show_data('listing_images', $db_data, ''));
683 ?>
684 </div>
685 </div>
686 <?php endif; ?>
687 <button type="submit" class="button button-primary wdk-submit-loading out"><?php echo esc_html__('Save Changes', 'wpdirectorykit'); ?></button>
688 </form>
689 </div>
690
691 <?php do_action('wpdirectorykit/admin/listing/edit/after_form', $db_data); ?>
692 </div>
693 <?php
694 wp_enqueue_style('leaflet');
695 wp_enqueue_script('leaflet');
696
697 wp_enqueue_style('wdk-notify');
698 wp_enqueue_script('wdk-notify');
699
700 wp_enqueue_style('jquery-confirm');
701 wp_enqueue_script('jquery-confirm');
702
703
704 wp_enqueue_style('wdk-geo-listing-google-places-search');
705 wp_enqueue_script('wdk-geo-listing-google-places-search');
706 ?>
707
708 <?php
709 wp_enqueue_script('jquery-ui-core', false, array('jquery'));
710 wp_enqueue_script('jquery-ui-sortable', false, array('jquery'));
711 ?>
712
713 <script>
714 // Generate table
715 jQuery(document).ready(function($) {
716
717 <?php if (get_option('wdk_is_address_enabled', FALSE)): ?>
718 var wdk_edit_map_marker, wdk_timerMap, wdk_edit_map;
719 wdk_edit_map = L.map('map', {
720 center: [<?php echo (wmvc_show_data('lat', $db_data) ?: get_option('wdk_default_lat', 51.505)); ?>, <?php echo (wmvc_show_data('lng', $db_data) ?: get_option('wdk_default_lng', -0.09)); ?>],
721 zoom: 4,
722 });
723
724 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
725 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
726 }).addTo(wdk_edit_map);
727
728 wdk_edit_map_marker = L.marker(
729 [<?php echo (wmvc_show_data('lat', $db_data) ?: get_option('wdk_default_lat', 51.505)); ?>, <?php echo (wmvc_show_data('lng', $db_data) ?: get_option('wdk_default_lng', -0.09)); ?>], {
730 draggable: true
731 }
732 ).addTo(wdk_edit_map);
733
734 wdk_edit_map_marker.on('dragend', function(event) {
735 clearTimeout(wdk_timerMap);
736 var marker = event.target;
737 var {
738 lat,
739 lng
740 } = marker.getLatLng();
741 $('#input_lat').val(lat);
742 $('#input_lng').val(lng);
743 //retrieved the position
744 });
745
746 /* reset map and gps */
747 $('.wdk_action_clear_gps_reset_map').on('click', function(e) {
748 e.preventDefault();
749 $('#input_lat,#input_lng').val('');
750
751 /* move marker on default poisition */
752 wdk_edit_map_marker.setLatLng([<?php echo esc_js(get_option('wdk_default_lat', 51.505)); ?>, <?php echo esc_js(get_option('wdk_default_lng', -0.09)); ?>]).update();
753 wdk_edit_map.panTo(new L.LatLng(<?php echo esc_js(get_option('wdk_default_lat', 51.505)); ?>, <?php echo esc_js(get_option('wdk_default_lng', -0.09)); ?>));
754 });
755
756 wdk_edit_map.on('click', function(e) {
757 let lat = e.latlng.lat;
758 let lng = e.latlng.lng;
759
760 wdk_edit_map_marker.setLatLng([lat, lng]).update();
761 $('#input_lat').val(lat);
762 $('#input_lng').val(lng);
763 })
764
765 $('#input_address').on('change keyup', function(e) {
766 clearTimeout(wdk_timerMap);
767 wdk_timerMap = setTimeout(function() {
768 var googleApiKey = '<?php echo esc_js(get_option('wdk_geo_google_api_key', '')); ?>';
769 var address = $('#input_address').val();
770
771 // If we have a Google API key, try Google Geocoding FIRST
772 if (googleApiKey) {
773 $.get('https://maps.googleapis.com/maps/api/geocode/json?address=' + encodeURIComponent(address) + '&key=' + googleApiKey, function(googleData) {
774 if (googleData.status === "OK" && googleData.results.length > 0) {
775 var location = googleData.results[0].geometry.location;
776 wdk_edit_map_marker.setLatLng([location.lat, location.lng]).update();
777 wdk_edit_map.panTo(new L.LatLng(location.lat, location.lng));
778 $('#input_lat').val(location.lat);
779 $('#input_lng').val(location.lng);
780 } else {
781 // If not found by Google, try Nominatim
782 $.get('https://nominatim.openstreetmap.org/search?format=json&q=' + encodeURIComponent(address), function(data) {
783 if (data.length && typeof data[0]) {
784 var {
785 lat,
786 lon
787 } = data[0];
788 wdk_edit_map_marker.setLatLng([lat, lon]).update();
789 wdk_edit_map.panTo(new L.LatLng(lat, lon));
790 $('#input_lat').val(lat);
791 $('#input_lng').val(lon);
792 } else {
793 wdk_log_notify('<?php echo esc_js(__('Address not found', 'wpdirectorykit')); ?>', 'error');
794 }
795 });
796 }
797 }).fail(function() {
798 wdk_log_notify('<?php echo esc_js(__('Google Geocoding API request failed.', 'wpdirectorykit')); ?>', 'error');
799 });
800 } else {
801 // If no API key, use Nominatim as fallback/only method
802 $.get('https://nominatim.openstreetmap.org/search?format=json&q=' + encodeURIComponent(address), function(data) {
803 if (data.length && typeof data[0]) {
804 var {
805 lat,
806 lon
807 } = data[0];
808 wdk_edit_map_marker.setLatLng([lat, lon]).update();
809 wdk_edit_map.panTo(new L.LatLng(lat, lon));
810 $('#input_lat').val(lat);
811 $('#input_lng').val(lon);
812 } else {
813 wdk_log_notify('<?php echo esc_js(__('Address not found', 'wpdirectorykit')); ?>', 'error');
814 if ($('#input_address').parent().find('[data-alert="google"]').length === 0) {
815 $('#input_address').parent().append(`<div class="alert alert-info" data-alert="google"><?php echo wdk_sprintf(
816 esc_html__('Address not found, try enter google maps api key for more accurate results %1$s[here]%2$s','wpdirectorykit'),
817 '<a target="_blank" href="'.esc_url(admin_url("admin.php?page=wdk_settings&wdk_tabs=wdk_tab_apis#wdk_geo_google_api_key")).'">','</a>'
818 );?></div>`);
819 }
820 return;
821 }
822 });
823 }
824
825 }, 1000);
826 });
827
828 $('#input_gps').on('change keyup', function(e) {
829 wdk_edit_map.panTo(new L.LatLng($('#input_lat').val(), $('#input_lng').val()));
830 wdk_edit_map_marker.setLatLng([parseFloat($('#input_lat').val()), parseFloat($('#input_lng').val())]).update();
831 })
832 <?php endif; ?>
833
834 /* agents */
835
836 $('.agents_group .add_button').on("click", function(e) {
837 e.preventDefault();
838 var group_agent = $(this).closest('.agents_group');
839 var agent_id = group_agent.find('input[name="agent_id"]').val();
840
841 if (agent_id != '') {
842 var exists = 0 != group_agent.find('#listing_agents').find('option[value=' + agent_id + ']').length;
843 var agent_name = group_agent.find('.wdk_dropdown_tree .btn-group .btn:first').text();
844
845 if (!exists) {
846 group_agent.find('#listing_agents').append('<option value="' + agent_id + '" selected>' + agent_name + '</option>');
847 } else {
848 wdk_log_notify('<?php echo esc_js(__('Already on list', 'wpdirectorykit')); ?>', 'error');
849 }
850 } else {
851 wdk_log_notify('<?php echo esc_js(__('Not selected', 'wpdirectorykit')); ?>', 'error');
852 }
853 });
854
855 $('.agents_group .rem_button').on("click", function() {
856 $(this).closest('.agents_group').find('#listing_agents option:selected:last').remove();
857 });
858
859
860 $('form.form_listing').on('submit', function(e) {
861 if ($(this).find('#listing_agents').length) {
862 $('#listing_agents').find('option').prop("selected", true).trigger('change')
863 }
864 });
865
866 wdk_childs_listings_list();
867
868 $('.select_ajax_user').on('select2:selecting', function(e) {
869 // Get the selected option value
870 var selectedValue = e.params.args.data.id;
871 var selecteduserEditor = $('[name="user_id_editor"]').val();
872
873 // Check if the selected option should be prevented from being added
874 if (selectedValue == selecteduserEditor) {
875 // Prevent the option from being added
876 e.preventDefault();
877 wdk_log_notify('<?php echo esc_js(esc_attr__('User Alread defiend like editor', 'wpdirectorykit')); ?>', 'error');
878 }
879 });
880
881
882
883 });
884
885
886 const wdk_childs_listings_list = ($selector = '.wdk-listing-childs-wrap', $field_name = 'listing_related_ids') => {
887 var el_wrapper = jQuery($selector);
888 var remove_child_listing, save_data;
889
890 remove_child_listing = () => {
891 el_wrapper.find(".wdk-listing-childs-drop .drop-listing-item .remove").off().on('click', function(e) {
892 e.preventDefault();
893
894 if (confirm("<?php echo esc_js(__('Are you sure?', 'wpdirectorykit')); ?>")) {
895 jQuery(this).closest('.drop-listing-item').remove();
896 save_data();
897 }
898 });
899 };
900
901 save_data = () => {
902 var data_fields_sublist = '';
903 el_wrapper.find('.wdk-listing-childs-drop .drop-listing-item').each(function(index) {
904 if (data_fields_sublist != '')
905 data_fields_sublist += ',';
906
907 data_fields_sublist += jQuery(this).attr('data-idlisting');
908 });
909 el_wrapper.find('input[name="' + $field_name + '"]').val(data_fields_sublist);
910 }
911
912 remove_child_listing();
913
914 el_wrapper.find(".wdk-listing-childs-drop").sortable({
915 connectWith: ".wdk-listing-childs-drop",
916 placeholder: "ui-sortable-placeholder widget-placeholder",
917 update: function(event, ui) {
918 save_data();
919 }
920 }).disableSelection();
921
922 el_wrapper.find('.add_new_listing').on('click', function(e) {
923 e.preventDefault();
924
925 var listing_id = el_wrapper.find('input[name="new_listing_id"]').val();
926 var listing_title = el_wrapper.find('.wdk_dropdown_tree button:first-child').text();
927
928 if (listing_id == '') {
929 wdk_log_notify('<?php echo esc_js(esc_attr__('Listing Not Defined', 'wpdirectorykit')); ?>', 'error');
930 return;
931 }
932
933 if (listing_id == '<?php echo esc_js(wmvc_show_data('ID', $db_data)); ?>') {
934 wdk_log_notify('<?php echo esc_js(esc_attr__('Impossible add current listing', 'wpdirectorykit')); ?>', 'error');
935 return;
936 }
937
938 if (el_wrapper.find(".wdk-listing-childs-drop .drop-listing-item[data-idlisting='" + listing_id + "']").length) {
939 wdk_log_notify('<?php echo esc_js(esc_attr__('Listing already added', 'wpdirectorykit')); ?>', 'error');
940 return;
941 }
942
943 var item_html = '<div class="drop-listing-item" data-idlisting="' + listing_id + '">\n\
944 <h3 class="handle"> \n\
945 <a target="_blank" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&id=')); ?>' + listing_id + '" class="title">' + listing_title + '</a>\n\
946 <a target="_blank" class="btn" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&id=')); ?>' + listing_id + '" target="_blank" title="Edit"><span class="dashicons dashicons-edit"></span></a>\n\
947 <a class="question_sure btn remove" href="#" title="<?php echo esc_js(__('Remove', 'wpdirectorykit')); ?>"><span class="dashicons dashicons-no"></span></a>\n\
948 </h3> \n\
949 </div>';
950
951 el_wrapper.find(".wdk-listing-childs-drop").append(item_html);
952 remove_child_listing();
953 save_data();
954 });
955 };
956
957
958 </script>
959
960 <style>
961 .form-table .agent_add.form-inline .wdk-field-edit {
962 display: inline-block;
963 }
964
965 .form-table .agent_add.form-inline .wdk-field-edit .wdk-field-container {
966 padding: 0;
967 }
968
969 .form-table .agent_add.form-inline .wdk-field-edit,
970 .form-table .agent_add.form-inline .button {
971 margin: 15px 0px;
972 }
973
974 .form-table #listing_agents {
975 max-width: 100%;
976 width: 25em;
977 }
978
979 .form-table .agent_add.form-inline .wdk_dropdown_tree {
980 width: 230px;
981 max-width: 100%;
982 }
983
984 .wdk-wrap .wdk-row {
985 margin-right: -12px;
986 margin-left: -12px;
987 }
988
989 </style>
990
991 <?php $this->view('general/footer', $data); ?>
992
993