commit 45255b2c80236f2188e7294bf520b60ca04c5cb9 Author: Jörg Lohrer Date: Sat Mar 22 06:42:17 2025 +0100 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/import.php b/import.php new file mode 100644 index 0000000..dae09b8 --- /dev/null +++ b/import.php @@ -0,0 +1,42 @@ +text($content_md); + +$data = [ + 'title' => $yaml['name'] ?? 'Kein Titel', + 'content' => $html, + 'status' => 'publish', + 'excerpt' => $yaml['description'] ?? '', + 'slug' => $yaml['url'] ?? '', +]; + +$response = wp_rest_post($data); +echo "\n✅ Beitrag ID: " . ($response['id'] ?? 'Fehler'); + +function wp_rest_post($data) { + $url = 'http://markdownimport.local/wp-json/wp/v2/posts'; + $username = 'wpadmin'; + $password = 'CZOm Nsa4 Gptt HS8c UVbl qSuK'; + $auth = base64_encode("$username:$password"); + + $options = [ + 'http' => [ + 'method' => 'POST', + 'header' => "Authorization: Basic $auth\r\nContent-Type: application/json\r\n", + 'content' => json_encode($data), + ] + ]; + $context = stream_context_create($options); + $result = file_get_contents($url, false, $context); + return json_decode($result, true); +} diff --git a/lib/Parsedown.php b/lib/Parsedown.php new file mode 100644 index 0000000..c41f499 --- /dev/null +++ b/lib/Parsedown.php @@ -0,0 +1,6 @@ +' . nl2br(htmlspecialchars($text)) . '

'; + } +} diff --git a/lib/spyc.php b/lib/spyc.php new file mode 100644 index 0000000..1611bc2 --- /dev/null +++ b/lib/spyc.php @@ -0,0 +1,22 @@ +