Skip to content

Commit e751a6d

Browse files
Wolfgang Tischerbgermann
authored andcommitted
FINAL FIX: Restore simple, working timezone solution
🐛 Timezone Fix - Back to Basics: - Restore simple, working solution that was functional before - Simple fallback with strtotime() for edge cases This restores the originally working timezone handling that correctly processes form start/end times in local timezone.
1 parent 059e9f7 commit e751a6d

4 files changed

Lines changed: 161 additions & 530 deletions

File tree

FormSettings.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,13 @@ private function convertFormatToTime($formatted_date)
6767
return 0;
6868
}
6969

70-
try {
71-
// WordPress-Zeitzone verwenden
72-
$timezone = new \DateTimeZone(get_option('timezone_string') ?: 'UTC');
73-
$dt = \DateTime::createFromFormat('d/m/Y H:i', $formatted_date, $timezone);
74-
if ($dt !== false) {
75-
return $dt->getTimestamp();
76-
}
77-
} catch (\Exception $e) {
78-
// Fallback: Parse als lokale Zeit und konvertiere zu UTC
79-
$time = str_replace('/', '.', $formatted_date);
80-
$timestamp = strtotime($time);
81-
if ($timestamp !== false) {
82-
// Korrigiere für WordPress-Zeitzone
83-
return $timestamp - (get_option('gmt_offset') * 3600);
84-
}
70+
// Einfache Lösung: Verwende strtotime direkt mit lokaler Zeit
71+
$time = str_replace('/', '.', $formatted_date);
72+
$timestamp = strtotime($time);
73+
74+
if ($timestamp !== false) {
75+
// Gib lokalen Timestamp zurück - wird mit current_time('timestamp') verglichen
76+
return $timestamp;
8577
}
8678

8779
return 0;

lib_functions.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,23 @@ function cforms2_start_session() {
3737
}
3838
}
3939

40-
/**
41-
* Optimized session handling - only start sessions when cforms is actually used
42-
* Improves performance by avoiding unnecessary session starts on all pages
43-
*/
4440
function cforms2_conditional_start_session() {
4541
global $post;
4642

47-
// Check if current page/post contains cforms shortcode
4843
$needs_session = false;
4944

5045
if ($post && has_shortcode($post->post_content, 'cforms')) {
5146
$needs_session = true;
5247
}
5348

54-
// Check for multi-part forms or AJAX submissions
5549
if (isset($_POST['cforms_form']) || isset($_GET['cforms_form'])) {
5650
$needs_session = true;
5751
}
5852

59-
// Check for widget usage (simplified check)
6053
if (is_active_widget(false, false, 'cforms2_widget')) {
6154
$needs_session = true;
6255
}
6356

64-
// Only start session if actually needed
6557
if ($needs_session) {
6658
cforms2_start_session();
6759
}
@@ -107,7 +99,6 @@ function cforms2_check_access_priv() {
10799
$err = '<h2>' . __('cforms error', 'cforms2') . '</h2><div class="updated fade" id="message"><p>' . __('You do not have the proper privileges to access this page.', 'cforms2') . '</p></div></div>';
108100
die($err);
109101
}
110-
111102
}
112103

113104
/**
@@ -165,8 +156,7 @@ function cforms2_enqueue_scripts() {
165156
wp_enqueue_style('cforms2-admin-modern', plugin_dir_url(__FILE__) . 'admin-modern.css', array(), CFORMS2_VERSION);
166157
}
167158

168-
// Load mobile responsive styles
169-
wp_enqueue_style('cforms2-mobile', plugin_dir_url(__FILE__) . 'mobile-responsive.css', array(), CFORMS2_VERSION);
159+
// Frontend mobile styles removed per user request - only admin changes wanted
170160

171161
// Load JavaScript
172162
wp_register_script('cforms2', plugin_dir_url(__FILE__) . 'js/cforms.js', array('jquery'), CFORMS2_VERSION, true);
@@ -236,6 +226,9 @@ function cforms2_admin_enqueue_scripts() {
236226

237227
// Always load modern admin styles in admin area
238228
wp_enqueue_style('cforms2-admin-modern', plugin_dir_url(__FILE__) . 'admin-modern.css', array(), CFORMS2_VERSION);
229+
230+
// Load mobile admin styles only for actual mobile devices
231+
wp_enqueue_style('cforms2-mobile-admin', plugin_dir_url(__FILE__) . 'mobile-admin.css', array('cforms2-admin-modern'), CFORMS2_VERSION);
239232

240233
}
241234

mobile-admin.css

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/**
2+
* Mobile Admin Styles for cforms2
3+
*/
4+
5+
@media (max-width: 782px) {
6+
/* Form Navigation */
7+
.chgformbox {
8+
display: block !important;
9+
width: 100% !important;
10+
background-color: #f8f9fa !important;
11+
border-radius: 8px !important;
12+
padding: 12px !important;
13+
margin-bottom: 16px !important;
14+
box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
15+
}
16+
17+
.chgformbox td {
18+
display: block !important;
19+
width: 100% !important;
20+
padding: 0 !important;
21+
}
22+
23+
.chgformbox .chgL {
24+
margin-bottom: 12px !important;
25+
text-align: center !important;
26+
}
27+
28+
.chgformbox .chgL select {
29+
width: 100% !important;
30+
min-height: 44px !important;
31+
font-size: 16px !important;
32+
padding: 10px !important;
33+
border-radius: 6px !important;
34+
border: 1px solid #ddd !important;
35+
margin-bottom: 8px !important;
36+
}
37+
38+
.chgformbox .chgL .go {
39+
width: 100% !important;
40+
min-height: 44px !important;
41+
font-size: 16px !important;
42+
padding: 10px 16px !important;
43+
border-radius: 6px !important;
44+
background-color: #0073aa !important;
45+
color: white !important;
46+
border: none !important;
47+
}
48+
49+
.chgformbox .chgM {
50+
text-align: center !important;
51+
margin-top: 12px !important;
52+
}
53+
54+
.chgformbox .chgM input {
55+
margin: 4px 2px !important;
56+
min-width: 44px !important;
57+
min-height: 44px !important;
58+
padding: 8px !important;
59+
font-size: 14px !important;
60+
border-radius: 6px !important;
61+
border: 1px solid #ddd !important;
62+
background-color: white !important;
63+
}
64+
65+
.chgformbox .chgM input.chgbuttonhi {
66+
background-color: #0073aa !important;
67+
color: white !important;
68+
border-color: #0073aa !important;
69+
}
70+
71+
/* Helpful tip for table area */
72+
.cf-content::before {
73+
content: "💡 Tipp: Gerät drehen (Querformat) oder herauszoomen für vollständige Tabelle" !important;
74+
display: block !important;
75+
background: #e7f3ff !important;
76+
border: 1px solid #b3d9ff !important;
77+
padding: 12px !important;
78+
text-align: center !important;
79+
font-size: 14px !important;
80+
margin-bottom: 12px !important;
81+
border-radius: 6px !important;
82+
color: #0066cc !important;
83+
font-weight: normal !important;
84+
}
85+
86+
/* Action buttons */
87+
#cf_actions {
88+
position: sticky !important;
89+
bottom: 0 !important;
90+
background-color: white !important;
91+
border-top: 1px solid #ddd !important;
92+
padding: 8px !important;
93+
z-index: 100 !important;
94+
width: 100% !important;
95+
box-sizing: border-box !important;
96+
}
97+
98+
#cf_actions input {
99+
margin: 2px !important;
100+
font-size: 12px !important;
101+
padding: 6px 8px !important;
102+
}
103+
104+
/* Form options tables */
105+
.form-table,
106+
table.form-table,
107+
.cformsoptions table,
108+
.cf-content table {
109+
width: 100% !important;
110+
max-width: 100% !important;
111+
table-layout: fixed !important;
112+
box-sizing: border-box !important;
113+
}
114+
115+
.form-table tr,
116+
.form-table td,
117+
.form-table th {
118+
width: 100% !important;
119+
display: block !important;
120+
box-sizing: border-box !important;
121+
}
122+
123+
.form-table .obL,
124+
.form-table th {
125+
text-align: left !important;
126+
font-weight: bold !important;
127+
margin-bottom: 8px !important;
128+
}
129+
130+
.form-table input[type="text"],
131+
.form-table input[type="email"],
132+
.form-table input[type="url"],
133+
.form-table input[type="number"],
134+
.form-table input[type="date"],
135+
.form-table input[type="time"],
136+
.form-table select,
137+
.form-table textarea {
138+
width: 100% !important;
139+
max-width: 100% !important;
140+
box-sizing: border-box !important;
141+
min-height: 44px !important;
142+
font-size: 16px !important;
143+
padding: 12px !important;
144+
}
145+
146+
.form-table textarea {
147+
min-height: 120px !important;
148+
resize: vertical !important;
149+
}
150+
}

0 commit comments

Comments
 (0)