Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions functions/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,15 @@ function sunflower_int_date2german_date( $int_date ) {
function sunflower_event_meta_box() {
global $post;

$sunflower_event_fields = sunflower_get_event_fields();
$sunflower_event_fields = sunflower_get_event_fields();
$sunflower_form_disabled = '';

$custom = get_post_custom( $post->ID );
$uid = $custom['_sunflower_event_uid'][0] ?? false;

if ( $uid ) {
printf( '<div style="color:red">%s</div>', esc_html__( 'This event will be imported by remote ical-calendar. All changes here will be overwritten.', 'sunflower' ) );
$sunflower_form_disabled = 'disabled';
?>
<script>
jQuery( function() {
Expand All @@ -244,7 +246,6 @@ function sunflower_event_meta_box() {
});
</script>
<?php
return;
} else {
?>
<script>
Expand All @@ -266,6 +267,9 @@ function sunflower_event_meta_box() {
if ( '_sunflower_event_until' === $id && 'checked' === $is_all_day ) {
$value = gmdate( 'Y.m.d', strtotime( $value ) - 86400 );
}
if ( $sunflower_form_disabled ) {
$config[4] = 'disabled="disabled"';
}
sunflower_event_field( $id, $config, $value );
}

Expand Down Expand Up @@ -303,6 +307,7 @@ function sunflower_event_field( $id, $config, $value ) {
$sunflower_class = $config[1] ?? '';
$sunflower_type = $config[2] ?? false;
$sunflower_initialized_checked = $config[3] ?? '';
$sunflower_field_disabled = $config[4] ?? '';

if ( 'datetimepicker' === $sunflower_class ) {
$value = sunflower_int_date2german_date( $value );
Expand All @@ -315,7 +320,7 @@ function sunflower_event_field( $id, $config, $value ) {

match ( $sunflower_type ) {
'checkbox' => printf(
'<div class="sunflower-field checkbox"><span><input class="%4$s" type="checkbox" name="%1$s" id="%1$s" %3$s value="checked" %5$s></span><label for="%1$s">%2$s</label></div>',
'<div class="sunflower-field checkbox"><span><input class="%4$s" type="checkbox" name="%1$s" id="%1$s" %3$s value="checked" ' . esc_attr( $sunflower_field_disabled ) . ' %5$s></span><label for="%1$s">%2$s</label></div>',
esc_attr( $id ),
esc_attr( $sunflower_label ),
esc_attr( $value ),
Expand All @@ -328,7 +333,7 @@ function sunflower_event_field( $id, $config, $value ) {
esc_attr( $value )
),
default => printf(
'<div class="sunflower-field text"><label for="%1$s">%2$s</label><br /><input class="%4$s" type="text" name="%1$s" placeholder="%2$s" autocomplete="off" value="%3$s"></div>',
'<div class="sunflower-field text"><label for="%1$s">%2$s</label><br /><input class="%4$s" type="text" name="%1$s" placeholder="%2$s" autocomplete="off" value="%3$s" ' . esc_attr( $sunflower_field_disabled ) . '></div>',
esc_attr( $id ),
esc_attr( $sunflower_label ),
esc_attr( $value ),
Expand Down
36 changes: 32 additions & 4 deletions functions/icalimport.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function sunflower_icalimport( $url = false, $auto_categories = false ) {
}

$updated_events = 0;
$new_events = 0;
$ids_from_remote = array();
$count_recurring_events = array();

Expand Down Expand Up @@ -96,7 +97,6 @@ function sunflower_icalimport( $url = false, $auto_categories = false ) {
if ( $is_imported->have_posts() ) {
$is_imported->the_post();
$wp_id = get_the_ID();
++$updated_events;
}

$post_content = sprintf( '<!-- wp:paragraph --><p>%s</p><!-- /wp:paragraph -->', nl2br( (string) $event->DESCRIPTION ) ); // phpcs:ignore
Expand All @@ -113,9 +113,24 @@ function sunflower_icalimport( $url = false, $auto_categories = false ) {
'post_status' => 'publish',
);
$id = wp_insert_post( (array) $post, true );

if ( ! is_int( $id ) ) {
echo 'Could not copy post';
return false;
printf(
'
<p class="notice notice-warning notice-large">
%1$s: %2$s - "%3$s"
</p>',
esc_attr__( 'Failed to import event', 'sunflower' ),
esc_attr( $event->DTSTART->getDateTime()->format( 'd.m.Y' ) ), // phpcs:ignore
esc_attr( $event->SUMMARY->getValue() ) // phpcs:ignore
);
continue;
}

if ( 0 === $wp_id ) {
++$new_events;
} elseif ( $wp_id === $id ) {
++$updated_events;
}

// Save all event post ids from imported ics ressources.
Expand Down Expand Up @@ -164,7 +179,12 @@ function sunflower_icalimport( $url = false, $auto_categories = false ) {
wp_set_post_terms( $id, $categories, 'sunflower_event_tag' );
}

return array( $ids_from_remote, count( $all_events ) - $updated_events, $updated_events );
return array(
$ids_from_remote,
count( $all_events ) - $updated_events,
'updated_events' => $updated_events,
'new_events' => $new_events,
);
}

/**
Expand Down Expand Up @@ -291,9 +311,17 @@ function sunflower_import_icals( $force = false ) {

$deleted_on_remote = array_diff( sunflower_get_events_having_uid(), $ids_from_remote );

$deleted_events = 0;
foreach ( $deleted_on_remote as $to_be_deleted ) {
wp_delete_post( $to_be_deleted );
++$deleted_events;
}

return array(
'deleted_events' => $deleted_events,
'updated_events' => $response['updated_events'],
'new_events' => $response['new_events'],
);
}

add_action( 'init', 'sunflower_import_icals' );
Expand Down
33 changes: 28 additions & 5 deletions functions/options/class-sunflowereventsettingspage.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,36 @@ public function create_sunflower_events_options_page(): void {
?>
</form>

<h2>Kalenderimport</h2>
<h2><?php esc_attr_e( 'ICS Calendar Import', 'sunflower' ); ?></h2>
<?php

if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'sunflower_events_options-icalimport' ) && isset( $_GET['icalimport'] ) ) {
sunflower_import_icals( true );
echo '<div>Die Termine wurden aktualisiert.</div>';
printf( '<div><a href="../?post_type=sunflower_event">Termine ansehen</a></div>' );
$count = sunflower_import_icals( true );
printf(
'<div>%1$s<ul>
<li>%2$s</li>
<li>%3$s</li>
<li>%4$s</li>
</ul>
</div>
',
esc_attr__( 'ICS calendar has been imported.', 'sunflower' ),
esc_attr__( 'new', 'sunflower' ) . ': ' . (int) $count['new_events'],
esc_attr__( 'deleted', 'sunflower' ) . ': ' . (int) $count['deleted_events'],
esc_attr__( 'updated', 'sunflower' ) . ': ' . (int) $count['updated_events'],
);
printf(
'<div>
<a href="../?post_type=sunflower_event" class="button button-secondary">%s</a>
<a href="edit.php?post_type=sunflower_event" class="button button-secondary">%s</a>
</div>',
esc_attr__( 'See all events (Frontend)', 'sunflower' ),
esc_attr__( 'Edit events (Backend)', 'sunflower' )
);
if ( ini_get( 'allow_url_fopen' ) ) {
$sunflower_icalimport_url = wp_nonce_url( 'admin.php?page=sunflower_events_options&icalimport=1', 'sunflower_events_options-icalimport' );
printf( '<a href="%s" class="button button-primary">%s</a>', esc_html( $sunflower_icalimport_url ), esc_attr__( 'Import calendars now', 'sunflower' ) );
}
} elseif ( sunflower_get_setting( 'sunflower_ical_urls' ) ) {
if ( ini_get( 'allow_url_fopen' ) ) {
$sunflower_icalimport_url = wp_nonce_url( 'admin.php?page=sunflower_events_options&icalimport=1', 'sunflower_events_options-icalimport' );
Expand Down Expand Up @@ -286,7 +309,7 @@ public function sunflower_ical_urls_callback(): void {
public function sunflower_zoom_callback(): void {
printf(
'<input type="number" min="1" max="19" id="sunflower_zoom" name="sunflower_events_options[sunflower_zoom]" value="%s">',
esc_attr( $this->options['sunflower_zoom'] ? $this->options['sunflower_zoom'] : '11' )
esc_attr( $this->options['sunflower_zoom'] ?? '11' )
);
echo '<div>1 (ganze Welt) bis 19 (einzelne Straße), Zoomlevel für die Übersichtskarte für Termine</div>';
}
Expand Down
Binary file modified languages/de_DE.mo
Binary file not shown.
89 changes: 58 additions & 31 deletions languages/de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ msgid ""
msgstr ""
"Project-Id-Version: sunflower 2.1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/theme/sunflower\n"
"POT-Creation-Date: 2025-06-27T08:29:18+00:00\n"
"PO-Revision-Date: 2025-06-27 10:30+0200\n"
"POT-Creation-Date: 2025-08-14T06:58:11+00:00\n"
"PO-Revision-Date: 2025-08-14 09:02+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de_DE\n"
Expand Down Expand Up @@ -58,7 +58,7 @@ msgstr "Vergangene Veranstaltungen"
#: archive-sunflower_event.php:39 functions/events.php:37
#: functions/options/class-sunflowereventsettingspage.php:34
#: functions/options/class-sunflowereventsettingspage.php:35
#: functions/options/class-sunflowereventsettingspage.php:146
#: functions/options/class-sunflowereventsettingspage.php:163
msgid "Events"
msgstr "Termine"

Expand All @@ -74,8 +74,8 @@ msgstr "Alle Termine"
msgid "Archive"
msgstr "Archiv"

#: archive-sunflower_event.php:63 functions/events.php:285
#: functions/options/class-sunflowereventsettingspage.php:123
#: archive-sunflower_event.php:63 functions/events.php:289
#: functions/options/class-sunflowereventsettingspage.php:140
msgid "Map"
msgstr "Landkarte"

Expand Down Expand Up @@ -279,30 +279,34 @@ msgstr "Zeige Karte beim Termin"
msgid "Event"
msgstr "Termin"

#: functions/events.php:236
#: functions/events.php:237
msgid ""
"This event will be imported by remote ical-calendar. All changes here will "
"be overwritten."
msgstr ""
"Dieser Termin wird automatisch über einen externen Kalender gepflegt. Alle "
"Änderungen hier werden regelmäßig überschrieben."

#: functions/events.php:286
#: functions/events.php:290
msgid "Load map and fix location marker"
msgstr "Karte laden und Postion korrigieren"

#: functions/events.php:571
#: functions/events.php:576
msgid "Event date"
msgstr "Datum der Veranstaltung"

#: functions/events.php:572
#: functions/events.php:577
msgid "Event location"
msgstr "Ort"

#: functions/icalimport.php:105
msgid "More Information"
msgstr "Weitere Informationen"

#: functions/icalimport.php:122
msgid "Failed to import event"
msgstr "Import der Veranstaltung fehlgeschlagen"

#: functions/metaboxes.php:15
#: functions/options/class-sunflowersettingspage.php:108
msgid "Layout"
Expand Down Expand Up @@ -346,50 +350,78 @@ msgstr "Wähle SHIFT + ENTER, um Zwischenzeile zu verhindern"
msgid "Sunflower Settings"
msgstr "Sunflower-Einstellungen"

#: functions/options/class-sunflowereventsettingspage.php:70
#: functions/options/class-sunflowereventsettingspage.php:60
msgid "ICS Calendar Import"
msgstr "ICS Kalender Import"

#: functions/options/class-sunflowereventsettingspage.php:72
msgid "ICS calendar has been imported."
msgstr "ICS Kalender wurde importiert."

#: functions/options/class-sunflowereventsettingspage.php:73
msgid "new"
msgstr "neu"

#: functions/options/class-sunflowereventsettingspage.php:74
msgid "deleted"
msgstr "gelöscht"

#: functions/options/class-sunflowereventsettingspage.php:75
msgid "updated"
msgstr "aktualisiert"

#: functions/options/class-sunflowereventsettingspage.php:81
msgid "See all events (Frontend)"
msgstr "Alle Veranstaltungen auf der Webseite"

#: functions/options/class-sunflowereventsettingspage.php:82
msgid "Edit events (Backend)"
msgstr "Veranstaltungen bearbeiten (Backend)"

#: functions/options/class-sunflowereventsettingspage.php:87
msgid "Import calendars now"
msgstr "Kalender jetzt importieren"

#: functions/options/class-sunflowereventsettingspage.php:89
#: functions/options/class-sunflowereventsettingspage.php:106
msgid "Adjust geo marker for:"
msgstr "Marker-Position für diesen Ort anpassen:"

#: functions/options/class-sunflowereventsettingspage.php:90
#: functions/options/class-sunflowereventsettingspage.php:107
msgid "please choose"
msgstr "bitte wählen"

#: functions/options/class-sunflowereventsettingspage.php:106
#: functions/options/class-sunflowereventsettingspage.php:123
msgid "Delete geo data for this location"
msgstr "Geo-Daten für diesen Ort löschen"

#: functions/options/class-sunflowereventsettingspage.php:124
#: functions/options/class-sunflowereventsettingspage.php:141
msgid "load map"
msgstr "Kartendaten laden"

#: functions/options/class-sunflowereventsettingspage.php:153
#: functions/options/class-sunflowereventsettingspage.php:170
msgid "Description shown on the events page"
msgstr "Beschreibung für die Termineseite"

#: functions/options/class-sunflowereventsettingspage.php:161
#: functions/options/class-sunflowereventsettingspage.php:178
msgid "URLs of iCal calendars, one per row"
msgstr "URLs der iCal-Kalender, pro Zeile eine URL"

#: functions/options/class-sunflowereventsettingspage.php:169
#: functions/options/class-sunflowereventsettingspage.php:173
#: functions/options/class-sunflowereventsettingspage.php:186
#: functions/options/class-sunflowereventsettingspage.php:190
msgid "Rectify time zone"
msgstr "Zeitzone korrigieren"

#: functions/options/class-sunflowereventsettingspage.php:178
#: functions/options/class-sunflowereventsettingspage.php:182
#: functions/options/class-sunflowereventsettingspage.php:195
#: functions/options/class-sunflowereventsettingspage.php:199
msgid "Show overall map"
msgstr "Übersichtskarte zeigen"

#: functions/options/class-sunflowereventsettingspage.php:187
#: functions/options/class-sunflowereventsettingspage.php:191
#: functions/options/class-sunflowereventsettingspage.php:204
#: functions/options/class-sunflowereventsettingspage.php:208
msgid "Show events archive"
msgstr "Vergangene Veranstaltungen anzeigen"

#: functions/options/class-sunflowereventsettingspage.php:196
#: functions/options/class-sunflowereventsettingspage.php:213
msgid "Zoom-level of overall map"
msgstr "Zoomlevel für Übersichtskarte"

Expand Down Expand Up @@ -659,10 +691,8 @@ msgid "Share on Facebook "
msgstr "Auf Facebook teilen "

#: inc/template-tags.php:128
#, fuzzy
#| msgid "Share on Mastodon "
msgid "Share on LinkedIn "
msgstr "Auf Mastodon teilen "
msgstr "Auf LinkedIn teilen "

#: inc/template-tags.php:144
msgid "Share on Mastodon "
Expand Down Expand Up @@ -767,8 +797,8 @@ msgstr "Weiterlesen<span class=\"screen-reader-text\"> \"%s\"</span>"
msgid "none"
msgstr "keine"

#: template-parts/header-standard.php:41 template-parts/header-standard.php:44
#: template-parts/header-standard.php:156
#: template-parts/header-standard.php:40 template-parts/header-standard.php:41
#: template-parts/header-standard.php:44 template-parts/header-standard.php:156
#: template-parts/header-standard.php:159
msgid "Search"
msgstr "Suche"
Expand Down Expand Up @@ -847,9 +877,6 @@ msgstr ""
#~ msgid "Show and adjust map marker"
#~ msgstr "Zeige Karte und korrigiere Marker-Positon"

#~ msgid "delete map"
#~ msgstr "Karte nicht anzeigen"

#~ msgid "Import Images to Media"
#~ msgstr "Bilder in Mediathek importieren"

Expand Down
Loading