开发者 | florianziegler |
---|---|
更新时间 | 2023年7月25日 23:41 |
PHP版本: | 3.9 及以上 |
WordPress版本: | 4.6 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
whereabouts
folder to your /wp-content/plugins
directory.[whereabouts user="2" link_location="1" time_format="H:i" show_tz="1"]
You need to enter a valid user id and the specified user must have saved his/her location for the widget to be displayed.
过滤
There is a filter available to change the html output of the widget/shortcode:
whab_widget_output
Three argument variables are availabe:
$output
The html Whereabouts generates by default as a string$args
The widget settings as an array$location
The location values as an arrayfunctions.php
like this:
`
add_filter( 'whab_widget_output', 'my_function_to_change_location_widget', 10, 3 );
function my_function_to_change_location_widget( $output, $args, $location ) {
$output = '
' . $location['location_name'] . ', ';
$output .= date( $args['time_format'], time() + $location['utc_difference'] );
if ( $args['show_tz'] ) {
$output .= ' (' . $location['timezone_name'] . ')';
}
return $output . '';
}
`
This will change the html output to:
<p class="my-location">Paris, France, 12:34 (Central European Standard Time)</p>
Usually it is a privacy issue: Make sure your browser and your website are allowed to use the location functionality of your device (eg. your smartphone). In general these settings are found in your device's privacy or location settings.
When you upgrade from 0.3.0 to a newer version, you have to (re) enter you location and (re) add the Whereabouts widget. Go to "Appearance > Widgets" and drag the Whereabouts widget to the sidebar of your choosing. From version 0.4.0 (or newer) the location is saved per user. You can choose the user, whose location you want to display, in the widget's options.