PluginProbe
WP Directory Kit / 1.2.9
WP Directory Kit v1.2.9
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.9, at application/views/wdk_listing/index.php

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