Changeset 1759726
- Timestamp:
- 11/06/2017 10:26:15 PM (8 years ago)
- Location:
- media-recode-custom-modules/trunk
- Files:
-
- 5 edited
-
mr-builder-modules.php (modified) (2 diffs)
-
mr-multipoint-map/includes/frontend.php (modified) (5 diffs)
-
mr-multipoint-map/js/mr-map-script.js (modified) (2 diffs)
-
mr-multipoint-map/mr-multipoint-map.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
media-recode-custom-modules/trunk/mr-builder-modules.php
r1739184 r1759726 4 4 * Plugin URI: https//www.mediarecode.com 5 5 * Description: Custom Beaver Builder modules developed by Media Recode. 6 * Version: 1. 16 * Version: 1.7 7 7 * Author: Matt Ryan 8 8 * Author URI: https://www.mediarecode.com … … 16 16 if ( class_exists( 'FLBuilder' ) ) { 17 17 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'; 18 20 } 19 21 } -
media-recode-custom-modules/trunk/mr-multipoint-map/includes/frontend.php
r1739187 r1759726 1 1 <?php 2 2 3 $settings->posts_per_page = -1; 3 4 $query = FLBuilderLoop::query( $settings ); 4 5 … … 24 25 } 25 26 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 27 35 $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 28 40 $permalink = get_permalink(); 41 29 42 30 43 $location_info[$counter]['lat'] = $location['lat']; … … 32 45 $location_info[$counter]['name'] = $name; 33 46 $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 } 38 80 39 81 $counter++; … … 51 93 var settings = new Array(); 52 94 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 53 169 </script> 54 170 … … 61 177 echo '</div>'; 62 178 } 63 64 179 ?> 65 180 -
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 () 4 2 5 3 function initMap() { … … 58 56 } 59 57 } 60 } 58 }*/ -
media-recode-custom-modules/trunk/mr-multipoint-map/mr-multipoint-map.php
r1748178 r1759726 36 36 'type' => 'text', 37 37 '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.') 38 40 ), 39 41 'location_field_name' => array( 40 42 'type' => 'text', 41 43 'label' => __( 'Location Field Name', 'fl-builder' ), 44 'placeholder' => 'The field name that has the latitude and longitude.' 42 45 ), 43 46 'description_field_name' => array( 44 47 'type' => 'text', 45 48 '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.' 47 51 ), 48 52 'zoom_level' => array( … … 57 61 'type' => 'text', 58 62 'label' => __( 'Center Latitude', 'fl-builder' ), 63 'placeholder' => 'Required.' 59 64 ), 60 65 'center_lng' => array( 61 66 'type' => 'text', 62 67 'label' => __( 'Center Longitude', 'fl-builder' ), 68 'placeholder' => 'Required.' 63 69 ), 64 70 'map_api_key' => array( 65 71 'type' => 'text', 66 72 'label' => __( 'Google Maps API Key', 'fl-builder' ), 73 'placeholder' => 'Your Google Maps API key.' 67 74 ), 68 75 'use_category_filter' => array( … … 93 100 'type' => 'text', 94 101 '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.' 96 103 ), 97 104 'post_taxonomy' => array( 98 105 'type' => 'text', 99 106 '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') 101 146 ) 102 147 ) -
media-recode-custom-modules/trunk/readme.txt
r1748180 r1759726 2 2 -Contributors: @mediarecode 3 3 -Tags: beaver builder, multipoint map, multimarker map, google maps, beaver builder module, beaver builder modules 4 -Requires at least: 4. 04 -Requires at least: 4.4 5 5 -Tested up to: 4.8 6 6 -Requires PHP: 5.6 7 -Stable tag: 1. 67 -Stable tag: 1.7 8 8 -License: GPLv2 9 9 -License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html … … 16 16 -Features: 17 17 -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 19 19 -Easily filter the map by category 20 -Add a radius to all markers or on a marker by marker basis 20 21 - 21 22 -== Installation ==
Note: See TracChangeset
for help on using the changeset viewer.