-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmymovi.php
673 lines (590 loc) · 21.6 KB
/
mymovi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
<?php
/*
Plugin Name: MyMoVi - My Mobility Vision
Plugin URI: https://perimobil.linieplus.de
Description: A tool for participatory mobility vision creation.
Version: 1.0.1
Requires at least: 6.1.1
Requires PHP: 8.0
Author: Linie Plus, Stadtkreation, and Perimobil project team
Author URI: https://perimobil.linieplus.de/about/
Textdomain: mymovi
Domain Path: /languages
License: GNU General Public License 3
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
MyMoVi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
any later version.
MyMoVi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MyMoVi. If not, see https://www.gnu.org/licenses/gpl-3.0.en.html.
*/
if ( !is_admin() ) {
// we are not in admin mode
require_once __DIR__ . '/public/class-mymovi-public.php';
}
if ( is_admin() ) {
// we are in admin mode
require_once __DIR__ . '/admin/class-mymovi-admin.php';
}
/**
* init MyMoVi survey entry post type
*/
function mymovi_posttype_init() {
$mymovi_posttypes = array(
array(
'name' => 'mymovi-survey-entry',
'slug' => 'survey-entry',
'singular' => __('Survey entry','mymovi'),
'plural' => __('Survey entries','mymovi')
),
);
foreach($mymovi_posttypes as $mymovi_posttype) {
$menu_name = (isset($mymovi_posttype['menu']) ? $mymovi_posttype['menu'] : $mymovi_posttype['plural']);
$labels = array(
'name' => _x( $mymovi_posttype['plural'], 'post type general name', 'mymovi' ),
'singular_name' => _x( $mymovi_posttype['singular'], 'post type singular name', 'mymovi' ),
'menu_name' => _x( $menu_name, 'admin menu', 'mymovi' ),
'name_admin_bar' => _x( $mymovi_posttype['singular'], 'add new on admin bar', 'mymovi' ),
'add_new' => _x( 'Add New', 'mymoviproposal', 'mymovi' ),
'add_new_item' => sprintf(__( 'Add New %s', 'mymovi' ),$mymovi_posttype['singular']),
'new_item' => sprintf(__( 'New %s', 'mymovi' ),$mymovi_posttype['singular']),
'edit_item' => sprintf(__( 'Edit %s', 'mymovi' ),$mymovi_posttype['singular']),
'view_item' => sprintf(__( 'View %s', 'mymovi' ),$mymovi_posttype['singular']),
'all_items' => sprintf(__( 'All %s', 'mymovi' ),$mymovi_posttype['plural']),
'search_items' => sprintf(__( 'Search %s', 'mymovi' ),$mymovi_posttype['plural']),
'parent_item_colon' => sprintf(__( 'Parent %s:', 'mymovi' ),$mymovi_posttype['plural']),
'not_found' => sprintf(__( 'No %s found.', 'mymovi' ),$mymovi_posttype['plural']),
'not_found_in_trash' => sprintf(__( 'No %s found in Trash.', 'mymovi' ),$mymovi_posttype['plural'])
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $mymovi_posttype['slug'] ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 5,
'taxonomies' => array('category','post_tag'),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields', 'revisions' )
);
register_post_type( $mymovi_posttype['name'], $args );
}
}
add_action( 'init', 'mymovi_posttype_init' );
function mymovi_blocks_init() {
$script_handles = (register_block_type( __DIR__ . '/blocks/mymovi-form-input/build' ))->editor_script_handles;
foreach ($script_handles as $handle) {
wp_set_script_translations($handle, 'mymovi', plugin_dir_path( __FILE__ ) . 'languages');
}
}
add_action( 'init', 'mymovi_blocks_init' );
/**
* MyMoVi form shortcode
*/
function mymovi_form_shortcode($atts, $content) {
$output = '';
// extract shortcode attributes
$a = shortcode_atts(
array(
'stop-at-page' => PHP_INT_MAX,
'stop-at-page-text' => esc_html__('Next pages not yet activated','mymovi'),
'fgcolor' => null,
'bgcolor' => null,
),
$atts
);
// output inline CSS if fgcolor or bgcolor present as attributes
if($a['fgcolor'] || $a['bgcolor']) {
$output .= '
<style>
:root { ' . ($a['fgcolor'] ? '
--mymovi-primary-color: ' . $a['fgcolor'] . ';' : '') . ($a['bgcolor'] ? '
--mymovi-secondary-color: ' . $a['bgcolor'] . ';' : '') . '
}
</style>';
}
// explode shortcode content to single form pages with [mymovi-form-pagebreak] as delimiter
$form_pages = explode('[mymovi-form-pagebreak]', $content);
// TBD: Error handling
// $err = false;
// handle form submit
if(isset($_POST['mymovi-submit']) && $_POST['mymovi-submit']) {
// output submit success message
$output .= '
<div class="mymovi-message success">
<p>' . esc_html__('You have successfully submitted your data.', 'mymovi') . '</p>
</div>';
// setup post object with submitted data
$post = array(
'post_title' => esc_html__('Entry','mymovi') . ' ' . current_datetime()->format('Y-m-d H:i:s'),
'post_status' => 'draft',
'post_type' => 'mymovi-survey-entry'
);
// insert new post with contents from post object
$postid = wp_insert_post($post);
// add custom field with title of current survey
add_post_meta($postid,'mymovi-field-survey-name',get_the_title());
// add all custom meta from survey form
foreach($_POST as $key => $value) {
if(str_starts_with($key, 'mymovi-field')) {
if(is_array($value)) $value = implode('||', $value);
add_post_meta($postid,$key,$value);
}
}
}
// form output if not submitted
else {
// output opening form HTML
$output .= '
<div class="wp-block-group has-global-padding">
<form class="mymovi-form" method="post" action="">
<div class="mymovi-form-pages-wrapper">
<div id="page-1" class="mymovi-form-page page-1">
';
$index = 1;
// loop over form pages for form field and content outputs
foreach($form_pages as $form_page) {
$output .= do_shortcode($form_page);
// submit button for last page
if($index == sizeof($form_pages)) {
$output .= '
<div class="mymovi-form-submit wp-block-buttons">
<div class="wp-block-button">
<input class="wp-block-button__link wp-element-button" type="submit" name="mymovi-submit" value="'. esc_html__('Submit data', 'mymovi') . '">
</div>
</div>';
}
$output .= '<div class="mymovi-nav-wrapper">
<div class="mymovi-nav prev wp-block-buttons">';
// previous page button
if($index > 1) {
$output .= '
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button mymovi-button" data-showpage="page-' . ($index - 1) . '" href="#">' . esc_html__('Prev', 'mymovi'). '</a></div>';
}
$output .= '
</div>
<div class="mymovi-nav next wp-block-buttons">';
// next page button
if($index < sizeof($form_pages)) {
if($index < $a['stop-at-page']) {
$output .= '
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button mymovi-button" data-showpage="page-' . ($index + 1) . '" href="#">' . esc_html__('Next', 'mymovi'). '</a></div>';
} else {
$output .= '
<p>' . $a['stop-at-page-text'] . '</p>';
}
}
// close nav wrapper
$output .= '
</div>
</div>';
// current page indicator
$output .= '
<div class="mymovi-form-page-counter">
<p>' . sprintf(esc_html__('Page %1$s of %2$s','mymovi'), $index, sizeof($form_pages)) . '</p>
</div>';
// close/open next page
if($index < sizeof($form_pages)) {
$output .= '
</div>
<div id="page-' . ($index + 1) . '" class="mymovi-form-page page-' . ($index + 1) . '">';
}
// break if shortcode att for pagebreak present for this index value
if($index == $a['stop-at-page']) break;
// increas index form loop
$index++;
}
// output closing form HTML
$output .= '
</div>
</div>
</form>
</div>';
}
return $output;
}
add_shortcode('mymovi-form', 'mymovi_form_shortcode');
/**
* MyMoVi form field shortcode
*/
function mymovi_form_field_shortcode($atts, $content, $tag) {
$output = '';
// extract shortcode attributes
$a = shortcode_atts(
array(
'type' => 'text',
'geometry-text-field' => esc_html__('Description','mymovi'),
'geometries' => 'Point,LineString,Circle,Polygon,None',
'features' => '',
'name' => '',
'options' => '',
'option_texts' => '',
'minlength' => '',
'maxlength' => '',
'min' => '',
'max' => '',
'step' => '',
'color' => 'rgb(230, 19, 126)',
'icon' => plugin_dir_url( __FILE__ ) . 'images/draw-in-map.png',
'icon-text' => esc_html__('Map input','mymovi'),
'single-layer' => 'false',
'show-on'=>'',
),
$atts
);
// set field to required if shortcode tag contains *
$required = '';
if(str_contains($tag, '*')) $required = ' required';
$options = explode('||', $a['options']);
$option_texts = explode('||', $a['option_texts']);
$geometries = explode(',', $a['geometries']);
$geometry_labels = array(
'Point' => array(esc_html__('Location', 'mymovi'), esc_html__('Locations', 'mymovi')),
'LineString' => array(esc_html__('Route', 'mymovi'), esc_html__('Routes', 'mymovi')),
'Circle' => array(esc_html__('Radius', 'mymovi'), esc_html__('Radii', 'mymovi')),
'Polygon' => array(esc_html__('Area', 'mymovi'), esc_html__('Areas', 'mymovi')),
'None' => array(esc_html__('None', 'mymovi'), esc_html__('None', 'mymovi'))
);
$type = 'text';
$label = '';
if(is_array($atts) && $atts) {
if(isset($atts[0]) && $atts[0]) $type = $atts[0];
if(isset($atts[1]) && $atts[1]) $name = $atts[1];
if(isset($atts[2]) && $atts[2]) $label = $atts[2];
}
if ($a['show-on'])
$output .= '<div data-mymovi-show-on="'. $a['show-on'] .'" style="display:none;">';
switch($type) {
case 'text':
$output .= '
<div class="mymovi-form-field input-field type-text">
<label>' . $label . '<br>
<input type="text" name="mymovi-field-' . $name . '" minlength="' . $a['minlength'] . '" maxlength="' . $a['minlength'] . '"' . $required . '>
</label>
</div>';
break;
case 'textarea':
$output .= '
<div class="mymovi-form-field input-field type-textarea">
<label>' . $label . '<br>
<textarea name="mymovi-field-' . $name . '" minlength="' . $a['minlength'] . '" maxlength="' . $a['minlength'] . '"' . $required . '></textarea>
</label>
</div>';
break;
case 'number':
$output .= '
<div class="mymovi-form-field input-field type-number">
<label>' . $label . '<br>
<input type="number" name="mymovi-field-' . $name . '" min="' . $a['min'] . '" max="' . $a['max'] . '"' . $required . '>
</label>
</div>';
break;
case 'range':
$output .= '
<div class="mymovi-form-field input-field type-range">
<label>' . $label . '<br>
<input type="range" id="range-'. $name .'" name="range-'. $name .'" min="'. $a['min'] .'" max="'. $a['max'] .'" step="'. $a['step'] .'" list="datalist-'. $name .'" />
</label>
<datalist id="datalist-'.$name.'">';
$count = 0;
foreach($options as $option) {
$output .= '
<option value="'. $option .'">'. (isset($option_texts[$count]) && $option_texts[$count] ? $option_texts[$count] : $option) .'</option>';
$count++;
}
$output .= '
</datalist>
</div>';
break;
case 'select':
$output .= '
<div class="mymovi-form-field input-field type-select">
<label>' . $label . '<br>
<select name="mymovi-field-' . $name . '"' . $required . '>
<option value="">' . esc_html__('Please select','mymovi') . '</option>';
$count = 0;
foreach($options as $option) {
$output .= '
<option value="' . $option . '"> ' . (isset($option_texts[$count]) && $option_texts[$count] ? $option_texts[$count] : $option) . '</option>';
$count++;
}
$output .= '
</select>
</label>
</div>';
break;
case 'checkbox':
$output .= '
<p class="mymovi-form-field-wrapper type-checkbox">';
if(sizeof($options) == 1) {
$output .= '
<label>
<input type="checkbox" name="mymovi-field-' . $name . '[]"' . $required . '> ' . $label . '
</label>';
} else {
$output .= '
<strong>' . $label . '</strong><br>';
$count = 0;
foreach($options as $option) {
$output .= '
<label>
<input type="checkbox" name="mymovi-field-' . $name . '[]"' . $required . ' value="' . $option . '"> ' . (isset($option_texts[$count]) && $option_texts[$count] ? $option_texts[$count] : $option) . '<br>
</label>';
$count++;
}
}
$output .= '
</p>';
break;
case 'radio':
$output .= '
<p class="mymovi-form-field-wrapper type-radio">
<strong>' . $label . '</strong><br>';
$count = 0;
foreach($options as $option) {
$output .= '
<label>
<input type="radio" name="mymovi-field-' . $name . '"' . $required . ' value="' . $option . '"> ' . (isset($option_texts[$count]) && $option_texts[$count] ? $option_texts[$count] : $option) . '<br>
</label>';
$count++;
}
$output .= '
</p>';
break;
case 'map':
$output .= '
<div class="mymovi-form-map-wrapper" id="'. $name .'">';
if($a['icon']) {
$icon_types = [];
foreach($geometries as $geometry) {
$geometry = trim($geometry);
if(array_key_exists($geometry,$geometry_labels)) {
$icon_types[] = $geometry_labels[$geometry][1];
}
}
$icon_types_text = implode(', ', $icon_types);
$output .= '
<div class="map-icon-outer">
<div class="map-icon" style="background:' . $a['color'] . '">
<div class="map-icon-inner">
<img src="' . $a['icon'] . '" alt="map icon ' . $a['name'] . '">
</div>
</div>
<div class="scroll-to-map">
<button>'.esc_html__('Scroll to map', 'mymovi').'</button>
</div>
' . $a['icon-text'] . ' (' . $icon_types_text . ')
</div>';
}
if (count($geometries) > 1) {
$output .= '
<p>' . esc_html__('Please select the desired map entry type','mymovi') . '<br>
<select class="form-select select-drawing-tools" id="select-geometry-type-' . $name . '" name="geometry-type">';
foreach($geometries as $geometry) {
$geometry = trim($geometry);
if(array_key_exists($geometry,$geometry_labels)) {
$output .= '
<option value="' . $geometry . '">' . $geometry_labels[$geometry][1] . '</option>';
}
}
$output .= '
</select></p>';
} else {
$output .= '
<input type="hidden" id="select-geometry-type-' . $name . '" name="geometry-type" value="'. $geometries[0] .'">';
}
$output .= '
<input type="hidden" name="mymovi-field-' . $name . '-geojson" id="' . $name . '-geojson" value="'. str_replace("\"", """, $a['features']) .'">
<script type="text/javascript"> document.addEventListener("DOMContentLoaded", () => {addLayer("' . $name . '", "' . $a['color'] . '", '. $a['single-layer'] .', "'. $a['geometry-text-field'] .'");});</script>
</div>';
break;
}
if ($a['show-on'])
$output .= "</div>";
return $output;
}
add_shortcode('mymovi-form-field','mymovi_form_field_shortcode');
add_shortcode('mymovi-form-field*','mymovi_form_field_shortcode');
/**
* MyMoVi form field subfields shortcode
*/
function mymovi_form_field_subfields_shortcode($atts, $content) {
$output = '';
$a = shortcode_atts(
array(
'type' => '',
'name' => '',
'options' => '',
'option_texts' => '',
),
$atts
);
$options = explode('||', $a['options']);
$option_texts = explode('||', $a['option_texts']);
$type = 'text';
$label = '';
if(is_array($atts) && $atts) {
if(isset($atts[0]) && $atts[0]) $type = $atts[0];
if(isset($atts[1]) && $atts[1]) $name = $atts[1];
if(isset($atts[2]) && $atts[2]) $label = $atts[2];
}
switch($type) {
case 'select':
$output .= '
<div class="mymovi-form-field input-field type-select">
<label>' . $label . '<br>
<select name="mymovi-field-' . $name . '" oninput=" showSubfields(\''. $name .'\', event.target); ">
<option value="">' . esc_html__('Please select','mymovi') . '</option>';
$count = 0;
foreach($options as $option) {
$output .= '
<option value="' . $option . '"> ' . (isset($option_texts[$count]) && $option_texts[$count] ? $option_texts[$count] : $option) . '</option>';
$count++;
}
$output .= '
</select>
</label>
</div>';
break;
case 'checkbox':
$output .= '
<p class="mymovi-form-field-wrapper type-checkbox">';
if(sizeof($options) == 1) {
$output .= '
<label>
<input type="checkbox" name="mymovi-field-' . $name . '" oninput=" showSubfields(\''. $name .'\', event.target, event.target); "> ' . $label . '
</label>';
} else {
$output .= '
<strong>' . $label . '</strong><br>';
$count = 0;
foreach($options as $option) {
$output .= '
<label>
<input type="checkbox" name="mymovi-field-' . $name . '" value="' . $option . '" oninput=" showSubfields(\''. $name .'\', event.target); "> ' . (isset($option_texts[$count]) && $option_texts[$count] ? $option_texts[$count] : $option) . '<br>
</label>';
$count++;
}
}
$output .= '
</p>';
break;
case 'radio':
$output .= '
<p class="mymovi-form-field-wrapper type-radio">
<strong>' . $label . '</strong><br>';
$count = 0;
foreach($options as $option) {
$output .= '
<label>
<input type="radio" name="mymovi-field-' . $name . '" value="' . $option . '" oninput=" showSubfields(\''. $name .'\', event.target); "> ' . (isset($option_texts[$count]) && $option_texts[$count] ? $option_texts[$count] : $option) . '<br>
</label>';
$count++;
}
$output .= '
</p>';
break;
}
$output .= '
<div id="mymovi-'. $name .'-subfields">'.
$content
.'</div>';
return do_shortcode($output);
}
add_shortcode('mymovi-form-field-subfields','mymovi_form_field_subfields_shortcode');
/**
* MyMoVi form the map shortcode
*/
function mymovi_the_map_shortcode($atts, $content) {
$output = '';
$a = shortcode_atts(
array(
'geometry-text-field' => esc_html__('Description','mymovi'),
'features' => '',
'map-center-lon' => 12.47245,
'map-center-lat' => 51.34671,
'map-default-zoom' => 12,
'name' => '',
'fgcolor' => null,
'bgcolor' => null
),
$atts
);
if($a['fgcolor'] || $a['bgcolor']) {
$output .= '
<style>
:root { ' . ($a['fgcolor'] ? '
--mymovi-primary-color: ' . $a['fgcolor'] . ';' : '') . ($a['bgcolor'] ? '
--mymovi-secondary-color: ' . $a['bgcolor'] . ';' : '') . '
}
</style>';
}
$name = $a['name'];
if(is_array($atts) && $atts) {
if(isset($atts[0]) && $atts[0]) $name = $atts[0];
}
$output .= '
<div class="mymovi-form-the-map">';
$output .= "
<div id=\"mymovi-$name-contents-wrapper\" class=\"mymovi-contents-wrapper opened\" style=\"display:none;\">
<a id=\"mymovi-$name-contents-toggle\" class=\"mymovi-contents-toggle\"></a>
<div id=\"mymovi-$name-contents\" class=\"mymovi-contents\">
$content
</div>
</div>";
$output .= '
<div class="ol-control scroll-to-survey">
<button>'.esc_html__('Scroll to survey', 'mymovi').'</button>
</div>
<div class="map-control-buttons" id="mymovi-' . $name . '-control-buttons">
<input class="form-control edit-button" type="button" value="✐ ' . esc_html__('Edit text or delete', 'mymovi') . '" id="mymovi-button-select-' . $name .'">
<input class="form-control modify-button" type="button" value="✐ ' . esc_html__('Modify features', 'mymovi') . '" id="mymovi-button-modify-'. $name .'" autocomplete="off">
<input class="form-control remove-last-point" type="button" value="⌫ ' . esc_html__('Remove last point','mymovi') . '" id="undo-' . $name . '">
</div>
<div class="properties-input" id="mymovi-' . $name . '-properties-input">
<p>
<label id="geometry-text-field" for="mymovi-property-description-'. $name .'">' .$a['geometry-text-field'] . '</label>
<textarea id="mymovi-property-description-' . $name . '" name="mymovi-property-description-' . $name . '"></textarea>
</p>
<p class="close-wrapper"><input type="button" class="close" value="' . esc_html__('Save and close','mymovi') . '"></p>
<p class="delete-feature-warpper"><input type="button" class="delete-feature" value="' . esc_html__('Delete feature','mymovi') . '"></p>
</div>';
$output .= '
<div class="mymovi-form-field mymovi-map map-field type-map" id="' . $name . '"></div>
<input type="hidden" name="mymovi-field-' . $name . '-geojson" id="' . $name . '-geojson" value="'. str_replace("\"", """, $a['features']) .'"></p>
<script> addMap("' . $name . '", ' . $a['map-center-lon'] . ', ' . $a['map-center-lat'] . ', ' . $a['map-default-zoom'] . ');
const GEOMETRY_TEXT = "'. $a['geometry-text-field'] .'"; </script>
</div>';
return do_shortcode($output);
}
add_shortcode('mymovi-the-map','mymovi_the_map_shortcode');
/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
*/
require plugin_dir_path( __FILE__ ) . 'includes/class-mymovi.php';
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 0.1
*/
function mymovi_run() {
$plugin = new MyMoVi();
$plugin->run();
}
mymovi_run();
add_filter( 'acf/settings/remove_wp_meta_box', '__return_false' );