<?php
/**
 * Post Types helper.
 *
 * A small shared helper for modules that operate on "content" post types
 * (the editor panels: AI Visibility Check, Meta Generator, Schema, etc.).
 * Returns the set of public, UI-visible post types, with `post` and `page`
 * as the sensible default. Filterable so site owners can extend it.
 *
 * @package Platform\Helm\Core
 */

declare( strict_types = 1 );

namespace Platform\Helm\Core;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

final class PostTypes {

	/**
	 * Content post types the editor-side modules attach to.
	 *
	 * @return string[]
	 */
	public static function content(): array {
		$types = get_post_types( [ 'public' => true, 'show_ui' => true ], 'names' );
		unset( $types['attachment'] );

		// Sensible default if something odd happens.
		if ( empty( $types ) ) {
			$types = [ 'post' => 'post', 'page' => 'page' ];
		}

		/**
		 * Filter the content post types Helm editor modules attach to.
		 *
		 * @param string[] $types
		 */
		$filtered = apply_filters( 'platform_helm_content_post_types', array_values( $types ) );

		return is_array( $filtered ) ? array_values( array_filter( $filtered, 'is_string' ) ) : [ 'post' ];
	}
}
