summary_json ) ? (string) $row->summary_json : ''; if ( '' === $raw ) { return array(); } $decoded = json_decode( $raw, true ); return is_array( $decoded ) ? $decoded : array(); }; $status_label = static function ( string $status ): string { $map = array( 'draft' => __( 'Draft', '4wp-drive' ), 'publish' => __( 'Published', '4wp-drive' ), 'pending' => __( 'Pending', '4wp-drive' ), 'private' => __( 'Private', '4wp-drive' ), 'future' => __( 'Scheduled', '4wp-drive' ), 'trash' => __( 'Trash', '4wp-drive' ), ); return $map[ $status ] ?? ( $status !== '' ? $status : '—' ); }; $tax_label = static function ( string $taxonomy ): string { if ( function_exists( 'get_taxonomy' ) ) { $obj = get_taxonomy( $taxonomy ); if ( $obj && ! empty( $obj->labels->name ) ) { return (string) $obj->labels->name; } } $map = array( 'category' => __( 'Categories', '4wp-drive' ), 'post_tag' => __( 'Tags', '4wp-drive' ), ); return $map[ $taxonomy ] ?? $taxonomy; }; $summary_rows = static function ( array $summary ) use ( $tax_label ): array { $rows = array(); $chars = isset( $summary['chars'] ) ? (int) $summary['chars'] : 0; $images = isset( $summary['images'] ) ? (int) $summary['images'] : 0; $rows[] = array( 'label' => __( 'Chars', '4wp-drive' ), 'value' => (string) number_format_i18n( $chars ), ); $rows[] = array( 'label' => __( 'Images', '4wp-drive' ), 'value' => (string) number_format_i18n( $images ), ); if ( ! empty( $summary['featured'] ) ) { $rows[] = array( 'label' => __( 'Featured', '4wp-drive' ), 'value' => __( 'yes', '4wp-drive' ), ); } $tax = isset( $summary['taxonomies'] ) && is_array( $summary['taxonomies'] ) ? $summary['taxonomies'] : array(); foreach ( $tax as $taxonomy => $names ) { if ( ! is_array( $names ) || empty( $names ) ) { continue; } if ( function_exists( 'get_taxonomy' ) ) { $obj = get_taxonomy( (string) $taxonomy ); if ( $obj && empty( $obj->public ) ) { continue; } } $rows[] = array( 'label' => $tax_label( (string) $taxonomy ), 'value' => implode( ', ', array_map( 'strval', $names ) ), ); } return $rows; }; ?>