1024 && $i < count($units) - 1; $i++) { $bytes /= 1024; } return round($bytes, $precision) . ' ' . $units[$i]; } /** * Verify nonce for security */ public static function verify_nonce($nonce_name, $action) { return isset($_POST[$nonce_name]) && wp_verify_nonce($_POST[$nonce_name], $action); } /** * Check if user can manage options */ public static function current_user_can_manage() { return current_user_can('manage_options'); } /** * Redirect with message */ public static function redirect_with_message($message, $page = 'tigerstyle-heat') { wp_redirect(add_query_arg(array( 'page' => $page, 'message' => $message ), admin_url('admin.php'))); exit; } /** * Get option with prefix */ public static function get_option($option_name, $default = false) { return get_option('tigerstyle_' . $option_name, $default); } /** * Update option with prefix */ public static function update_option($option_name, $value) { return update_option('tigerstyle_' . $option_name, $value); } /** * Parse business days from shorthand to Schema.org format */ public static function parse_business_days($days_string) { $day_mapping = array( 'Mo' => 'Monday', 'Tu' => 'Tuesday', 'We' => 'Wednesday', 'Th' => 'Thursday', 'Fr' => 'Friday', 'Sa' => 'Saturday', 'Su' => 'Sunday' ); // Handle ranges like "Mo-Fr" if (strpos($days_string, '-') !== false) { $parts = explode('-', $days_string); if (count($parts) === 2) { $start_day = trim($parts[0]); $end_day = trim($parts[1]); $all_days = array_keys($day_mapping); $start_index = array_search($start_day, $all_days); $end_index = array_search($end_day, $all_days); if ($start_index !== false && $end_index !== false) { $result = array(); for ($i = $start_index; $i <= $end_index; $i++) { $result[] = $day_mapping[$all_days[$i]]; } return $result; } } } // Handle individual days $days = array_map('trim', explode(',', $days_string)); $result = array(); foreach ($days as $day) { if (isset($day_mapping[$day])) { $result[] = $day_mapping[$day]; } } return $result; } /** * Log debug information */ public static function debug_log($message, $data = null) { if (WP_DEBUG_LOG) { if ($data !== null) { $message .= ' Data: ' . print_r($data, true); } error_log('[TigerStyle Heat] ' . $message); } } }