posts will be published immediately fixed

This commit is contained in:
2026-02-08 17:56:50 -05:00
parent 8aee2bf813
commit 7953bd07f7
2 changed files with 38 additions and 8 deletions

View File

@@ -3,8 +3,10 @@ from __future__ import annotations
import json
import subprocess
from dataclasses import dataclass
from datetime import timedelta, timezone
from pathlib import Path
from typing import Dict, List, Optional
from zoneinfo import ZoneInfo
from .errors import WordPressError
@@ -78,6 +80,26 @@ class WordPressCLI:
except ValueError as exc:
raise WordPressError(f"Invalid tag id from wp cli: {output}") from exc
def get_timezone(self):
tz_name = self._run(
["wp", "option", "get", "timezone_string"],
capture_output=True,
).stdout.strip()
if tz_name and tz_name.upper() != "UTC":
try:
return ZoneInfo(tz_name)
except Exception:
pass
offset_value = self._run(
["wp", "option", "get", "gmt_offset"],
capture_output=True,
).stdout.strip()
try:
offset = float(offset_value)
except ValueError:
offset = 0.0
return timezone(timedelta(hours=offset))
def create_category(self, name: str, parent: int) -> int:
result = self._run(
[