'post_type', 'operator' => '==', 'value' => $post_type, ]]; } return $group; } public function load_post_types(array $field):array { $field['choices'] = wp_list_pluck(get_post_types(['public' => true], 'objects'), 'label', 'name'); return $field; } public function load_business_types(array $field):array { $field['choices'] = $this->get_json_data('data/business-type.json'); return $field; } public function load_organization_types(array $field):array { $field['choices'] = $this->get_json_data('data/organization-type.json'); return $field; } private function get_json_data(string $relpath):array { $path = Plugin::instance()->get_path() . ltrim($relpath, '/'); if (!str_ends_with($path, '.json') || !file_exists($path)) return []; $data = json_decode(file_get_contents($path), true); return is_array($data) ? $data : []; } } Fields::instance();