Plugin Directory

Changeset 2380712


Ignore:
Timestamp:
09/14/2020 03:38:23 AM (6 years ago)
Author:
teplosup
Message:

Added option to save coordinates by default.

Location:
shmapper-by-teplitsa/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • shmapper-by-teplitsa/trunk/README.txt

    r2360842 r2380712  
    55Tags: map, OpenStreetMap, OSM, yandex.map, crowdsourcing, карта, Яндекс.карты, картирование, mapping, crowdsourced mapping, user mapping
    66Requires at least: 3.6.1
    7 Tested up to: 5.5
     7Tested up to: 5.5.1
    88Requires PHP: 5.6
    99Stable tag: trunk
  • shmapper-by-teplitsa/trunk/assets/js/ShMapper.admin.js

    r2202274 r2380712  
    171171
    172172    function shmMapProviderChangeHandler(mapProvider) {
    173         console.log(mapProvider);
    174173        if(mapProvider == 1) {
    175174            $yandexMapsAPIKeyControl.show();
  • shmapper-by-teplitsa/trunk/assets/js/ShMapper.js

    r2202274 r2380712  
    6767    {
    6868        $("#shm_vocabulary_cont").css("opacity", 0.7);
    69         shm_send(["shm_voc", $(evt.currentTarget).attr("name"), $(evt.currentTarget).val()]);   
    70     }});
     69        shm_send(["shm_voc", $(evt.currentTarget).attr("name"), $(evt.currentTarget).val()]);
     70    }});
     71    $("[name=shm_default_longitude]").on( 'change', function(evt) {
     72        setTimeout(function(){
     73            shm_send(["shm_default_longitude", $(evt.currentTarget).val() ]);
     74        },100);
     75        setTimeout(function(){
     76            shm_send(["shm_default_latitude", $('[name=shm_default_latitude]').val() ]);
     77        },500);
     78    });
     79    $("[name=shm_default_zoom]").on( 'change', function(evt) {
     80        setTimeout(function(){
     81            shm_send(["shm_default_zoom", $(evt.currentTarget).val() ]);
     82        },1000);
     83    });
    7184    $("[name='map_api']").live({click:function(evt)
    7285    {
     
    245258                document.getElementsByTagName('head')[0].appendChild(style);
    246259                var classes = 'dashicons dashicons-location shm-size-40 __class'+ elem.post_id;
    247                 var myIcon = L.divIcon({className: classes, iconSize:L.point(30, 40) });//
     260                var myIcon = L.divIcon({className: classes, iconSize:L.point(40, 40) });//
    248261                L.marker([ elem.latitude, elem.longitude ], {icon: myIcon})
    249262                    .addTo(shm_maps[elem.mapid])
  • shmapper-by-teplitsa/trunk/assets/js/ShMapper_osm.js

    r2150592 r2380712  
    328328                document.getElementsByTagName('head')[0].appendChild(style);
    329329                var classes = 'dashicons dashicons-location shm-size-40 __class'+ elem.post_id;
    330                 var myIcon = L.divIcon({className: classes, iconSize:L.point(30, 40) });//
     330                var myIcon = L.divIcon({className: classes, iconSize:L.point(40, 40) });//
    331331                marker = L.marker(
    332332                    [ elem.latitude, elem.longitude ],
  • shmapper-by-teplitsa/trunk/class/ShMapPointType.class.php

    r2126782 r2380712  
    344344        if( isset($params['default_none'])  )
    345345        {
     346            if ( ! isset( $class ) ) {
     347                $class = '';
     348            }
    346349            $html .= "
    347350            <div class='$col_width'>
  • shmapper-by-teplitsa/trunk/class/ShMapper.class.php

    r2360915 r2380712  
    409409    static function setting_pages()
    410410    {
    411         //var_dump(static::$options);
     411        $latitude  = 55.8;
     412        $longitude = 37.8;
     413        $zoom      = 4;
     414        if ( static::$options['shm_default_zoom'] ) {
     415            $zoom = static::$options['shm_default_zoom'];
     416        }
     417        if ( static::$options['shm_default_latitude'] ) {
     418            $latitude = static::$options['shm_default_latitude'];
     419        }
     420        if ( static::$options['shm_default_longitude'] ) {
     421            $longitude = static::$options['shm_default_longitude'];
     422        }
     423
     424        $mapType = ShmMap::get_map_types()[ ShMapper::$options['map_api'] ][0];
     425
    412426        echo "<div class='shm-container shm-padding-20'>
    413427            <div class='shm-row'>
     
    533547                           
    534548                        </div> 
    535                     </div>             
     549                    </div>
    536550                </li>   
    537551                <li>
     
    563577                    </div>             
    564578                </li>
     579
     580
     581                <li>
     582                    <div class='shm-row'>
     583                        <div class='shm-2 shm-color-grey sh-right sh-align-middle shm-title-3 '>".
     584                            __( "Coordinates", SHMAPPER ) .
     585                        "</div>
     586                        <div class='shm-9'>
     587                            <div id='map_default_coordinates' style='width:100%;height:300px;border:1px solid darkgrey;'>
     588           
     589                    </div>
     590                        <p>
     591                            <span class='shm-color-grey'><small>" . esc_html__( "Set default coordinates", SHMAPPER ) . "</small></span>
     592                        </p>
     593
     594                        <script>
     595                            jQuery(document).ready( function($)
     596                            {
     597                                var points      = [];
     598                                var mData = {
     599                                    mapType         : '$mapType',
     600                                    uniq            : 'map_default_coordinates',
     601                                    muniq           : 'map_default_coordinates',
     602                                    latitude        : '$latitude',
     603                                    longitude       : '$longitude',
     604                                    zoom            : '$zoom',
     605                                    map_id          : 'default_coordinates',
     606                                    isClausterer    : 0,
     607                                    isLayerSwitcher : 0,
     608                                    isFullscreen    : 1,
     609                                    isDesabled      : 0,
     610                                    isSearch        : 1,
     611                                    isZoomer        : 1,
     612                                    isAdmin         : 0,
     613                                    isMap           : true,
     614                                };
     615                               
     616                                if( map_type == 1 ) {
     617                                    ymaps.ready(() => init_map( mData, points ));
     618                                } else if (map_type == 2) {
     619                                    init_map( mData, points );
     620                               
     621                                    // On zoom map.
     622                                    myMap.on('zoom', function(e) {
     623                                        $('[name=shm_default_zoom]').val( myMap.getZoom() ).trigger('change');
     624                                    });
     625
     626                                    // On move map.
     627                                    myMap.on('move', function(e) {
     628                                        marker.setLatLng(myMap.getCenter());
     629                                    });
     630
     631                                    // On moveend map.
     632                                    myMap.on('moveend', function(e) {
     633                                        var shmCenter = myMap.getCenter();
     634                                        var shmLat = shmCenter.lat;
     635                                        var shmLng = shmCenter.lng;
     636                                        $('[name=shm_default_latitude]').val( shmLat ).trigger('change');
     637                                        $('[name=shm_default_longitude]').val( shmLng ).trigger('change');
     638                                        console.log($('[name=shm_default_longitude]').val());
     639                                        console.log($('[name=shm_default_latitude]').val());
     640                                    });
     641
     642                                    // Add Center Marker.
     643                                    var classes = 'dashicons dashicons-location shm-size-40 shm-color-danger';
     644                                    var myIcon = L.divIcon({className: classes, iconSize:L.point(40, 40) });
     645                                    marker = L.marker(
     646                                        [ '$latitude', '$longitude' ],
     647                                        {draggable: true, icon: myIcon}
     648                                    )
     649                                    .addTo(myMap);
     650                                }
     651
     652                            });
     653                        </script>
     654
     655                            <input class='sh-form' name='shm_default_latitude' value='" . esc_attr( $latitude ) . "' readonly disabled>
     656                            <input class='sh-form' name='shm_default_longitude' value='" . esc_attr( $longitude ) . "' readonly disabled>
     657                            <input class='sh-form' name='shm_default_zoom' value='" . esc_attr( $zoom ) . "' readonly disabled>
     658
     659                        </div>
     660                        <div class='shm-1'></div>
     661                    </div>
     662                </li>
    565663                <li>
    566664                    <div class='shm-row' id='shm_vocabulary_cont'>
     
    570668                        <div class='shm-9' id='shm_voc'>
    571669                            <div class='button' id='shm_settings_wizzard' >" . __("Restart wizzard", SHMAPPER) . "</div>
    572                         </div> 
    573                         <div class='shm-1'>
    574                            
    575                         </div> 
    576                     </div>             
    577                 </li>   
     670                        </div>
     671                        <div class='shm-1'></div>
     672                    </div
     673                </li>
    578674            </ul>
    579675        </div>";
  • shmapper-by-teplitsa/trunk/class/ShMapper_ajax.class.php

    r2202274 r2380712  
    419419                );
    420420                break;
     421            case "shm_default_longitude":
     422                ShMapper::$options['shm_default_longitude'] = sanitize_text_field($params[1]);
     423                ShMapper::update_options();
     424                $d = array(
     425                    $action,
     426                    array(
     427                        "msg" => __( "New coordinates saved" , SHMAPPER ),
     428                    ),
     429                );
     430                break;
     431            case "shm_default_latitude":
     432                ShMapper::$options['shm_default_latitude'] = sanitize_text_field($params[1]);
     433                ShMapper::update_options();
     434                $d = array(
     435                    $action,
     436                    array(
     437                        //"msg" => __( "New coordinates saved" , SHMAPPER ),
     438                    ),
     439                );
     440                break;
     441            case "shm_default_zoom":
     442                ShMapper::$options['shm_default_zoom'] = sanitize_text_field($params[1]);
     443                ShMapper::update_options();
     444                $d = array(
     445                    $action,
     446                    array(
     447                        //"msg" => __( "New coordinates saved" , SHMAPPER ),
     448                    ),
     449                );
     450                break;
    421451            case "shm_map_is_crowdsourced":
    422452                ShMapper::$options['shm_map_is_crowdsourced'] = sanitize_text_field($params[1]);
  • shmapper-by-teplitsa/trunk/class/ShmPoint.class.php

    r2154674 r2380712  
    11<?php
     2/**
     3 * ShMapper
     4 *
     5 * @package Teplitsa
     6 */
     7
    28class ShmPoint extends SMC_Post
    39{
     
    5662        $bb                 = $SMC_Object_type->object [static::get_type()];
    5763        $html = "";
     64
     65        $default_latitude  = 55.8;
     66        $default_longitude = 37.8;
     67        $default_zoom      = 4;
     68        if ( isset( ShMapper::$options['shm_default_latitude'] ) ) {
     69            $default_latitude = ShMapper::$options['shm_default_latitude'];
     70        }
     71        if ( isset( ShMapper::$options['shm_default_longitude'] ) ) {
     72            $default_longitude = ShMapper::$options['shm_default_longitude'];
     73        }
     74        if ( isset( ShMapper::$options['shm_default_zoom'] ) ) {
     75            $default_zoom = ShMapper::$options['shm_default_zoom'];
     76        }
    5877        foreach($bb as $key=>$value)
    5978        {
     
    6382            {
    6483                case "latitude":
    65                     $meta       = $meta ? $meta : 55.8;
     84                    $meta       = $meta ? $meta : $default_latitude;
    6685                    $opacity    = " style='display:none;' " ;
    6786                    break;
    6887                case "longitude":
    69                     $meta       = $meta ? $meta : 37.8;
     88                    $meta       = $meta ? $meta : $default_longitude;
    7089                    $opacity    = " style='display:none;' " ;
    7190                    break;
    7291                case "zoom":
    73                     $meta       = $meta ? $meta : 4;
     92                    $meta       = $meta ? $meta : $default_zoom;
    7493                    $opacity    = " style='display:none;' " ;
    7594                    break;
     
    313332                <input class='shm-form shm-title-4' name='shm-new-point-location' onclick='this.classList.remove(\"shm-alert\");' value='".$data[3]."'/>
    314333            </div>
    315         <div>
     334        </div>
    316335        ";
    317336       
     
    371390        return $before . implode($separator, $d) . $after;
    372391    }
    373     function draw()
    374     {
     392    function draw() {
     393
     394        $default_latitude  = 55.8;
     395        $default_longitude = 37.8;
     396        $default_zoom      = 4;
     397        if ( isset( ShMapper::$options['shm_default_latitude'] ) ) {
     398            $default_latitude = ShMapper::$options['shm_default_latitude'];
     399        }
     400        if ( isset( ShMapper::$options['shm_default_longitude'] ) ) {
     401            $default_longitude = ShMapper::$options['shm_default_longitude'];
     402        }
     403        if ( isset( ShMapper::$options['shm_default_zoom'] ) ) {
     404            $default_zoom = ShMapper::$options['shm_default_zoom'];
     405        }
     406
    375407        $mapType    = ShmMap::get_map_types()[ ShMapper::$options['map_api'] ][0];
    376408        $types      = wp_get_object_terms($this->id, SHM_POINT_TYPE);
     
    381413        $location   = $this->get_meta("location");
    382414        $latitude   = $this->get_meta("latitude");
    383         $latitude   = $latitude ? $latitude : 55.8;
     415        $latitude   = $latitude ? $latitude : $default_latitude;
    384416        $longitude  = $this->get_meta("longitude");
    385         $longitude  = $longitude ? $longitude : 37.8;
     417        $longitude  = $longitude ? $longitude : $default_longitude;
    386418
    387419        $zoom       = $this->get_meta("zoom");
    388         $zoom       = $zoom ? $zoom : 4;
     420        $zoom       = $zoom ? $zoom : $default_zoom;
    389421       
    390422        $html = "
     
    397429                    <div class='spacer-10'></div>
    398430                </div> 
    399             </div>  "; 
     431            </div>  ";
    400432        $point = $this->body;
    401433           
    402         $html   .= "</div>         
    403         <section>
     434        $html   .= "
    404435        <script type='text/javascript'>
    405436            jQuery(document).ready( function($)
     
    407438                var points      = [],
    408439                p = {};
    409                 p.post_id   = '" . $point->ID . "';
    410                 p.post_title    = '" . $post_title . "';
    411                 p.post_content  = '" . html_entity_decode( esc_js($post_content) )." <a href=\"" .get_permalink($point->ID) . "\" class=\"shm-no-uline\"> <span class=\"dashicons dashicons-location\"></span></a><div class=\"shm_ya_footer\">" . esc_js($location) . "</div>';
    412                 p.latitude      = '" . $latitude . "';
    413                 p.longitude     = '" . $longitude . "';
    414                 p.location      = '" . esc_js($location) . "';
    415                 p.draggable     = ".(is_admin() ? 1 : 0).";
    416                 p.type          = '" . $term_id . "';
    417                 p.height        = '" . get_term_meta($term_id, "height", true) . "';
    418                 p.width         = '" . get_term_meta($term_id, "width", true) . "';
    419                 p.term_id       = '" . $term_id . "';
    420                 p.icon          = '" . (ShMapPointType::get_icon_src( $term_id )[0]) . "';
    421                 p.color         = '" . get_term_meta($term_id, 'color', true) . "';
    422 
    423                 points.push(p);
    424                 /*console.log( p );*/
     440                p.post_id   = '" . $point->ID . "';
     441                p.post_title    = '" . $post_title . "';
     442                p.post_content  = '" . html_entity_decode( esc_js($post_content) )." <a href=\"" .get_permalink($point->ID) . "\" class=\"shm-no-uline\"> <span class=\"dashicons dashicons-location\"></span></a><div class=\"shm_ya_footer\">" . esc_js($location) . "</div>';
     443                p.latitude      = '" . $latitude . "';
     444                p.longitude     = '" . $longitude . "';
     445                p.location      = '" . esc_js($location) . "';
     446                p.draggable     = ".(is_admin() ? 1 : 0).";
     447                p.type          = '" . $term_id . "';
     448                p.height        = '" . get_term_meta($term_id, "height", true) . "';
     449                p.width         = '" . get_term_meta($term_id, "width", true) . "';
     450                p.term_id       = '" . $term_id . "';
     451                p.icon          = '" . (ShMapPointType::get_icon_src( $term_id )[0]) . "';
     452                p.color         = '" . get_term_meta($term_id, 'color', true) . "';
     453
     454                points.push(p);
     455
    425456                var mData = {
    426457                    mapType         : '$mapType',
     
    435466                    isFullscreen    : 1,
    436467                    isDesabled      : 0,
    437                     isSearch        : 0,
     468                    isSearch        : 1,
    438469                    isZoomer        : 1,
    439470                    isAdmin         : 1,
     
    445476                else if (map_type == 2)
    446477                    init_map( mData, points );
     478
     479                // Disable submit post form on this page.
     480                $('form#post').on('keyup keypress', function(e) {
     481                    var keyCode = e.keyCode || e.which;
     482                    if (keyCode === 13) {
     483                    e.preventDefault();
     484                        return false;
     485                    }
     486                });
    447487            });
    448          
    449488        </script>";
    450489        return $html;
  • shmapper-by-teplitsa/trunk/shmapper.php

    r2360804 r2380712  
    44 * Plugin URI: http://genagl.ru/?p=652
    55 * Description: Location and logistics services for NKO
    6  * Version: 1.3.6
     6 * Version: 1.3.7
    77 * Author: Teplitsa. Technologies for Social Good
    88 * Author URI:  https://te-st.ru
     
    1212 * Contributors:
    1313    Genagl (genag1@list.ru)
    14     Lev "ahaenor" Zvyagintsev (ahaenor@gmail.com)
     14    Lev "ahaenor" Zvyagintsev (ahaenor@gmail.com)
    1515    Denis Cherniatev (denis.cherniatev@gmail.com)
    16     Teplitsa Support Team (suptestru@gmail.com)
     16    Teplitsa Support Team (suptestru@gmail.com)
    1717
    1818 * License: GPLv2 or later
     
    3434    along with this program; if not, write to the Free Software
    3535    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    36 */
     36 */
    3737
    38 // load textdomain
    39 function init_textdomain_shmapper()
    40 {
    41     if (function_exists('load_textdomain')) {
    42         load_textdomain("shmapper-by-teplitsa", WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) .'/languages/shmapper-by-teplitsa-'.get_locale().'.mo');
     38/** Load textdomain */
     39function init_textdomain_shmapper() {
     40    if ( function_exists('load_textdomain') ) {
     41        load_textdomain( 'shmapper-by-teplitsa', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) . '/languages/shmapper-by-teplitsa-' . get_locale() . '.mo' );
    4342    }
    44  
    45     if (function_exists('load_plugin_textdomain')) {
    46         load_plugin_textdomain("shmapper-by-teplitsa", false , dirname( plugin_basename( __FILE__ ) ) .'/languages/');
    47     } 
     43
     44    if ( function_exists( 'load_plugin_textdomain' ) ) {
     45        load_plugin_textdomain( 'shmapper-by-teplitsa', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
     46    }
    4847}
    4948add_action('plugins_loaded', 'init_textdomain_shmapper');
    5049
    51 //Paths
    52 define('SHM_URLPATH', WP_PLUGIN_URL.'/' . plugin_basename(dirname(__FILE__)) . '/');
    53 define('SHM_REAL_PATH', WP_PLUGIN_DIR.'/'.plugin_basename(dirname(__FILE__)).'/');
    54 define('SHMAPPER', 'shmapper-by-teplitsa');
    55 define('SHM_MAP', 'shm_map');
    56 define('SHM_POINT', 'shm_point');
    57 define('SHM_POINT_TYPE', 'shm_point_type');
    58 define('SHM_REQUEST', 'shm_request');
    59 define('SHMAPPER_PLAIN_TEXT_TYPE_ID', 1);
    60 define('SHMAPPER_NAME_TYPE_ID', 2);
    61 define('SHMAPPER_PLAIN_NUMBER_TYPE_ID', 3);
    62 define('SHMAPPER_EMAIL_TYPE_ID', 4);
    63 define('SHMAPPER_PHONE_TYPE_ID', 5);
    64 define('SHMAPPER_TEXTAREA_TYPE_ID', 6);
    65 define('SHMAPPER_IMAGE_TYPE_ID', 7);
    66 define('SHMAPPER_MARK_TYPE_ID', 8);
    67 define('SHMAPPER_TITLE_TYPE_ID', 9);
    68 define('SHM_CSV_STROKE_SEPARATOR', ';');
    69 define('SHM_CSV_ROW_SEPARATOR', '
     50// Paths.
     51define( 'SHM_URLPATH', WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/' );
     52define( 'SHM_REAL_PATH', WP_PLUGIN_DIR . '/' . plugin_basename(dirname(__FILE__) ) . '/' );
     53define( 'SHMAPPER', 'shmapper-by-teplitsa' );
     54define( 'SHM_MAP', 'shm_map' );
     55define( 'SHM_POINT', 'shm_point' );
     56define( 'SHM_POINT_TYPE', 'shm_point_type' );
     57define( 'SHM_REQUEST', 'shm_request' );
     58define( 'SHMAPPER_PLAIN_TEXT_TYPE_ID', 1 );
     59define( 'SHMAPPER_NAME_TYPE_ID', 2 );
     60define( 'SHMAPPER_PLAIN_NUMBER_TYPE_ID', 3 );
     61define( 'SHMAPPER_EMAIL_TYPE_ID', 4 );
     62define( 'SHMAPPER_PHONE_TYPE_ID', 5 );
     63define( 'SHMAPPER_TEXTAREA_TYPE_ID', 6 );
     64define( 'SHMAPPER_IMAGE_TYPE_ID', 7 );
     65define( 'SHMAPPER_MARK_TYPE_ID', 8 );
     66define( 'SHMAPPER_TITLE_TYPE_ID', 9 );
     67define( 'SHM_CSV_STROKE_SEPARATOR', ';' );
     68define( 'SHM_CSV_ROW_SEPARATOR', '
    7069');
    71 define('SHMAPPER_VERSION', '1.3.3');
     70define('SHMAPPER_VERSION', '1.3.3' );
    7271
    73 require_once(SHM_REAL_PATH.'class/ShMapper.class.php');
    74 require_once(SHM_REAL_PATH.'class/ShMapper_ajax.class.php');
    75 if(!class_exists("SMC_Post"))
    76     require_once(SHM_REAL_PATH.'class/SMC_Post.php');
    77 if(!class_exists("SMC_Object_type"))
    78     require_once(SHM_REAL_PATH.'class/SMC_Object_type.php');
    79 require_once(SHM_REAL_PATH.'class/ShmMap.class.php');
    80 require_once(SHM_REAL_PATH.'class/ShMapPointType.class.php');
    81 require_once(SHM_REAL_PATH.'class/ShmPoint.class.php');
    82 require_once(SHM_REAL_PATH.'class/ShMapperRequest.class.php');
    83 require_once(SHM_REAL_PATH.'class/ShmForm.class.php');
    84 require_once(SHM_REAL_PATH.'class/ShMapper_Assistants.class.php');
    85 require_once(SHM_REAL_PATH.'class/ShmAdminPage.class.php');
    86 require_once(SHM_REAL_PATH.'shortcode/shm_shortcodes.php');
    87 require_once(SHM_REAL_PATH.'widget/ShMap.widget.php');
     72require_once SHM_REAL_PATH . 'class/ShMapper.class.php';
     73require_once SHM_REAL_PATH . 'class/ShMapper_ajax.class.php';
     74if ( ! class_exists( 'SMC_Post' ) ) {
     75    require_once SHM_REAL_PATH . 'class/SMC_Post.php';
     76}
     77if ( ! class_exists( 'SMC_Object_type' ) ) {
     78    require_once SHM_REAL_PATH . 'class/SMC_Object_type.php';
     79}
     80require_once SHM_REAL_PATH . 'class/ShmMap.class.php';
     81require_once SHM_REAL_PATH . 'class/ShMapPointType.class.php';
     82require_once SHM_REAL_PATH . 'class/ShmPoint.class.php';
     83require_once SHM_REAL_PATH . 'class/ShMapperRequest.class.php';
     84require_once SHM_REAL_PATH . 'class/ShmForm.class.php';
     85require_once SHM_REAL_PATH . 'class/ShMapper_Assistants.class.php';
     86require_once SHM_REAL_PATH . 'class/ShmAdminPage.class.php';
     87require_once SHM_REAL_PATH . 'shortcode/shm_shortcodes.php';
     88require_once SHM_REAL_PATH . 'widget/ShMap.widget.php';
    8889
    8990register_activation_hook( __FILE__, array( 'ShMapper', 'activate' ) );
    90 if (function_exists('register_deactivation_hook'))
    91 {
    92     register_deactivation_hook(__FILE__, array('ShMapper', 'deactivate'));
     91
     92if ( function_exists( 'register_deactivation_hook' ) ) {
     93    register_deactivation_hook(__FILE__, array( 'ShMapper', 'deactivate' ) );
    9394}
    94 add_action("init", "init_shmapper", 1);
    95 function init_shmapper()
    96 {
     95
     96/** Shamapper init */
     97function init_shmapper() {
    9798    ShMapper::get_instance();
    9899    ShMapper_Assistants::get_instance();
     
    104105    ShmForm::init();
    105106}
    106 function shm_is_session()
    107 {
    108     require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    109     return is_plugin_active( 'wp-session-manager/wp-session-manager.php' ) ;       
     107add_action( 'init', 'init_shmapper', 1 );
     108
     109/** Is session */
     110function shm_is_session() {
     111    require_once ABSPATH . 'wp-admin/includes/plugin.php';
     112    return is_plugin_active( 'wp-session-manager/wp-session-manager.php' );
    110113}
    111114
    112 function shmapper_prefix_disable_gutenberg($current_status, $post_type) {
    113     if(in_array($post_type, array(SHM_POINT))) {
    114         return false;
    115     }
    116     return $current_status;
     115/**
     116 * Disable Gugenberg
     117 * @param bool   $current_status Current gutenberg status. Default true.
     118 * @param string $post_type      The post type being checked.
     119 */
     120function shmapper_disable_gutenberg( $current_status, $post_type ) {
     121    if ( in_array( $post_type, array( SHM_POINT ), true ) ) {
     122        return false;
     123    }
     124    return $current_status;
    117125}
    118 add_filter('use_block_editor_for_post_type', 'shmapper_prefix_disable_gutenberg', 10, 2);
     126add_filter( 'use_block_editor_for_post_type', 'shmapper_disable_gutenberg', 10, 2);
Note: See TracChangeset for help on using the changeset viewer.