Plugin Directory

Changeset 2476886


Ignore:
Timestamp:
02/18/2021 09:20:18 AM (5 years ago)
Author:
bluisier
Message:

new novo-map version 1.1.0 with new Gutenberg block

Location:
novo-map
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • novo-map/tags/1.1.0/README.txt

    r2262554 r2476886  
    44Tags: google maps, maps, map, map markers, google map, google maps plugin, google map widget, google map shortcode, map with posts, post map, wp google maps, wp google map, map plugin, google map
    55Requires at least: 4.0
    6 Tested up to: 5.3.2
    7 Stable tag: 1.0.10
     6Tested up to: 5.6.1
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1616With Novo-Map you can :
    1717
    18 * Add an **unlimited number of google maps** anywhere on your site using **shortcodes** or **widgets**.
     18* Add an **unlimited number of google maps** anywhere on your site using **blocks**, **shortcodes** or **widgets**.
    1919* Easily geolocate your **posts or pages** and display them (and link to them) on the maps.
    2020* **Filter** the posts you want to display on a map with **categories or tags**.
     
    2525* And **all the above features are available for free** and always will be.
    2626
    27 If you want to see the plugin in action, you can see some examples on my **[travel blog](https://www.novo-monde.com)** or check **[the plugin demo page](https://www.novo-monde.com/novo-map-wordpress-plugin-demos/)**.
    28 If you want detailed informations about the plugin, have a look at the **[user guide](https://www.novo-monde.com/novo-map-user-guide/)**.
     27If you want to see the plugin in action, you can see some examples on my **[travel blog](https://www.novo-monde.com/en/)** or check **[the plugin demo page](https://www.novo-monde.com/en/novo-map-wordpress-plugin-demos/)**.
     28If you want detailed informations about the plugin, have a look at the **[user guide](https://www.novo-monde.com/en/novo-map-user-guide/)**.
    2929
    3030Pour les utilisateurs francophones, si vous voulez voir le plugin en action, passez jeter un oeil à mon **[blog de voyage](https://www.novo-monde.com)** ou à la **[page des exemples](https://www.novo-monde.com/novo-map-wordpress-plugin-examples/)** du plugin.
     
    53531. Just click on the map to add a latitude and a longitude to your post. Title, image and description should be prefilled with your post title, featured image and post excerpt if they exists. Then just click on the 'Add Marker' button
    54541. Go back on the main novo-map menu and chose the map you just created from the drop down menu. You should see the pin you just created in the preview.
    55 1. You can now either use the provided Shortcode or the novo-map widget from the widget menu to display this novo-map anywhere on your website.
     551. You can now either use the provided novo-map block, shortcode or the novo-map widget from the widget menu to display this novo-map anywhere on your website.
    5656
    5757If you need more detailed informations about the plugin, have a look at the **[user guide](https://www.novo-monde.com/novo-map-user-guide/)**.
     
    6161= Generate a Google Map API Key =
    6262
    63 Generate a google map API key can be frustrating but it is required by google and it is the same for every google map plugin. But don't worry it's really not that complicated. Just click on the 'Get API key' button on [This Page](https://developers.google.com/maps/documentation/javascript/get-api-key) and follows the few steps requiered. It really takes 1 minute! Then save the generated key in the novo-map menu.
     63Generate a google map API key can be frustrating but it is required by google and it is the same for every google map plugin. But don't worry it's really not that complicated. Just click on the 'Get API key' button on [This Page](https://developers.google.com/maps/documentation/javascript/get-api-key) and follows the few steps requiered (you will need to add your billing credentials but you will have [28'000 map downloads/months for free](https://cloud.google.com/maps-platform/pricing/sheet/)). It really takes 1 minute! Then save the generated key in the novo-map menu.
    6464
    6565= Display the same map with different parameters ? =
     
    102102
    103103== Changelog ==
     104
     105= 1.1.0 =
     106* upgrade to gmap api 3.43
     107* New Novo-map block to display map from the Gutenberg block editor (Finally!!!). Still need to update the post meta_box menu the Gutenberg way though...
     108* small bug fixes
    104109
    105110= 1.0.10 =
  • novo-map/tags/1.1.0/admin/class-novo-map-admin.php

    r2262554 r2476886  
    101101     */
    102102    public function enqueue_post_admin_script() {
    103         wp_enqueue_script( $this->plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.40&key=' . esc_attr(get_option($this->plugin_name.'_gmap_api_key')) . '', array(), null, false );
     103        wp_enqueue_script( $this->plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.43&key=' . esc_attr(get_option($this->plugin_name.'_gmap_api_key')) . '', array(), null, false );
    104104    }
    105105
     
    108108     */
    109109    public function enqueue_main_admin_script() {
    110         wp_enqueue_script( $this->plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.40&key=' . esc_attr(get_option($this->plugin_name.'_gmap_api_key')) . '', array(), null, false );
     110        wp_enqueue_script( $this->plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.43&key=' . esc_attr(get_option($this->plugin_name.'_gmap_api_key')) . '', array(), null, false );
    111111        wp_enqueue_script( $this->plugin_name.'-infobox', plugins_url( $this->plugin_name) .'/public/assets/js/infobox.js', array( $this->plugin_name.'-gmap-api' ) );
    112112        wp_enqueue_script( $this->plugin_name.'-markerclusterer', plugins_url( $this->plugin_name) .'/public/assets/js/markerclusterer.js', array( $this->plugin_name.'-gmap-api' ) );
     
    229229
    230230        //get the map to render in main menu
    231         add_action( 'admin_footer', array($gmap, 'generate_script_admin'), 15 );
     231        add_action( 'admin_footer', array($gmap, 'echo_script_css_admin'), 15 );
    232232
    233233        //get a default map to render a small map in the additional marker section
     
    237237        $gmap_small_map->set_name('gmapmainmenusmall');
    238238
    239         add_action( 'admin_footer', array($gmap_small_map, 'generate_script_admin'), 16 );
     239        add_action( 'admin_footer', array($gmap_small_map, 'echo_script_css_admin'), 16 );
    240240
    241241        //get clustered marker to generate image in the form and additional marker
     
    392392                __( 'Novo Map', $this->plugin_name ),
    393393                array($this, 'post_admin_menu_callback'),
    394                 $screen
     394                $screen,
     395                'normal'
    395396            );
    396397        }
     
    442443        $gmap = new Gmap($default_gmap);
    443444        $gmap->set_name('postmenumap');
    444         add_action( 'admin_footer', array($gmap, 'generate_script_admin'), 15 );
     445        add_action( 'admin_footer', array($gmap, 'echo_script_css_admin'), 15 );
    445446
    446447        //if there is no marker, get the default class value
  • novo-map/tags/1.1.0/includes/class-novo-map-gmap.php

    r2262554 r2476886  
    1212 * @subpackage Novo_Map/includes
    1313 */
    14 class Gmap {
     14class Gmap implements \JsonSerializable {
    1515
    1616    /**
     
    367367
    368368    /**
     369     * Allows to send private properties with json through the API
     370     *
     371     * @since 1.1.0
     372     * @return array|mixed
     373     */
     374    public function jsonSerialize(){
     375        $vars = get_object_vars($this);
     376        return $vars;
     377    }
     378
     379    /**
    369380     * All getters and setters for the Gmap class
    370381     *
     
    693704    public function enqueue_map($plugin_name) {
    694705        // enqueue necessary stuff
    695         wp_enqueue_script( $plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.40&key=' . esc_attr(get_option($plugin_name.'_gmap_api_key')) . '', array(), null, true );
     706        wp_enqueue_script( $plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.43&key=' . esc_attr(get_option($plugin_name.'_gmap_api_key')) . '', array(), null, true );
    696707        wp_enqueue_script( $plugin_name.'-infobox', plugins_url( $plugin_name) .'/public/assets/js/infobox.js', array( $plugin_name.'-gmap-api' ) );
    697708        if($this->pin_clustering()) {
     
    700711
    701712        // generate and enqueue map script
    702         add_action( 'wp_print_footer_scripts', array( $this, 'generate_script'), 15 );
    703     }
    704 
    705     /**
    706      * function that generate the gmap specific part of the script
    707      *
    708      * @since    1.0.0
    709      */
    710     public function generate_script() {
     713        add_action( 'wp_print_footer_scripts', array( $this, 'echo_script_css'), 15 );
     714    }
     715
     716    /**
     717     * echo map script and css for the front end
     718     *
     719     * @since    1.0.0
     720     */
     721    public function echo_script_css() {
    711722        //get the necessary classes
    712723        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker.php';
     
    764775        //add custom styles for necessary infoboxes
    765776        foreach ($infobox_style_list as $infobox_style) {
    766             $infobox_style->add_css($gmap_name);
     777            $infobox_style->echo_css($gmap_name);
    767778        }
    768779
     
    777788
    778789    /**
    779      * generate map script for the admin side (post menu and gmap menu)
    780      *
    781      * @since    1.0.0
    782      */
    783     public function generate_script_admin() {
     790     * echo map script and css for the admin side (post menu and gmap menu)
     791     *
     792     * @since    1.0.0
     793     */
     794    public function echo_script_css_admin() {
    784795        //get the necessary classes
    785796        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker.php';
     
    843854        //add custom styles for necessary infoboxes
    844855        foreach ($infobox_style_list as $infobox_style) {
    845             $infobox_style->add_css($gmap_name);
     856            $infobox_style->echo_css($gmap_name);
    846857        }
    847858
     
    854865        echo fn_minify_js($gmap_script);
    855866    }
     867
     868    /**
     869     * Generate and return the gmap script for use in the API for exemple
     870     *
     871     * @since    1.0.0
     872     */
     873    public function generate_script_css($container_id) {
     874        //get the necessary classes
     875        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker.php';
     876        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker-manager.php';
     877        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker-logo.php';
     878        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker-logo-manager.php';
     879        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-infobox-style.php';
     880        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-infobox-style-manager.php';
     881        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/helpers/php-html-css-js-minifier.php';
     882        global $wpdb;
     883        $marker_logo_manager = new Marker_Logo_Manager($wpdb);
     884        $marker_manager = new Marker_Manager($wpdb);
     885        $infobox_style_manager = new Infobox_Style_Manager($wpdb);
     886        $gmap_name = 'novomap'.$container_id;
     887        $script_css = array (
     888            'script' => '',
     889            'css' => []
     890        );
     891
     892        //get all markers to display
     893        $category = $this->category();
     894        $tag = $this->tag();
     895        if(empty($category) and empty($tag)) {
     896            $marker_list = $marker_manager->get_list();
     897        }
     898        elseif (! empty($category)) {
     899            $marker_list = $marker_manager->get_list_category($this->category());
     900        }
     901        elseif (! empty($tag)) {
     902            $marker_list = $marker_manager->get_list_tag($this->tag());
     903        }
     904
     905        //get additional marker if defined
     906        if($this->additional_marker()) {
     907            $additional_marker_array = array(
     908                'latitude' => $this->additional_marker_latitude(),
     909                'longitude' => $this->additional_marker_longitude(),
     910                'title' => $this->additional_marker_title(),
     911                'marker_logo_id' => $this->additional_marker_logo_id(),
     912                'infobox_style' => '',
     913            );
     914            $additional_marker = new Marker($additional_marker_array);
     915        }
     916
     917        //get only the necessary marker logo for this map
     918        $marker_logo_id_list = get_marker_logo_ids_from_map_marker($this, $marker_list);
     919        $marker_logo_list = $marker_logo_manager->get_list_from_ids_list($marker_logo_id_list);
     920
     921        //get the necessary infobox styles for this map
     922        if ($this->infobox_style()!=='no') {
     923            $infobox_style_list[$this->infobox_style()] = $infobox_style_manager->get($this->infobox_style());
     924        }
     925        else {
     926            $infobox_style_list = $infobox_style_manager->get_infobox_styles_from_marker($marker_list);
     927        }
     928
     929        //add custom styles for necessary infoboxes
     930        foreach ($infobox_style_list as $infobox_style) {
     931            array_push($script_css['css'], $infobox_style->add_css($gmap_name));
     932        }
     933
     934        //generate the script from template
     935        ob_start();
     936        include( plugin_dir_path(dirname( __FILE__ )) .'admin/partials/gmap-script-api.php' );
     937        $gmap_script = ob_get_contents();
     938        ob_end_clean();
     939        //echo a minified version of the js
     940        $script_css['script'] = fn_minify_js($gmap_script);
     941
     942        return $script_css;
     943    }
    856944}
  • novo-map/tags/1.1.0/includes/class-novo-map-infobox-style.php

    r1773144 r2476886  
    270270
    271271    /**
    272      * enqueue unique css for the infoboxes of a maè
     272     * enqueue unique css for the infoboxes of a map
    273273     *
    274274     * @param $gmap_name
    275275     * @since 1.0.0
     276     */
     277    public function echo_css($gmap_name) {
     278        //generate the css from template
     279        ob_start();
     280        include( plugin_dir_path(dirname( __FILE__ )) .'public/partials/infobox-styles/'.$this->css_template() );
     281        $infobox_css = ob_get_contents();
     282        ob_end_clean();
     283        echo fn_minify_css($infobox_css);
     284    }
     285
     286    /**
     287     * returns unique css for the infoboxes of a map
     288     *
     289     * @param $gmap_name
     290     * @since 1.1.0
    276291     */
    277292    public function add_css($gmap_name) {
     
    281296        $infobox_css = ob_get_contents();
    282297        ob_end_clean();
    283         echo fn_minify_css($infobox_css);
     298        return fn_minify_css($infobox_css);
    284299    }
    285300}
  • novo-map/tags/1.1.0/includes/class-novo-map-marker-logo.php

    r1949383 r2476886  
    129129                $parsed['scheme'] = 'http';
    130130            }
    131             return $parsed['scheme'].'://'.$parsed['host'].$parsed['path'];
     131            if(isset($parsed['port'])) {
     132                return $parsed['scheme'].'://'.$parsed['host'].':'.$parsed['port'].'/'.$parsed['path'];
     133            }
     134            else {
     135                return $parsed['scheme'].'://'.$parsed['host'].$parsed['path'];
     136            }
    132137        }
    133138        else{
  • novo-map/tags/1.1.0/includes/class-novo-map.php

    r1993784 r2476886  
    7979        $this->define_admin_hooks();
    8080        $this->define_public_hooks();
     81        $this->define_gutenberg_hooks();
    8182
    8283    }
     
    122123         */
    123124        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-novo-map-public.php';
     125
     126        /**
     127         * The class responsible for defining all actions that occur in the Gutenberg editor
     128         */
     129        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'gutenberg/class-novo-map-gutenberg.php';
     130
     131        /**
     132         * The class responsible for defining all api endpoints
     133         */
     134        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-api.php';
    124135
    125136        $this->loader = new Novo_Map_Loader();
     
    201212    }
    202213
     214    /**
     215     * Register all of the hooks related to Gutenberg
     216     *
     217     * @since 1.1.0
     218     * @access private
     219     */
     220    private function define_gutenberg_hooks() {
     221
     222        $plugin_gutenberg = new Novo_Map_Gutenberg( $this->get_plugin_name(), $this->get_version() );
     223        $api = new Novo_Map_Api( $this->get_plugin_name() );
     224
     225        $this->loader->add_action( 'init', $plugin_gutenberg, 'register_scripts' );
     226        $this->loader->add_action( 'init', $plugin_gutenberg, 'register_styles' );
     227        $this->loader->add_action( 'enqueue_block_editor_assets', $plugin_gutenberg, 'enqueue_block_editor_assets' );
     228
     229        $plugin_gutenberg->blocks_register_block_type('novo-map',
     230            array(
     231                'render_callback' => [ $plugin_gutenberg, 'render_block_novo_map' ],
     232            )
     233        );
     234
     235        $api->run();
     236
     237    }
     238
    203239    /**
    204240     * Run the loader to execute all of the hooks with WordPress.
  • novo-map/tags/1.1.0/novo-map.php

    r2262554 r2476886  
    99 * that starts the plugin.
    1010 *
    11  * @link              www.novo-media.ch
     11 * @link              https://novo-media.ch
    1212 * @since             1.0.0
    1313 * @package           Novo_Map
     
    1717 * Plugin URI:        https://wordpress.org/plugins/novo-map/
    1818 * Description:       Display all your posts and pages on custom google maps
    19  * Version:           1.0.10
     19 * Version:           1.1.0
    2020 * Author:            novo-media
    21  * Author URI:        www.novo-media.ch
     21 * Author URI:        https://novo-media.ch
    2222 * License:           GPL-2.0+
    2323 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
     
    3131}
    3232
    33 define( 'NOVO_MAP_VERSION', '1.0.10' );
     33define( 'NOVO_MAP_VERSION', '1.1.0' );
    3434
    3535/**
  • novo-map/trunk/README.txt

    r2262554 r2476886  
    44Tags: google maps, maps, map, map markers, google map, google maps plugin, google map widget, google map shortcode, map with posts, post map, wp google maps, wp google map, map plugin, google map
    55Requires at least: 4.0
    6 Tested up to: 5.3.2
    7 Stable tag: 1.0.10
     6Tested up to: 5.6.1
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1616With Novo-Map you can :
    1717
    18 * Add an **unlimited number of google maps** anywhere on your site using **shortcodes** or **widgets**.
     18* Add an **unlimited number of google maps** anywhere on your site using **blocks**, **shortcodes** or **widgets**.
    1919* Easily geolocate your **posts or pages** and display them (and link to them) on the maps.
    2020* **Filter** the posts you want to display on a map with **categories or tags**.
     
    2525* And **all the above features are available for free** and always will be.
    2626
    27 If you want to see the plugin in action, you can see some examples on my **[travel blog](https://www.novo-monde.com)** or check **[the plugin demo page](https://www.novo-monde.com/novo-map-wordpress-plugin-demos/)**.
    28 If you want detailed informations about the plugin, have a look at the **[user guide](https://www.novo-monde.com/novo-map-user-guide/)**.
     27If you want to see the plugin in action, you can see some examples on my **[travel blog](https://www.novo-monde.com/en/)** or check **[the plugin demo page](https://www.novo-monde.com/en/novo-map-wordpress-plugin-demos/)**.
     28If you want detailed informations about the plugin, have a look at the **[user guide](https://www.novo-monde.com/en/novo-map-user-guide/)**.
    2929
    3030Pour les utilisateurs francophones, si vous voulez voir le plugin en action, passez jeter un oeil à mon **[blog de voyage](https://www.novo-monde.com)** ou à la **[page des exemples](https://www.novo-monde.com/novo-map-wordpress-plugin-examples/)** du plugin.
     
    53531. Just click on the map to add a latitude and a longitude to your post. Title, image and description should be prefilled with your post title, featured image and post excerpt if they exists. Then just click on the 'Add Marker' button
    54541. Go back on the main novo-map menu and chose the map you just created from the drop down menu. You should see the pin you just created in the preview.
    55 1. You can now either use the provided Shortcode or the novo-map widget from the widget menu to display this novo-map anywhere on your website.
     551. You can now either use the provided novo-map block, shortcode or the novo-map widget from the widget menu to display this novo-map anywhere on your website.
    5656
    5757If you need more detailed informations about the plugin, have a look at the **[user guide](https://www.novo-monde.com/novo-map-user-guide/)**.
     
    6161= Generate a Google Map API Key =
    6262
    63 Generate a google map API key can be frustrating but it is required by google and it is the same for every google map plugin. But don't worry it's really not that complicated. Just click on the 'Get API key' button on [This Page](https://developers.google.com/maps/documentation/javascript/get-api-key) and follows the few steps requiered. It really takes 1 minute! Then save the generated key in the novo-map menu.
     63Generate a google map API key can be frustrating but it is required by google and it is the same for every google map plugin. But don't worry it's really not that complicated. Just click on the 'Get API key' button on [This Page](https://developers.google.com/maps/documentation/javascript/get-api-key) and follows the few steps requiered (you will need to add your billing credentials but you will have [28'000 map downloads/months for free](https://cloud.google.com/maps-platform/pricing/sheet/)). It really takes 1 minute! Then save the generated key in the novo-map menu.
    6464
    6565= Display the same map with different parameters ? =
     
    102102
    103103== Changelog ==
     104
     105= 1.1.0 =
     106* upgrade to gmap api 3.43
     107* New Novo-map block to display map from the Gutenberg block editor (Finally!!!). Still need to update the post meta_box menu the Gutenberg way though...
     108* small bug fixes
    104109
    105110= 1.0.10 =
  • novo-map/trunk/admin/class-novo-map-admin.php

    r2262554 r2476886  
    101101     */
    102102    public function enqueue_post_admin_script() {
    103         wp_enqueue_script( $this->plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.40&key=' . esc_attr(get_option($this->plugin_name.'_gmap_api_key')) . '', array(), null, false );
     103        wp_enqueue_script( $this->plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.43&key=' . esc_attr(get_option($this->plugin_name.'_gmap_api_key')) . '', array(), null, false );
    104104    }
    105105
     
    108108     */
    109109    public function enqueue_main_admin_script() {
    110         wp_enqueue_script( $this->plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.40&key=' . esc_attr(get_option($this->plugin_name.'_gmap_api_key')) . '', array(), null, false );
     110        wp_enqueue_script( $this->plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.43&key=' . esc_attr(get_option($this->plugin_name.'_gmap_api_key')) . '', array(), null, false );
    111111        wp_enqueue_script( $this->plugin_name.'-infobox', plugins_url( $this->plugin_name) .'/public/assets/js/infobox.js', array( $this->plugin_name.'-gmap-api' ) );
    112112        wp_enqueue_script( $this->plugin_name.'-markerclusterer', plugins_url( $this->plugin_name) .'/public/assets/js/markerclusterer.js', array( $this->plugin_name.'-gmap-api' ) );
     
    229229
    230230        //get the map to render in main menu
    231         add_action( 'admin_footer', array($gmap, 'generate_script_admin'), 15 );
     231        add_action( 'admin_footer', array($gmap, 'echo_script_css_admin'), 15 );
    232232
    233233        //get a default map to render a small map in the additional marker section
     
    237237        $gmap_small_map->set_name('gmapmainmenusmall');
    238238
    239         add_action( 'admin_footer', array($gmap_small_map, 'generate_script_admin'), 16 );
     239        add_action( 'admin_footer', array($gmap_small_map, 'echo_script_css_admin'), 16 );
    240240
    241241        //get clustered marker to generate image in the form and additional marker
     
    392392                __( 'Novo Map', $this->plugin_name ),
    393393                array($this, 'post_admin_menu_callback'),
    394                 $screen
     394                $screen,
     395                'normal'
    395396            );
    396397        }
     
    442443        $gmap = new Gmap($default_gmap);
    443444        $gmap->set_name('postmenumap');
    444         add_action( 'admin_footer', array($gmap, 'generate_script_admin'), 15 );
     445        add_action( 'admin_footer', array($gmap, 'echo_script_css_admin'), 15 );
    445446
    446447        //if there is no marker, get the default class value
  • novo-map/trunk/includes/class-novo-map-gmap.php

    r2262554 r2476886  
    1212 * @subpackage Novo_Map/includes
    1313 */
    14 class Gmap {
     14class Gmap implements \JsonSerializable {
    1515
    1616    /**
     
    367367
    368368    /**
     369     * Allows to send private properties with json through the API
     370     *
     371     * @since 1.1.0
     372     * @return array|mixed
     373     */
     374    public function jsonSerialize(){
     375        $vars = get_object_vars($this);
     376        return $vars;
     377    }
     378
     379    /**
    369380     * All getters and setters for the Gmap class
    370381     *
     
    693704    public function enqueue_map($plugin_name) {
    694705        // enqueue necessary stuff
    695         wp_enqueue_script( $plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.40&key=' . esc_attr(get_option($plugin_name.'_gmap_api_key')) . '', array(), null, true );
     706        wp_enqueue_script( $plugin_name.'-gmap-api', 'https://maps.googleapis.com/maps/api/js?v=3.43&key=' . esc_attr(get_option($plugin_name.'_gmap_api_key')) . '', array(), null, true );
    696707        wp_enqueue_script( $plugin_name.'-infobox', plugins_url( $plugin_name) .'/public/assets/js/infobox.js', array( $plugin_name.'-gmap-api' ) );
    697708        if($this->pin_clustering()) {
     
    700711
    701712        // generate and enqueue map script
    702         add_action( 'wp_print_footer_scripts', array( $this, 'generate_script'), 15 );
    703     }
    704 
    705     /**
    706      * function that generate the gmap specific part of the script
    707      *
    708      * @since    1.0.0
    709      */
    710     public function generate_script() {
     713        add_action( 'wp_print_footer_scripts', array( $this, 'echo_script_css'), 15 );
     714    }
     715
     716    /**
     717     * echo map script and css for the front end
     718     *
     719     * @since    1.0.0
     720     */
     721    public function echo_script_css() {
    711722        //get the necessary classes
    712723        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker.php';
     
    764775        //add custom styles for necessary infoboxes
    765776        foreach ($infobox_style_list as $infobox_style) {
    766             $infobox_style->add_css($gmap_name);
     777            $infobox_style->echo_css($gmap_name);
    767778        }
    768779
     
    777788
    778789    /**
    779      * generate map script for the admin side (post menu and gmap menu)
    780      *
    781      * @since    1.0.0
    782      */
    783     public function generate_script_admin() {
     790     * echo map script and css for the admin side (post menu and gmap menu)
     791     *
     792     * @since    1.0.0
     793     */
     794    public function echo_script_css_admin() {
    784795        //get the necessary classes
    785796        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker.php';
     
    843854        //add custom styles for necessary infoboxes
    844855        foreach ($infobox_style_list as $infobox_style) {
    845             $infobox_style->add_css($gmap_name);
     856            $infobox_style->echo_css($gmap_name);
    846857        }
    847858
     
    854865        echo fn_minify_js($gmap_script);
    855866    }
     867
     868    /**
     869     * Generate and return the gmap script for use in the API for exemple
     870     *
     871     * @since    1.0.0
     872     */
     873    public function generate_script_css($container_id) {
     874        //get the necessary classes
     875        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker.php';
     876        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker-manager.php';
     877        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker-logo.php';
     878        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-marker-logo-manager.php';
     879        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-infobox-style.php';
     880        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-infobox-style-manager.php';
     881        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/helpers/php-html-css-js-minifier.php';
     882        global $wpdb;
     883        $marker_logo_manager = new Marker_Logo_Manager($wpdb);
     884        $marker_manager = new Marker_Manager($wpdb);
     885        $infobox_style_manager = new Infobox_Style_Manager($wpdb);
     886        $gmap_name = 'novomap'.$container_id;
     887        $script_css = array (
     888            'script' => '',
     889            'css' => []
     890        );
     891
     892        //get all markers to display
     893        $category = $this->category();
     894        $tag = $this->tag();
     895        if(empty($category) and empty($tag)) {
     896            $marker_list = $marker_manager->get_list();
     897        }
     898        elseif (! empty($category)) {
     899            $marker_list = $marker_manager->get_list_category($this->category());
     900        }
     901        elseif (! empty($tag)) {
     902            $marker_list = $marker_manager->get_list_tag($this->tag());
     903        }
     904
     905        //get additional marker if defined
     906        if($this->additional_marker()) {
     907            $additional_marker_array = array(
     908                'latitude' => $this->additional_marker_latitude(),
     909                'longitude' => $this->additional_marker_longitude(),
     910                'title' => $this->additional_marker_title(),
     911                'marker_logo_id' => $this->additional_marker_logo_id(),
     912                'infobox_style' => '',
     913            );
     914            $additional_marker = new Marker($additional_marker_array);
     915        }
     916
     917        //get only the necessary marker logo for this map
     918        $marker_logo_id_list = get_marker_logo_ids_from_map_marker($this, $marker_list);
     919        $marker_logo_list = $marker_logo_manager->get_list_from_ids_list($marker_logo_id_list);
     920
     921        //get the necessary infobox styles for this map
     922        if ($this->infobox_style()!=='no') {
     923            $infobox_style_list[$this->infobox_style()] = $infobox_style_manager->get($this->infobox_style());
     924        }
     925        else {
     926            $infobox_style_list = $infobox_style_manager->get_infobox_styles_from_marker($marker_list);
     927        }
     928
     929        //add custom styles for necessary infoboxes
     930        foreach ($infobox_style_list as $infobox_style) {
     931            array_push($script_css['css'], $infobox_style->add_css($gmap_name));
     932        }
     933
     934        //generate the script from template
     935        ob_start();
     936        include( plugin_dir_path(dirname( __FILE__ )) .'admin/partials/gmap-script-api.php' );
     937        $gmap_script = ob_get_contents();
     938        ob_end_clean();
     939        //echo a minified version of the js
     940        $script_css['script'] = fn_minify_js($gmap_script);
     941
     942        return $script_css;
     943    }
    856944}
  • novo-map/trunk/includes/class-novo-map-infobox-style.php

    r1773144 r2476886  
    270270
    271271    /**
    272      * enqueue unique css for the infoboxes of a maè
     272     * enqueue unique css for the infoboxes of a map
    273273     *
    274274     * @param $gmap_name
    275275     * @since 1.0.0
     276     */
     277    public function echo_css($gmap_name) {
     278        //generate the css from template
     279        ob_start();
     280        include( plugin_dir_path(dirname( __FILE__ )) .'public/partials/infobox-styles/'.$this->css_template() );
     281        $infobox_css = ob_get_contents();
     282        ob_end_clean();
     283        echo fn_minify_css($infobox_css);
     284    }
     285
     286    /**
     287     * returns unique css for the infoboxes of a map
     288     *
     289     * @param $gmap_name
     290     * @since 1.1.0
    276291     */
    277292    public function add_css($gmap_name) {
     
    281296        $infobox_css = ob_get_contents();
    282297        ob_end_clean();
    283         echo fn_minify_css($infobox_css);
     298        return fn_minify_css($infobox_css);
    284299    }
    285300}
  • novo-map/trunk/includes/class-novo-map-marker-logo.php

    r1949383 r2476886  
    129129                $parsed['scheme'] = 'http';
    130130            }
    131             return $parsed['scheme'].'://'.$parsed['host'].$parsed['path'];
     131            if(isset($parsed['port'])) {
     132                return $parsed['scheme'].'://'.$parsed['host'].':'.$parsed['port'].'/'.$parsed['path'];
     133            }
     134            else {
     135                return $parsed['scheme'].'://'.$parsed['host'].$parsed['path'];
     136            }
    132137        }
    133138        else{
  • novo-map/trunk/includes/class-novo-map.php

    r1993784 r2476886  
    7979        $this->define_admin_hooks();
    8080        $this->define_public_hooks();
     81        $this->define_gutenberg_hooks();
    8182
    8283    }
     
    122123         */
    123124        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-novo-map-public.php';
     125
     126        /**
     127         * The class responsible for defining all actions that occur in the Gutenberg editor
     128         */
     129        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'gutenberg/class-novo-map-gutenberg.php';
     130
     131        /**
     132         * The class responsible for defining all api endpoints
     133         */
     134        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-novo-map-api.php';
    124135
    125136        $this->loader = new Novo_Map_Loader();
     
    201212    }
    202213
     214    /**
     215     * Register all of the hooks related to Gutenberg
     216     *
     217     * @since 1.1.0
     218     * @access private
     219     */
     220    private function define_gutenberg_hooks() {
     221
     222        $plugin_gutenberg = new Novo_Map_Gutenberg( $this->get_plugin_name(), $this->get_version() );
     223        $api = new Novo_Map_Api( $this->get_plugin_name() );
     224
     225        $this->loader->add_action( 'init', $plugin_gutenberg, 'register_scripts' );
     226        $this->loader->add_action( 'init', $plugin_gutenberg, 'register_styles' );
     227        $this->loader->add_action( 'enqueue_block_editor_assets', $plugin_gutenberg, 'enqueue_block_editor_assets' );
     228
     229        $plugin_gutenberg->blocks_register_block_type('novo-map',
     230            array(
     231                'render_callback' => [ $plugin_gutenberg, 'render_block_novo_map' ],
     232            )
     233        );
     234
     235        $api->run();
     236
     237    }
     238
    203239    /**
    204240     * Run the loader to execute all of the hooks with WordPress.
  • novo-map/trunk/novo-map.php

    r2262554 r2476886  
    99 * that starts the plugin.
    1010 *
    11  * @link              www.novo-media.ch
     11 * @link              https://novo-media.ch
    1212 * @since             1.0.0
    1313 * @package           Novo_Map
     
    1717 * Plugin URI:        https://wordpress.org/plugins/novo-map/
    1818 * Description:       Display all your posts and pages on custom google maps
    19  * Version:           1.0.10
     19 * Version:           1.1.0
    2020 * Author:            novo-media
    21  * Author URI:        www.novo-media.ch
     21 * Author URI:        https://novo-media.ch
    2222 * License:           GPL-2.0+
    2323 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
     
    3131}
    3232
    33 define( 'NOVO_MAP_VERSION', '1.0.10' );
     33define( 'NOVO_MAP_VERSION', '1.1.0' );
    3434
    3535/**
Note: See TracChangeset for help on using the changeset viewer.