952e98c217
* Move the `create_function()` code into a file that's only loaded, and into a test that's only run, on PHP <= 7.2 to avoid deprecated warnings in 7.2+. * Convert the test skipping into a failure if the GlotPress locale file cannot be downloaded. * Ensure `test_exceptions` fails if an exception is not thrown. * Docs improvements See #41562, #40109 git-svn-id: https://develop.svn.wordpress.org/trunk@41730 602fd350-edb4-49c9-b593-d223f7449a82
17 lines
381 B
PHP
17 lines
381 B
PHP
<?php
|
|
|
|
/**
|
|
* Legacy plural form function.
|
|
*
|
|
* @param int $nplurals
|
|
* @param string $expression
|
|
*/
|
|
function tests_make_plural_form_function( $nplurals, $expression ) {
|
|
$expression = str_replace( 'n', '$n', $expression );
|
|
$func_body = "
|
|
\$index = (int)($expression);
|
|
return (\$index < $nplurals)? \$index : $nplurals - 1;";
|
|
|
|
return create_function( '$n', $func_body );
|
|
}
|