PluginProbe
WP Directory Kit / 1.2.6
WP Directory Kit v1.2.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.2.6, at application/views/wdk_listing/index.php

809 lines 57.6 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 Edit Listing.
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 __('Add/Edit Listing', 'wpdirectorykit'); ?></h1>
17 <br /><br />
18 <div class="wdk-body">
19 <form method="post" class="form_listing" action="<?php echo wmvc_current_edit_url(); ?>" enctype="multipart/form-data" novalidate="novalidate">
20 <?php wp_nonce_field( 'wdk-listing-edit_'.wmvc_show_data('ID', $db_data, 0), '_wpnonce'); ?>
21
22 <div class="postbox" style="display: block;">
23 <div class="postbox-header">
24 <h3 class="wide">
25 <?php echo __('Main Data', 'wpdirectorykit'); ?>
26 <?php if(get_option('wdk_sub_listings_enable')): ?>
27 <?php if(!empty(wmvc_show_data('listing_parent_post_id', $db_data))):?>
28 <?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>
29 <?php elseif(isset($_GET['parent_post_id']) && !empty($_GET['parent_post_id'])):?>
30 <?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>
31 <?php endif;?>
32 <?php endif;?>
33 </h3>
34 <?php if(!empty(wmvc_show_data('ID', $db_data))):?>
35
36 <?php if($calendar_id):?>
37 <a href="<?php echo get_admin_url() . "admin.php?page=wdk-bookings-calendar&function=edit&id=".esc_attr($calendar_id); ?>"
38 class="wdk-mr-5 button button-secondary alignright"
39 >
40 <span class="dashicons dashicons-calendar" style="margin-top: 4px;"></span> <?php echo __('Edit Calendar','wpdirectorykit')?>
41 </a>
42 <?php endif;?>
43
44 <a href="<?php echo get_admin_url() . "admin.php?page=wdk-duplicate-listing&function=duplicate&listing_post_id=".wmvc_show_data('ID', $db_data); ?>"
45 <?php if ( !file_exists(ABSPATH . 'wp-content/plugins/wdk-duplicate-listing/wdk-duplicate-listing.php') ):?>
46 class="wdk-mr-5 button button-secondary alignright wdk-pro"
47 data-button-succuss = "<?php echo esc_attr__('Purchase Now', 'wpdirectorykit');?>"
48 data-title = "<?php echo esc_attr__('Your version doesn\'t support this functionality, please upgrade', 'wpdirectorykit');?>"
49 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');?>"
50 data-action = "https://www.wpdirectorykit.com/plugins/wp-directory-duplicate-listing.html"
51 <?php elseif ( file_exists(ABSPATH . 'wp-content/plugins/wdk-duplicate-listing/wdk-duplicate-listing.php') && !function_exists('run_wdk_duplicate_listing')):?>
52 class="wdk-mr-5 button button-secondary alignright wdk-pro"
53 data-button-succuss = "<?php echo esc_attr__('Activate addon WDK Duplicate Listing', 'wpdirectorykit');?>"
54 data-title = "<?php echo esc_attr__('Your version doesn\'t support this functionality, please upgrade', 'wpdirectorykit');?>"
55 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');?>"
56
57 data-action = "<?php echo get_admin_url() . "plugins.php?plugin_status=all#activate-wdk-duplicate-listing"; ?>"
58 <?php else:?>
59 class="wdk-mr-5 button button-secondary alignright"
60 <?php endif;?>
61 >
62 <span class="dashicons dashicons-admin-page" style="margin-top: 4px;"></span> <?php echo __('Duplicate Listing','wpdirectorykit')?>
63 </a>
64 <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" style="margin-top: 4px;"></span> <?php echo __('View listing', 'wpdirectorykit'); ?></a>
65 <?php endif;?>
66 </div>
67 <div class="inside">
68 <?php
69
70 $success_message = NULL;
71 if(isset($_GET['custom_message']))
72 $success_message = esc_html(urldecode($_GET['custom_message']));
73
74 $form->messages('class="alert alert-danger"', $success_message);
75 ?>
76 <div class="wdk-side-content">
77 <div class="wdk-col main">
78 <table class="form-table" role="presentation">
79 <tbody>
80 <tr>
81 <th scope="row"><label for="post_title"><?php echo __('Title', 'wpdirectorykit'); ?>*</label></th>
82 <td><input name="post_title" type="text" id="post_title" value="<?php echo wmvc_show_data('post_title', $db_data, ''); ?>" placeholder="<?php echo esc_html__('Title', 'wpdirectorykit');?>" class="regular-text"></td>
83 </tr>
84 <?php if(get_option('wdk_is_address_enabled', FALSE)): ?>
85 <tr>
86 <th scope="row"><label for="input_address"><?php echo __('Address', 'wpdirectorykit'); ?></label></th>
87 <td>
88 <input name="address" type="text" id="input_address" value="<?php echo wmvc_show_data('address', $db_data, ''); ?>" placeholder="<?php echo esc_html__('Address', 'wpdirectorykit');?>" class="regular-text">
89 <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>
90 </td>
91 </tr>
92 <?php endif; ?>
93
94 <?php if(get_option('wdk_sub_listings_enable')): ?>
95
96 <?php if(!empty(wmvc_show_data('listing_parent_post_id', $db_data)) || (isset($_GET['parent_post_id']) && !empty($_GET['parent_post_id']))):?>
97 <tr class="<?php echo (defined( 'WP_DEBUG' ) && WP_DEBUG) ? '': 'hidden';?>">
98 <th scope="row"><label for="listing_parent_post_id"><?php echo __('Parent ID', 'wpdirectorykit'); ?>*</label></th>
99 <td>
100 <?php if(!empty(wmvc_show_data('listing_parent_post_id', $db_data))):?>
101 <input readonly name="listing_parent_post_id" type="text" id="listing_parent_post_id" value="<?php echo wmvc_show_data('listing_parent_post_id', $db_data, ''); ?>" placeholder="<?php echo esc_html__('listing_parent_post_id', 'wpdirectorykit');?>" class="regular-text">
102 <?php elseif(isset($_GET['parent_post_id']) && !empty($_GET['parent_post_id'])):?>
103 <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">
104 <?php endif;?>
105 </td>
106 </tr>
107 <?php else:?>
108 <?php if(!empty(wmvc_show_data('ID', $db_data)) && empty(wmvc_show_data('parent_post_id', $db_data))):?>
109 <tr>
110 <th scope="row"><label for="listing_related_ids"><?php echo __('Related', 'wpdirectorykit'); ?></label></th>
111 <td>
112 <div class="wdk-listing-childs-wrap">
113
114 <div class="wdk-listing-childs-drop">
115 <?php $related_ids = wmvc_show_data('listing_related_ids', $db_data, ''); ?>
116 <?php if(!empty(wmvc_show_data('listing_related_ids', $db_data, ''))):?>
117 <?php foreach (explode(',',wmvc_show_data('listing_related_ids', $db_data, '')) as $key => $child_idlisting):?>
118
119 <?php
120 if(empty(wdk_field_value('post_id', $child_idlisting))) {
121 $related_ids = trim(str_replace(','.$child_idlisting.'','', ','.$related_ids.','),',');
122 continue;
123 }
124 ?>
125
126 <div class="drop-listing-item" data-idlisting="<?php echo esc_attr($child_idlisting);?>">
127 <h3 class="handle">
128 <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>
129 <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>
130 <a class="question_sure btn remove" href="#" title="Remove"><span class="dashicons dashicons-no"></span></a>
131 </h3>
132 </div>
133 <?php endforeach;?>
134 <?php endif;?>
135 </div>
136 <input readonly name="listing_related_ids" type="hidden" id="listing_related_ids" value="<?php echo esc_attr($related_ids); ?>" class="regular-text">
137
138 <div class="wdk-field-edit">
139 <div class="wdk-field-container" style="padding: 0;">
140 <?php echo wdk_treefield_option('new_listing_id', 'listing_m', NULL, 'post_title', '', __('Not Selected', 'wpdirectorykit'),'',FALSE,'listing_parent_post_id IS NOT NULL');?>
141 <a class="button button-primary add_new_listing" style="margin-left: 5px" href="#"><?php echo __('Add', 'wpdirectorykit'); ?></a>
142 </div>
143 </div>
144 <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>
145 </div>
146 </td>
147 </tr>
148 <?php endif;?>
149
150 <?php endif;?>
151
152 <?php endif;?>
153
154 <?php if(get_option('wdk_is_category_enabled', FALSE)): ?>
155 <?php if(wdk_get_option('wdk_multi_categories_edit_field_type') == 'wdk_treefield_dropdown'):?>
156 <tr>
157 <th scope="row"><label for="category_id"><?php echo __('Category', 'wpdirectorykit'); ?><?php if(wdk_get_option('wdk_listing_category_required')):?>*<?php endif;?></label></th>
158 <td class="wdk_multi_treefield_dropdown_container">
159 <?php
160 global $Winter_MVC_WDK;
161 $Winter_MVC_WDK->load_helper('listing');
162 $Winter_MVC_WDK->model('category_m');
163 $field_value = wmvc_show_data('category_id', $db_data, '');
164 $field_key = 'category_id';
165
166 $categories = array();
167 if(!empty($field_value)) {
168 $categories[] = $field_value;
169 $category = $Winter_MVC_WDK->category_m->get($field_value, TRUE);
170
171 while(!empty($category->parent_id)) {
172 $category = $Winter_MVC_WDK->category_m->get($category->parent_id, TRUE);
173 $categories[] = $category->idcategory;
174 }
175 krsort($categories);
176 } else {
177 $categories[] = 0;
178 }
179
180 wp_enqueue_style('wdk-treefield-dropdown');
181 wp_enqueue_script('wdk-treefield-dropdown');
182 wp_enqueue_style( 'dashicons' );
183
184
185 $level_max = $Winter_MVC_WDK->category_m->get_max_level();
186
187 $placeholder = [
188 0 => esc_html__('Select Categories','wpdirectorykit'),
189 1 => esc_html__('Select Sub Categories','wpdirectorykit'),
190 2 => esc_html__('Select Sub Categories','wpdirectorykit'),
191 3 => esc_html__('Select Sub Categories','wpdirectorykit'),
192 4 => esc_html__('Select Sub Categories','wpdirectorykit'),
193 5 => esc_html__('Select Sub Categories','wpdirectorykit'),
194 ];
195 ?>
196
197 <input name="<?php echo esc_attr($field_key); ?>" type="hidden" value="<?php echo esc_attr($field_value); ?>">
198 <?php
199 $level = 0;
200 $current = NULL;
201
202 foreach ($categories as $category) {
203 $current = $Winter_MVC_WDK->category_m->get($category, TRUE);
204
205 $list = $Winter_MVC_WDK->category_m->get_by(array('parent_id = '.$current->parent_id => NULL));
206
207 if(isset($placeholder[$level])) {
208 $values_list = array(''=> $placeholder[$level]);
209
210 } else {
211 $values_list = array(''=> esc_html__('Select Sub Categories','wpdirectorykit'));
212 }
213
214 foreach ($list as $list_value) {
215 $values_list[$list_value->idcategory] = $list_value->category_title;
216 }
217 ?>
218
219 <div data-level="<?php echo esc_attr($level);?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk_multi_treefield_dropdown wdk_treefield_dropdown">
220 <div class="wdk-field-group">
221 <?php echo wmvc_select_option('category_'.$level, $values_list, $category, 'class="wdk-control"');?>
222 </div>
223 </div>
224
225 <?php
226 $level++;
227 }
228
229 if($level<$level_max ) {
230 for (; $level<$level_max;) {
231
232 if(isset($placeholder[$level])) {
233 $values_list = array(''=> $placeholder[$level]);
234 } else {
235 $values_list = array(''=> esc_html__('Select Sub Categories','wpdirectorykit'));
236 }
237
238 if($category) {
239 $list = $Winter_MVC_WDK->category_m->get_by(array('parent_id = '.$category => NULL));
240 foreach ($list as $list_value) {
241 $values_list[$list_value->idcategory] = $list_value->category_title;
242 }
243 $category = NULL;
244 }
245
246 ?>
247 <div data-level="<?php echo esc_attr($level);?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk_multi_treefield_dropdown wdk_treefield_dropdown">
248 <div class="wdk-field-group">
249 <?php echo wmvc_select_option('category_'.$level, $values_list, NULL, 'class="wdk-control"');?>
250 </div>
251 </div>
252
253 <?php
254 $level++;
255 }
256 }
257 ?>
258 </td>
259 </tr>
260 <?php else: ?>
261 <tr>
262 <th scope="row"><label for="category_id"><?php echo __('Category', 'wpdirectorykit'); ?><?php if(wdk_get_option('wdk_listing_category_required')):?>*<?php endif;?></label></th>
263 <td >
264 <?php
265 echo wmvc_select_option('category_id', $categories, wmvc_show_data('category_id', $db_data, ''), "id='category_id'", __('Not Selected', 'wpdirectorykit'));
266 ?>
267 </td>
268 </tr>
269 <?php endif; ?>
270 <?php endif; ?>
271
272 <?php if(get_option('wdk_is_category_enabled', FALSE) && get_option('wdk_multi_categories_other_enable', FALSE)): ?>
273 <tr>
274 <th scope="row"><label for="listing_categories"><?php echo __('More Categories', 'wpdirectorykit'); ?></label></th>
275 <td class="">
276 <?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"');?>
277 </td>
278 </tr>
279 <?php endif; ?>
280
281 <?php if(get_option('wdk_is_location_enabled', FALSE)): ?>
282 <?php if(wdk_get_option('wdk_multi_categories_edit_field_type') == 'wdk_treefield_dropdown'):?>
283 <tr>
284 <th scope="row"><label for="location_id"><?php echo __('Location', 'wpdirectorykit'); ?><?php if(wdk_get_option('wdk_listing_category_required')):?>*<?php endif;?></label></th>
285 <td class="wdk_multi_treefield_dropdown_container">
286 <?php
287 global $Winter_MVC_WDK;
288 $Winter_MVC_WDK->load_helper('listing');
289 $Winter_MVC_WDK->model('location_m');
290 $field_value = wmvc_show_data('location_id', $db_data, '');
291 $field_key = 'location_id';
292
293 $locations = array();
294 if(!empty($field_value)) {
295 $locations[] = $field_value;
296 $location = $Winter_MVC_WDK->location_m->get($field_value, TRUE);
297
298 while(!empty($location->parent_id)) {
299 $location = $Winter_MVC_WDK->location_m->get($location->parent_id, TRUE);
300 $locations[] = $location->idlocation;
301 }
302 krsort($locations);
303 } else {
304 $locations[] = 0;
305 }
306
307 wp_enqueue_style('wdk-treefield-dropdown');
308 wp_enqueue_script('wdk-treefield-dropdown');
309 wp_enqueue_style( 'dashicons' );
310
311 $level_max = $Winter_MVC_WDK->location_m->get_max_level();
312
313 $placeholder = [
314 0 => esc_html__('Select Country','wpdirectorykit'),
315 1 => esc_html__('Select City','wpdirectorykit'),
316 2 => esc_html__('Select Neighborhood','wpdirectorykit'),
317 3 => esc_html__('Select Sub Area','wpdirectorykit'),
318 4 => esc_html__('Select Sub Area','wpdirectorykit'),
319 5 => esc_html__('Select Sub Area','wpdirectorykit'),
320 ];
321 ?>
322
323 <input name="<?php echo esc_attr($field_key); ?>" type="hidden" value="<?php echo esc_attr($field_value); ?> wdk_field_id_location">
324 <?php
325 $level = 0;
326 $current = NULL;
327
328 foreach ($locations as $location) {
329 $current = $Winter_MVC_WDK->location_m->get($location, TRUE);
330
331 $list = $Winter_MVC_WDK->location_m->get_by(array('parent_id = '.$current->parent_id => NULL));
332
333 if(isset($placeholder[$level])) {
334 $values_list = array(''=> $placeholder[$level]);
335 } else {
336 $values_list = array(''=> esc_html__('Select Sub Area','wpdirectorykit'));
337 }
338
339 foreach ($list as $list_value) {
340 $values_list[$list_value->idlocation] = $list_value->location_title;
341 }
342 ?>
343
344 <div data-level="<?php echo esc_attr($level);?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk_multi_treefield_dropdown wdk_treefield_dropdown">
345 <div class="wdk-field-group">
346 <?php echo wmvc_select_option('location_'.$level, $values_list, $location, 'class="wdk-control"');?>
347 </div>
348 </div>
349
350 <?php
351 $level++;
352 }
353
354 if($level<$level_max ) {
355 for (; $level<$level_max;) {
356
357 if(isset($placeholder[$level])) {
358 $values_list = array(''=> $placeholder[$level]);
359 } else {
360 $values_list = array(''=> esc_html__('Select Sub Area','wpdirectorykit'));
361 }
362
363
364 if(isset($placeholder[$level])) {
365 $values_list = array(''=> $placeholder[$level]);
366 } else {
367 $values_list = array(''=> esc_html__('Select Sub Area','wpdirectorykit'));
368 }
369
370 if($location) {
371 $list = $Winter_MVC_WDK->location_m->get_by(array('parent_id = '.$location => NULL));
372 foreach ($list as $list_value) {
373 $values_list[$list_value->idlocation] = $list_value->location_title;
374 }
375 $location = NULL;
376 }
377
378 ?>
379 <div data-level="<?php echo esc_attr($level);?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk_multi_treefield_dropdown wdk_treefield_dropdown">
380 <div class="wdk-field-group">
381 <?php echo wmvc_select_option('location_'.$level, $values_list, NULL, 'class="wdk-control"');?>
382 </div>
383 </div>
384
385 <?php
386 $level++;
387 }
388 }
389 ?>
390 </td>
391 </tr>
392 <?php else: ?>
393 <tr>
394 <th scope="row"><label for="location_id"><?php echo __('Location', 'wpdirectorykit'); ?><?php if(wdk_get_option('wdk_listing_category_required')):?>*<?php endif;?></label></th>
395 <td >
396 <?php
397 echo wmvc_select_option('location_id', $locations, wmvc_show_data('location_id', $db_data, ''), "id='location_id'", __('Not Selected', 'wpdirectorykit'));
398 ?>
399 </td>
400 </tr>
401 <?php endif; ?>
402 <?php endif; ?>
403
404 <?php if(get_option('wdk_is_location_enabled', FALSE) && get_option('wdk_multi_locations_other_enable', FALSE)): ?>
405 <tr>
406 <th scope="row"><label for="listing_agents"><?php echo __('More Locations', 'wpdirectorykit'); ?></label></th>
407 <td class="">
408 <?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"');?>
409 </td>
410 </tr>
411 <?php endif; ?>
412 <tr>
413 <th scope="row"><label for="user_id_editor"><?php echo __('Agent Editor', 'wpdirectorykit'); ?></label></th>
414 <td>
415 <div class="wdk-field-edit edittable">
416 <div class="wdk-field-container">
417 <?php echo wdk_treefield_option('user_id_editor', 'user_m', wmvc_show_data('user_id_editor', $db_data, ''), 'display_name', '', __('Not Selected', 'wpdirectorykit'));?>
418 </div>
419 </div>
420 </td>
421 </tr>
422 <?php if(function_exists('run_wdk_membership')): ?>
423 <tr>
424 <th scope="row"><label for="listing_agents"><?php echo __('Alternative Agents', 'wpdirectorykit'); ?></label></th>
425 <td class="">
426 <?php echo wdk_user_select_ajax ('listing_agents[]', array_keys( wmvc_show_data('listing_agents', $db_data, '', TRUE, TRUE)), __('Add Agents', 'wpdirectorykit'));?>
427 </td>
428 <?php if(false):?>
429 <td class="agents_group">
430 <?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'");?>
431 <div class="agent_add form-inline">
432 <div class="wdk-field-edit">
433 <div class="wdk-field-container">
434 <?php echo wdk_treefield_option('agent_id', 'user_m', '', 'display_name', '', __('Not Selected', 'wpdirectorykit'));?>
435 </div>
436 </div>
437 <button type="button" class="button button-primary add_button"><?php echo __('Add agent', 'wpdirectorykit'); ?></button>
438 <button type="button" title="<?php echo __('Remove latest on list', 'wpdirectorykit'); ?>" class="button button-secondary rem_button"><?php echo __('X', 'wpdirectorykit'); ?></button>
439 </div>
440 </td>
441 <?php endif; ?>
442 </tr>
443 <?php endif; ?>
444 <?php if(wdk_get_option('wdk_membership_is_enable_subscriptions') && function_exists('run_wdk_membership')):?>
445 <tr>
446 <th scope="row"><label for="subscription_id"><?php echo __('Membership Subscription', 'wpdirectorykit'); ?></label></th>
447 <td>
448 <?php
449 echo wmvc_select_option('subscription_id', $subscriptions, wmvc_show_data('subscription_id', $db_data, ''), "id='subscription_id'", __('Not Selected', 'wpdirectorykit'));
450 ?>
451 </td>
452 </tr>
453 <?php endif;?>
454
455 <?php if(function_exists('run_wdk_payments') && isset($packages)):?>
456 <tr>
457 <th scope="row"><label for="packages"><?php echo __('Package', 'wpdirectorykit'); ?></label></th>
458 <td>
459 <?php
460 echo wmvc_select_option('package_id', $packages, wmvc_show_data('package_id', $db_data, ''), "id='packages'", __('Not Selected', 'wpdirectorykit'));
461 ?>
462 </td>
463 </tr>
464 <?php endif;?>
465 <tr>
466 <th scope="row"><label for="rank"><?php echo __('Rank', 'wpdirectorykit'); ?></label></th>
467 <td>
468 <input <?php if(!wmvc_user_in_role('administrator')):?> readonly="readonly" <?php endif;?> name="rank" type="number" id="rank" value="<?php echo wmvc_show_data('rank', $db_data, ''); ?>" placeholder="<?php echo esc_html__('Rank', 'wpdirectorykit');?>" class="regular-text">
469 </td>
470 </tr>
471 <tr>
472 <th scope="row"><label for="is_featured"><?php echo __('Is Featured', 'wpdirectorykit'); ?></label></th>
473 <td>
474 <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>
475 <p class="description" id="is_featured-description"><?php echo __('Featured/Highlighted listing in results','wpdirectorykit'); ?></p>
476 </td>
477 </tr>
478 <tr>
479 <th scope="row"><label for="is_activated"><?php echo __('Is Activated', 'wpdirectorykit'); ?></label></th>
480 <td>
481 <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>
482 <p class="description" id="is_activated-description"><?php echo __('When listing is activated will be visible on frontend','wpdirectorykit'); ?></p>
483 </td>
484 </tr>
485 <?php if(function_exists('run_wdk_membership')):?>
486 <tr>
487 <th scope="row"><label for="is_approved"><?php echo __('Is Approved', 'wpdirectorykit'); ?></label></th>
488 <td>
489 <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>
490 <p class="description" id="is_approved-description"><?php echo __('When listing is approved will be visible on frontend','wpdirectorykit'); ?> (<?php echo __('only admin can approve','wpdirectorykit'); ?>)</p>
491 </td>
492 </tr>
493 <?php endif;?>
494 <tr>
495 <th scope="row"><label for="slug"><?php echo __('Slug', 'wpdirectorykit'); ?></label></th>
496 <td>
497 <input <?php if(!wmvc_user_in_role('administrator')):?> readonly="readonly" <?php endif;?> name="slug" type="text" id="slug" value="<?php echo wmvc_show_data('post_name', $db_data, ''); ?>" placeholder="<?php echo esc_html__('Slug', 'wpdirectorykit');?>" class="regular-text">
498 </td>
499 </tr>
500 </tbody>
501 </table>
502 </div>
503 <div class="wdk-col sidebar">
504 <?php if(get_option('wdk_is_address_enabled', FALSE)): ?>
505 <div class="clearfix">
506 <a href="#" class="button button-secondary alignright wdk_action_clear_gps_reset_map"><?php echo esc_html__('Clear Gps coordinates', 'wpdirectorykit');?></a>
507 </div>
508 <br/>
509 <div id="map" class="listing_edit_map"></div>
510 <br/>
511 <p class="alert alert-info"><?php echo esc_html__('Drag and drop pin to desired location','wpdirectorykit');?></p>
512 <div class="wdk-field-edit inline">
513 <label for="listing_gps"><?php echo esc_html__('GPS','wpdirectorykit');?>:</label>
514 <div class="wdk-field-container">
515 <input name="lat" readonly="readonly" type="text" id="input_lat" value="<?php echo wmvc_show_data('lat', $db_data, ''); ?>" class="regular-text" placeholder="<?php echo esc_html__('lat', 'wpdirectorykit');?>">
516 <input name="lng" readonly="readonly" type="text" id="input_lng" value="<?php echo wmvc_show_data('lng', $db_data, ''); ?>" class="regular-text" placeholder="<?php echo esc_html__('lng', 'wpdirectorykit');?>">
517 </div>
518 </div>
519 <?php endif;?>
520 </div>
521 </div>
522 <table class="form-table" role="presentation">
523 <tbody>
524 <tr>
525 <th scope="row"><label for="post_content"><?php echo __('Content', 'wpdirectorykit'); ?>*</label></th>
526 <td><?php wp_editor(wmvc_show_data('post_content', $db_data, ''), 'post_content', array('media_buttons' => FALSE)); ?></td>
527 </tr>
528 </tbody>
529 </table>
530 </div>
531 </div>
532 <div class="postbox listing_custom_fields" style="display: block;">
533 <div class="inside wdk-row">
534 <?php if(count($fields) == 0): ?>
535 <div class="wdk-col-12">
536 <div class="alert alert-success mb0"><p><?php echo __('Fields doesn\'t exists','wpdirectorykit'); ?> <a href="<?php echo get_admin_url() . "admin.php?page=wdk_fields"; ?>" class="button button-primary" id="add_field_button"><?php echo __('Manage Fields','wpdirectorykit'); ?></a></p></div>
537 </div>
538 <?php endif; ?>
539
540 <?php echo wdk_generate_fields($fields, $db_data); ?>
541 </div>
542 </div>
543 <?php if(!wdk_get_option('wdk_listing_plangs_documents_disable')):?>
544 <div class="postbox" style="display: block;">
545 <div class="postbox-header">
546 <h3><?php echo __('Listing plans and documents', 'wpdirectorykit'); ?></h3>
547 </div>
548 <div class="inside">
549 <p class="alert alert-info"><?php echo __('Drag and drop image to change order', 'wpdirectorykit'); ?></p>
550 <?php
551 echo wdk_upload_multi_files('listing_plans_documents', wmvc_show_data('listing_plans_documents', $db_data, ''));
552 ?>
553 </div>
554 </div>
555 <?php endif;?>
556 <div class="postbox" style="display: block;">
557 <div class="postbox-header">
558 <h3><?php echo __('Listing Images/Videos', 'wpdirectorykit'); ?></h3>
559 </div>
560 <div class="inside">
561 <p class="alert alert-info"><?php echo __('Drag and drop image to change order', 'wpdirectorykit'); ?></p>
562 <?php
563 echo wmvc_upload_multiple('listing_images', wmvc_show_data('listing_images', $db_data, ''));
564 ?>
565 </div>
566 </div>
567 <button type="submit" class="button button-primary wdk-submit-loading out"><?php echo esc_html__('Save Changes','wpdirectorykit'); ?></button>
568 </form>
569 </div>
570
571 <?php do_action('wpdirectorykit/admin/listing/edit/after_form', $db_data);?>
572 </div>
573 <?php
574 wp_enqueue_style('leaflet');
575 wp_enqueue_script('leaflet');
576
577 wp_enqueue_style('wdk-notify');
578 wp_enqueue_script('wdk-notify');
579
580 wp_enqueue_style('jquery-confirm');
581 wp_enqueue_script('jquery-confirm');
582 ?>
583
584 <?php
585 wp_enqueue_script( 'jquery-ui-core', false, array('jquery') );
586 wp_enqueue_script( 'jquery-ui-sortable', false, array('jquery') );
587 ?>
588
589 <script>
590 // Generate table
591 jQuery(document).ready(function($) {
592
593 <?php if(get_option('wdk_is_address_enabled', FALSE)): ?>
594 var wdk_edit_map_marker,wdk_timerMap,wdk_edit_map;
595 wdk_edit_map = L.map('map', {
596 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)); ?>],
597 zoom: 4,
598 });
599
600 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
601 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
602 }).addTo(wdk_edit_map);
603
604 wdk_edit_map_marker = L.marker(
605 [<?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)); ?>],
606 {draggable: true}
607 ).addTo(wdk_edit_map);
608
609 wdk_edit_map_marker.on('dragend', function(event){
610 clearTimeout(wdk_timerMap);
611 var marker = event.target;
612 var {lat,lng} = marker.getLatLng();
613 $('#input_lat').val(lat);
614 $('#input_lng').val(lng);
615 //retrieved the position
616 });
617
618 /* reset map and gps */
619 $('.wdk_action_clear_gps_reset_map').on('click', function(e){
620 e.preventDefault();
621 $('#input_lat,#input_lng').val('');
622
623 /* move marker on default poisition */
624 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();
625 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)); ?>));
626 });
627
628 $('#input_address').on('change keyup', function (e) {
629 clearTimeout(wdk_timerMap);
630 wdk_timerMap = setTimeout(function () {
631 $.get('https://nominatim.openstreetmap.org/search?format=json&q='+$('#input_address').val(), function(data){
632 if(data.length && typeof data[0]) {
633 var {lat,lon} =data[0];
634 wdk_edit_map_marker.setLatLng([lat, lon]).update();
635 wdk_edit_map.panTo(new L.LatLng(lat, lon));
636 $('#input_lat').val(lat);
637 $('#input_lng').val(lon);
638 } else {
639 wdk_log_notify('<?php echo esc_js(__('Address not found', 'wpdirectorykit')); ?>', 'error');
640 return;
641 }
642 });
643 }, 1000);
644 });
645
646 $('#input_gps').on('change keyup', function (e) {
647 wdk_edit_map.panTo(new L.LatLng($('#input_lat').val(), $('#input_lng').val()));
648 wdk_edit_map_marker.setLatLng([parseFloat($('#input_lat').val()), parseFloat($('#input_lng').val())]).update();
649 })
650 <?php endif;?>
651
652 /* agents */
653
654 $('.agents_group .add_button').on( "click", function(e) {
655 e.preventDefault();
656 var group_agent = $(this).closest('.agents_group');
657 var agent_id = group_agent.find('input[name="agent_id"]').val();
658
659 if(agent_id != '')
660 {
661 var exists = 0 != group_agent.find('#listing_agents').find('option[value='+agent_id+']').length;
662 var agent_name = group_agent.find('.wdk_dropdown_tree .btn-group .btn:first').text();
663
664 if(!exists)
665 {
666 group_agent.find('#listing_agents').append('<option value="'+agent_id+'" selected>'+agent_name+'</option>');
667 }
668 else
669 {
670 wdk_log_notify('<?php echo esc_js(__('Already on list', 'wpdirectorykit')); ?>', 'error');
671 }
672 }
673 else
674 {
675 wdk_log_notify('<?php echo esc_js(__('Not selected', 'wpdirectorykit')); ?>', 'error');
676 }
677 });
678
679 $('.agents_group .rem_button').on( "click", function() {
680 $(this).closest('.agents_group').find('#listing_agents option:selected:last').remove();
681 });
682
683
684 $('form.form_listing').on('submit', function(e){
685 if($(this).find('#listing_agents').length) {
686 $('#listing_agents').find('option').prop("selected", true).trigger('change')
687 }
688 });
689
690 wdk_childs_listings_list();
691
692 $('.select_ajax_user').on('select2:selecting', function (e) {
693 // Get the selected option value
694 var selectedValue = e.params.args.data.id;
695 var selecteduserEditor = $('[name="user_id_editor"]').val();
696
697 // Check if the selected option should be prevented from being added
698 if (selectedValue == selecteduserEditor) {
699 // Prevent the option from being added
700 e.preventDefault();
701 wdk_log_notify('<?php echo esc_js(esc_attr__('User Alread defiend like editor','wpdirectorykit'));?>', 'error');
702 }
703 });
704
705 });
706
707
708 const wdk_childs_listings_list = ($selector= '.wdk-listing-childs-wrap', $field_name = 'listing_related_ids') => {
709 var el_wrapper = jQuery($selector);
710 var remove_child_listing,save_data;
711
712 remove_child_listing = () => {
713 el_wrapper.find( ".wdk-listing-childs-drop .drop-listing-item .remove" ).off().on('click', function(e){
714 e.preventDefault();
715
716 if(confirm("<?php echo esc_js(__('Are you sure?','wpdirectorykit')); ?>")) {
717 jQuery(this).closest('.drop-listing-item').remove();
718 save_data();
719 }
720 });
721 };
722
723 save_data = () => {
724 var data_fields_sublist = '';
725 el_wrapper.find('.wdk-listing-childs-drop .drop-listing-item').each(function( index ) {
726 if(data_fields_sublist !='')
727 data_fields_sublist +=',';
728
729 data_fields_sublist += jQuery(this).attr('data-idlisting');
730 });
731 console.log(el_wrapper.find('input[name="'+$field_name+'"]'));
732 el_wrapper.find('input[name="'+$field_name+'"]').val(data_fields_sublist);
733 }
734
735 remove_child_listing();
736
737 el_wrapper.find( ".wdk-listing-childs-drop" ).sortable({
738 connectWith: ".wdk-listing-childs-drop",
739 placeholder: "ui-sortable-placeholder widget-placeholder",
740 update: function(event, ui) {
741 save_data();
742 }
743 }).disableSelection();
744
745 el_wrapper.find('.add_new_listing').on('click', function(e){
746 e.preventDefault();
747
748 var listing_id = el_wrapper.find('input[name="new_listing_id"]').val();
749 var listing_title = el_wrapper.find('.wdk_dropdown_tree button:first-child').text();
750
751 if(listing_id == '') {
752 wdk_log_notify('<?php echo esc_js(esc_attr__('Listing Not Defined','wpdirectorykit'));?>', 'error');
753 return;
754 }
755
756 if(listing_id == '<?php echo esc_js(wmvc_show_data('ID', $db_data));?>') {
757 wdk_log_notify('<?php echo esc_js(esc_attr__('Impossible add current listing','wpdirectorykit'));?>', 'error');
758 return;
759 }
760
761 if( el_wrapper.find( ".wdk-listing-childs-drop .drop-listing-item[data-idlisting='"+listing_id+"']" ).length) {
762 wdk_log_notify('<?php echo esc_js(esc_attr__('Listing already added','wpdirectorykit'));?>', 'error');
763 return;
764 }
765
766 var item_html = '<div class="drop-listing-item" data-idlisting="'+listing_id+'">\n\
767 <h3 class="handle"> \n\
768 <a target="_blank" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&id='));?>'+listing_id+'" class="title">'+listing_title+'</a>\n\
769 <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\
770 <a class="question_sure btn remove" href="#" title="<?php echo esc_js(__('Remove','wpdirectorykit'));?>"><span class="dashicons dashicons-no"></span></a>\n\
771 </h3> \n\
772 </div>';
773
774 el_wrapper.find( ".wdk-listing-childs-drop" ).append(item_html);
775 remove_child_listing();
776 save_data();
777 });
778 };
779
780 </script>
781
782 <style>
783
784 .form-table .agent_add.form-inline .wdk-field-edit {
785 display: inline-block;
786 }
787
788 .form-table .agent_add.form-inline .wdk-field-edit .wdk-field-container {
789 padding: 0;
790 }
791
792 .form-table .agent_add.form-inline .wdk-field-edit,
793 .form-table .agent_add.form-inline .button {
794 margin: 15px 0px;
795 }
796
797 .form-table #listing_agents {
798 max-width: 100%;
799 width: 25em;
800 }
801
802 .form-table .agent_add.form-inline .wdk_dropdown_tree {
803 width: 230px;
804 max-width: 100%;
805 }
806
807 </style>
808
809 <?php $this->view('general/footer', $data); ?>