'https://aumcreate.com/manual/aumnexcart', 'zh-hans' => 'https://aumcreate.com/zh-hans/manual/aumnexcart', 'zh-hant' => 'https://aumcreate.com/zh-hant/manual/aumnexcart', 'ja' => 'https://aumcreate.com/ja/manual/aumnexcart', ); /** * WordPress admin language → which of those four to send them to. * * 🔴 **The language of the prose and the language of the screenshots are two different things.** * This plugin ships one translation, `zh_CN` (there is no `zh_TW` and no `ja` in `languages/`, * and WordPress does not fall `zh_TW` back to `zh_CN`). So a Traditional Chinese or Japanese * administrator is reading an **English admin screen**, and the manual's zh-hant and ja pages * are translations of the prose carrying the **English** screenshots — which is what matches * what is on their screen. Sending them to the English page would be worse; sending `zh_TW` * to zh-hans would be a guess. */ private const WP_TO_SITE = array( 'zh_CN' => 'zh-hans', 'zh_TW' => 'zh-hant', 'zh_HK' => 'zh-hant', 'ja' => 'ja', ); private const FALLBACK = 'en'; /** * Which page this administrator gets. * * `get_user_locale()` rather than `get_locale()`: the Plugins screen is read in whatever * language **that administrator** set for themselves, which can differ from the site's. */ private static function locale(): string { return self::WP_TO_SITE[ get_user_locale() ] ?? self::FALLBACK; } /** The URL for this administrator, or '' when the page is not published in their language. */ public static function url(): string { return self::URLS[ self::locale() ] ?? ''; } /** The row action on the Plugins screen. Adds nothing while the manual is unpublished. */ public static function action_link( array $links ): array { $url = self::url(); if ( '' === $url ) { return $links; } $links[] = sprintf( '%s', esc_url( $url ), esc_html__( 'Manual', 'aumnexcart' ) ); return $links; } }