Status slug => status slug. */ public static function selectable_statuses(): array { $statuses = get_post_stati(); if ( ! is_array( $statuses ) ) { return array( self::FALLBACK => self::FALLBACK ); } foreach ( self::EXCLUDED as $excluded ) { unset( $statuses[ $excluded ] ); } return $statuses; } /** * Checking whether a status slug may be used. * * @param string $status Status slug. * * @return bool Whether the status is registered and permitted. */ public static function is_selectable( string $status ): bool { return array_key_exists( $status, self::selectable_statuses() ); } /** * Resolving the post status for a Kordiam status. * * @param int $kordiam_status_id Kordiam status ID. * * @return string A registered post status; never an empty string or null. */ public static function wp_status_for( int $kordiam_status_id ): string { $status = self::wp_status_for_key( (string) $kordiam_status_id ); return '' === $status ? self::FALLBACK : $status; } /** * Resolving the post status for a named mapping. * * Returns '' rather than 'draft' when unmapped, so an unmapped 'removed' does not * unpublish a live post. * * @param string $mapping_key Kordiam status ID as a string, or 'removed'. * * @return string A registered post status, or an empty string when none is configured. */ public static function wp_status_for_key( string $mapping_key ): string { $configured = Options::get_string( 'status_import_' . $mapping_key ); // Both 'No Status' and 'No status' are stored. if ( '' === $configured || 0 === strcasecmp( self::NO_STATUS, $configured ) ) { return ''; } return self::is_selectable( $configured ) ? $configured : ''; } /** * Checking whether stories in a Kordiam status should be skipped entirely. * * @param int $kordiam_status_id Kordiam status ID. * * @return bool Whether the site is configured not to import them. */ public static function is_import_disabled( int $kordiam_status_id ): bool { return Options::is_do_not_import( self::option_key( $kordiam_status_id ) ); } /** * Checking whether the status itself should be left alone (story still imported). * * @param int $kordiam_status_id Kordiam status ID. * * @return bool Whether status syncing is switched off for this status. */ public static function is_status_sync_disabled( int $kordiam_status_id ): bool { return Options::is_no_sync( self::option_key( $kordiam_status_id ) ); } /** * Building the option key holding a status mapping. * * @param int $kordiam_status_id Kordiam status ID. * * @return string Unprefixed option key. */ public static function option_key( int $kordiam_status_id ): string { return 'status_import_' . $kordiam_status_id; } }