-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate geo location module (#41193)
* Deprecate Jetpack geo location module * changelog * Prevent linting error * Fix linting error * Update projects/plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php Co-authored-by: Karen Attfield <karenlattfield@gmail.com> --------- Co-authored-by: Karen Attfield <karenlattfield@gmail.com>
- Loading branch information
1 parent
a166b07
commit 47714da
Showing
6 changed files
with
9 additions
and
922 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/remove-remove-jetpack-geo-location-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: other | ||
|
||
Deprecate Jetpack geo location module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,9 @@ | ||
<?php | ||
<?php // phpcs:ignore Squiz.Commenting.FileComment.Missing | ||
/** | ||
* Module: geo-location | ||
* Module Name: Geo Location | ||
* Module Description: Add location data to your posts. | ||
* | ||
* @package automattic/jetpack | ||
*/ | ||
|
||
/** | ||
* Adds support for geo-location features. | ||
*/ | ||
|
||
require_once __DIR__ . '/geo-location/class.jetpack-geo-location.php'; | ||
|
||
/** | ||
* Geo-location shortcode callback for display of location data associated with a post. | ||
* | ||
* Usage with current global $post: | ||
* [geo-location] | ||
* | ||
* Usage with specific post ID: | ||
* [geo-location post=5] | ||
* | ||
* @param array $attributes Shortcode attributes. | ||
*/ | ||
function jetpack_geo_shortcode( $attributes ) { | ||
$attributes = shortcode_atts( | ||
array( | ||
'post' => null, | ||
'id' => null, | ||
), | ||
$attributes | ||
); | ||
return jetpack_geo_get_location( $attributes['post'] ? $attributes['post'] : $attributes['id'] ); | ||
} | ||
add_shortcode( 'geo-location', 'jetpack_geo_shortcode' ); | ||
|
||
/** | ||
* Get the geo-location data associated with the supplied post ID, if it's available | ||
* and marked as being available for public display. The returned array will contain | ||
* "latitude", "longitude" and "label" keys. | ||
* | ||
* If you do not supply a value for $post_id, the global $post will be used, if | ||
* available. | ||
* | ||
* @param integer|null $post_id Post ID. | ||
* | ||
* @return array|null | ||
*/ | ||
function jetpack_geo_get_data( $post_id = null ) { | ||
$geo = Jetpack_Geo_Location::init(); | ||
|
||
if ( ! $post_id ) { | ||
$post_id = $geo->get_post_id(); | ||
} | ||
|
||
$meta_values = $geo->get_meta_values( $post_id ); | ||
|
||
if ( ! $meta_values['is_public'] || ! $meta_values['is_populated'] ) { | ||
return null; | ||
} | ||
|
||
return array( | ||
'latitude' => $meta_values['latitude'], | ||
'longitude' => $meta_values['longitude'], | ||
'label' => $meta_values['label'], | ||
); | ||
} | ||
|
||
/** | ||
* Display the label HTML for the geo-location information associated with the supplied | ||
* post ID. | ||
* | ||
* If you do not supply a value for $post_id, the global $post will be used, if | ||
* available. | ||
* | ||
* @param integer|null $post_id Post ID. | ||
* | ||
* @return void | ||
*/ | ||
function jetpack_geo_display_location( $post_id = null ) { | ||
echo jetpack_geo_get_location( $post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in `Jetpack_Geo_Location::get_location_label`. | ||
} | ||
|
||
/** | ||
* Return the label HTML for the geo-location information associated with the supplied | ||
* post ID. | ||
* | ||
* If you do not supply a value for $post_id, the global $post will be used, if | ||
* available. | ||
* | ||
* @param integer|null $post_id Post ID. | ||
* | ||
* @return string | ||
*/ | ||
function jetpack_geo_get_location( $post_id = null ) { | ||
return Jetpack_Geo_Location::init()->get_location_label( $post_id ); | ||
} |
Oops, something went wrong.