Plugin Directory

Changeset 3235714


Ignore:
Timestamp:
02/05/2025 10:26:11 PM (14 months ago)
Author:
yhunter
Message:

plugin update

Location:
yamaps
Files:
8 edited
9 copied

Legend:

Unmodified
Added
Removed
  • yamaps/trunk/js/btn.js

    r3207180 r3235714  
    22var apikey = '', apikeyexist = false, wp_locale=tinymce.util.I18n.getCode();
    33if (yamap_defaults['apikey_map_option']!='') {
    4     apikey="&apikey="+yamap_defaults['apikey_map_option'];
     4    apikey="&apikey="+encodeURIComponent(yamap_defaults['apikey_map_option']);
    55    apikeyexist = true;
    66}
    7 if (typeof wp_locale !== 'undefined') { //Защита от пустой локали. У кого-то была такая проблема
     7if (typeof wp_locale !== 'undefined') { // Protection against empty locale. Some users had this problem
    88    if (wp_locale.length<1) {wp_locale="en_US";}
    99}
     
    1111    wp_locale="en_US";
    1212}
    13 script.src = "https://api-maps.yandex.ru/2.1/?lang="+wp_locale+apikey;   
     13script.src = "https://api-maps.yandex.ru/2.1/?lang="+encodeURIComponent(wp_locale)+apikey;   
    1414script.setAttribute('type', 'text/javascript');
    1515document.getElementsByTagName('head')[0].appendChild(script);
     
    1818var placemark = [];
    1919
    20 if (!editMapAction) {//Перенесено для корректной работы в WP 5.6
     20if (!editMapAction) { // Moved for correct operation in WP 5.6
    2121                           
    2222    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'), container: '', places: {}}};
     
    2424
    2525
    26 //Определяем отключен ли скролл колесом на редактируемой карте
     26// Determine if scroll zoom is disabled on the edited map
    2727function checkParam(param) {
    2828    var checker=true;
     
    3333}
    3434
    35 //Задаем дефолтные параметры из настроек
     35// Set default parameters from settings
    3636function optionCheck(param) {
    3737    var checker="0";
     
    4242}
    4343
    44 //Определяем заголовок окна для создания или редактирования
     44// Determine the window title for creating or editing
    4545function checkTitle() {
    4646    if (editMapAction) {
     
    5252}
    5353
    54 //Дефолтные данные
     54// Default data
    5555var coords=[], mapcenter=yamap_defaults['center_map_option'], mapzoom=yamap_defaults['zoom_map_option'], maptype=yamap_defaults['type_map_option'], markicon, markcount=0, mapcount=1;
    5656
     
    6060
    6161
    62 //Изменение поля типа иконки   
     62// Change the icon type field   
    6363function iconselectchange() {      // change icon type   
    6464        if (activeplace!=='') {
     
    6969}
    7070
    71 
    72 
    73 //Округляем координаты до 4 знаков после запятой
     71// Round coordinates to 4 decimal places
    7472function coordaprox(fullcoord) {
    75         //надо сделать проверку на корректный ввод координат
     73        // Need to check for valid coordinate input
    7674        if (fullcoord.length!==2) {
    7775            fullcoord=fullcoord.split(',');
     
    8381}
    8482
    85 //Изменяем поле с координатами метки
     83// Change the coordinates field of the marker
    8684function markcoordchange() {
    8785        jQuery("#markercoord").val(coordaprox(ym[mapselector].places[activeplace].coord));
    8886}
    8987
    90 //Активируем выключенное поле
     88// Activate the disabled field
    9189function enablesinglefield(field) {
    9290        jQuery(field).attr('disabled',false);
     
    9593}
    9694
    97 //Деактивируем поле
     95// Deactivate the field
    9896function disablesinglefield(field) {
    9997        jQuery(field).attr('disabled',true);
     
    102100}
    103101
    104 //Активируем выключенные поля после создания метки
     102// Activate disabled fields after creating a marker
    105103function enablefields(fieldact=true) {
    106104        if (fieldact) {
     
    113111}
    114112
    115 //Проверяем значение чекбокса
     113// Check the value of the checkbox
    116114function checkcheckbox(param) {
    117115    if (jQuery("#"+param).attr('aria-checked')!="undefined") {
     
    124122}
    125123
    126 //Изменяем данные карты в массиве после изменения полей
     124// Change the map data in the array after changing fields
    127125function mapdatechange() {
    128126       
     
    149147}
    150148
    151 //Изменяем данные карты в массиве после изменения карты в редакторе
     149// Change the map data in the array after changing the map in the editor
    152150function mapSave() {
    153151        ym[mapselector].zoom=mapzoom;
     
    156154}
    157155
    158 //Изменаем данные активной метки в массиве по данным полей ввода
     156// Change the active marker data in the array based on input field data
    159157function markchange() {
    160 
    161158        if (activeplace!=='') {
    162        
    163             ym[mapselector].places[activeplace].name=jQuery("#markername").val().replace(/["]/g, '&quot;');
    164             ym[mapselector].places[activeplace].coord=jQuery("#markercoord").val();
    165             ym[mapselector].places[activeplace].color=jQuery("#colorbox #colorbox-inp").val();
    166             ym[mapselector].places[activeplace].icon=jQuery("#markericon #markericon-inp").val();
     159            // Escape special characters in the marker name
     160            var markerName = jQuery("#markername").val().replace(/[&<>"']/g, function(m) {
     161                return {
     162                    '&': '&amp;',
     163                    '<': '&lt;',
     164                    '>': '&gt;',
     165                    '"': '&quot;',
     166                    "'": '&#039;'
     167                }[m];
     168            });
    167169           
    168             ym[mapselector].places[activeplace].url=jQuery("#markerurl").val();
    169 
    170         }
    171 }
    172 
    173 //Изменяем данные полей ввода по данным массива   
     170            ym[mapselector].places[activeplace].name = markerName;
     171            ym[mapselector].places[activeplace].coord = jQuery("#markercoord").val();
     172            ym[mapselector].places[activeplace].color = jQuery("#colorbox #colorbox-inp").val();
     173            ym[mapselector].places[activeplace].icon = jQuery("#markericon #markericon-inp").val();
     174           
     175            // Escape URL
     176            var markerUrl = jQuery("#markerurl").val();
     177            if(markerUrl) {
     178                try {
     179                    markerUrl = encodeURI(markerUrl);
     180                } catch(e) {
     181                    markerUrl = '';
     182                }
     183            }
     184            ym[mapselector].places[activeplace].url = markerUrl;
     185        }
     186}
     187
     188// Change the input field data based on the array data   
    174189function markerfields() {
    175190        if (typeof ym[mapselector].places[activeplace].name !== 'undefined') {
     
    184199}
    185200
    186 //Выключаем поле координат, когда не выбрана метка
     201// Disable the coordinates field when no marker is selected
    187202function inactive() {
    188203            jQuery("#markercoord").val(yamap_object.NoCoord);
     
    190205}
    191206
    192 
    193 //Изменяем имя или хинт иконки в зависимости от ее типа
    194 function iconname(place) {       //change icon name
     207// Change the name or hint of the icon depending on its type
     208function iconname(place) {       // change icon name
    195209        yacontent="";
    196210        if (activeplace!=='') {
     
    201215        var yahint = "";
    202216
    203         //Если иконка тянется, выводим название в iconContent
     217        // Escape the marker name for safe display
     218        markername = markername ? markername.replace(/[&<>"']/g, function(m) {
     219            return {
     220                '&': '&amp;',
     221                '<': '&lt;',
     222                '>': '&gt;',
     223                '"': '&quot;',
     224                "'": '&#039;'
     225            }[m];
     226        }) : '';
     227
     228        // If the icon is stretchy, display the name in iconContent
    204229        if (markicon.indexOf("Stretchy")!==-1) {
    205230            yahint="";
    206231            yacontent=markername;
    207232        }
    208 
    209         //Если круглая пустая иконка, то выводим в iconContent первый символ и название в hintContent
    210233        else {
    211234            if ((markicon==="islands#blueIcon")||(markicon==="islands#blueCircleIcon")) {
    212235                yahint=markername;
    213 
    214236                if ((yahint!="")&&(yahint!=undefined)) {
    215237                    yacontent=yahint[0];
    216238                }
    217                
    218239            }
    219             //Если иконка с точкой, то выводим название в hintContent
    220240            else {
    221241                yahint=markername;
     
    227247            placemark[place.replace('placemark', '')].properties.set('hintContent', yahint);
    228248            placemark[place.replace('placemark', '')].properties.set('iconContent', yacontent);
    229             //Проверяем, является ли поле иконки url-адресом. Если да, то ставим в качестве иконки кастомное изображение.
     249            // Check if the icon field is a URL. If yes, set a custom image as the icon.
    230250            if (markicon.indexOf("http")===-1) {
    231251                placemark[place.replace('placemark', '')].options.unset('iconLayout', 'default#image');
     
    236256                placemark[place.replace('placemark', '')].options.unset('preset', markicon);
    237257                placemark[place.replace('placemark', '')].options.set('iconLayout', 'default#image');
     258                // Escape the icon URL
     259                markicon = encodeURI(markicon);
    238260                placemark[place.replace('placemark', '')].options.set('iconImageHref', markicon);
    239261            }
     
    241263}
    242264
    243 
    244 //Работаем с редактором tinyMCE в модальном окне
     265// Work with the tinyMCE editor in the modal window
    245266(function() {
    246267    var editor = tinymce.activeEditor;
    247268
    248     //Изменяем цвет иконки на карте, записываем в массив 
     269    // Change the icon color on the map, write to the array 
    249270    function markercolor (pcolor) {
    250         //Если метки нет, цвета не прописываем
     271        // If there is no marker, do not set the color
    251272        if (activeplace!=='') {
    252273            placemark[activeplace.replace('placemark', '')].options.set('iconColor', pcolor);
     
    255276    }
    256277
    257     //Плагин colorPicker для tinyMCE
     278    // ColorPicker plugin for tinyMCE
    258279    function createColorPickAction() {
    259280
     
    277298    }
    278299
    279 
    280     //Добавляем кнопку и меню плагина в редактор
     300    // Add button and plugin menu to the editor
    281301    tinymce.create("tinymce.plugins.yamap_plugin", {
    282302
    283         //url argument holds the absolute url of our plugin directory
     303        // url argument holds the absolute url of our plugin directory
    284304        init : function(ed, url) {
    285305
    286 
    287 
    288             //add new button   
     306            // Add new button   
    289307            ed.addButton("yamap", {
    290308                title : yamap_object.AddMap,
     
    297315                        ed.execCommand("yamap_command");
    298316                }
    299 
    300 
    301317            });
    302318
    303 
    304 
    305 
    306 
    307             //Функционал кнопки в редакторе
     319            // Functionality of the button in the editor
    308320            ed.addCommand("yamap_command", function() {
    309321            activeplace="";   
    310322            markcount=0;         
    311323                   
    312                    
    313                     //Инициализируем карту
     324                    // Initialize the map
    314325                    jQuery(document).ready(function() {                       
    315326                       
    316327
    317                         if (!editMapAction) { //Перенесено в начало кода из-за проблем в WP 5.6
     328                        if (!editMapAction) { // Moved to the beginning of the code due to issues in WP 5.6
    318329                            delete  ym.map0.places;
    319330                            ym.map0.places = {};
    320331
    321                         //    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'), container: '', places: {}}};
    322 
    323332                        } 
    324333                        ymaps.ready(init);                     
     
    326335                    });
    327336                   
    328                     //Удаляем метку с карты
     337                    // Remove the marker from the map
    329338                    function removeplacemark(map, place) {
    330339                        map.geoObjects.remove(place);
    331340                    }
    332341
    333                     //Функция создания метки
     342                    // Function to create a marker
    334343                    function createplacemark(map, defcoord=[55.7532,37.6225]) {
    335344                        var newmark=false;
    336                         enablefields(); //Активируем выключенные поля
     345                        enablefields(); // Activate disabled fields
    337346
    338347                        if (!ym.map0.places.hasOwnProperty('placemark'+markcount))  { 
    339348                            newmark=true;
    340349                            ym.map0['places']['placemark'+markcount] = {name: '', coord: defcoord, icon: yamap_defaults['type_icon_option'], color: jQuery("#colorbox #colorbox-inp").val(), url: ''}; //: {name: 'placemark1', coord: coords, type: 'islands#blueDotIcon', color: '#ff0000', url: 'url1'};
    341                             if (activeplace==='') { //Если создается первая метка, берем значения из полей формы
     350                            if (activeplace==='') { // If the first marker is being created, take values from the form fields
    342351                                activeplace = 'placemark'+markcount;
    343352                                markchange();
     
    349358                        }
    350359
    351                        
    352 
    353 
    354                         //Создание метки на карте
     360                        // Create a marker on the map
    355361                        placemark[markcount] = new ymaps.Placemark(defcoord, {
    356362                                hintContent: "name",
     
    371377                        coords = defcoord;
    372378
    373 
    374 
    375                         //Отслеживаем событие перемещения метки
     379                        // Track the event of moving the marker
    376380                        placemark[markcount].events.add("dragend", function (e) {   
    377381                            var trg = e.get('target');         
     
    382386                        }, placemark[markcount]);
    383387
    384                         //Отслеживаем событие начала перемещения метки
     388                        // Track the event of starting to move the marker
    385389                        placemark[markcount].events.add("dragstart", function (e) {           
    386390                            var trg = e.get('target');
     
    396400
    397401                       
    398                         //Добавляем событие клика по метке
     402                        // Add click event to the marker
    399403                        placemark[markcount].events.add('click', function (e) {
    400404
     
    405409                            enablefields();
    406410                           
    407                             //Удаляем метку-закрытия для всех меток
     411                            // Remove the closing marker for all markers
    408412                            map.geoObjects.each(function (geoObject) {
    409413                                if (geoObject.properties.get('id') == 'closesvg') {
     
    413417                            });
    414418
    415                             //Добавляем метку-кнопку закрытия родительской метки
     419                            // Add a closing button marker for the parent marker
    416420                            var closePlacemark = new ymaps.Placemark(
    417421                                  plcoord,
     
    424428                                    iconImageHref: url+ "/img/close.svg",
    425429                                    iconImageSize: [16, 16],
    426                                     // Описываем фигуру активной области
    427                                     // "Прямоугольник".
     430                                    // Describe the shape of the active area
     431                                    // "Rectangle".
    428432                                    iconOffset: [-2, -30],
    429433                                    iconImageOffset: [5, 10],
     
    439443                                activeplace=''; 
    440444                                inactive();                               
    441                                 delete ym.map0['places'][trg.properties.get('id')]; // удаляем все свойства точки из массива
     445                                delete ym.map0['places'][trg.properties.get('id')]; // remove all properties of the point from the array
    442446                                if (Object.keys(ym.map0.places).length===0) {
    443                                     //Выключаем поле с координатами
     447                                    // Disable the coordinates field
    444448                                    jQuery('#markercoord').val(yamap_object.NoCoord);
    445449                                    enablefields(false);
     
    447451                            });
    448452
    449                             //Событие клика для закрытия метки
     453                            // Click event for closing the marker
    450454                            map.events.add('click', function (e) {
    451455                                removeplacemark(map, closePlacemark);
     
    460464                    }   
    461465
    462 
    463 
    464                     //Функция инициализации карты
     466                    // Function to initialize the map
    465467                    function init () {
    466468                            var myMap=[];
    467469                            var controlsArr=["zoomControl", "typeSelector"];
    468                             if (apikeyexist) controlsArr.push("searchControl"); //Если определен API key, добавляем поиск на карту. Без ключа он все равно не будет работать и выдавать ошибку.
     470                            if (apikeyexist) controlsArr.push("searchControl"); // If the API key is defined, add search to the map. Without a key, it won't work anyway and will throw an error.
    469471
    470472                            mapcenter=ym.map0.center[0];
     
    480482                            });
    481483
    482                         //Заполняем данные формы из массива при редактировании
     484                        // Fill in the form data from the array when editing
    483485                        function loadMap() {
    484486                            if (ym.map0.height!=="undefined") jQuery('#mapheight').val(ym.map0.height);
     
    487489                        }
    488490
    489 
    490 
    491                         //Ставим метки редактируемой карты
     491                        // Set markers for the edited map
    492492                        function loadPlacemarks(map) {
    493493
     
    507507                        }
    508508
    509                         //Отслеживаем событие щелчка по карте
     509                        // Track the event of clicking on the map
    510510                        myMap[mapcount].events.add('click', function (e) {
    511511                            createplacemark(myMap[mapcount], e.get('coords'));
    512512                        });
    513513
    514 
    515                         //Отслеживаем событие поиска и ставим метку в центр
     514                        // Track the event of searching and place a marker in the center
    516515                        if (apikeyexist) {
    517516                            var searchControl = myMap[mapcount].controls.get('searchControl');                       
     
    524523                        }
    525524
    526 
    527                         //Ослеживаем событие изменения области просмотра карты - масштаб и центр карты
     525                        // Track the event of changing the map view area - zoom and center of the map
    528526                        myMap[mapcount].events.add('boundschange', function (event) {
    529527                        if (event.get('newZoom') != event.get('oldZoom')) {     
     
    541539                        maptype = myMap[mapcount].getType();                       
    542540
    543                         //Отслеживаем изменение типа карты
     541                        // Track the change of the map type
    544542                        myMap[mapcount].events.add('typechange', function (event) {
    545543                            maptype = myMap[mapcount].getType();
     
    549547                        iconselectchange();
    550548
    551 
    552549                        jQuery("#mapheight, #mapcontrols").change(function() {
    553550                            mapdatechange();
     
    557554                        });
    558555
    559                         //отслеживаем изменение полей иконки 
     556                        // Track the change of icon fields 
    560557                        jQuery("#markername, #markercoord, #markericon-inp, #markerurl").change(function() {
    561558                            markchange();
    562559                        });   
    563560
    564 
    565                         //отслеживаем изменение имени иконки 
     561                        // Track the change of the icon name 
    566562                        jQuery("#markername").change(function() {
    567563                            if (activeplace!=="") {
     
    570566                        }); 
    571567
    572 
    573                         //отслеживаем изменение типа иконки
     568                        // Track the change of the icon type
    574569                        jQuery("#markericon-inp").change(function() {
    575570                            iconselectchange();
     
    587582                    }
    588583
    589                     //Параметры модального окна редактора
     584                    // Parameters of the editor modal window
    590585                    function checkApiKeyForSearchField() {
    591586                        if (apikeyexist) {
     
    893888                mapdatechange();
    894889                mapSave();
    895 
    896 
    897                
    898 
    899                
    900890            });
    901891
     
    916906   
    917907    tinymce.PluginManager.add("yamap_plugin", tinymce.plugins.yamap_plugin);
    918 
    919 
    920    
    921908})();
    922 
  • yamaps/trunk/js/shortcode_parser.js

    r2461407 r3235714  
    11//Парсим шорткод меток внутри карты
    22function findPlaceMarks(found) {
     3    if (typeof found !== 'string') return;
     4   
    35    foundplace = found.match(/\[yaplacemark(.*?)\]/g);
    4         if (foundplace!==null) {
    5                 for (var j = 0; j < foundplace.length; j++) {       
    6                     foundplacemark=foundplace[j].match(/([a-zA-Z]+)="([^"]+)+"/gi);     
    7                     ym['map0'].places['placemark'+j]={};
    8                     for (var k = 0; k < foundplacemark.length; k++) {
     6    if (foundplace !== null) {
     7        for (var j = 0; j < foundplace.length; j++) {       
     8            foundplacemark = foundplace[j].match(/([a-zA-Z]+)="([^"]+)+"/gi);     
     9            ym['map0'].places['placemark'+j] = {};
     10            for (var k = 0; k < foundplacemark.length; k++) {
     11                foundplacemark[k] = foundplacemark[k].split("&amp;").join("&"); //Bugfix: Гутенберг меняет амперсанды на html тэги. Меняем обратно.
    912
    10                         foundplacemark[k]=foundplacemark[k].split("&amp;").join("&"); //Bugfix: Гутенберг меняет амперсанды на html тэги. Меняем обратно.
     13                placeparams = foundplacemark[k].split("=");
     14                if (placeparams.length > 2) { //Bugfix: Если строка в шорткоде содержит знак равества, не теряем ее продолжение при делении на ключ/значение
     15                    placeparams[1] = foundplacemark[k].replace(placeparams[0]+"=", "");
     16                }
     17                placeparams[1] = placeparams[1].replace(/\"|\'/g, '');
    1118
    12                         placeparams=foundplacemark[k].split("=");
    13                         if (placeparams.length>2) { //Bugfix: Если строка в шорткоде содержит знак равества, не теряем ее продолжение при делении на ключ/значение
    14                             placeparams[1]=foundplacemark[k].replace(placeparams[0]+"=", "");
     19                // Безопасная обработка URL и координат
     20                if (placeparams[0] === 'coord') {
     21                    // Валидация координат
     22                    var coords = placeparams[1].split(',');
     23                    if (coords.length === 2) {
     24                        var lat = parseFloat(coords[0]);
     25                        var lng = parseFloat(coords[1]);
     26                        if (!isNaN(lat) && !isNaN(lng) && lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180) {
     27                            ym['map0'].places['placemark'+j][placeparams[0]] = lat + ',' + lng;
     28                        } else {
     29                            ym['map0'].places['placemark'+j][placeparams[0]] = '55.7473,37.6247'; // Дефолтные координаты
    1530                        }
    16                         placeparams[1]=placeparams[1].replace(/\"|\'/g, '');
    17                         if (placeparams[0]==='coord') {
    18                             ym['map0'].places['placemark'+j][placeparams[0]]=placeparams[1];
     31                    } else {
     32                        ym['map0'].places['placemark'+j][placeparams[0]] = '55.7473,37.6247'; // Дефолтные координаты
     33                    }
     34                }
     35                else if (placeparams[0] === 'url') {
     36                    // Безопасная обработка URL
     37                    try {
     38                        var url = decodeURI(placeparams[1]);
     39                        // Проверяем, является ли значение числом (ID поста)
     40                        if (!isNaN(url)) {
     41                            ym['map0'].places['placemark'+j][placeparams[0]] = placeparams[1];
     42                        } else {
     43                            // Если это URL, кодируем его
     44                            ym['map0'].places['placemark'+j][placeparams[0]] = encodeURI(url);
    1945                        }
    20                         else {
    21                             ym['map0'].places['placemark'+j][placeparams[0]]=[placeparams[1]].join('');                           
    22                         }                                           
     46                    } catch(e) {
     47                        ym['map0'].places['placemark'+j][placeparams[0]] = '';
    2348                    }
     49                }
     50                else {
     51                    ym['map0'].places['placemark'+j][placeparams[0]] = placeparams[1];
     52                }
     53            }
    2454        }
    2555    }
  • yamaps/trunk/languages/yamaps.pot

    r2849437 r3235714  
    44"Project-Id-Version: YaMaps for Wordpress\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2022-05-01 19:28+0000\n"
     6"POT-Creation-Date: 2025-02-05 21:57+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1515"X-Generator: Loco https://localise.biz/"
    1616
    17 #: options.php:282
     17#: options.php:291
    1818msgid ""
    1919"<a href=\"https://developer.tech.yandex.com/services/\">Get a key</a> "
     
    2121msgstr ""
    2222
    23 #: yamap.php:397 options.php:147
     23#: options.php:154 includes/admin.php:42
    2424msgid ""
    2525"<div style=\"position: relative; display: block; width: 100%; white-space: "
     
    4747msgstr ""
    4848
    49 #: yamap.php:399 options.php:150
    50 msgid ""
    51 "<div style=\"position: relative; display: block; width: 100%; white-space: "
    52 "normal !important;\"><h2 style=\"color: #444;font-size: 18px;font-weight: "
    53 "600;line-height: 36px;\">Want other plugin features?</h2>Do you like the "
    54 "plugin but lack features for your project? For commercial modifications of "
    55 "the plugin, please contact me.</div><div style=\"position: relative; display:"
    56 " block; width: 100%; white-space: normal !important;\"><h2 style=\"color: "
    57 "#444;font-size: 18px;font-weight: 600;line-height: 36px;\">WordPress website "
    58 "design and development</h2>My name is Yuri and I have been creating websites "
    59 "for over 15 years. I have been familiar with WordPress since 2008. I know "
    60 "and love this CMS for its user friendly interface. This is exactly how I "
    61 "tried to make the interface of my YaMaps plugin, which you are currently "
    62 "using. If you need to create a website, make an interface design or write a "
    63 "plugin for WordPress - I will be happy to help you!<p style=\"margin-top: ."
    64 "5rem; text-align: center;\"><b>Contacts:</b>  <a href=\"mailto:mail@yhunter."
    65 "ru\">[email protected]</a>, <b>telegram:</b> <a href=\"tg://resolve?"
    66 "domain=yhunter\">@yhunter</a>, <b>tel:</b> <a href=\"tel:+79028358830\">+7-"
    67 "902-83-588-30</a></p></div>"
    68 msgstr ""
    69 
    70 #: yamap.php:366
     49#: includes/admin.php:10
    7150msgid "Add map"
    7251msgstr ""
    7352
    74 #: options.php:285
     53#: options.php:294
    7554msgid "API key"
    7655msgstr ""
    7756
    78 #: options.php:252
     57#: options.php:261
    7958msgid "Author link"
    8059msgstr ""
    8160
    82 #: options.php:244
     61#: options.php:253
    8362msgid "Big map"
    8463msgstr ""
    8564
    86 #: yamap.php:372
     65#: includes/admin.php:16
    8766msgid "Blue only"
    8867msgstr ""
    8968
    90 #: options.php:199
     69#: options.php:208
    9170msgid "Choose default map type: yandex#map, yandex#satellite, yandex#hybrid"
    9271msgstr ""
    9372
    94 #: yamap.php:380
     73#: includes/admin.php:24
    9574msgid "Click on the map to choose or create the mark"
    9675msgstr ""
    9776
    98 #: yamap.php:382
     77#: includes/admin.php:26
    9978msgid "Delete"
    10079msgstr ""
    10180
    102 #: yamap.php:398
     81#: includes/admin.php:41
    10382msgid "Design & Development"
    10483msgstr ""
    10584
    106 #: options.php:250
     85#: options.php:259
    10786msgid "Disable link to plugin page"
    10887msgstr ""
    10988
    110 #: yamap.php:395
     89#: includes/admin.php:39
    11190msgid ""
    11291"Do not create a block in the content. Use the existing block of the WP theme "
     
    11493msgstr ""
    11594
    116 #: options.php:181
     95#: options.php:190
    11796msgid "Drag the map to set its default coordinates"
    11897msgstr ""
    11998
    120 #: yamap.php:367
     99#: includes/admin.php:11
    121100msgid "Edit map"
    122101msgstr ""
    123102
    124 #: yamap.php:396
     103#: includes/admin.php:40
    125104msgid "Extra"
    126105msgstr ""
    127106
    128 #: options.php:270
     107#: options.php:279
    129108msgid "For example:"
    130109msgstr ""
    131110
    132 #: yamap.php:391 options.php:218
     111#: options.php:227 includes/admin.php:35
    133112msgid "Full screen"
    134113msgstr ""
    135114
    136 #: yamap.php:392 options.php:218
     115#: options.php:227 includes/admin.php:36
    137116msgid "Geolocation"
    138117msgstr ""
    139118
    140 #: yamap.php:371 options.php:264
     119#: options.php:273 includes/admin.php:15
    141120msgid "Icon"
    142121msgstr ""
    143122
    144 #: yamap.php:373
     123#: includes/admin.php:17
    145124msgid "Link"
    146125msgstr ""
    147126
    148 #: yamap.php:365 yamap.php:370
     127#: includes/admin.php:9 includes/admin.php:14
    149128msgid "Map"
    150129msgstr ""
    151130
     131#: options.php:193
     132msgid "Map center"
     133msgstr ""
     134
     135#: options.php:229 includes/admin.php:25
     136msgid "Map controls"
     137msgstr ""
     138
     139#: options.php:220 includes/admin.php:19
     140msgid "Map height"
     141msgstr ""
     142
    152143#: options.php:184
    153 msgid "Map center"
    154 msgstr ""
    155 
    156 #: yamap.php:381 options.php:220
    157 msgid "Map controls"
    158 msgstr ""
    159 
    160 #: yamap.php:375 options.php:211
    161 msgid "Map height"
    162 msgstr ""
    163 
    164 #: options.php:175
    165144msgid "Map options"
    166145msgstr ""
    167146
    168 #: yamap.php:383 options.php:202 options.php:218
     147#: options.php:211 options.php:227 includes/admin.php:27
    169148msgid "Map type"
    170149msgstr ""
    171150
    172 #: options.php:193
     151#: options.php:202
    173152msgid "Map zoom"
    174153msgstr ""
    175154
    176 #: yamap.php:393 options.php:272
     155#: options.php:281 includes/admin.php:37
    177156msgid "Marker color"
    178157msgstr ""
    179158
    180 #: options.php:256
     159#: options.php:265
    181160msgid "Marker options"
    182161msgstr ""
    183162
    184 #: yamap.php:386 options.php:236
     163#: options.php:245 includes/admin.php:30
    185164msgid "Mobile drag"
    186165msgstr ""
    187166
    188 #: options.php:242
     167#: options.php:251
    189168msgid "Open big map/how to get button"
    190169msgstr ""
    191170
    192 #: options.php:262
     171#: options.php:271
    193172msgid "Other icon types"
    194173msgstr ""
    195174
    196 #: yamap.php:369
     175#: includes/admin.php:13
    197176msgid "Placemark"
    198177msgstr ""
    199178
    200 #: yamap.php:374
     179#: includes/admin.php:18
    201180msgid "Placemark hyperlink url or post ID"
    202181msgstr ""
    203182
    204 #: yamap.php:376
     183#: includes/admin.php:20
    205184msgid "Placemark name"
    206185msgstr ""
    207186
    208 #: yamap.php:394
     187#: includes/admin.php:38
    209188msgid "Put in ID"
    210189msgstr ""
    211190
    212 #: options.php:289 options.php:297
     191#: options.php:298 options.php:306
    213192msgid "Reset options"
    214193msgstr ""
    215194
    216 #: options.php:295
     195#: options.php:304
    217196msgid "Restore defaults"
    218197msgstr ""
    219198
    220 #: yamap.php:388 options.php:218
     199#: options.php:227 includes/admin.php:32
    221200msgid "Route"
    222201msgstr ""
    223202
    224 #: yamap.php:389 options.php:218
     203#: options.php:227 includes/admin.php:33
    225204msgid "Ruler"
    226205msgstr ""
    227206
    228 #: yamap.php:387 options.php:218
     207#: options.php:227 includes/admin.php:31
    229208msgid "Search"
    230209msgstr ""
    231210
    232 #: yamap.php:377
     211#: options.php:382
     212msgid "Security check failed"
     213msgstr ""
     214
     215#: includes/admin.php:21
    233216msgid "Text for hint or icon content"
    234217msgstr ""
    235218
    236 #: options.php:234
     219#: options.php:243
    237220msgid "The map can be dragged on mobile"
    238221msgstr ""
    239222
    240 #: options.php:226
     223#: options.php:235
    241224msgid "The map can be scaled with mouse scroll"
    242225msgstr ""
    243226
    244 #: yamap.php:390 options.php:218
     227#: options.php:227 includes/admin.php:34
    245228msgid "Traffic"
    246229msgstr ""
    247230
    248 #: yamap.php:378
     231#: includes/admin.php:22
    249232msgid "Use the links below"
    250233msgstr ""
    251234
    252 #: yamap.php:385 options.php:228
     235#: options.php:237 includes/admin.php:29
    253236msgid "Wheel zoom"
    254237msgstr ""
     
    262245msgstr ""
    263246
    264 #: options.php:39
     247#: options.php:44
    265248msgid "YaMaps default options"
    266249msgstr ""
     
    270253msgstr ""
    271254
    272 #: yamap.php:330
     255#: includes/shortcodes.php:207
    273256msgid "YaMaps plugin for Wordpress"
    274257msgstr ""
    275258
    276 #: yamap.php:368
     259#: includes/admin.php:12
    277260msgid "YaMaps plugin: Yandex.Map"
    278261msgstr ""
     
    282265msgstr ""
    283266
    284 #: options.php:276
     267#: options.php:285
    285268msgid "Yandex.Maps API key"
     269msgstr ""
     270
     271#: options.php:31
     272msgid "You do not have sufficient permissions to access this page."
    286273msgstr ""
    287274
     
    290277msgstr ""
    291278
    292 #: yamap.php:384 options.php:218
     279#: options.php:227 includes/admin.php:28
    293280msgid "Zoom"
    294281msgstr ""
    295282
    296 #: options.php:190
     283#: options.php:199
    297284msgid "Zoom the map to set its default scale"
    298285msgstr ""
    299286
    300 #: yamap.php:379
     287#: includes/admin.php:23
    301288msgid "Сoordinates"
    302289msgstr ""
  • yamaps/trunk/options.php

    r3207180 r3235714  
    22$yamaps_page = 'yamaps-options.php';
    33
    4 global $yamaps_page, $yamaps_defaults, $yamaps_defaults_front_bak;
     4global $yamaps_page, $yamaps_defaults, $yamaps_defaults_front_bak, $lang_array;
    55$option_name = 'yamaps_options';
    66if(get_option($option_name)){
     
    1515
    1616/*
    17  * Функция, добавляющая страницу в пункт меню Настройки
     17 * Function to add a page to the Settings menu
    1818 */
    1919function yamaps_options() {
     
    2424 
    2525/**
    26  * Возвратная функция (Callback)
     26 * Callback function
    2727 */
    2828function yamaps_option_page(){
     29    // Check user permissions
     30    if (!current_user_can('manage_options')) {
     31        wp_die(__('You do not have sufficient permissions to access this page.', 'yamaps'));
     32    }
     33
    2934    global $yamaps_page, $yamaps_defaults;
    3035    $maplocale = get_locale();
    3136    if (strlen($maplocale)<5) $maplocale = "en_US";
    3237    if (trim($yamaps_defaults['apikey_map_option'])<>"") {
    33             $apikey='&apikey='.$yamaps_defaults['apikey_map_option'];
     38            $apikey='&apikey='.esc_attr($yamaps_defaults['apikey_map_option']);
    3439    }
    3540    else {
     
    3742    }
    3843    ?><div class="wrap">
    39         <h2><?php echo __( 'YaMaps default options', 'yamaps' ); ?></h2>
     44        <h2><?php echo esc_html__('YaMaps default options', 'yamaps'); ?></h2>
    4045        <form method="post" id="YaMapsOptions" enctype="multipart/form-data" action="options.php">
    41         <?php echo'<script src="https://api-maps.yandex.ru/2.1/?lang='.$maplocale.$apikey.'" type="text/javascript"></script>'; ?>
     46        <?php
     47        wp_nonce_field('yamaps_options_verify', 'yamaps_options_nonce');
     48        echo '<script src="https://api-maps.yandex.ru/2.1/?lang='.esc_attr($maplocale).esc_attr($apikey).'" type="text/javascript"></script>'; ?>
    4249            <script type="text/javascript">
    43                         //Округляем координаты до 4 знаков после запятой
     50                        // Round coordinates to 4 decimal places
    4451                        function coordaprox(fullcoord) {
    4552                                if (fullcoord.length!==2) {
     
    5562
    5663
    57                         //Инициализируем карту для страницы настроек
     64                        // Initialize the map for the settings page
    5865                        function init () {
    5966                            var testvar=document.getElementById('center_map_option').value;
     
    6168                            if (apikey!=="") apikeyexist=true;
    6269                            var controlsArr=["zoomControl", "typeSelector"];
    63                             if (apikeyexist) controlsArr.push("searchControl"); //Если определен API key, добавляем поиск на карту. Без ключа он все равно не будет работать и выдавать ошибку.
     70                            if (apikeyexist) controlsArr.push("searchControl"); // If the API key is defined, add search to the map. Without a key, it won't work anyway and will throw an error.
    6471
    6572                            var myMap0 = new ymaps.Map("yamap", {
     
    7077                                });   
    7178
    72                             //Добавляем пример метки
     79                            // Add a sample placemark
    7380                            placemark1 = new ymaps.Placemark([<?php echo $yamaps_defaults["center_map_option"]; ?>], {
    7481                                hintContent: "Placemark",
     
    7885                            }, {
    7986                                <?php
    80                                     //Проверяем, является ли поле иконки url-адресом. Если да, то ставим в качестве иконки кастомное изображение.
     87                                    // Check if the icon field is a URL. If yes, set a custom image as the icon.
    8188                                    $iconurl = strripos($yamaps_defaults["type_icon_option"], 'http');
    8289                                    if (is_int($iconurl)) {
     
    101108                            myMap0.geoObjects.add(placemark1);
    102109
    103                             //Событие перемещения карты
     110                            // Map movement event
    104111                            myMap0.events.add('boundschange', function (event) {
    105                                         //Если изменили масштаб
     112                                        // If the zoom level changed
    106113                                        if (event.get('newZoom') != event.get('oldZoom')) {     
    107114                                            document.getElementById('zoom_map_option').value = event.get('newZoom');                                           
    108115                                        }
    109                                         //Если переместили центр
     116                                        // If the center was moved
    110117                                          if (event.get('newCenter') != event.get('oldCenter')) {
    111118                                            document.getElementById('center_map_option').value = coordaprox(event.get('newCenter'));   
    112119                                        }
    113                                         //Помещаем метку в новый центр
     120                                        // Place the marker in the new center
    114121                                        placemark1.geometry.setCoordinates(event.get('newCenter'));                                 
    115122                            });
    116                             //Событие смены иконки
     123                            // Icon change event
    117124                            myMap0.events.add('typechange', function (event) {
    118125                                        document.getElementById('type_map_option').value = myMap0.getType();
    119126                            });
    120                             //Cобытие поиска, скрываем метку результата
    121                             if (apikeyexist) { //Баг, если нет API.ключа, то нет поискового поля и вызывает ошибку
     127                            // Search event, hide the result marker
     128                            if (apikeyexist) { // Bug, if there is no API key, then there is no search field and it throws an error
    122129                                var searchControl = myMap0.controls.get('searchControl');                       
    123130                                searchControl.events.add('resultshow', function (e) {
     
    125132                                });
    126133                            }
    127                             //Функция добавления элементов управления картой в поле настроек
     134                            // Function to add map control elements in the settings field
    128135                            var controlElems = document.querySelectorAll('#addcontrol a');
    129136                            for (var i = 0; i < controlElems.length; i++) {
     
    154161            </div>
    155162            <?php
    156             settings_fields('yamaps_options'); // Идентификатор настроек плагина
     163            settings_fields('yamaps_options'); // Plugin settings identifier
    157164            do_settings_sections($yamaps_page);
    158165            ?>
     
    166173 
    167174/*
    168  * Регистрируем настройки
    169  * Мои настройки будут храниться в базе под названием yamaps_options (это также видно в предыдущей функции)
     175 * Register settings
     176 * My settings will be stored in the database under the name yamaps_options (this is also visible in the previous function)
    170177 */
    171178function yamaps_option_settings() {
    172179    global $yamaps_page;
    173     // Присваиваем функцию валидации ( yamaps_validate_settings() ). Вы найдете её ниже
     180    // Assign validation function ( yamaps_validate_settings() ). You will find it below
    174181    register_setting( 'yamaps_options', 'yamaps_options', 'yamaps_validate_settings' ); // yamaps_options
    175182 
    176     // Область настроек карты
     183    // Map settings area
    177184    add_settings_section( 'map_section', __( 'Map options', 'yamaps' ), '', $yamaps_page );
    178185 
    179     // Поле центра карты
    180     $yamaps_field_params = array(
    181         'type'      => 'text', // тип
     186    // Map center field
     187    $yamaps_field_params = array(
     188        'type'      => 'text', // type
    182189        'id'        => 'center_map_option',
    183190        'desc'      => __( 'Drag the map to set its default coordinates', 'yamaps' ),
     
    186193    add_settings_field( 'center_map_option', __( 'Map center', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params );
    187194
    188     // Поле масштаба карты
    189     $yamaps_field_params = array(
    190         'type'      => 'text', // тип
     195    // Map zoom field
     196    $yamaps_field_params = array(
     197        'type'      => 'text', // type
    191198        'id'        => 'zoom_map_option',
    192199        'desc'      => __( 'Zoom the map to set its default scale', 'yamaps' ),
     
    195202    add_settings_field( 'zoom_map_option', __( 'Map zoom', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params );
    196203
    197     // Поле типа карты
    198     $yamaps_field_params = array(
    199         'type'      => 'text', // тип
     204    // Map type field
     205    $yamaps_field_params = array(
     206        'type'      => 'text', // type
    200207        'id'        => 'type_map_option',
    201208        'desc'      => __( 'Choose default map type: yandex#map, yandex#satellite, yandex#hybrid', 'yamaps' ),
     
    204211    add_settings_field( 'type_map_option', __( 'Map type', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params );
    205212
    206     // Поле высоты карты
    207     $yamaps_field_params = array(
    208         'type'      => 'text', // тип
     213    // Map height field
     214    $yamaps_field_params = array(
     215        'type'      => 'text', // type
    209216        'id'        => 'height_map_option',
    210217        'desc'      => 'rem, em, px, %',
     
    214221
    215222 
    216     // Поле элементов управления карты
     223    // Map controls field
    217224    $yamaps_field_params = array(
    218225        'type'      => 'textarea',
     
    222229    add_settings_field( 'controls_map_option', __( 'Map controls', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params );
    223230
    224     // Чекбокс масштаба колесом
     231    // Checkbox for wheel zoom
    225232    $yamaps_field_params = array(
    226233        'type'      => 'checkbox',
     
    230237    add_settings_field( 'wheelzoom_map_option', __( 'Wheel zoom', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params );
    231238
    232     // Чекбокс мобильного перетаскивания
     239    // Checkbox for mobile dragging
    233240    $yamaps_field_params = array(
    234241        'type'      => 'checkbox',
     
    238245    add_settings_field( 'mobiledrag_map_option', __( 'Mobile drag', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params );
    239246
    240     // Чекбокс открытия большой карты
     247    // Checkbox for opening a big map
    241248    $yamaps_field_params = array(
    242249        'type'      => 'checkbox',
     
    246253    add_settings_field( 'open_map_option', __( 'Big map', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params );
    247254
    248     // Чекбокс ссылки на автора
     255    // Checkbox for author link
    249256    $yamaps_field_params = array(
    250257        'type'      => 'checkbox',
     
    254261    add_settings_field( 'authorlink_map_option', __( 'Author link', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'map_section', $yamaps_field_params );
    255262 
    256     // Область настроек метки
     263    // Marker settings area
    257264 
    258265    add_settings_section( 'icon_section', __( 'Marker options', 'yamaps' ), '', $yamaps_page );
    259266 
    260     // Поле типа метки
     267    // Marker type field
    261268    $yamaps_field_params = array(
    262269        'type'      => 'text',
     
    266273    add_settings_field( 'type_icon_option', __( 'Icon', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'icon_section', $yamaps_field_params );
    267274
    268     // Поле цвета метки
     275    // Marker color field
    269276    $yamaps_field_params = array(
    270277        'type'      => 'text',
     
    274281    add_settings_field( 'color_icon_option', __( 'Marker color', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'icon_section', $yamaps_field_params );
    275282
    276     // Область ключа API
     283    // API key area
    277284
    278285    add_settings_section( 'apikey_section', __( 'Yandex.Maps API key', 'yamaps' ), '', $yamaps_page );
    279286
    280     // Поле ключа API
    281     $yamaps_field_params = array(
    282         'type'      => 'text', // тип
     287    // API key field
     288    $yamaps_field_params = array(
     289        'type'      => 'text', // type
    283290        'id'        => 'apikey_map_option',
    284291        'desc'      => __( '<a href="https://developer.tech.yandex.com/services/">Get a key</a> (JavaScript API & HTTP Geocoder) if it necessary', 'yamaps' ),
     
    287294    add_settings_field( 'apikey_map_option', __( 'API key', 'yamaps' ), 'yamaps_option_display_settings', $yamaps_page, 'apikey_section', $yamaps_field_params );
    288295
    289     // Область сброса настроек
     296    // Reset settings area
    290297 
    291298    add_settings_section( 'reset_section', __( 'Reset options', 'yamaps' ), '', $yamaps_page );
    292299
    293     // Чекбокс сброса настроек
     300    // Reset settings checkbox
    294301    $yamaps_field_params = array(
    295302        'type'      => 'checkbox',
     
    303310 
    304311/*
    305  * Функция отображения полей ввода
    306  * Здесь задаётся HTML и PHP, выводящий поля
     312 * Function to display input fields
     313 * Here is the HTML and PHP that outputs the fields
    307314 */
    308315function yamaps_option_display_settings($args) {
     
    311318 
    312319    $option_name = 'yamaps_options';
    313     //delete_option($option_name); //удаление настроек для тестов
     320    //delete_option($option_name); // delete settings for testing
    314321   
    315     //Если настройки не найдены в БД, сохраняем туда дефолтные настройки плагина
     322    // If settings are not found in the database, save the default settings of the plugin there
    316323    if(!get_option( $option_name)){
    317324        update_option( $option_name, $yamaps_defaults_front_bak);
    318325    }
    319326
    320     //Нужно перебрать настройки и поставить дефолт в отсутствующие.
     327    // Need to iterate through the settings and set the default for the missing ones.
    321328
    322329    $o = get_option( $option_name );
     
    367374}
    368375
     376/*
     377 * Data validation function
     378 */
     379function yamaps_validate_settings($input) {
     380    // Check nonce
     381    if (!isset($_POST['yamaps_options_nonce']) || !wp_verify_nonce($_POST['yamaps_options_nonce'], 'yamaps_options_verify')) {
     382        add_settings_error('yamaps_options', 'invalid_nonce', __('Security check failed', 'yamaps'));
     383        return get_option('yamaps_options');
     384    }
     385
     386    return $input;
     387}
     388
    369389?>
  • yamaps/trunk/readme.txt

    r3207180 r3235714  
    102102== Changelog ==
    103103
     104= 0.6.30 =
     105* Security improvements.
     106* Code refactoring.
     107* Fixed: Bugfix.
     108
    104109= 0.6.28 =
    105110* Fixed: Bugfix.
  • yamaps/trunk/style.content.css

    r1917981 r3235714  
    1 .yamap_shortcode {
    2     clear:both;
    3     padding: .0rem 1rem 1rem 1rem;
    4     border: 1px #ccc dashed;
    5     overflow: hidden;
    6     display: block;
    7 }
    8 
    9 .yamap_shortcode .content{
    10     margin: 1px 0 0 0px;
    11     display: inline-block;
    12     float: left;
    13     padding: 0;
    14 
    15 }
    16 
    17 .yamap_title {
    18     font-size: .8em;
    19     color: #666;
    20     margin-bottom: .5em;
    21     border-bottom: 1px #ccc dashed;
    22     padding: .5em 0;
    23 }
    24 
    25 .yamap_icon {
    26     display: inline-block;
    27     position: relative;
    28     width: 1.2em;
    29     height: 1.2em;
    30     background-image: url('js/img/placeholder.svg');
    31     background-repeat: no-repeat;
    32     opacity: .7;
    33 }
    34 
    35 
    36 .mce-container ymaps {
    37         font-family: "Source Sans Pro",HelveticaNeue-Light,"Helvetica Neue Light","Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif !important;
    38         font-size: 12px !important;
    39 }
  • yamaps/trunk/templates/tmpl-editor-yamap.html

    r1917981 r3235714  
    11<script type="text/html" id="tmpl-editor-yamap">
     2    <style>
     3        .yamap_shortcode {
     4            clear: both;
     5            padding: .0rem 1rem 1rem 1rem;
     6            border: 1px #ccc dashed;
     7            overflow: hidden;
     8            display: block;
     9        }
     10
     11        .yamap_shortcode .content {
     12            margin: 1px 0 0 0px;
     13            display: inline-block;
     14            float: left;
     15            padding: 0;
     16
     17        }
     18
     19        .yamap_title {
     20            font-size: .8em;
     21            color: #666;
     22            margin-bottom: .5em;
     23            border-bottom: 1px #ccc dashed;
     24            padding: .5em 0;
     25        }
     26
     27        .yamap_icon {
     28            display: inline-block;
     29            position: relative;
     30            width: 1.2em;
     31            height: 1.2em;
     32            background-image: url('js/img/placeholder.svg');
     33            background-repeat: no-repeat;
     34            opacity: .7;
     35        }
     36
     37
     38        .mce-container ymaps {
     39            font-family: "Source Sans Pro", HelveticaNeue-Light, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif !important;
     40            font-size: 12px !important;
     41        }
     42    </style>
    243    <div class="yamap_shortcode">
    344        <div class="yamap_title"><span class="yamap_icon"></span> {{ data.plugin }} </div>
  • yamaps/trunk/yamap.php

    r3207180 r3235714  
    66 * Author URI:  www.yhunter.ru
    77 * Author:      Yuri Baranov
    8  * Version:     0.6.28
     8 * Version:     0.6.30
    99 *
    1010 *
     
    1515 *
    1616 */
    17 global $maps_count, $count_content, $yamap_load_api;
    1817
    19 if (!isset($maps_count)) {
    20     $maps_count=0;
     18 $lang_array = array();
     19
     20// Load components
     21require_once plugin_dir_path(__FILE__) . 'includes/init.php';
     22require_once plugin_dir_path(__FILE__) . 'includes/shortcodes.php';
     23require_once plugin_dir_path(__FILE__) . 'includes/api.php';
     24require_once plugin_dir_path(__FILE__) . 'includes/admin.php';
     25
     26// Load text domain for localization
     27function yamaps_plugin_load_plugin_textdomain() {
     28    load_plugin_textdomain('yamaps', FALSE, basename(dirname(__FILE__)) . '/languages/');
    2129}
    22 if (!isset($count_content)) {
    23     $count_content=0;
    24 }
     30add_action('plugins_loaded', 'yamaps_plugin_load_plugin_textdomain');
    2531
    26 // Test for the first time content and single map (WooCommerce and other custom posts)
    27 //$count_content=0;
    28 $yamap_load_api=true;
    29 $apikey='';
    30 
    31 $yamaps_defaults_front = array(
    32     'center_map_option'         => '55.7473,37.6247',
    33     'zoom_map_option'           => '12',
    34     'type_map_option'           => 'yandex#map',
    35     'height_map_option'         => '22rem',
    36     'controls_map_option'       => '',
    37     'wheelzoom_map_option'      => 'off',
    38     'mobiledrag_map_option'     => 'off',
    39     'type_icon_option'          => 'islands#dotIcon',
    40     'color_icon_option'         => '#1e98ff',
    41     'authorlink_map_option'     => 'off',
    42     'open_map_option'           => 'off',
    43     'apikey_map_option'         => '',
    44     'reset_maps_option'         => 'off',
    45 ); 
    46 
    47 $yamaps_defaults_front_bak=$yamaps_defaults_front;
    48 $yamaps_defaults=$yamaps_defaults_front;
    49 
    50 //Загрузка настроек
    51 
    52 $option_name = 'yamaps_options';
    53 if(get_option($option_name)){
    54     $yamaps_defaults_front=get_option($option_name);
    55     //исправляем ошибку с дефолтными настройками 0.5.7
    56     $fixpos = strripos($yamaps_defaults_front['controls_map_option'], '111');
    57     if (is_int($fixpos)) {
    58         $fixpattern=array('111;','111');
    59         $yamaps_defaults_front['controls_map_option']=str_replace($fixpattern, '', $yamaps_defaults_front['controls_map_option']);
    60         echo esc_html($yamaps_defaults_front['controls_map_option']);
    61         update_option($option_name, $yamaps_defaults_front);
    62     }
    63     //конец правки. Будет удалено в следующих версиях.
    64 }
    65 
    66 //Проверяем все ли дефолтные параметры есть в настройках плагина
    67 foreach($yamaps_defaults_front_bak as $yamaps_options_key => $yamaps_options_val) {
    68     if(!isset($yamaps_defaults_front[$yamaps_options_key])) {
    69         $yamaps_defaults_front[$yamaps_options_key]=$yamaps_defaults_front_bak[$yamaps_options_key];
    70     }
    71 }
    72 
    73 //Добавляем счетчик полей с контентом (для постов с произвольными полями)
    74 add_filter( 'the_content', 'yamaps_the_content');
    75 add_filter('widget_text', 'yamaps_the_content');
    76 add_filter('requirement', 'yamaps_the_content');
    77 
    78 function yamaps_the_content( $content ) {
    79     global $count_content;
    80     $count_content++;
    81     return $content;
    82 }
    83 
    84 //Новый вызов Yandex Map API. Если передаем true, отдается только адрес API с локалью и API-ключем. Нужно для альтернативного подключения API, при отсутствии wp_footer
    85 function YandexMapAPI_script($noFooter = false) { 
    86         global $yamaps_defaults_front, $apikey, $post;
    87         $maplocale = get_locale();
    88         if (strlen($maplocale)<5) $maplocale = "en_US";
    89         if (trim($yamaps_defaults_front['apikey_map_option'])<>"") {
    90             $apikey='&apikey='.esc_html($yamaps_defaults_front['apikey_map_option']);
    91         }
    92         else {
    93             $apikey = '';
    94         }
    95         if ($noFooter) {
    96             $AltApiSrc = 'https://api-maps.yandex.ru/2.1/?lang='.esc_html($maplocale).esc_html($apikey).'&ver=2.1';
    97             $AltApiSrc = str_replace("&amp;", "&", $AltApiSrc);
    98             return $AltApiSrc;
    99         }
    100         else {
    101             if ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'yamap') ) {
    102                 // Register the script like this for a plugin: 
    103                 wp_register_script( 'YandexMapAPI', 'https://api-maps.yandex.ru/2.1/?lang='.esc_html($maplocale).esc_html($apikey), [], 2.1, true ); 
    104 
    105                 // For either a plugin or a theme, you can then enqueue the script: 
    106                 wp_enqueue_script( 'YandexMapAPI' );
    107             }   
    108         }
    109          
    110 }
    111 
    112 //Функция добавления метки на карту
    113 function yaplacemark_func($atts) {
    114     $atts = shortcode_atts( array(
    115         'coord' => '',
    116         'name' => '',
    117         'color' => 'blue',
    118         'url' => '',
    119         'icon' => 'islands#dotIcon',
    120     ), $atts );
    121 
    122     global $yaplacemark_count, $maps_count;
    123     $yaplacemark_count++;
    124     $yahint="";
    125     $yacontent="";
    126     $yaicon=trim(esc_html($atts["icon"]));
    127 
    128 
    129     if (strstr($yaicon, "Stretchy")<>FALSE) {
    130         $yahint="";
    131         $yacontent=sanitize_text_field($atts["name"]);
    132         }
    133     else {
    134             if (($yaicon==="islands#blueIcon")or($yaicon==="islands#blueCircleIcon")) {
    135                 $yahint=esc_html($atts["name"]);
    136                 $yacontent=esc_html(mb_substr($yahint, 0, 1));
    137             }
    138             else {
    139                 $yahint=esc_html($atts["name"]);
    140                 $yacontent="";
    141             }
    142     }
    143    
    144    
    145     $yaplacemark='
    146         YaMapsWP.myMap'.$maps_count.'.places.placemark'.$yaplacemark_count.' = {icon: "'.esc_js($atts["icon"]).'", name: "'.esc_js($atts["name"]).'", color: "'.esc_js($atts["color"]).'", coord: "'.esc_js($atts["coord"]).'", url: "'.esc_url($atts["url"]).'",};
    147         myMap'.$maps_count.'placemark'.$yaplacemark_count.' = new ymaps.Placemark(['.$atts["coord"].'], {
    148                                 hintContent: "'.esc_js($yahint).'",
    149                                 iconContent: "'.esc_js($yacontent).'",
    150 
    151 
    152                              
    153                             }, {';
    154     //Проверяем, является ли поле иконки url-адресом. Если да, то ставим в качестве иконки кастомное изображение.
    155     $iconurl = strripos($atts["icon"], 'http');
    156     if (is_int($iconurl)) {
    157         $yaplacemark.='                       
    158                                 iconLayout: "default#image",
    159                                 iconImageHref: "'.esc_js($atts["icon"]).'"
    160                             }); 
    161         ';
    162 
    163     }
    164     else {
    165         $yaplacemark.='                       
    166                                 preset: "'.esc_js($atts["icon"]).'",
    167                                 iconColor: "'.esc_js($atts["color"]).'",
    168                             }); 
    169         ';
    170     }
    171    
    172     $atts["url"]=trim(esc_js($atts["url"]));
    173     if (($atts["url"]<>"")and($atts["url"]<>"0")) {
    174         $marklink=$atts["url"];
    175         settype($marklink, "integer");
    176         if ($marklink<>0) {
    177             $marklink=get_the_permalink(esc_js($atts["url"]));
    178             $yaplacemark.='YaMapsWP.myMap'.$maps_count.'.places["placemark'.$yaplacemark_count.'"].url="'.$marklink.'"';
    179         }
    180         else {
    181             $marklink=$atts["url"];
    182         }
    183         $yaplacemark.='
    184                 YMlisteners.myMap'.$maps_count.'['.$yaplacemark_count.'] = myMap'.$maps_count.'placemark'.$yaplacemark_count.'.events.group().add("click", function(e) {yamapsonclick("'.esc_url($marklink).'")});
    185 
    186         ';
    187     }
    188     return $yaplacemark;
    189 }
    190 
    191 //Функция вывода карты
    192 function yamap_func($atts, $content){
    193     global $yaplacemark_count, $yamaps_defaults_front, $yamaps_defaults_front_bak, $yacontrol_count, $maps_count, $count_content, $yamap_load_api, $suppressMapOpenBlock, $yamap_onpage;
    194 
    195     $placearr = '';
    196     $atts = shortcode_atts( array(
    197         'center' => esc_js($yamaps_defaults_front['center_map_option']),
    198         'zoom' => esc_js($yamaps_defaults_front['zoom_map_option']),
    199         'type' => 'map',
    200         'height' => esc_js($yamaps_defaults_front['height_map_option']),
    201         'controls' => esc_js($yamaps_defaults_front['controls_map_option']),
    202         'scrollzoom' => '1',
    203         'mobiledrag' => '1',
    204         'container' => '',
    205 
    206     ), $atts );
    207    
    208     $yaplacemark_count=0;
    209     $yacontrol_count=0;
    210     $yamap_onpage=true;
    211 
    212     $yamactrl=str_replace(';', '", "', esc_js($atts["controls"]));
    213 
    214     if (trim($yamactrl)<>"") $yamactrl='"'.$yamactrl.'"';
    215 
    216     if (($yamap_load_api)) { // First time content and single map
    217         if (trim($yamaps_defaults_front['apikey_map_option'])<>"") {
    218             $apikey='&apikey='.esc_js($yamaps_defaults_front['apikey_map_option']);
    219         }
    220         else {
    221             $apikey = '';
    222         }
    223 
    224         $yamap='
    225         <script>
    226             if (typeof(YaMapsWP) === "undefined") {
    227                 var YaMapsWP = {}, YMlisteners = {};
    228                 var YaMapsScript = document.createElement("script");   
    229                 var YaMapsScriptCounter = [];                   
    230             }
    231             var myMap'.$maps_count.';           
    232         </script>';
    233     }
    234     else {
    235         $yamap='';
    236     }
    237    
    238     $placemarkscode=str_replace("&nbsp;", "", strip_tags($content));
    239 
    240     $atts["container"]=trim($atts["container"]);
    241     if ($atts["container"]<>"") {
    242         $mapcontainter=esc_html($atts["container"]);
    243         $mapcontainter=str_replace("#", "", $mapcontainter);
    244     }
    245     else {
    246         $mapcontainter='yamap'.$maps_count;
    247     }   
    248    
    249     // Проверяем опцию включения кнопки большой карты
    250     if ($yamaps_defaults_front['open_map_option']<>'on') {
    251         $suppressMapOpenBlock='true';
    252     }
    253     else {
    254         $suppressMapOpenBlock='false';
    255     }
    256     //1. Дожидаемся загрузки всей страницы для инициализации карты
    257     //2. Проверяем, подключился ли API в wp_footer по ID "YandexMapAPI-js" (wp_footer может не оказаться в кастомных шаблонах)
    258     //3. Если нет, запускаем функцию альтернативного подключения API - AltApiLoad, подключаем скрипт с ID "YandexMapAPI-alt-js"
    259     //4. Функцию инициализации каждой карты на странице записываем в массив YaMapsScriptCounter и, после загрузки скрипта, поочередно инициализируем
    260     $yamap.='
    261                         <script type="text/javascript">                                     
    262                         document.addEventListener("DOMContentLoaded", function() {
    263                            if (document.getElementById("YandexMapAPI-js") == null ) {
    264                                 YaMapsScriptCounter.push(function() {ymaps.ready(init)});
    265                                 if (document.getElementById("YandexMapAPI-alt-js") == null ) {
    266                                     function AltApiLoad(src){
    267 
    268                                       YaMapsScript.id = "YandexMapAPI-alt-js";
    269                                       YaMapsScript.src = src;
    270                                       YaMapsScript.async = false;
    271                                       document.head.appendChild(YaMapsScript);
    272 
    273                                     }
    274 
    275                                     AltApiLoad("'.YandexMapAPI_script(true).'");
    276 
    277                                     window.onload = function() {
    278                                         YaMapsScriptCounter.forEach(function(entryFunc) {
    279                                             entryFunc();
    280                                         });
    281                                     }
    282                                 }
    283 
    284                                
    285 
    286                            }
    287                            else {
    288                                 ymaps.ready(init);
    289                            }
    290                            
    291                            
    292                             YMlisteners.myMap'.$maps_count.' = {};
    293                             YaMapsWP.myMap'.$maps_count.' = {center: "'.esc_js($atts["center"]).'", zoom: "'.esc_js($atts["zoom"]).'", type: "'.esc_js($atts["type"]).'", controls: "'.esc_js($atts["controls"]).'", places: {}};
    294 
    295                             var yamapsonclick = function (url) {
    296                                 location.href=url;
    297                             }                       
    298 
    299                             function init () {
    300                                 myMap'.$maps_count.' = new ymaps.Map("'.$mapcontainter.'", {
    301                                         center: ['.sanitize_text_field($atts["center"]).'],
    302                                         zoom: '.sanitize_text_field($atts["zoom"]).',
    303                                         type: "'.sanitize_text_field($atts["type"]).'",
    304                                         controls: ['.sanitize_text_field($yamactrl).'] ,
    305                                        
    306                                     },
    307                                     {
    308                                         suppressMapOpenBlock: '.esc_js($suppressMapOpenBlock).'
    309                                     });
    310 
    311                                 '.do_shortcode($placemarkscode);                           
    312                                
    313                                 for ($i = 1; $i <= $yaplacemark_count; $i++) {
    314                                     $placearr.='.add(myMap'.$maps_count.'placemark'.$i.')';
    315                                 }
    316                                 $yamap.='myMap'.$maps_count.'.geoObjects'.$placearr.';';
    317                                 if ($atts["scrollzoom"]=="0") $yamap.="myMap".$maps_count.".behaviors.disable('scrollZoom');";
    318                                 //Если у карты mobiledrag=0, отключаем прокрутку карты для следующих платформ
    319                                 if ($atts["mobiledrag"]=="0") {
    320                                     $yamap.="
    321                                     if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)) {
    322                                         myMap".$maps_count.".behaviors.disable('drag');
    323                                     }";
    324                                 }
    325                                 $yamap.='
    326 
    327                             }
    328                         }, false);
    329                     </script>
    330                    
    331     ';
    332     $authorLinkTitle=__( 'YaMaps plugin for Wordpress', 'yamaps' );
    333 
    334     if($yamaps_defaults_front['authorlink_map_option']<>'on'){
    335        
    336     $authorlink='<div style="position: relative; height: 0;  margin-bottom: 1rem !important; margin-top:0 !important; overflow: visible; width: 100%; text-align: center; top: -32px;"><a href="https://www.yhunter.ru/portfolio/dev/yamaps/" title="'.esc_attr($authorLinkTitle).'" target="_blank" style="display: inline-block; -webkit-box-align: center; padding: 3.5px 5px; text-decoration: none !important; border-bottom: 0; border-radius: 3px; background-color: #fff; cursor: pointer; white-space: nowrap; box-shadow: 0 1px 2px 1px rgba(0,0,0,.15),0 2px 5px -3px rgba(0,0,0,.15);"><img src="'.plugins_url( 'js/img/placeholder.svg' , __FILE__ ).'" alt="" style="width: 17px; height: 17px; margin: 0; display: block;" /></a></div>';
    337     }
    338     else {
    339         $authorlink="";
    340     }
    341     if ($atts["container"]=="") $yamap.='<div id="'.esc_attr($mapcontainter).'"  style="position: relative; height: '.esc_attr($atts["height"]).'; margin-bottom: 0 !important;"></div>'.$authorlink;
    342 
    343     if ($count_content>=1) $maps_count++;
    344     return $yamap;
    345 }
    346 
    347 add_shortcode( 'yaplacemark', 'yaplacemark_func' ); 
    348 add_shortcode( 'yamap', 'yamap_func' );
    349 add_shortcode( 'yacontrol', 'yacontrol_func' );
    350 
    351 //Функция подключения текстового домена для локализации
    352 function yamaps_plugin_load_plugin_textdomain() {
    353     load_plugin_textdomain( 'yamaps', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
    354 }
    355 add_action( 'plugins_loaded', 'yamaps_plugin_load_plugin_textdomain' );
    356 
    357 
    358 // Функция подключения скриптов и массив для локализации
    359 function yamap_plugin_scripts($plugin_array)
    360 {
    361    
    362     // Plugin localization
    363 
    364     wp_register_script('yamap_plugin', plugin_dir_url(__FILE__) . 'js/shortcode_parser.js?v=0.2');
    365     wp_enqueue_script('yamap_plugin');
    366    
    367     $lang_array  = array('YaMap' => __('Map', 'yamaps'),
    368                          'AddMap' => __('Add map', 'yamaps'),
    369                          'EditMap' => __('Edit map', 'yamaps'),
    370                          'PluginTitle' => __('YaMaps plugin: Yandex.Map', 'yamaps'),
    371                          'MarkerTab' => __('Placemark', 'yamaps'),
    372                          'MapTab' => __('Map', 'yamaps'),
    373                          'MarkerIcon' => __('Icon', 'yamaps'),
    374                          'BlueOnly' => __('Blue only', 'yamaps'),
    375                          'MarkerUrl' => __('Link', 'yamaps'),
    376                          'MarkerUrlTip' => __('Placemark hyperlink url or post ID', 'yamaps'),
    377                          'MapHeight' => __('Map height', 'yamaps'),
    378                          'MarkerName' => __('Placemark name', 'yamaps'),
    379                          'MarkerNameTip' => __('Text for hint or icon content', 'yamaps'),
    380                          'MapControlsTip' => __('Use the links below', 'yamaps'),       
    381                          'MarkerCoord' => __('Сoordinates', 'yamaps'),
    382                          'NoCoord' => __('Click on the map to choose or create the mark', 'yamaps'),
    383                          'MapControls' => __('Map controls', 'yamaps'),
    384                          'MarkerDelete' => __('Delete', 'yamaps'),
    385                          'type' => __('Map type', 'yamaps'),
    386                          'zoom' => __('Zoom', 'yamaps'),
    387                          'ScrollZoom' => __('Wheel zoom', 'yamaps'),
    388                          'MobileDrag' => __('Mobile drag', 'yamaps'),
    389                          'search' => __('Search', 'yamaps'),
    390                          'route' => __('Route', 'yamaps'),
    391                          'ruler' => __('Ruler', 'yamaps'),
    392                          'traffic' => __('Traffic', 'yamaps'),
    393                          'fullscreen' => __('Full screen', 'yamaps'),
    394                          'geolocation' => __('Geolocation', 'yamaps'),
    395                          'MarkerColor' => __('Marker color', 'yamaps'),
    396                          'MapContainerID' => __('Put in ID', 'yamaps'),
    397                          'MapContainerIDTip' => __('Do not create a block in the content. Use the existing block of the WP theme with the specified ID', 'yamaps'),
    398                          'Extra' => __('Extra', 'yamaps'),
    399                          'ExtraHTML' => __('<div style="position: relative; display: block; width: 100%; white-space: normal !important;"><h2 style="color: #444;font-size: 18px;font-weight: 600;line-height: 36px;">Want other icon types?</h2>Additional types of icons can be found by the link in the <a href="https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/option.presetStorage-docpage/ " style="white-space: normal">Yandex.Map documentation</a>.</div><div style="position: relative; display: block; width: 100%; white-space: normal !important;"><h2 style="color: #444;font-size: 18px;font-weight: 600;line-height: 36px;">Do you like YaMaps plugin?</h2>You can support its development by donate (<a href="https://yoomoney.ru/to/41001278340150" style="white-space: normal">Yoomoney</a>) or just leave a positive feedback in the <a href="https://wordpress.org/support/plugin/yamaps/reviews/" style="white-space: normal">plugin repository</a>. It\'s very motivating!</div><div style="position: relative; display: block; width: 100%; white-space: normal !important;"><h2 style="color: #444;font-size: 18px;font-weight: 600;line-height: 36px;">Any questions?</h2>Ask in the comments <a href="https://www.yhunter.ru/portfolio/dev/yamaps/" style="white-space: normal">on the plug-in\'s page</a>, <a href="https://wordpress.org/support/plugin/yamaps" style="white-space: normal">WP support forum</a> or <a href="https://github.com/yhunter-ru/yamaps/issues" style="white-space: normal">on GitHub</a>.</div>', 'yamaps'),
    400                             'DeveloperInfoTab' => __('Design & Development', 'yamaps'),
    401                             'DeveloperInfo' => __('<div style="position: relative; display: block; width: 100%; white-space: normal !important;"><h2 style="color: #444;font-size: 18px;font-weight: 600;line-height: 36px;">Want other plugin features?</h2>Do you like the plugin but lack features for your project? For commercial modifications of the plugin, please contact me.</div><div style="position: relative; display: block; width: 100%; white-space: normal !important;"><h2 style="color: #444;font-size: 18px;font-weight: 600;line-height: 36px;">WordPress website design and development</h2>My name is Yuri and I have been creating websites for over 15 years. I have been familiar with WordPress since 2008. I know and love this CMS for its user friendly interface. This is exactly how I tried to make the interface of my YaMaps plugin, which you are currently using. If you need to create a website, make an interface design or write a plugin for WordPress - I will be happy to help you!<p style="margin-top: .5rem; text-align: center;"><b>Contacts:</b>  <a href="mailto:[email protected]">[email protected]</a>, <b>telegram:</b> <a href="tg://resolve?domain=yhunter">@yhunter</a>, <b>tel:</b> <a href="tel:+79028358830">+7-902-83-588-30</a></p></div>', 'yamaps'),
    402 
    403                         );
    404 
    405 
    406 
    407    
    408     wp_localize_script('yamap_plugin', 'yamap_object', $lang_array);
    409 
    410     global $yamaps_defaults_front;
    411     wp_localize_script('yamap_plugin', 'yamap_defaults', $yamaps_defaults_front);
    412 
    413     //enqueue TinyMCE plugin script with its ID.
    414 
    415     $plugin_array["yamap_plugin"] =  plugin_dir_url(__FILE__) . "js/btn.js?v=0.34";
    416 
    417     return $plugin_array;
    418 
    419 }
    420 
    421 
    422 
    423 
    424 add_filter("mce_external_plugins", "yamap_plugin_scripts", 999 );
    425 
    426 //Функция регистрации кнопок в редакторе
    427 function register_buttons_editor($buttons)
    428 {
    429     //register buttons with their id.
    430     array_push($buttons, "yamap");
    431     return $buttons;
    432 }
    433 
    434 
    435 add_filter("mce_buttons", "register_buttons_editor", 999 );
    436 
    437 add_action('admin_head', 'yamaps_custom_fonts', 999 );
    438 
    439 //Исправляем проблему со съехавшим шрифтом в Stretchy метке на карте в редакторе
    440 function yamaps_custom_fonts() {           
    441       echo '<style>
    442         .mce-container ymaps {         
    443             font-family: "Source Sans Pro",HelveticaNeue-Light,"Helvetica Neue Light","Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif !important;
    444             font-size: 11px !important;
    445         }
    446       </style>';
    447 }
    448 
    449 
    450 //Подключаем шаблон шорткода
    451 function yamaps_shortcode_tmpl() {
    452     //Подключаем шаблон правки шорткода
    453     include_once dirname(__FILE__).'/templates/tmpl-editor-yamap.html';
    454 }
    455 
    456 add_action('admin_head', 'yamaps_shortcode_tmpl');
    457 
    458 //Подключаем внешние стили
    459 function yamap_mce_css( $mce_css ) {
    460   if ( !empty( $mce_css ) )
    461     $mce_css .= ',';
    462     $mce_css .= plugins_url( 'style.content.css', __FILE__ );
    463     return $mce_css;
    464   }
    465 add_filter( 'mce_css', 'yamap_mce_css' );
    466 
    467 //Подключаем стили для нового редактора Gutenberg
    468 function yamaps_gutenberg_styles() {
    469     // Load the theme styles within Gutenberg.
    470      wp_enqueue_style( 'yamaps-gutenberg', plugins_url( 'style.content.css', __FILE__ ));
    471 }
    472 add_action( 'enqueue_block_editor_assets', 'yamaps_gutenberg_styles' );
    473 
    474 
    475 if (($yamap_load_api)) { 
    476     add_action( 'wp_enqueue_scripts', 'YandexMapAPI_script', 5 );
    477 }
    478 
    479 include( plugin_dir_path( __FILE__ ) . 'options.php');
     32// Load options
     33require_once plugin_dir_path(__FILE__) . 'options.php';
Note: See TracChangeset for help on using the changeset viewer.