public || !$type->_builtin); } function get_post_type_options() { $result = []; foreach (get_post_types([], 'objects') as $type) { if (!is_catalogable($type->name)) continue; $result[] = ['slug' => $type->name, 'label' => $type->labels->name, 'public' => (bool) $type->public, 'singular_label' => $type->labels->singular_name, 'published_count' => Languages\published_count($type->name), 'tracked' => in_array($type->name, get_tracked_post_types(), true)]; } return $result; } function update_tracking($types, $add_only = false) { if ($add_only) $types = array_merge(get_tracked_post_types(), $types); $types = array_values(array_unique(array_filter((array) $types, __NAMESPACE__ . '\\is_catalogable'))); update_option(TRACKING_OPTION, $types, false); return $types; } function get_post_type_catalog($post_type) { if (!is_catalogable($post_type) || !in_array($post_type, get_tracked_post_types(), true)) return []; return Languages\cached('free-catalog|' . $post_type, static function () use ($post_type) { $taxonomies = Languages\taxonomy_catalog($post_type); $type = get_post_type_object($post_type); return ['slug' => $post_type, 'label' => $type->labels->name, 'public' => (bool) $type->public, 'published_count' => Languages\published_count($post_type), 'taxonomies' => $taxonomies, 'meta_fields' => [], 'acf_fields' => []]; }); } function get_catalog($requested = []) { $tracked = get_tracked_post_types(); $types = $requested ? array_intersect($tracked, (array) $requested) : $tracked; $result = ['schema_version' => 1, 'generated_at' => gmdate('c'), 'tracked_post_types' => $tracked, 'post_types' => []]; foreach ($types as $type) $result['post_types'][$type] = get_post_type_catalog($type); return $result; } function rebuild() { return get_catalog(); }