Files
coraislovely-codeandClaude Fable 5 df577938aa Keep legacy-named translation files loading
No language pack ever loaded under the old 'comiceasel' domain, but a site
that compiled its own comiceasel-{locale}.mo did load it, and the rename
would have dropped that translation without a word. A load_textdomain_mofile
filter answers with the legacy filename when nothing exists under the new
one, looking both in wp-content/languages/plugins and in the directory
WordPress asked about, since 6.7 names the registered domain directory rather
than the one the file is in.

The explicit load_plugin_textdomain() call is kept and commented for the same
reason: on WordPress before 6.7 nothing else requests a translation file by
name, so it is the only place the filter can intervene.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-13 18:11:05 -04:00

60 lines
1.8 KiB
PHP

<?php
/**
* PHPUnit bootstrap for Comic Easel.
*
* WordPress is not loaded. See tests/stubs.php for the rationale and for the stubs the
* tests depend on.
*/
// Plugin files guard themselves with `if (!defined('ABSPATH')) exit;`, so this has to be
// defined before any of them are required.
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', dirname( __DIR__ ) . '/' );
}
if ( ! defined( 'ARRAY_N' ) ) {
define( 'ARRAY_N', 'ARRAY_N' );
}
// WordPress points this at wp-content/languages. ceo_legacy_textdomain_mofile() looks under it
// for translations a site installed itself, so the tests aim it at a directory they can write to.
if ( ! defined( 'WP_LANG_DIR' ) ) {
define( 'WP_LANG_DIR', sys_get_temp_dir() . '/ce-wp-lang-' . getmypid() );
}
define( 'CE_PLUGIN_DIR', dirname( __DIR__ ) );
require_once __DIR__ . '/stubs.php';
/**
* ceo_pluginfo() is the plugin's own config accessor. It lives in comiceasel.php, which
* does far too much at load time to require in a unit test, so it is stubbed here and
* driven from CE_Test_State::$pluginfo.
*/
if ( ! function_exists( 'ceo_pluginfo' ) ) {
function ceo_pluginfo( $which = null ) {
if ( null === $which ) {
return CE_Test_State::$pluginfo;
}
return array_key_exists( $which, CE_Test_State::$pluginfo ) ? CE_Test_State::$pluginfo[ $which ] : '';
}
}
/**
* Plugin-local navigation helpers, stubbed so the archive listings can be called without
* dragging in functions/navigation.php and its query dependencies. Not under test here.
*/
if ( ! function_exists( 'ceo_get_last_comic' ) ) {
function ceo_get_last_comic( $in_same_chapter = false ) {
return null;
}
}
if ( ! function_exists( 'ceo_get_first_comic' ) ) {
function ceo_get_first_comic( $in_same_chapter = false ) {
return null;
}
}
require_once __DIR__ . '/CE_TestCase.php';