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