Changeset 3412598
- Timestamp:
- 12/05/2025 08:16:07 PM (3 months ago)
- Location:
- yamaps
- Files:
-
- 7 edited
- 12 copied
-
tags/0.6.31 (copied) (copied from yamaps/trunk)
-
tags/0.6.31/includes (copied) (copied from yamaps/trunk/includes)
-
tags/0.6.31/js/btn.js (copied) (copied from yamaps/trunk/js/btn.js)
-
tags/0.6.31/js/shortcode_parser.js (copied) (copied from yamaps/trunk/js/shortcode_parser.js)
-
tags/0.6.31/languages/yamaps-ru_RU.mo (copied) (copied from yamaps/trunk/languages/yamaps-ru_RU.mo)
-
tags/0.6.31/languages/yamaps-ru_RU.po (copied) (copied from yamaps/trunk/languages/yamaps-ru_RU.po)
-
tags/0.6.31/languages/yamaps.pot (copied) (copied from yamaps/trunk/languages/yamaps.pot)
-
tags/0.6.31/options.php (copied) (copied from yamaps/trunk/options.php)
-
tags/0.6.31/readme.txt (copied) (copied from yamaps/trunk/readme.txt)
-
tags/0.6.31/style.content.css (copied) (copied from yamaps/trunk/style.content.css)
-
tags/0.6.31/templates/tmpl-editor-yamap.html (copied) (copied from yamaps/trunk/templates/tmpl-editor-yamap.html)
-
tags/0.6.31/yamap.php (copied) (copied from yamaps/trunk/yamap.php)
-
trunk/includes/admin.php (modified) (3 diffs)
-
trunk/includes/init.php (modified) (1 diff)
-
trunk/includes/shortcodes.php (modified) (5 diffs)
-
trunk/js/btn.js (modified) (10 diffs)
-
trunk/js/shortcode_parser.js (modified) (4 diffs)
-
trunk/options.php (modified) (3 diffs)
-
trunk/yamap.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
yamaps/trunk/includes/admin.php
r3235800 r3412598 4 4 function yamap_plugin_scripts($plugin_array) { 5 5 // Plugin localization 6 wp_register_script('yamap_plugin', plugin_dir_url(__FILE__) . '../js/shortcode_parser.js?v=0. 2');6 wp_register_script('yamap_plugin', plugin_dir_url(__FILE__) . '../js/shortcode_parser.js?v=0.3'); 7 7 wp_enqueue_script('yamap_plugin'); 8 8 … … 39 39 'MapContainerID' => __('Put in ID', 'yamaps'), 40 40 'MapContainerIDTip' => __('Do not create a block in the content. Use the existing block of the WP theme with the specified ID', 'yamaps'), 41 'ClusterTab' => __('Clustering', 'yamaps'), 42 'ClusterEnable' => __('Enable clustering', 'yamaps'), 43 'ClusterGrid' => __('Cluster grid size (px)', 'yamaps'), 44 'ClusterInfo' => __('Clustering groups nearby markers into clusters.<br>The grid size determines how close markers need to be to form a cluster.', 'yamaps'), 41 45 'Extra' => __('Extra', 'yamaps'), 42 46 'DeveloperInfoTab' => __('Design & Development', 'yamaps'), … … 52 56 53 57 //enqueue TinyMCE plugin script with its ID. 54 $plugin_array["yamap_plugin"] = plugin_dir_url(__FILE__) . "../js/btn.js?v=0. 40";58 $plugin_array["yamap_plugin"] = plugin_dir_url(__FILE__) . "../js/btn.js?v=0.5"; 55 59 56 60 return $plugin_array; -
yamaps/trunk/includes/init.php
r3235800 r3412598 34 34 'apikey_map_option' => '', 35 35 'reset_maps_option' => 'off', 36 'cluster_map_option' => 'off', // Кластеризация по умолчанию 37 'cluster_grid_option' => '64', // Размер ячейки кластеризации 36 38 ); 37 39 -
yamaps/trunk/includes/shortcodes.php
r3235800 r3412598 79 79 80 80 $placearr = ''; 81 82 // Clustering is disabled by default 83 // Works only when cluster="1" is explicitly specified in the shortcode 84 // The option in options.php only affects the checkbox in the editor when creating a map 85 $cluster_grid = isset($yamaps_defaults_front['cluster_grid_option']) ? $yamaps_defaults_front['cluster_grid_option'] : '64'; 86 81 87 $atts = shortcode_atts( array( 82 88 'center' => esc_js($yamaps_defaults_front['center_map_option']), … … 88 94 'mobiledrag' => '1', 89 95 'container' => '', 96 'cluster' => '0', // Disabled by default, works only with cluster="1" 97 'clustergrid' => $cluster_grid, 90 98 ), $atts ); 91 99 … … 93 101 $yacontrol_count = 0; 94 102 $yamap_onpage = true; 103 104 // Sanitize content: only allow [yaplacemark ...] shortcodes, remove everything else 105 $safe_content = ''; 106 if ( ! empty( $content ) ) { 107 // Match only [yaplacemark ...] shortcodes (self-closing or with closing tag) 108 if ( preg_match_all( '/\[yaplacemark\s+[^\]]*\](?:\[\/yaplacemark\])?/i', $content, $matches ) ) { 109 $safe_content = implode( '', $matches[0] ); 110 } 111 } 95 112 96 113 $yamactrl = str_replace(';', '", "', esc_js($atts["controls"])); … … 119 136 } 120 137 121 $placemarkscode =str_replace(" ", "", strip_tags($content));138 $placemarkscode = $safe_content; 122 139 123 140 $atts["container"]=trim($atts["container"]); … … 190 207 $placearr.='.add(myMap'.$current_map_index.'placemark'.$i.')'; 191 208 } 192 $yamap.='myMap'.$current_map_index.'.geoObjects'.$placearr.';'; 209 210 // If clustering is enabled 211 if ($atts["cluster"]=="1") { 212 $yamap.=' 213 var yaClusterer'.$current_map_index.' = new ymaps.Clusterer({ 214 clusterIconLayout: "default#pieChart", 215 clusterIconPieChartRadius: 25, 216 clusterIconPieChartCoreRadius: 15, 217 clusterIconPieChartStrokeWidth: 3, 218 hasBalloon: false, 219 gridSize: '.intval($atts["clustergrid"]).' 220 }); 221 yaClusterer'.$current_map_index.'.add(['; 222 for ($i = 1; $i <= $yaplacemark_count; $i++) { 223 $yamap.='myMap'.$current_map_index.'placemark'.$i; 224 if ($i < $yaplacemark_count) $yamap.=','; 225 } 226 $yamap.=']); 227 myMap'.$current_map_index.'.geoObjects.add(yaClusterer'.$current_map_index.'); 228 '; 229 } else { 230 $yamap.='myMap'.$current_map_index.'.geoObjects'.$placearr.';'; 231 } 232 193 233 if ($atts["scrollzoom"]=="0") $yamap.="myMap".$current_map_index.".behaviors.disable('scrollZoom');"; 194 234 // If map has mobiledrag=0, disable map dragging for the following platforms -
yamaps/trunk/js/btn.js
r3235714 r3412598 20 20 if (!editMapAction) { // Moved for correct operation in WP 5.6 21 21 22 ym={map0: {center: coordaprox(yamap_defaults['center_map_option']), controls: yamap_defaults['controls_map_option'], height: yamap_defaults['height_map_option'], zoom: yamap_defaults['zoom_map_option'], maptype: yamap_defaults['type_map_option'], scrollzoom: optionCheck('wheelzoom_map_option'), mobiledrag: optionCheck('mobiledrag_map_option'), c ontainer: '', places: {}}};22 ym={map0: {center: coordaprox(yamap_defaults['center_map_option']), controls: yamap_defaults['controls_map_option'], height: yamap_defaults['height_map_option'], zoom: yamap_defaults['zoom_map_option'], maptype: yamap_defaults['type_map_option'], scrollzoom: optionCheck('wheelzoom_map_option'), mobiledrag: optionCheck('mobiledrag_map_option'), cluster: (yamap_defaults['cluster_map_option']==='on' ? '1' : '0'), clustergrid: yamap_defaults['cluster_grid_option'] || '64', container: '', places: {}}}; 23 23 24 24 } … … 27 27 function checkParam(param) { 28 28 var checker=true; 29 if (ym.map0[param]==="0") { 30 checker=false; 29 if (param === 'cluster') { 30 // For cluster: '1' means enabled, '0' means disabled 31 checker = (ym.map0[param] === '1'); 32 } else { 33 // For scrollzoom, mobiledrag: '0' means disabled, '' means enabled 34 if (ym.map0[param]==="0") { 35 checker=false; 36 } 31 37 } 32 38 return checker; … … 136 142 setTimeout(checkcheckbox, 200, 'scrollzoom'); 137 143 setTimeout(checkcheckbox, 200, 'mobiledrag'); 144 setTimeout(checkcheckbox, 200, 'cluster'); // Добавлено 145 146 if(document.getElementById('clustergrid')) { 147 ym[mapselector].clustergrid=jQuery("#clustergrid").val(); 148 } 138 149 139 150 if(document.getElementById('mapcontainer')) { … … 553 564 mapdatechange(); 554 565 }); 566 567 // Track cluster checkbox change 568 jQuery("#cluster").click(function() { 569 mapdatechange(); 570 }); 555 571 556 572 // Track the change of icon fields … … 718 734 label: yamap_object.MapHeight, 719 735 id: 'mapheight', 720 value: ym[mapselector].height, //yamap_defaults['height_map_option'],736 value: ym[mapselector].height, 721 737 maxLength: '10', 722 738 tooltip: 'rem, em, px, %', … … 729 745 label: yamap_object.MapControls, 730 746 id: 'mapcontrols', 731 value: ym[mapselector].controls, //yamap_defaults['controls_map_option'],747 value: ym[mapselector].controls, 732 748 tooltip: yamap_object.MapControlsTip, 733 749 onaction: mapdatechange(), … … 769 785 ] 770 786 }, 771 772 773 774 775 776 787 ] 777 788 789 }, 790 { 791 type: 'panel', 792 title: yamap_object.ClusterTab || 'Clustering', 793 items: [ 794 { 795 type: 'form', 796 name: 'formCluster', 797 minWidth : 598, 798 items: [ 799 { 800 type: 'checkbox', 801 checked: checkParam('cluster'), 802 name: 'cluster', 803 label: yamap_object.ClusterEnable || 'Enable clustering', 804 id: 'cluster', 805 onaction: mapdatechange(), 806 }, 807 { 808 type: 'textbox', 809 name: 'clustergrid', 810 label: yamap_object.ClusterGrid || 'Cluster grid size (px)', 811 id: 'clustergrid', 812 value: ym[mapselector].clustergrid || '64', 813 maxLength: '4', 814 tooltip: '2, 4, 8, 16, 32, 64, 128, 256', 815 onaction: mapdatechange(), 816 }, 817 { 818 type : 'container', 819 name : 'clusterinfo', 820 minWidth : 598, 821 html : '<div style="padding: 10px 0; color: #666;">' + (yamap_object.ClusterInfo || 'Clustering groups nearby markers into clusters.<br>The grid size determines how close markers need to be to form a cluster.') + '</div>' 822 }, 823 ] 824 }, 825 ] 778 826 }, 779 827 { … … 783 831 { 784 832 type: 'form', 785 name: 'form 2',833 name: 'form3', 786 834 minWidth : 598, 787 835 … … 797 845 ] 798 846 }, 799 800 801 802 803 804 847 ] 805 848 806 }//, 807 //{ 808 // type: 'panel', 809 // title: '🦉\u00A0' + yamap_object.DeveloperInfoTab, 810 // items: [ 811 // { 812 // type: 'form', 813 // name: 'form2', 814 // minWidth : 598, 815 816 // items: [ 817 // { 818 // type : 'container', 819 // name : 'addcontrol', 820 821 // minWidth : 598, 822 // html : yamap_object.DeveloperInfo, 823 // }, 824 825 // ] 826 // }, 827 828 829 830 831 832 // ] 833 834 //} 835 849 } 836 850 837 851 ] … … 879 893 if (ym[mapselector].scrollzoom==="0") mapArgs.attrs.scrollzoom=ym[mapselector].scrollzoom; 880 894 if (ym[mapselector].mobiledrag==="0") mapArgs.attrs.mobiledrag=ym[mapselector].mobiledrag; 895 if (ym[mapselector].cluster==="1") mapArgs.attrs.cluster=ym[mapselector].cluster; 896 if (ym[mapselector].cluster==="1" && ym[mapselector].clustergrid && ym[mapselector].clustergrid!=="64") mapArgs.attrs.clustergrid=ym[mapselector].clustergrid; 881 897 if (ym[mapselector].controls!=="") mapArgs.attrs.controls=ym[yamapnumber].controls; 882 898 ed.insertContent( wp.shortcode.string( mapArgs ) ); -
yamaps/trunk/js/shortcode_parser.js
r3235714 r3412598 1 // Парсим шорткод меток внутри карты1 // Parse placemark shortcodes inside the map 2 2 function findPlaceMarks(found) { 3 3 if (typeof found !== 'string') return; … … 9 9 ym['map0'].places['placemark'+j] = {}; 10 10 for (var k = 0; k < foundplacemark.length; k++) { 11 foundplacemark[k] = foundplacemark[k].split("&").join("&"); //Bugfix: Гутенберг меняет амперсанды на html тэги. Меняем обратно. 11 // Bugfix: Gutenberg changes ampersands to HTML tags. Change back. 12 foundplacemark[k] = foundplacemark[k].split("&").join("&"); 12 13 13 14 placeparams = foundplacemark[k].split("="); 14 if (placeparams.length > 2) { //Bugfix: Если строка в шорткоде содержит знак равества, не теряем ее продолжение при делении на ключ/значение 15 // Bugfix: If the string in the shortcode contains an equals sign, don't lose its continuation when splitting into key/value 16 if (placeparams.length > 2) { 15 17 placeparams[1] = foundplacemark[k].replace(placeparams[0]+"=", ""); 16 18 } 17 19 placeparams[1] = placeparams[1].replace(/\"|\'/g, ''); 18 20 19 // Безопасная обработка URL и координат21 // Safe handling of URL and coordinates 20 22 if (placeparams[0] === 'coord') { 21 // Валидация координат23 // Coordinate validation 22 24 var coords = placeparams[1].split(','); 23 25 if (coords.length === 2) { … … 27 29 ym['map0'].places['placemark'+j][placeparams[0]] = lat + ',' + lng; 28 30 } else { 29 ym['map0'].places['placemark'+j][placeparams[0]] = '55.7473,37.6247'; // Дефолтные координаты31 ym['map0'].places['placemark'+j][placeparams[0]] = '55.7473,37.6247'; // Default coordinates 30 32 } 31 33 } else { 32 ym['map0'].places['placemark'+j][placeparams[0]] = '55.7473,37.6247'; // Дефолтные координаты34 ym['map0'].places['placemark'+j][placeparams[0]] = '55.7473,37.6247'; // Default coordinates 33 35 } 34 36 } 35 37 else if (placeparams[0] === 'url') { 36 // Безопасная обработка URL38 // Safe URL handling 37 39 try { 38 40 var url = decodeURI(placeparams[1]); 39 // Проверяем, является ли значение числом (ID поста)41 // Check if value is a number (post ID) 40 42 if (!isNaN(url)) { 41 43 ym['map0'].places['placemark'+j][placeparams[0]] = placeparams[1]; 42 44 } else { 43 // Если это URL, кодируем его45 // If it's a URL, encode it 44 46 ym['map0'].places['placemark'+j][placeparams[0]] = encodeURI(url); 45 47 } … … 70 72 options.plugin = yamap_object.PluginTitle; 71 73 options.innercontent = this.shortcode.content; 72 if (typeof ElementorConfig === 'undefined') { //код внутри функции блокирует вставку шорткода в Elementor. Нужно разобраться. 74 // Code inside function blocks shortcode insertion in Elementor. Need to investigate. 75 if (typeof ElementorConfig === 'undefined') { 73 76 return this.template(options); 74 77 } -
yamaps/trunk/options.php
r3235714 r3412598 245 245 add_settings_field( 'mobiledrag_map_option', __( 'Mobile drag', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params ); 246 246 247 // Checkbox for clustering 248 $yamaps_field_params = array( 249 'type' => 'checkbox', 250 'id' => 'cluster_map_option', 251 'desc' => __( 'Enable marker clustering by default', 'yamaps' ) 252 ); 253 add_settings_field( 'cluster_map_option', __( 'Clustering', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params ); 254 255 // Cluster grid size field 256 $yamaps_field_params = array( 257 'type' => 'text', 258 'id' => 'cluster_grid_option', 259 'desc' => __( 'Cluster grid size in pixels (2, 4, 8 ... 64, 128, 256)', 'yamaps' ), 260 'label_for' => 'cluster_grid_option' 261 ); 262 add_settings_field( 'cluster_grid_option', __( 'Cluster grid', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params ); 263 247 264 // Checkbox for opening a big map 248 265 $yamaps_field_params = array( … … 328 345 329 346 $o = get_option( $option_name ); 347 348 // Ensure $o is an array 349 if ( ! is_array( $o ) ) { 350 $o = array(); 351 } 330 352 331 353 foreach ($yamaps_defaults_front_bak as $key => $value) { 332 354 if (!isset($o[$key])) { 333 if (($value=='off')or($value=='on')) { 334 $o[$key]=$yamaps_defaults_front_bak[$key]; 335 } 355 // Set default value for missing keys 356 $o[$key] = $yamaps_defaults_front_bak[$key]; 336 357 } 337 338 } 358 } 359 360 // Ensure the current field exists in options 361 if ( ! isset( $o[$id] ) ) { 362 $o[$id] = isset( $yamaps_defaults_front_bak[$id] ) ? $yamaps_defaults_front_bak[$id] : ''; 363 } 364 339 365 switch ( $type ) { 340 366 case 'text': 341 $o[$id] = esc_attr( stripslashes( $o[$id]) );342 echo "<input class='regular-text' type='text' id=' $id' name='" . $option_name . "[$id]' value='$o[$id]' />";343 echo ($desc != '') ? "<br /><span class='description'> $desc</span>" : "";367 $o[$id] = esc_attr( stripslashes( (string) $o[$id] ) ); 368 echo "<input class='regular-text' type='text' id='" . esc_attr($id) . "' name='" . esc_attr($option_name) . "[" . esc_attr($id) . "]' value='" . esc_attr($o[$id]) . "' />"; 369 echo ($desc != '') ? "<br /><span class='description'>" . wp_kses_post($desc) . "</span>" : ""; 344 370 break; 345 371 case 'textarea': 346 $o[$id] = esc_attr( stripslashes( $o[$id]) );347 echo "<textarea class='code large-text' cols='50' rows='2' type='text' id=' $id' name='" . $option_name . "[$id]'>$o[$id]</textarea>";348 echo ($desc != '') ? "<br /><span class='description'> $desc</span>" : "";372 $o[$id] = esc_attr( stripslashes( (string) $o[$id] ) ); 373 echo "<textarea class='code large-text' cols='50' rows='2' type='text' id='" . esc_attr($id) . "' name='" . esc_attr($option_name) . "[" . esc_attr($id) . "]'>" . esc_textarea($o[$id]) . "</textarea>"; 374 echo ($desc != '') ? "<br /><span class='description'>" . wp_kses_post($desc) . "</span>" : ""; 349 375 break; 350 376 case 'checkbox': 351 $checked = ( $o[$id] == 'on') ? " checked='checked'" : '';352 echo "<label><input type='checkbox' id=' $id' name='" . $option_name . "[$id]' $checked /> ";353 echo ($desc != '') ? $desc: "";377 $checked = ( isset($o[$id]) && $o[$id] == 'on' ) ? " checked='checked'" : ''; 378 echo "<label><input type='checkbox' id='" . esc_attr($id) . "' name='" . esc_attr($option_name) . "[" . esc_attr($id) . "]' $checked /> "; 379 echo ($desc != '') ? wp_kses_post($desc) : ""; 354 380 echo "</label>"; 355 381 break; 356 382 case 'select': 357 echo "<select id=' $id' name='" . $option_name . "[$id]'>";383 echo "<select id='" . esc_attr($id) . "' name='" . esc_attr($option_name) . "[" . esc_attr($id) . "]'>"; 358 384 foreach($vals as $v=>$l){ 359 $selected = ( $o[$id] == $v) ? "selected='selected'" : '';360 echo "<option value=' $v' $selected>$l</option>";385 $selected = ( isset($o[$id]) && $o[$id] == $v ) ? "selected='selected'" : ''; 386 echo "<option value='" . esc_attr($v) . "' $selected>" . esc_html($l) . "</option>"; 361 387 } 362 echo ($desc != '') ? $desc: "";388 echo ($desc != '') ? wp_kses_post($desc) : ""; 363 389 echo "</select>"; 364 390 break; … … 366 392 echo "<fieldset>"; 367 393 foreach($vals as $v=>$l){ 368 $checked = ( $o[$id] == $v) ? "checked='checked'" : '';369 echo "<label><input type='radio' name='" . $option_name . "[$id]' value='$v' $checked />$l</label><br />";394 $checked = ( isset($o[$id]) && $o[$id] == $v ) ? "checked='checked'" : ''; 395 echo "<label><input type='radio' name='" . esc_attr($option_name) . "[" . esc_attr($id) . "]' value='" . esc_attr($v) . "' $checked />" . esc_html($l) . "</label><br />"; 370 396 } 371 397 echo "</fieldset>"; -
yamaps/trunk/yamap.php
r3235800 r3412598 6 6 * Author URI: www.yhunter.ru 7 7 * Author: Yuri Baranov 8 * Version: 0.6. 318 * Version: 0.6.40 9 9 * 10 10 *
Note: See TracChangeset
for help on using the changeset viewer.