$model * @param int $post_id * @param string $subtree_id * @return array */ protected function analyze( array $model, int $post_id, string $subtree_id ): array { $types = (array) $model['widget_types']; $findings = array(); foreach ( Design_Model::FURNITURE_WIDGETS as $widget ) { $count = (int) ( $types[ $widget ] ?? 0 ); if ( $count < 4 ) { continue; } $per_row = $model['row_count'] > 0 ? $count / (int) $model['row_count'] : 0; $findings[] = array( 'type' => 'repeated_component', 'widget' => $widget, 'count' => $count, 'per_row' => round( $per_row, 2 ), 'severity' => $count >= 8 ? 'medium' : 'low', 'message' => sprintf( /* translators: 1: widget name, 2: count */ __( 'The %1$s widget appears %2$d times.', 'acrossai-abilities-manager' ), $widget, $count ), ); } return array( 'findings' => $findings, 'recommendations' => array_map( static fn( array $f ): array => array( 'widget' => $f['widget'], 'suggestion' => 'button' === $f['widget'] ? __( 'Repeating the same call to action in every section dilutes it. Keep the strongest one or two and let the rest be links.', 'acrossai-abilities-manager' ) : __( 'Consider whether every instance is earning its place, or whether a native widget expresses the same thing once.', 'acrossai-abilities-manager' ), ), $findings ), 'score' => max( 0, 100 - count( $findings ) * 15 ), 'extras' => array( 'widget_types' => $types ), ); } }