Plugin Directory

Changeset 1759726


Ignore:
Timestamp:
11/06/2017 10:26:15 PM (8 years ago)
Author:
mediarecode
Message:

Updated to include an option for setting radius around each marker or all markers as well as added an 'uncategorized' section for all markers that don't have an assigned category when using category filtering.

Location:
media-recode-custom-modules/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • media-recode-custom-modules/trunk/mr-builder-modules.php

    r1739184 r1759726  
    44 * Plugin URI: https//www.mediarecode.com
    55 * Description: Custom Beaver Builder modules developed by Media Recode.
    6  * Version: 1.1
     6 * Version: 1.7
    77 * Author: Matt Ryan
    88 * Author URI: https://www.mediarecode.com
     
    1616    if ( class_exists( 'FLBuilder' ) ) {
    1717        require_once 'mr-multipoint-map/mr-multipoint-map.php';
     18        require_once 'mr-breaking-news/mr-breaking-news.php';
     19        require_once 'enhancements/membership-requirement/membership-requirement-row.php';
    1820    }
    1921}
  • media-recode-custom-modules/trunk/mr-multipoint-map/includes/frontend.php

    r1739187 r1759726  
    11<?php
    2 
     2   
     3    $settings->posts_per_page = -1;
    34    $query = FLBuilderLoop::query( $settings );
    45
     
    2425            }
    2526
    26             $location = get_post_meta(get_the_ID(), $settings->location_field_name)[0];
     27            $location = get_post_meta(get_the_ID(), $settings->location_field_name, single);
     28
     29            if (!is_array($location)) {
     30                $geolocation = explode(",", $location);
     31
     32                $location = ['lat' => $geolocation[0], 'lng' => $geolocation[1]];
     33            }
     34
    2735            $category = get_the_terms(get_the_ID(), $settings->post_taxonomy)[0];
     36
     37            $icon_id = get_term_meta($category->term_id)[$settings->icon_field_name][0];
     38            $category_image = wp_get_attachment_image_url($icon_id, 'full');
     39
    2840            $permalink = get_permalink();
     41
    2942
    3043            $location_info[$counter]['lat'] = $location['lat'];
     
    3245            $location_info[$counter]['name'] = $name;
    3346            $location_info[$counter]['description'] = "<h4><a href='" . $permalink . "'>" . $name . "</a></h4><br />" . $description;
    34             $location_info[$counter]['category'] = $category;
    35             $location_info[$counter]['category image'] = get_field($settings->icon_field_name,
    36                                                             $location_info[$counter]['category']->taxonomy . '_' .
    37                                                             $location_info[$counter]['category']->term_id);
     47
     48            if($settings->use_category_filter == 'yes') {
     49                if (!is_null($category)) {
     50                    $location_info[$counter]['category'] = $category;
     51                } else {
     52                    // ['category']['name'] because in the above if $category is an array that has the category name as a name
     53                    // field. That's why I use the ['category']['name'] down below.
     54                    $location_info[$counter]['category']['name'] = 'Uncategorized';
     55                }
     56            }
     57
     58            if($settings->use_custom_icon == 'yes' && $location_info[$counter]['category'] != 'Uncategorized') {
     59                $location_info[$counter]['category image'] = $category_image;
     60            }
     61
     62            if($settings->show_marker_radius === 'yes') {
     63
     64                if (!empty($settings->radius_field)) {
     65                    $radius_size = get_post_meta(get_the_ID(), $settings->radius_field, single);
     66
     67                    if (empty($radius_size) && !empty($settings->radius_size)) {
     68                        $radius_size =  $settings->radius_size;
     69                    }
     70                }
     71                else {
     72                    $radius_size = '20';
     73                }
     74
     75                $location_info[$counter]['radius size'] = $radius_size;
     76                $location_info[$counter]['fill color'] = '#' . $settings->fill_color;
     77                $location_info[$counter]['stroke color'] = '#' . $settings->stroke_color;
     78                $location_info[$counter]['stroke weight'] = $settings->stroke_weight;
     79            }
    3880
    3981            $counter++;
     
    5193    var settings = new Array();
    5294    settings = <?php echo json_encode($settings); ?>;
     95
     96    mapMarkers = new Array ();
     97    alreadyAddedCategories = new Array ();
     98
     99    function initMap() {
     100        var map_center = {lat: parseFloat(settings['center_lat']), lng: parseFloat(settings['center_lng'])};
     101
     102        if (settings['zoom_level']) {
     103            var zoom_level = parseInt(settings['zoom_level'])
     104        } else {
     105            var zoom_level = 10
     106        }
     107        var map = new google.maps.Map(document.getElementById('mr-multi-map'), {
     108                zoom: zoom_level,
     109                center: map_center
     110        });
     111
     112        var infowindow = new google.maps.InfoWindow();
     113
     114        var use_category_filter = settings['use_category_filter']
     115        var use_custom_icon = settings['use_custom_icon']
     116
     117        markers.forEach(function(location) {
     118
     119            var latlng = new google.maps.LatLng(location['lat'], location['lng']);
     120
     121            marker = new google.maps.Marker({
     122                position: latlng,
     123                map: map,
     124                title: location['name'],
     125                <?php if($settings->use_category_filter == 'yes') { echo "category: location['category']['name'],"; } ?>
     126                <?php if($settings->use_custom_icon == 'yes') { echo "icon: location['category image']"; } ?>
     127            });
     128
     129            <?php if ($settings->show_marker_radius) {
     130                    echo 'var circle = new google.maps.Circle({';
     131                    echo 'map: map,';
     132                    echo "radius: parseInt(location['radius size'])*1609,";
     133                    echo "fillColor: location['fill color'],";
     134                    echo "strokeColor: location['stroke color'],";
     135                    echo "strokeWeight: parseInt(location['stroke weight']),";
     136                    echo "center: latlng";
     137                    echo '})';
     138            } ?>
     139
     140            marker.addListener('click', function() {
     141                infowindow.setContent(location['description']);
     142                infowindow.open(map, this);
     143            });
     144
     145            mapMarkers.push(marker);
     146
     147            if (use_category_filter == 'yes' && !alreadyAddedCategories.includes(location['category']['name'])  ) {
     148                    document.getElementById("mr-multi-map-filters")
     149                    .innerHTML += "<div id='filter-buttons' onclick='filterMarkers(\"" + location['category']['name'] + "\")'><input type='checkbox' name='filter' id='" + location['category']['name'] + "' class='mr-chk-btn'><label for='" + location['category']['name'] + "'><a><img src='" + location['category image'] + "'>" + location['category']['name'] + "</a></label></div>"
     150
     151                    alreadyAddedCategories.push(location['category']['name'])
     152            }
     153
     154        });
     155
     156    }
     157
     158    filterMarkers = function (category) {
     159        for (i = 0; i < mapMarkers.length; i++) {
     160            if(mapMarkers[i]['category'] === category || category.length === 0){
     161                mapMarkers[i].setVisible(true);
     162            }
     163            else {
     164                mapMarkers[i].setVisible(false);
     165            }
     166        }
     167    }
     168
    53169</script>
    54170
     
    61177        echo '</div>';
    62178    }
    63 
    64179?>
    65180
  • media-recode-custom-modules/trunk/mr-multipoint-map/js/mr-map-script.js

    r1739187 r1759726  
    1     console.log(settings);
    2 
    3     mapMarkers = new Array ()
     1    /*mapMarkers = new Array ()
    42
    53    function initMap() {
     
    5856            }
    5957        }
    60     }
     58    }*/
  • media-recode-custom-modules/trunk/mr-multipoint-map/mr-multipoint-map.php

    r1748178 r1759726  
    3636                        'type'          => 'text',
    3737                        'label'         => __( 'Location Name', 'fl-builder' ),
     38                        'placeholder'   => 'Defaults to standard WP title.',
     39                        'help'          => __('The field name of your post that will be used for the title in the info box when a location is clicked on.')
    3840                    ),
    3941                    'location_field_name'     => array(
    4042                        'type'          => 'text',
    4143                        'label'         => __( 'Location Field Name', 'fl-builder' ),
     44                        'placeholder'   => 'The field name that has the latitude and longitude.'
    4245                    ),
    4346                    'description_field_name'     => array(
    4447                        'type'          => 'text',
    4548                        'label'         => __( 'Description Field Name', 'fl-builder' ),
    46                         'placeholder'   => 'Field name that has the description. Defaults to the_content()',
     49                        'placeholder'   => 'Defaults to the standard WordPress content area.',
     50                        'help'          => 'The field name of your post that contains what you would like to appear below the title in the infobox when a location is clicked on.'
    4751                    ),
    4852                    'zoom_level'     => array(
     
    5761                        'type'          => 'text',
    5862                        'label'         => __( 'Center Latitude', 'fl-builder' ),
     63                        'placeholder'   => 'Required.'
    5964                    ),
    6065                    'center_lng'     => array(
    6166                        'type'          => 'text',
    6267                        'label'         => __( 'Center Longitude', 'fl-builder' ),
     68                        'placeholder'   => 'Required.'
    6369                    ),
    6470                    'map_api_key'     => array(
    6571                        'type'          => 'text',
    6672                        'label'         => __( 'Google Maps API Key', 'fl-builder' ),
     73                        'placeholder'   => 'Your Google Maps API key.'
    6774                    ),
    6875                    'use_category_filter' => array(
     
    93100                        'type'          => 'text',
    94101                        'label'         => __('Icon Field Name', 'fl-builder'),
    95                         'placeholder'   => 'Enter the name of the field that has the icon.',
     102                        'placeholder'   => 'Enter the name of the field that has the icon.'
    96103                    ),
    97104                    'post_taxonomy'    => array(
    98105                        'type'          => 'text',
    99106                        'label'         => __('CPT Taxonomy Name', 'fl-builder'),
    100                         'placeholder'   => 'Enter the name of the taxonomy that has the icon.',
     107                        'placeholder'   => 'Enter the name of the taxonomy that has the icon.'
     108                    ),
     109                    'show_marker_radius' => array(
     110                        'type'                  => 'select',
     111                        'label'                 => __('Show Marker Radius'),
     112                        'default'               => 'no',
     113                        'options'               => array(
     114                            'yes'                   => __('Yes', 'fl-builder'),
     115                            'no'                   => __('No', 'fl-builder')
     116                        ),
     117                        'toggle'    => array(
     118                            'yes'=> array(
     119                                'fields'    => array('radius_size', 'radius_field', 'fill_color', 'stroke_color', 'stroke_weight'),
     120                            ),
     121                            'no' => array()
     122                        )
     123                    ),
     124                    'radius_size'    => array(
     125                        'type'          => 'text',
     126                        'label'         => __('Radius in Miles', 'fl-builder'),
     127                    ),
     128                    'radius_field'    => array(
     129                        'type'          => 'text',
     130                        'label'         => __('Radius Field Name', 'fl-builder'),
     131                        'placeholder'   => 'The name of the field that has the radius.'
     132                    ),
     133                    'fill_color'     => array(
     134                        'type'  => 'color',
     135                        'label' => __('Fill Color', 'fl-builder'),
     136                        'show_reset'    => true
     137                    ),
     138                    'stroke_color'     => array(
     139                        'type'  => 'color',
     140                        'label' => __('Stroke Color', 'fl-builder'),
     141                        'show_reset'    => true
     142                    ),
     143                    'stroke_weight'     => array(
     144                        'type'  => 'text',
     145                        'label' => __('Stroke Weight', 'fl-builder')
    101146                    )
    102147                )                   
  • media-recode-custom-modules/trunk/readme.txt

    r1748180 r1759726  
    22 -Contributors: @mediarecode
    33 -Tags: beaver builder, multipoint map, multimarker map, google maps, beaver builder module, beaver builder modules
    4  -Requires at least: 4.0
     4 -Requires at least: 4.4
    55 -Tested up to: 4.8
    66 -Requires PHP: 5.6
    7  -Stable tag: 1.6
     7 -Stable tag: 1.7
    88 -License: GPLv2
    99 -License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
     
    1616 -Features:
    1717 -Places a marker for every post  of a given post type (great for event locations or a business directory)
    18  -Add a custom field to your categories for an icon and the module will use that instead
     18 -Add a custom field to your categories for an icon and the module will use that instead for map markers
    1919 -Easily filter the map by category
     20 -Add a radius to all markers or on a marker by marker basis
    2021 -
    2122 -== Installation ==
Note: See TracChangeset for help on using the changeset viewer.