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