Skip to content

Commit 6685f29

Browse files
authored
Use always the proper nonce for WP forms in backend fixes location fi… (#616)
* Use always the proper nonce for WP forms in backend fixes location fix wizard * More detailed documentation about geocoding
1 parent d6ff4ab commit 6685f29

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

assets/js/admin.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ jQuery( function ( $ ) {
66
'click',
77
'.sunflower-plugins .notice-dismiss',
88
function () {
9+
const id = $( this ).parent().attr( 'id' );
910
jQuery.ajax( {
1011
url: ajaxurl,
1112
method: 'POST',
1213
data: {
13-
id: $( this ).parent().attr( 'id' ),
14-
_wpnonce: $( '#_wpnonce' ).val(),
14+
id,
15+
_wpnonce: $( '#' + id + ' #_wpnonce' ).val(),
1516
action: 'sunflower_plugins_dismiss',
1617
},
1718
} );
@@ -93,7 +94,7 @@ function sunflowerSetMarker( lat, lon, zoom, setmarker ) {
9394
method: 'POST',
9495
data: {
9596
action: 'sunflower_fix_event_location',
96-
_wpnonce: jQuery( '#_wpnonce' ).val(),
97+
_wpnonce: jQuery( '#_wpnonce-locationfix' ).val(),
9798
lat,
9899
lon,
99100
transient: jQuery( '#sunflower-location option:selected' ).text(),
@@ -112,6 +113,7 @@ function sunflowerFixLocationDelete() {
112113
method: 'POST',
113114
data: {
114115
action: 'sunflower_fix_event_location',
116+
_wpnonce: jQuery( '#_wpnonce-locationfix' ).val(),
115117
lat: 0,
116118
lon: 0,
117119
transient: jQuery( '#sunflower-location option:selected' ).text(),

functions/admin.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ function sunflower_notice() {
4040
<?php wp_nonce_field( 'sunflower_update_notice' ); ?>
4141
<p>
4242
<?php
43-
$linkgithub = "<a href='https://github.com/verdigado/sunflower' target='_blank'>open source</a>";
44-
$linkverdigado = "<a href='https://www.verdigado.com/' target='_blank' title='verdigado eG'>
43+
$linkgithub = "<a href='https://github.com/verdigado/sunflower' target='_blank'>open source</a>";
44+
$linkverdigado = "<a href='https://www.verdigado.com/' target='_blank' title='verdigado eG'>
4545
<img src='" . get_template_directory_uri() . "/assets/img/verdigado-logo.png' alt='Logo of verdigado eG' /></a>";
4646
printf(
4747
/* translators: %1$s and %2$s are replaced with links */
@@ -70,6 +70,7 @@ function sunflower_notice_php() {
7070

7171
?>
7272
<div id="sunflower-plugins-php-82" class="notice notice-error update-nag sunflower-plugins is-dismissible">
73+
<?php wp_nonce_field( 'sunflower_update_notice' ); ?>
7374
<p class="h3"><?php esc_attr_e( 'PHP Version End of Life', 'sunflower' ); ?></p>
7475
<p>
7576
<?php
@@ -109,6 +110,7 @@ function sunflower_notice_terms() {
109110

110111
?>
111112
<div id="sunflower-notice-terms" class="notice notice-error update-nag sunflower-plugins is-dismissible">
113+
<?php wp_nonce_field( 'sunflower_update_notice' ); ?>
112114
<p class="h3"><?php esc_attr_e( 'New Terms and Use Settings', 'sunflower' ); ?></p>
113115
<p>
114116
<?php
@@ -177,7 +179,8 @@ function sunflower_update_notice() {
177179
* Delete dissmissed option for admins.
178180
*/
179181
function sunflower_admin() {
180-
delete_option( 'sunflower-plugins-dismissed' );
182+
// phpcs:ignore
183+
// delete_option( 'sunflower-plugins-dismissed' );
181184
}
182185

183186
add_action( 'admin_init', 'sunflower_admin' );

functions/options/class-sunflowereventsettingspage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function create_sunflower_events_options_page(): void {
7979
<h2>Korrektur der Marker auf Landkarten von importierten Terminen</h2>
8080
<input type="hidden" name="_sunflower_event_lat" id="_sunflower_event_lat">
8181
<input type="hidden" name="_sunflower_event_lon" id="_sunflower_event_lon">
82-
<?php wp_nonce_field( 'sunflower_location' ); ?>
82+
<?php wp_nonce_field( 'sunflower_location', '_wpnonce-locationfix' ); ?>
8383
<div id="sunflower-location-row" style="display:none">
8484
Bearbeite die Geo-Markierung für:
8585
<select name="sunflower_location" id="sunflower-location">

mkdocs/docs/events.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@ Sich wiederholende Termine werden bis längstens in einem Jahr importiert. Du ka
9292
importierenden Termine bei sich wiederholenden Terminen so festlegen:
9393
``define('SUNFLOWER_EVENT_RECURRING_EVENTS', 10);``
9494

95-
### Geodaten
95+
### Geokodierung der Veranstaltungsorte
96+
9697
Die Information zum Veranstaltungsort werden über [Nominatim](https://nominatim.openstreetmap.org/ui/) auf einer Landkarte gesucht. Die Geokoordinaten werden lokal gespeichert. Pro Import-Lauf werden höchstens drei neue Orte über Nominatim gesucht, damit die Import-Performance hoch bleibt.
9798

98-
Fehlerhafte Geodaten können in den Sunflower-Einstellungen unter Termine korrigiert werden. Sie werden beim nächsten Import-Lauf wirksam.
99+
Wird ein Ort mit Straße und Ort beschrieben ist die Genauigkeit sehr hoch. Ein allgemeiner Begriff, wie z.B. "Geschäftsstelle" führt zu einem zufälligen Ergebnis.
100+
101+
Fehlerhafte Geodaten können in den Sunflower-Einstellungen unter `Termine -> Korrektur der Marker auf Landkarten von importierten Terminen` korrigiert werden. Sie werden bei allen zukünftigen Import-Läufen mit der selben Ortsbezeichnung wirksam.
99102

100103
### Zoom-Level für importierte Termine festlegen
101104
Importierte Termine haben standardmäßig das Zoom-Level 12. Wenn Du davon abweichen möchtest, trage in der *wp-config.php* bitte die Zeile

0 commit comments

Comments
 (0)