| 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 |
<tr> |
| 156 |
<th scope="row"><label for="category_id"><?php echo __('Category', 'wpdirectorykit'); ?><?php if(wdk_get_option('wdk_listing_category_required')):?>*<?php endif;?></label></th> |
| 157 |
<td > |
| 158 |
<?php |
| 159 |
echo wmvc_select_option('category_id', $categories, wmvc_show_data('category_id', $db_data, ''), "id='category_id'", __('Not Selected', 'wpdirectorykit')); |
| 160 |
?> |
| 161 |
</td> |
| 162 |
</tr> |
| 163 |
<?php endif; ?> |
| 164 |
|
| 165 |
<?php if(get_option('wdk_is_category_enabled', FALSE) && get_option('wdk_multi_categories_other_enable', FALSE)): ?> |
| 166 |
<tr> |
| 167 |
<th scope="row"><label for="listing_categories"><?php echo __('More Categories', 'wpdirectorykit'); ?></label></th> |
| 168 |
<td class=""> |
| 169 |
<?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"');?> |
| 170 |
</td> |
| 171 |
</tr> |
| 172 |
<?php endif; ?> |
| 173 |
|
| 174 |
<?php if(get_option('wdk_is_location_enabled', FALSE)): ?> |
| 175 |
<tr> |
| 176 |
<th scope="row"><label for="location_id"><?php echo __('Location', 'wpdirectorykit'); ?><?php if(wdk_get_option('wdk_listing_location_required')):?>*<?php endif;?></label></th> |
| 177 |
<td> |
| 178 |
<?php |
| 179 |
echo wmvc_select_option('location_id', $locations, wmvc_show_data('location_id', $db_data, ''), "id='location_id'", __('Not Selected', 'wpdirectorykit')); |
| 180 |
?> |
| 181 |
</td> |
| 182 |
</tr> |
| 183 |
<?php endif; ?> |
| 184 |
|
| 185 |
<?php if(get_option('wdk_is_location_enabled', FALSE) && get_option('wdk_multi_locations_other_enable', FALSE)): ?> |
| 186 |
<tr> |
| 187 |
<th scope="row"><label for="listing_agents"><?php echo __('More Locations', 'wpdirectorykit'); ?></label></th> |
| 188 |
<td class=""> |
| 189 |
<?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"');?> |
| 190 |
</td> |
| 191 |
</tr> |
| 192 |
<?php endif; ?> |
| 193 |
<tr> |
| 194 |
<th scope="row"><label for="user_id_editor"><?php echo __('Agent Editor', 'wpdirectorykit'); ?></label></th> |
| 195 |
<td> |
| 196 |
<div class="wdk-field-edit edittable"> |
| 197 |
<div class="wdk-field-container"> |
| 198 |
<?php echo wdk_treefield_option('user_id_editor', 'user_m', wmvc_show_data('user_id_editor', $db_data, ''), 'display_name', '', __('Not Selected', 'wpdirectorykit'));?> |
| 199 |
</div> |
| 200 |
</div> |
| 201 |
</td> |
| 202 |
</tr> |
| 203 |
<?php if(function_exists('run_wdk_membership')): ?> |
| 204 |
<tr> |
| 205 |
<th scope="row"><label for="listing_agents"><?php echo __('Alternative Agents', 'wpdirectorykit'); ?></label></th> |
| 206 |
<td class=""> |
| 207 |
<?php echo wdk_user_select_ajax ('listing_agents[]', array_keys( wmvc_show_data('listing_agents', $db_data, '', TRUE, TRUE)), __('Add Agents', 'wpdirectorykit'));?> |
| 208 |
</td> |
| 209 |
<?php if(false):?> |
| 210 |
<td class="agents_group"> |
| 211 |
<?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'");?> |
| 212 |
<div class="agent_add form-inline"> |
| 213 |
<div class="wdk-field-edit"> |
| 214 |
<div class="wdk-field-container"> |
| 215 |
<?php echo wdk_treefield_option('agent_id', 'user_m', '', 'display_name', '', __('Not Selected', 'wpdirectorykit'));?> |
| 216 |
</div> |
| 217 |
</div> |
| 218 |
<button type="button" class="button button-primary add_button"><?php echo __('Add agent', 'wpdirectorykit'); ?></button> |
| 219 |
<button type="button" title="<?php echo __('Remove latest on list', 'wpdirectorykit'); ?>" class="button button-secondary rem_button"><?php echo __('X', 'wpdirectorykit'); ?></button> |
| 220 |
</div> |
| 221 |
</td> |
| 222 |
<?php endif; ?> |
| 223 |
</tr> |
| 224 |
<?php endif; ?> |
| 225 |
<?php if(wdk_get_option('wdk_membership_is_enable_subscriptions') && function_exists('run_wdk_membership')):?> |
| 226 |
<tr> |
| 227 |
<th scope="row"><label for="subscription_id"><?php echo __('Membership Subscription', 'wpdirectorykit'); ?></label></th> |
| 228 |
<td> |
| 229 |
<?php |
| 230 |
echo wmvc_select_option('subscription_id', $subscriptions, wmvc_show_data('subscription_id', $db_data, ''), "id='subscription_id'", __('Not Selected', 'wpdirectorykit')); |
| 231 |
?> |
| 232 |
</td> |
| 233 |
</tr> |
| 234 |
<?php endif;?> |
| 235 |
|
| 236 |
<?php if(function_exists('run_wdk_payments') && isset($packages)):?> |
| 237 |
<tr> |
| 238 |
<th scope="row"><label for="packages"><?php echo __('Package', 'wpdirectorykit'); ?></label></th> |
| 239 |
<td> |
| 240 |
<?php |
| 241 |
echo wmvc_select_option('package_id', $packages, wmvc_show_data('package_id', $db_data, ''), "id='packages'", __('Not Selected', 'wpdirectorykit')); |
| 242 |
?> |
| 243 |
</td> |
| 244 |
</tr> |
| 245 |
<?php endif;?> |
| 246 |
<tr> |
| 247 |
<th scope="row"><label for="rank"><?php echo __('Rank', 'wpdirectorykit'); ?></label></th> |
| 248 |
<td> |
| 249 |
<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"> |
| 250 |
</td> |
| 251 |
</tr> |
| 252 |
<tr> |
| 253 |
<th scope="row"><label for="is_featured"><?php echo __('Is Featured', 'wpdirectorykit'); ?></label></th> |
| 254 |
<td> |
| 255 |
<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> |
| 256 |
<p class="description" id="is_featured-description"><?php echo __('Featured/Highlighted listing in results','wpdirectorykit'); ?></p> |
| 257 |
</td> |
| 258 |
</tr> |
| 259 |
<tr> |
| 260 |
<th scope="row"><label for="is_activated"><?php echo __('Is Activated', 'wpdirectorykit'); ?></label></th> |
| 261 |
<td> |
| 262 |
<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> |
| 263 |
<p class="description" id="is_activated-description"><?php echo __('When listing is activated will be visible on frontend','wpdirectorykit'); ?></p> |
| 264 |
</td> |
| 265 |
</tr> |
| 266 |
<?php if(function_exists('run_wdk_membership')):?> |
| 267 |
<tr> |
| 268 |
<th scope="row"><label for="is_approved"><?php echo __('Is Approved', 'wpdirectorykit'); ?></label></th> |
| 269 |
<td> |
| 270 |
<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> |
| 271 |
<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> |
| 272 |
</td> |
| 273 |
</tr> |
| 274 |
<?php endif;?> |
| 275 |
<tr class='hidden'> |
| 276 |
<th scope="row"><label for="location_id"><?php echo __('Address', 'wpdirectorykit'); ?></label></th> |
| 277 |
<td> |
| 278 |
<input name="lat" type="text" id="input_lat" value="<?php echo wmvc_show_data('lat', $db_data, ''); ?>" class="regular-text" placeholder="<?php echo esc_html__('lat', 'wpdirectorykit');?>"> |
| 279 |
<input name="lng" type="text" id="input_lng" value="<?php echo wmvc_show_data('lng', $db_data, ''); ?>" class="regular-text" placeholder="<?php echo esc_html__('lng', 'wpdirectorykit');?>"> |
| 280 |
</td> |
| 281 |
</tr> |
| 282 |
<tr> |
| 283 |
<th scope="row"><label for="slug"><?php echo __('Slug', 'wpdirectorykit'); ?></label></th> |
| 284 |
<td> |
| 285 |
<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"> |
| 286 |
</td> |
| 287 |
</tr> |
| 288 |
</tbody> |
| 289 |
</table> |
| 290 |
</div> |
| 291 |
<div class="wdk-col sidebar"> |
| 292 |
<?php if(get_option('wdk_is_address_enabled', FALSE)): ?> |
| 293 |
<div class="clearfix"> |
| 294 |
<a href="#" class="button button-secondary alignright wdk_action_clear_gps_reset_map"><?php echo esc_html__('Clear Gps coordinates', 'wpdirectorykit');?></a> |
| 295 |
</div> |
| 296 |
<br/> |
| 297 |
<div id="map" class="listing_edit_map"></div> |
| 298 |
<br/> |
| 299 |
<p class="alert alert-info"><?php echo esc_html__('Drag and drop pin to desired location','wpdirectorykit');?></p> |
| 300 |
<?php endif;?> |
| 301 |
</div> |
| 302 |
</div> |
| 303 |
<table class="form-table" role="presentation"> |
| 304 |
<tbody> |
| 305 |
<tr> |
| 306 |
<th scope="row"><label for="post_content"><?php echo __('Content', 'wpdirectorykit'); ?>*</label></th> |
| 307 |
<td><?php wp_editor(wmvc_show_data('post_content', $db_data, ''), 'post_content', array('media_buttons' => FALSE)); ?></td> |
| 308 |
</tr> |
| 309 |
</tbody> |
| 310 |
</table> |
| 311 |
</div> |
| 312 |
</div> |
| 313 |
<div class="postbox listing_custom_fields" style="display: block;"> |
| 314 |
<div class="inside wdk-row"> |
| 315 |
<?php if(count($fields) == 0): ?> |
| 316 |
<div class="wdk-col-12"> |
| 317 |
<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> |
| 318 |
</div> |
| 319 |
<?php endif; ?> |
| 320 |
|
| 321 |
<?php echo wdk_generate_fields($fields, $db_data); ?> |
| 322 |
</div> |
| 323 |
</div> |
| 324 |
<?php if(!wdk_get_option('wdk_listing_plangs_documents_disable')):?> |
| 325 |
<div class="postbox" style="display: block;"> |
| 326 |
<div class="postbox-header"> |
| 327 |
<h3><?php echo __('Listing plans and documents', 'wpdirectorykit'); ?></h3> |
| 328 |
</div> |
| 329 |
<div class="inside"> |
| 330 |
<p class="alert alert-info"><?php echo __('Drag and drop image to change order', 'wpdirectorykit'); ?></p> |
| 331 |
<?php |
| 332 |
echo wdk_upload_multi_files('listing_plans_documents', wmvc_show_data('listing_plans_documents', $db_data, '')); |
| 333 |
?> |
| 334 |
</div> |
| 335 |
</div> |
| 336 |
<?php endif;?> |
| 337 |
<div class="postbox" style="display: block;"> |
| 338 |
<div class="postbox-header"> |
| 339 |
<h3><?php echo __('Listing Images/Videos', 'wpdirectorykit'); ?></h3> |
| 340 |
</div> |
| 341 |
<div class="inside"> |
| 342 |
<p class="alert alert-info"><?php echo __('Drag and drop image to change order', 'wpdirectorykit'); ?></p> |
| 343 |
<?php |
| 344 |
echo wmvc_upload_multiple('listing_images', wmvc_show_data('listing_images', $db_data, '')); |
| 345 |
?> |
| 346 |
</div> |
| 347 |
</div> |
| 348 |
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_html__('Save Changes','wpdirectorykit'); ?>"> |
| 349 |
</form> |
| 350 |
</div> |
| 351 |
|
| 352 |
<?php do_action('wpdirectorykit/admin/listing/edit/after_form', $db_data);?> |
| 353 |
</div> |
| 354 |
<?php |
| 355 |
wp_enqueue_style('leaflet'); |
| 356 |
wp_enqueue_script('leaflet'); |
| 357 |
|
| 358 |
wp_enqueue_style('wdk-notify'); |
| 359 |
wp_enqueue_script('wdk-notify'); |
| 360 |
|
| 361 |
wp_enqueue_style('jquery-confirm'); |
| 362 |
wp_enqueue_script('jquery-confirm'); |
| 363 |
?> |
| 364 |
|
| 365 |
<?php |
| 366 |
wp_enqueue_script( 'jquery-ui-core', false, array('jquery') ); |
| 367 |
wp_enqueue_script( 'jquery-ui-sortable', false, array('jquery') ); |
| 368 |
?> |
| 369 |
|
| 370 |
<script> |
| 371 |
// Generate table |
| 372 |
jQuery(document).ready(function($) { |
| 373 |
|
| 374 |
<?php if(get_option('wdk_is_address_enabled', FALSE)): ?> |
| 375 |
var wdk_edit_map_marker,wdk_timerMap,wdk_edit_map; |
| 376 |
wdk_edit_map = L.map('map', { |
| 377 |
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)); ?>], |
| 378 |
zoom: 4, |
| 379 |
}); |
| 380 |
|
| 381 |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
| 382 |
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' |
| 383 |
}).addTo(wdk_edit_map); |
| 384 |
|
| 385 |
wdk_edit_map_marker = L.marker( |
| 386 |
[<?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)); ?>], |
| 387 |
{draggable: true} |
| 388 |
).addTo(wdk_edit_map); |
| 389 |
|
| 390 |
wdk_edit_map_marker.on('dragend', function(event){ |
| 391 |
clearTimeout(wdk_timerMap); |
| 392 |
var marker = event.target; |
| 393 |
var {lat,lng} = marker.getLatLng(); |
| 394 |
$('#input_lat').val(lat); |
| 395 |
$('#input_lng').val(lng); |
| 396 |
//retrieved the position |
| 397 |
}); |
| 398 |
|
| 399 |
/* reset map and gps */ |
| 400 |
$('.wdk_action_clear_gps_reset_map').on('click', function(e){ |
| 401 |
e.preventDefault(); |
| 402 |
$('#input_lat,#input_lng').val(''); |
| 403 |
|
| 404 |
/* move marker on default poisition */ |
| 405 |
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(); |
| 406 |
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)); ?>)); |
| 407 |
}); |
| 408 |
|
| 409 |
$('#input_address').on('change keyup', function (e) { |
| 410 |
clearTimeout(wdk_timerMap); |
| 411 |
wdk_timerMap = setTimeout(function () { |
| 412 |
$.get('https://nominatim.openstreetmap.org/search?format=json&q='+$('#input_address').val(), function(data){ |
| 413 |
if(data.length && typeof data[0]) { |
| 414 |
var {lat,lon} =data[0]; |
| 415 |
wdk_edit_map_marker.setLatLng([lat, lon]).update(); |
| 416 |
wdk_edit_map.panTo(new L.LatLng(lat, lon)); |
| 417 |
$('#input_lat').val(lat); |
| 418 |
$('#input_lng').val(lon); |
| 419 |
} else { |
| 420 |
wdk_log_notify('<?php echo esc_js(__('Address not found', 'wpdirectorykit')); ?>', 'error'); |
| 421 |
return; |
| 422 |
} |
| 423 |
}); |
| 424 |
}, 1000); |
| 425 |
}); |
| 426 |
|
| 427 |
$('#input_gps').on('change keyup', function (e) { |
| 428 |
wdk_edit_map.panTo(new L.LatLng($('#input_lat').val(), $('#input_lng').val())); |
| 429 |
wdk_edit_map_marker.setLatLng([parseFloat($('#input_lat').val()), parseFloat($('#input_lng').val())]).update(); |
| 430 |
}) |
| 431 |
<?php endif;?> |
| 432 |
|
| 433 |
/* agents */ |
| 434 |
|
| 435 |
$('.agents_group .add_button').on( "click", function(e) { |
| 436 |
e.preventDefault(); |
| 437 |
var group_agent = $(this).closest('.agents_group'); |
| 438 |
var agent_id = group_agent.find('input[name="agent_id"]').val(); |
| 439 |
|
| 440 |
if(agent_id != '') |
| 441 |
{ |
| 442 |
var exists = 0 != group_agent.find('#listing_agents').find('option[value='+agent_id+']').length; |
| 443 |
var agent_name = group_agent.find('.wdk_dropdown_tree .btn-group .btn:first').text(); |
| 444 |
|
| 445 |
if(!exists) |
| 446 |
{ |
| 447 |
group_agent.find('#listing_agents').append('<option value="'+agent_id+'" selected>'+agent_name+'</option>'); |
| 448 |
} |
| 449 |
else |
| 450 |
{ |
| 451 |
wdk_log_notify('<?php echo esc_js(__('Already on list', 'wpdirectorykit')); ?>', 'error'); |
| 452 |
} |
| 453 |
} |
| 454 |
else |
| 455 |
{ |
| 456 |
wdk_log_notify('<?php echo esc_js(__('Not selected', 'wpdirectorykit')); ?>', 'error'); |
| 457 |
} |
| 458 |
}); |
| 459 |
|
| 460 |
$('.agents_group .rem_button').on( "click", function() { |
| 461 |
$(this).closest('.agents_group').find('#listing_agents option:selected:last').remove(); |
| 462 |
}); |
| 463 |
|
| 464 |
|
| 465 |
$('form.form_listing').on('submit', function(e){ |
| 466 |
if($(this).find('#listing_agents').length) { |
| 467 |
$('#listing_agents').find('option').prop("selected", true).trigger('change') |
| 468 |
} |
| 469 |
}); |
| 470 |
|
| 471 |
wdk_childs_listings_list(); |
| 472 |
|
| 473 |
$('.select_ajax_user').on('select2:selecting', function (e) { |
| 474 |
// Get the selected option value |
| 475 |
var selectedValue = e.params.args.data.id; |
| 476 |
var selecteduserEditor = $('[name="user_id_editor"]').val(); |
| 477 |
|
| 478 |
// Check if the selected option should be prevented from being added |
| 479 |
if (selectedValue == selecteduserEditor) { |
| 480 |
// Prevent the option from being added |
| 481 |
e.preventDefault(); |
| 482 |
wdk_log_notify('<?php echo esc_js(esc_attr__('User Alread defiend like editor','wpdirectorykit'));?>', 'error'); |
| 483 |
} |
| 484 |
}); |
| 485 |
|
| 486 |
}); |
| 487 |
|
| 488 |
|
| 489 |
const wdk_childs_listings_list = ($selector= '.wdk-listing-childs-wrap', $field_name = 'listing_related_ids') => { |
| 490 |
var el_wrapper = jQuery($selector); |
| 491 |
var remove_child_listing,save_data; |
| 492 |
|
| 493 |
remove_child_listing = () => { |
| 494 |
el_wrapper.find( ".wdk-listing-childs-drop .drop-listing-item .remove" ).off().on('click', function(e){ |
| 495 |
e.preventDefault(); |
| 496 |
|
| 497 |
if(confirm("<?php echo esc_js(__('Are you sure?','wpdirectorykit')); ?>")) { |
| 498 |
jQuery(this).closest('.drop-listing-item').remove(); |
| 499 |
save_data(); |
| 500 |
} |
| 501 |
}); |
| 502 |
}; |
| 503 |
|
| 504 |
save_data = () => { |
| 505 |
var data_fields_sublist = ''; |
| 506 |
el_wrapper.find('.wdk-listing-childs-drop .drop-listing-item').each(function( index ) { |
| 507 |
if(data_fields_sublist !='') |
| 508 |
data_fields_sublist +=','; |
| 509 |
|
| 510 |
data_fields_sublist += jQuery(this).attr('data-idlisting'); |
| 511 |
}); |
| 512 |
console.log(el_wrapper.find('input[name="'+$field_name+'"]')); |
| 513 |
el_wrapper.find('input[name="'+$field_name+'"]').val(data_fields_sublist); |
| 514 |
} |
| 515 |
|
| 516 |
remove_child_listing(); |
| 517 |
|
| 518 |
el_wrapper.find( ".wdk-listing-childs-drop" ).sortable({ |
| 519 |
connectWith: ".wdk-listing-childs-drop", |
| 520 |
placeholder: "ui-sortable-placeholder widget-placeholder", |
| 521 |
update: function(event, ui) { |
| 522 |
save_data(); |
| 523 |
} |
| 524 |
}).disableSelection(); |
| 525 |
|
| 526 |
el_wrapper.find('.add_new_listing').on('click', function(e){ |
| 527 |
e.preventDefault(); |
| 528 |
|
| 529 |
var listing_id = el_wrapper.find('input[name="new_listing_id"]').val(); |
| 530 |
var listing_title = el_wrapper.find('.wdk_dropdown_tree button:first-child').text(); |
| 531 |
|
| 532 |
if(listing_id == '') { |
| 533 |
wdk_log_notify('<?php echo esc_js(esc_attr__('Listing Not Defined','wpdirectorykit'));?>', 'error'); |
| 534 |
return; |
| 535 |
} |
| 536 |
|
| 537 |
if(listing_id == '<?php echo esc_js(wmvc_show_data('ID', $db_data));?>') { |
| 538 |
wdk_log_notify('<?php echo esc_js(esc_attr__('Impossible add current listing','wpdirectorykit'));?>', 'error'); |
| 539 |
return; |
| 540 |
} |
| 541 |
|
| 542 |
if( el_wrapper.find( ".wdk-listing-childs-drop .drop-listing-item[data-idlisting='"+listing_id+"']" ).length) { |
| 543 |
wdk_log_notify('<?php echo esc_js(esc_attr__('Listing already added','wpdirectorykit'));?>', 'error'); |
| 544 |
return; |
| 545 |
} |
| 546 |
|
| 547 |
var item_html = '<div class="drop-listing-item" data-idlisting="'+listing_id+'">\n\ |
| 548 |
<h3 class="handle"> \n\ |
| 549 |
<a target="_blank" href="<?php echo esc_url(admin_url('admin.php?page=wdk_listing&id='));?>'+listing_id+'" class="title">'+listing_title+'</a>\n\ |
| 550 |
<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\ |
| 551 |
<a class="question_sure btn remove" href="#" title="<?php echo esc_js(__('Remove','wpdirectorykit'));?>"><span class="dashicons dashicons-no"></span></a>\n\ |
| 552 |
</h3> \n\ |
| 553 |
</div>'; |
| 554 |
|
| 555 |
el_wrapper.find( ".wdk-listing-childs-drop" ).append(item_html); |
| 556 |
remove_child_listing(); |
| 557 |
save_data(); |
| 558 |
}); |
| 559 |
}; |
| 560 |
|
| 561 |
</script> |
| 562 |
|
| 563 |
<style> |
| 564 |
|
| 565 |
.form-table .agent_add.form-inline .wdk-field-edit { |
| 566 |
display: inline-block; |
| 567 |
} |
| 568 |
|
| 569 |
.form-table .agent_add.form-inline .wdk-field-edit .wdk-field-container { |
| 570 |
padding: 0; |
| 571 |
} |
| 572 |
|
| 573 |
.form-table .agent_add.form-inline .wdk-field-edit, |
| 574 |
.form-table .agent_add.form-inline .button { |
| 575 |
margin: 15px 0px; |
| 576 |
} |
| 577 |
|
| 578 |
.form-table #listing_agents { |
| 579 |
max-width: 100%; |
| 580 |
width: 25em; |
| 581 |
} |
| 582 |
|
| 583 |
.form-table .agent_add.form-inline .wdk_dropdown_tree { |
| 584 |
width: 230px; |
| 585 |
max-width: 100%; |
| 586 |
} |
| 587 |
|
| 588 |
</style> |
| 589 |
|
| 590 |
<?php $this->view('general/footer', $data); ?> |