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/controllers/Wdk_location.php +40 -10 1.1.8 → 1.5.9 View file →
@@ -37,8 +37,11 @@
37 37 {
38 38 $id = (int) $this->input->post_get('id');
39 39 $paged = (int) $this->input->post_get('paged');
40 40
41 + // Check _wpnonce
42 + check_admin_referer( 'wdk-location-delete_'.$id, '_wpnonce' );
43 + wdk_access_check('location_m', $id);
41 44 $this->load->model('location_m');
42 45
43 46 $this->location_m->delete($id);
44 47
@@ -46,11 +49,15 @@
46 49 }
47 50
48 51 public function bulk_delete($posts_selected)
49 52 {
53 + // Check _wpnonce
54 + check_admin_referer( 'wdk-location-bulk', '_wpnonce');
55 +
50 56 $this->load->model('location_m');
51 57 foreach($posts_selected as $id)
52 58 {
59 + wdk_access_check('location_m', $id);
53 60 $this->location_m->delete($id);
54 61 }
55 62
56 63 wp_redirect(admin_url("admin.php?page=wdk_location&is_updated=true&custom_message=".urlencode(esc_html__('Selected Locations removed', 'wpdirectorykit'))));
@@ -60,9 +67,9 @@
60 67 public function edit()
61 68 {
62 69 $this->load->model('location_m');
63 70
64 - $id = $this->input->post_get('id');
71 + $id = (int) $this->input->post_get('id');
65 72 wdk_access_check('location_m', $id);
66 73
67 74 $this->data['db_data'] = NULL;
68 75
@@ -107,8 +114,13 @@
107 114 'field' => 'related_svg_map_location',
108 115 'label' => __('Related SVG Map Location', 'wpdirectorykit'),
109 116 'rules' => ''
110 117 ),
118 + array(
119 + 'field' => 'titles_for_search',
120 + 'label' => __('Alternative titles for search', 'wpdirectorykit'),
121 + 'rules' => ''
122 + ),
111 123 );
112 124
113 125 global $wp_filesystem;
114 126 // Initialize the WP filesystem, no more using 'file-put-contents' function
@@ -127,9 +139,11 @@
127 139
128 140 /* translate */
129 141 $this->data['maps_list'] = array();
130 142 foreach ($maps_list as $location_key => $location) {
131 - $this->data['maps_list'][str_replace('.svg', '', $location_key)] = esc_html__($location, 'wdk-svg-map');
143 + // Dynamic field values are registered in the translation catalog separately.
144 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
145 + $this->data['maps_list'][str_replace('.svg', '', $location_key)] = esc_html__($location, 'wpdirectorykit');
132 146 }
133 147 }
134 148
135 149 $this->data['map_related_locations'] = array();
@@ -141,9 +155,11 @@
141 155
142 156 if(function_exists('run_wdk_svg_map')) {
143 157 if(wmvc_show_data('related_svg_map', $this->data['db_data'], false) && isset($maps_data[wmvc_show_data('related_svg_map', $this->data['db_data'])])) {
144 158 foreach ($maps_data[wmvc_show_data('related_svg_map', $this->data['db_data'])]['locations'] as $location_key => $location) {
145 - $this->data['map_related_locations'][$location_key] = esc_html__($location, 'wdk-svg-map');
159 + // Dynamic field values are registered in the translation catalog separately.
160 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
161 + $this->data['map_related_locations'][$location_key] = esc_html__($location, 'wpdirectorykit');
146 162 }
147 163
148 164 asort($this->data['map_related_locations']);
149 165 }
@@ -150,16 +166,20 @@
150 166 }
151 167
152 168 if($this->form->run($rules))
153 169 {
170 +
171 + // Check _wpnonce
172 + check_admin_referer( 'wdk-location-edit_'.$id, '_wpnonce' );
173 +
154 174 // Save procedure for basic data
155 - $data = $this->location_m->prepare_data($this->input->post(), $rules);
175 + $data = $this->location_m->prepare_data(wdk_get_post(), $rules);
156 176
157 177 if(empty($id) && strpos($data['location_title'], ',') !== FALSE) {
158 178
159 179 foreach (explode(',', $data['location_title']) as $title) {
160 180 // Save standard wp post
161 - $insert_id = $this->location_m->insert(array_merge($data, array('location_title' => $title)), NULL);
181 + $insert_id = $this->location_m->insert(array_merge($data, array('location_title' => trim($title))), NULL);
162 182 }
163 183 wp_redirect(admin_url("admin.php?page=wdk_location&is_updated=true&custom_message=".urlencode(esc_html__('Bulk Locations added', 'wpdirectorykit'))));
164 184 exit;
165 185 } else {
@@ -204,9 +224,9 @@
204 224 public function import_from_svg()
205 225 {
206 226
207 227 if(!function_exists('run_wdk_svg_map')) {
208 - exit(esc_html__('Addon WDK SVG Map missing', 'wdk-svg-map'));
228 + exit(esc_html__('Addon WDK SVG Map missing', 'wpdirectorykit'));
209 229 }
210 230
211 231 $this->load->model('location_m');
212 232
@@ -226,9 +246,11 @@
226 246
227 247 /* translate */
228 248 $this->data['maps_list'] = array();
229 249 foreach ($maps_data as $location_key => $location) {
230 - $this->data['maps_list'][str_replace('.svg', '', $location_key)] = esc_html__($location, 'wdk-svg-map');
250 + // Dynamic field values are registered in the translation catalog separately.
251 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
252 + $this->data['maps_list'][str_replace('.svg', '', $location_key)] = esc_html__($location, 'wpdirectorykit');
231 253 }
232 254
233 255 $this->data['db_data'] = NULL;
234 256
@@ -253,10 +275,14 @@
253 275 );
254 276
255 277 if($this->form->run($rules))
256 278 {
279 +
280 + // Check _wpnonce
281 + check_admin_referer( 'wdk-svg-import', '_wpnonce' );
282 +
257 283 // Save procedure for basic data
258 - $data = $this->location_m->prepare_data($this->input->post(), $rules);
284 + $data = $this->location_m->prepare_data(wdk_get_post(), $rules);
259 285
260 286 $maps_data_json = $wp_filesystem->get_contents(WDK_SVG_MAP_PATH.'resourse/maps-db.json');
261 287 $maps_data = json_decode($maps_data_json, JSON_OBJECT_AS_ARRAY);
262 288
@@ -262,10 +288,14 @@
262 288
263 289 if(isset($maps_data[strtolower(wmvc_show_data('related_svg_map',$data))])) {
264 290 $insert_data = array('parent_id' => wmvc_show_data('related_svg_map_location',$data, NULL));
265 291 foreach ($maps_data[strtolower(wmvc_show_data('related_svg_map',$data))]['locations'] as $location_key => $location) {
266 - if(!$this->location_m->get_by(array('parent_id'=>wmvc_show_data('related_svg_map_location',$data, NULL),'location_title'=>esc_html__($location, 'wdk-svg-map')), TRUE))
267 - $insert_id = $this->location_m->insert(array_merge($insert_data, array('location_title' => esc_html__($location, 'wdk-svg-map'))), NULL);
292 + // Dynamic field values are registered in the translation catalog separately.
293 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
294 +if(!$this->location_m->get_by(array('parent_id'=>wmvc_show_data('related_svg_map_location',$data, NULL),'location_title'=>esc_html__($location, 'wpdirectorykit')), TRUE))
295 + // Dynamic field values are registered in the translation catalog separately.
296 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
297 + $insert_id = $this->location_m->insert(array_merge($insert_data, array('location_title' => esc_html__($location, 'wpdirectorykit'))), NULL);
268 298 }
269 299 }
270 300
271 301 }