Changeset 3096423
- Timestamp:
- 06/02/2024 10:09:42 PM (22 months ago)
- Location:
- ootb-openstreetmap
- Files:
-
- 6 edited
- 1 copied
-
tags/.2.8.2 (copied) (copied from ootb-openstreetmap/trunk)
-
tags/.2.8.2/includes/classes/Query.php (modified) (2 diffs)
-
tags/.2.8.2/ootb-openstreetmap.php (modified) (2 diffs)
-
tags/.2.8.2/readme.txt (modified) (4 diffs)
-
trunk/includes/classes/Query.php (modified) (2 diffs)
-
trunk/ootb-openstreetmap.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ootb-openstreetmap/tags/.2.8.2/includes/classes/Query.php
r3092806 r3096423 179 179 continue; 180 180 } 181 181 182 $markers[][] = (object) [ 182 183 'lat' => $latitude, 183 184 'lng' => $longitude, 184 'text' => $address,185 'text' => wp_kses_post( apply_filters( 'ootb_cf_modal_content', $address, $post_id ) ), 185 186 'id' => $post_id, 187 'icon' => self::get_cf_marker_icon( $post_id ), 186 188 ]; 187 189 } else { … … 342 344 ]; 343 345 } 346 347 /** 348 * Gets the marker icon and allows the user to override it with a hook. 349 * 350 * @param int $post_id The post ID. 351 * 352 * @return array|null 353 */ 354 private static function get_cf_marker_icon( int $post_id = 0 ): ?array { 355 if ( empty( $post_id ) ) { 356 return null; 357 } 358 $icon_url = apply_filters( 'ootb_cf_marker_icon', '', $post_id ); 359 $icon = null; 360 if ( ! empty( $icon_url ) && filter_var( $icon_url, FILTER_VALIDATE_URL ) ) { 361 $icon = [ 362 'url' => esc_url( $icon_url ), 363 ]; 364 } 365 366 return $icon; 367 } 344 368 } -
ootb-openstreetmap/tags/.2.8.2/ootb-openstreetmap.php
r3092809 r3096423 6 6 * Requires at least: 5.8.6 7 7 * Requires PHP: 7.4 8 * Version: 2.8. 18 * Version: 2.8.2 9 9 * Author: Giorgos Sarigiannidis 10 10 * Author URI: https://www.gsarigiannidis.gr … … 22 22 23 23 const OOTB_BLOCK_NAME = 'ootb/openstreetmap'; 24 const OOTB_VERSION = '2.8. 1';24 const OOTB_VERSION = '2.8.2'; 25 25 const OOTB_SCRIPT_VERSION = [ 26 26 'leaflet' => '1.9.4', -
ootb-openstreetmap/tags/.2.8.2/readme.txt
r3092809 r3096423 6 6 Tested up to: 6.5 7 7 Requires PHP: 7.4 8 Stable tag: 2.8. 18 Stable tag: 2.8.2 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 23 23 * [Release history](https://github.com/gsarig/ootb-openstreetmap/releases) 24 24 * [Roadmap](https://github.com/users/gsarig/projects/1) 25 * [Hooks🪝](https://github.com/gsarig/ootb-openstreetmap?tab=readme-ov-file#hooks) 26 * [Shortcodes](https://github.com/gsarig/ootb-openstreetmap?tab=readme-ov-file#shortcodes) 25 27 26 28 = Features = … … 87 89 88 90 = How can I use the shortcode? = 89 The shortcode `[ootb_query]` allows you to display a dynamic map, which retrieves markers from other posts or post types. Just add it to a post or page and you're good to go. By default, it will fetch the markers from the 100 most recent posts. The shortcode supports the following attributes: 90 * source: (Optional) The source of the data. Can be either `geodata`, if you want to retrieve the posts based on their Location custom meta field, or `block`, to retrieve posts containing map blocks in their content. The default option, which will be used if the attribute is omitted, is `block`. 91 * post_type: (Optional) The type of post to query. By default, it is set to `post`. 92 * posts_per_page: (Optional) The number of posts to be displayed on page. Default value is `100`. 93 * post_ids: (Optional) Comma-separated IDs of the posts to include in the query. 94 * height: (Optional) The desired height for the map. Default value is empty, which falls back to `400px`. 95 * provider: (Optional) Specifies the map provider. Options are: `openstreetmap`, `mapbox` and `stamen`. The default value is an empty string which falls back to `openstreetmap`. 96 * maptype: (Optional) Specifies the type of map. Options are: `markers`, `polygon` and `polyline`. The default value is an empty string, which will fall back to `markers`. 97 * touchzoom: (Optional) If set, touch zoom will be enabled on the map. It can be either `true` or `false`. The default value is an empty string, which falls back to `true`. 98 * scrollwheelzoom: (Optional) If set, enables zooming on the map with mouse scroll wheel. It can be either `true` or `false`. The default value is an empty string, which falls back to `true`. 99 * dragging: (Optional) If set, dragging is enabled on the map. It can be either `true` or `false`. The default value is an empty string, which falls back to `true`. 100 * doubleclickzoom: (Optional) If set, allows zooming in on the map with a double click. It can be either `true` or `false`. The default value is an empty string, which falls back to `true`. 101 * marker: (Optional) Specifies the marker for the map. This should correspond to the URL of the image that you want to use as the marker's icon (example: `https://www.example.com/my-custom-icon.png`). The default value is an empty string, which retrieves the default marker. 102 103 Here's an example of how you can use it: 104 ``` 105 [ootb_query post_type="post" post_ids="1,2,3,4" height="400px" provider="mapbox" maptype="polygon" touchzoom="true" scrollwheelzoom="true" dragging="true" doubleclickzoom="true" marker="https://www.example.com/my-custom-icon.png"] 106 ``` 91 To see the available shortcodes and the parameters that you can pass, [go here](https://github.com/gsarig/ootb-openstreetmap?tab=readme-ov-file#shortcodes). 107 92 108 93 = I want more control. Are there any hooks that I could use? = 109 Glad you asked! There are a few hooks that you can use to further customize the plugin's behavior. Here they are: 110 * `ootb_query_post_type`: Allows you to change the post type that the plugin will query for markers. By default, it is set to `post`. You can pass multiple post types as an array. Example: 111 ``` 112 add_filter( 'ootb_query_post_type', function() { return array( 'post', 'page' ); } ); 113 ``` 114 * `ootb_query_posts_per_page`: Allows you to change the number of posts that the plugin will query for markers. By default, it is set to `100`. Example: 115 ``` 116 add_filter( 'ootb_query_posts_per_page', function() { return 500; } ); 117 ``` 118 * `ootb_query_extra_args`: Allows you to add extra arguments to the query that the plugin will use to retrieve markers. By default, it is set to an empty array. Example: 119 ``` 120 add_filter( 121 'ootb_query_extra_args', 122 function() { 123 return [ 124 'tax_query' => [ 125 [ 126 'taxonomy' => 'people', 127 'field' => 'slug', 128 'terms' => 'bob' 129 ] 130 ]; 131 } 132 ); 133 ``` 134 Keep in mind that the extra args will be merged with the default ones, so you don't have to worry about overriding them. In fact, the args that are required for the query to work, cannot be overridden. 94 Glad you asked! There are a few hooks that you can use to further customize the plugin's behavior. [You can find them here](https://github.com/gsarig/ootb-openstreetmap?tab=readme-ov-file#hooks). 135 95 136 96 == Screenshots == … … 177 137 178 138 == Changelog == 139 = 2.8.2 = 140 * [NEW] Adds the `ootb_cf_modal_content` and `ootb_cf_marker_icon` hooks, which allow you to change the content of the modal that appears when you query posts based on their "Location" custom fields, as well as the marker icon. For more info, check the plugin's FAQ section. 141 179 142 = 2.8.0 = 180 143 * [NEW] Adds an option to enable a location custom field, which can be used to store a post's or post type's location, following the [Geodata guidelines](https://codex.wordpress.org/Geodata). -
ootb-openstreetmap/trunk/includes/classes/Query.php
r3092806 r3096423 179 179 continue; 180 180 } 181 181 182 $markers[][] = (object) [ 182 183 'lat' => $latitude, 183 184 'lng' => $longitude, 184 'text' => $address,185 'text' => wp_kses_post( apply_filters( 'ootb_cf_modal_content', $address, $post_id ) ), 185 186 'id' => $post_id, 187 'icon' => self::get_cf_marker_icon( $post_id ), 186 188 ]; 187 189 } else { … … 342 344 ]; 343 345 } 346 347 /** 348 * Gets the marker icon and allows the user to override it with a hook. 349 * 350 * @param int $post_id The post ID. 351 * 352 * @return array|null 353 */ 354 private static function get_cf_marker_icon( int $post_id = 0 ): ?array { 355 if ( empty( $post_id ) ) { 356 return null; 357 } 358 $icon_url = apply_filters( 'ootb_cf_marker_icon', '', $post_id ); 359 $icon = null; 360 if ( ! empty( $icon_url ) && filter_var( $icon_url, FILTER_VALIDATE_URL ) ) { 361 $icon = [ 362 'url' => esc_url( $icon_url ), 363 ]; 364 } 365 366 return $icon; 367 } 344 368 } -
ootb-openstreetmap/trunk/ootb-openstreetmap.php
r3092809 r3096423 6 6 * Requires at least: 5.8.6 7 7 * Requires PHP: 7.4 8 * Version: 2.8. 18 * Version: 2.8.2 9 9 * Author: Giorgos Sarigiannidis 10 10 * Author URI: https://www.gsarigiannidis.gr … … 22 22 23 23 const OOTB_BLOCK_NAME = 'ootb/openstreetmap'; 24 const OOTB_VERSION = '2.8. 1';24 const OOTB_VERSION = '2.8.2'; 25 25 const OOTB_SCRIPT_VERSION = [ 26 26 'leaflet' => '1.9.4', -
ootb-openstreetmap/trunk/readme.txt
r3092809 r3096423 6 6 Tested up to: 6.5 7 7 Requires PHP: 7.4 8 Stable tag: 2.8. 18 Stable tag: 2.8.2 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 23 23 * [Release history](https://github.com/gsarig/ootb-openstreetmap/releases) 24 24 * [Roadmap](https://github.com/users/gsarig/projects/1) 25 * [Hooks🪝](https://github.com/gsarig/ootb-openstreetmap?tab=readme-ov-file#hooks) 26 * [Shortcodes](https://github.com/gsarig/ootb-openstreetmap?tab=readme-ov-file#shortcodes) 25 27 26 28 = Features = … … 87 89 88 90 = How can I use the shortcode? = 89 The shortcode `[ootb_query]` allows you to display a dynamic map, which retrieves markers from other posts or post types. Just add it to a post or page and you're good to go. By default, it will fetch the markers from the 100 most recent posts. The shortcode supports the following attributes: 90 * source: (Optional) The source of the data. Can be either `geodata`, if you want to retrieve the posts based on their Location custom meta field, or `block`, to retrieve posts containing map blocks in their content. The default option, which will be used if the attribute is omitted, is `block`. 91 * post_type: (Optional) The type of post to query. By default, it is set to `post`. 92 * posts_per_page: (Optional) The number of posts to be displayed on page. Default value is `100`. 93 * post_ids: (Optional) Comma-separated IDs of the posts to include in the query. 94 * height: (Optional) The desired height for the map. Default value is empty, which falls back to `400px`. 95 * provider: (Optional) Specifies the map provider. Options are: `openstreetmap`, `mapbox` and `stamen`. The default value is an empty string which falls back to `openstreetmap`. 96 * maptype: (Optional) Specifies the type of map. Options are: `markers`, `polygon` and `polyline`. The default value is an empty string, which will fall back to `markers`. 97 * touchzoom: (Optional) If set, touch zoom will be enabled on the map. It can be either `true` or `false`. The default value is an empty string, which falls back to `true`. 98 * scrollwheelzoom: (Optional) If set, enables zooming on the map with mouse scroll wheel. It can be either `true` or `false`. The default value is an empty string, which falls back to `true`. 99 * dragging: (Optional) If set, dragging is enabled on the map. It can be either `true` or `false`. The default value is an empty string, which falls back to `true`. 100 * doubleclickzoom: (Optional) If set, allows zooming in on the map with a double click. It can be either `true` or `false`. The default value is an empty string, which falls back to `true`. 101 * marker: (Optional) Specifies the marker for the map. This should correspond to the URL of the image that you want to use as the marker's icon (example: `https://www.example.com/my-custom-icon.png`). The default value is an empty string, which retrieves the default marker. 102 103 Here's an example of how you can use it: 104 ``` 105 [ootb_query post_type="post" post_ids="1,2,3,4" height="400px" provider="mapbox" maptype="polygon" touchzoom="true" scrollwheelzoom="true" dragging="true" doubleclickzoom="true" marker="https://www.example.com/my-custom-icon.png"] 106 ``` 91 To see the available shortcodes and the parameters that you can pass, [go here](https://github.com/gsarig/ootb-openstreetmap?tab=readme-ov-file#shortcodes). 107 92 108 93 = I want more control. Are there any hooks that I could use? = 109 Glad you asked! There are a few hooks that you can use to further customize the plugin's behavior. Here they are: 110 * `ootb_query_post_type`: Allows you to change the post type that the plugin will query for markers. By default, it is set to `post`. You can pass multiple post types as an array. Example: 111 ``` 112 add_filter( 'ootb_query_post_type', function() { return array( 'post', 'page' ); } ); 113 ``` 114 * `ootb_query_posts_per_page`: Allows you to change the number of posts that the plugin will query for markers. By default, it is set to `100`. Example: 115 ``` 116 add_filter( 'ootb_query_posts_per_page', function() { return 500; } ); 117 ``` 118 * `ootb_query_extra_args`: Allows you to add extra arguments to the query that the plugin will use to retrieve markers. By default, it is set to an empty array. Example: 119 ``` 120 add_filter( 121 'ootb_query_extra_args', 122 function() { 123 return [ 124 'tax_query' => [ 125 [ 126 'taxonomy' => 'people', 127 'field' => 'slug', 128 'terms' => 'bob' 129 ] 130 ]; 131 } 132 ); 133 ``` 134 Keep in mind that the extra args will be merged with the default ones, so you don't have to worry about overriding them. In fact, the args that are required for the query to work, cannot be overridden. 94 Glad you asked! There are a few hooks that you can use to further customize the plugin's behavior. [You can find them here](https://github.com/gsarig/ootb-openstreetmap?tab=readme-ov-file#hooks). 135 95 136 96 == Screenshots == … … 177 137 178 138 == Changelog == 139 = 2.8.2 = 140 * [NEW] Adds the `ootb_cf_modal_content` and `ootb_cf_marker_icon` hooks, which allow you to change the content of the modal that appears when you query posts based on their "Location" custom fields, as well as the marker icon. For more info, check the plugin's FAQ section. 141 179 142 = 2.8.0 = 180 143 * [NEW] Adds an option to enable a location custom field, which can be used to store a post's or post type's location, following the [Geodata guidelines](https://codex.wordpress.org/Geodata).
Note: See TracChangeset
for help on using the changeset viewer.