__( 'Database collation', 'rooster-lms' ), 'test' => array( $this, 'run' ), ); return $tests; } public function run(): array { $site = Collation::site(); $server = Collation::server(); $off = Collation::rooster_tables_off( $site ); $best = Collation::best_available(); $out = array( 'label' => '', 'status' => 'good', 'badge' => array( 'label' => __( 'Rooster LMS', 'rooster-lms' ), 'color' => 'blue', ), 'description' => '', 'actions' => '', 'test' => self::TEST, ); if ( array() !== $off ) { $out['label'] = __( 'Rooster LMS tables differ from the site’s database collation', 'rooster-lms' ); $out['status'] = 'critical'; $out['description'] = '
' . esc_html( sprintf( /* translators: 1: number of tables, 2: the site's collation, 3: the first differing table's name. */ _n( '%1$d Rooster LMS table uses another collation than the site’s %2$s (%3$s): a query that compares its text with another table fails with “Illegal mix of collations”.', '%1$d Rooster LMS tables use another collation than the site’s %2$s (first: %3$s): a query that compares their text with another table fails with “Illegal mix of collations”.', count( $off ), 'rooster-lms' ), count( $off ), $site, $off[0] ) ) . '
'; $out['actions'] = 'wp rooster-lms collation align
' . esc_html( sprintf( /* translators: 1: the site's collation, 2: the server version, 3: the collation available, 4: the Unicode version it implements. */ __( 'The site’s tables use %1$s; this server (%2$s) offers %3$s: Unicode %4$s, accent- and case-insensitive, so Greek with or without tonos matches and every script sorts right. To use it, set DB_COLLATE in wp-config.php to %3$s, then convert every table once, after a backup.', 'rooster-lms' ), $site, $server, $best, Collation::MODERN[ $best ] ) ) . '
'; $out['actions'] = 'define( \'DB_COLLATE\', \'' . esc_html( $best ) . '\' );wp rooster-lms collation convert --to=' . esc_html( $best ) . ' --all-tables
' . esc_html( sprintf( /* translators: 1: the site's collation, 2: the server version. */ __( 'Rooster LMS’s tables use the site’s collation %1$s (server %2$s); accent- and case-insensitive matching and Unicode sorting follow it.', 'rooster-lms' ), $site, $server ) ) . '
'; return $out; } }