ACF\CLI

JsonCommand::get_post_typesprivateACF 6.8

Determines which item types to process.

Method of the class: JsonCommand{}

No Hooks.

Returns

Array. List of item type slugs.

Usage

// private - for code of main (parent) class only
$result = $this->get_post_types( $type_filter );
$type_filter(string|null)
The CLI type flag value.
Default: null

Changelog

Since 6.8 Introduced.

JsonCommand::get_post_types() code ACF 6.8.8

private function get_post_types( $type_filter = null ) {
	if ( $type_filter ) {
		if ( ! isset( self::TYPE_MAP[ $type_filter ] ) ) {
			WP_CLI::error(
				sprintf(
					"Unknown type '%s'.\n\n" .
					"Valid types:\n" .
					"  - field-group\n" .
					"  - post-type\n" .
					"  - taxonomy\n" .
					"  - options-page (ACF PRO only)\n\n" .
					'See: wp help acf json',
					$type_filter
				)
			);
		}

		$post_type = self::TYPE_MAP[ $type_filter ];

		if ( 'acf-ui-options-page' === $post_type && ! acf_is_pro() ) {
			WP_CLI::error(
				"Options pages require ACF PRO.\n\n" .
				"To sync options pages, you need:\n" .
				"  - ACF PRO license\n" .
				"  - Active license key\n\n" .
				'See: https://www.advancedcustomfields.com/pro/'
			);
		}

		return array( $post_type );
	}

	$post_types = acf_get_internal_post_types();

	// Remove options pages from non-PRO installs.
	if ( ! acf_is_pro() ) {
		$post_types = array_filter(
			$post_types,
			function ( $pt ) {
				return 'acf-ui-options-page' !== $pt;
			}
		);
	}

	return array_values( $post_types );
}