, parts: array} */ public function summary( string $lang ): array { $out = array( 'total' => 0, 'done' => 0, 'types' => array(), 'parts' => $this->parts_status( $lang ), ); $settings = $this->settings->get(); $counts = $this->translations->coverage_counts( $settings->post_types(), $settings->default_code(), $lang ); ksort( $counts ); // page, portfolio, post: pages first. foreach ( $counts as $post_type => $count ) { $type = get_post_type_object( $post_type ); $out['types'][ $post_type ] = array( 'label' => $type ? (string) $type->labels->name : $post_type, 'total' => $count['total'], 'done' => $count['done'], ); $out['total'] += $count['total']; $out['done'] += $count['done']; } return $out; } /** * Published default-language content with no version in $lang, pages first. * * @return WP_Post[] */ public function missing_posts( string $lang, int $limit = self::LIMIT ): array { $settings = $this->settings->get(); $ids = $this->translations->missing_ids( $settings->post_types(), $settings->default_code(), $lang, $limit ); if ( ! $ids ) { return array(); } _prime_post_caches( $ids, false, false ); return array_values( array_filter( array_map( 'get_post', $ids ) ) ); } /** * Header/footer parts the theme uses and whether $lang has its copy. * * @return array */ public function parts_status( string $lang ): array { if ( ! wp_is_block_theme() ) { return array(); } $out = array(); foreach ( $this->parts->used_parts() as $part ) { $out[] = array( 'slug' => $part->slug, 'title' => (string) $part->title, 'exists' => $this->parts->exists( TemplateParts::slug_for( $part->slug, $lang ) ), ); } return $out; } }