load_pod(['name' => 'lit_person'])) { $api->delete_pod(['name' => 'lit_person'], false, true); } echo "deleted\n"; return; } if ($action === 'fixture') { // Etappe 3b fixture pod (ruling Q1): its own type, so no smoke deletes the fixture persons. if (! $api->load_pod(['name' => 'lit_fixture_person'])) { $api->save_pod([ 'name' => 'lit_fixture_person', 'label' => '[Fixture] Personen', 'label_singular' => '[Fixture] Person', 'type' => 'post_type', 'storage' => 'meta', 'public' => 1, 'show_ui' => 1, ]); } $fixtureFields = [ ['name' => 'role', 'label' => 'Funktion', 'type' => 'text'], [ 'name' => 'level', 'label' => 'Stufe', 'type' => 'pick', 'pick_object' => 'custom-simple', 'pick_custom' => "junior|Junior\nsenior|Senior", ], [ 'name' => 'mentor', 'label' => 'Mentor', 'type' => 'pick', 'pick_object' => 'post_type', 'pick_val' => 'lit_fixture_person', 'pick_format_type' => 'single', ], ]; foreach ($fixtureFields as $field) { if (! $api->load_field(['pod' => 'lit_fixture_person', 'name' => $field['name']])) { $api->save_field(array_merge(['pod' => 'lit_fixture_person'], $field)); } } $existing = static function (string $title): int { $found = get_posts([ 'post_type' => 'lit_fixture_person', 'post_status' => 'any', 'title' => $title, 'fields' => 'ids', 'numberposts' => 1, ]); return (int) ($found[0] ?? 0); }; $erika = $existing('[Fixture 3b] Erika Muster') ?: (int) pods('lit_fixture_person')->add([ 'post_title' => '[Fixture 3b] Erika Muster', 'post_content' => '

Beitragsinhalt der Fixture-Person Erika Muster.

', 'post_status' => 'publish', 'role' => 'Geschäftsführung', 'level' => 'senior', ]); $max = $existing('[Fixture 3b] Max Beispiel') ?: (int) pods('lit_fixture_person')->add([ 'post_title' => '[Fixture 3b] Max Beispiel', 'post_content' => '

Beitragsinhalt der Fixture-Person Max Beispiel.

', 'post_status' => 'publish', 'role' => 'Entwicklung', 'level' => 'junior', 'mentor' => $erika, ]); echo "persons {$erika} {$max}\n"; return; } if (! $api->load_pod(['name' => 'lit_person'])) { $api->save_pod([ 'name' => 'lit_person', 'label' => 'Personen', 'label_singular' => 'Person', 'type' => 'post_type', 'storage' => 'meta', 'public' => 1, 'show_ui' => 1, ]); } $fields = [ ['name' => 'role', 'label' => 'Funktion', 'type' => 'text', 'required' => 1], [ 'name' => 'level', 'label' => 'Stufe', 'type' => 'pick', 'pick_object' => 'custom-simple', 'pick_custom' => "junior|Junior\nsenior|Senior", ], [ 'name' => 'mentor', 'label' => 'Mentor', 'type' => 'pick', 'pick_object' => 'post_type', 'pick_val' => 'lit_person', 'pick_format_type' => 'single', ], ]; foreach ($fields as $field) { $api->save_field(array_merge(['pod' => 'lit_person'], $field)); } echo "created\n";