| @@ -8,15 +8,33 @@ | ||
| 8 | 8 | * |
| 9 | 9 | * @since 1.6 |
| 10 | 10 | */ |
| 11 | 11 | class PLL_Admin_Strings { |
| 12 | - protected static $strings = array(); // strings to translate | |
| 13 | - protected static $default_strings; // default strings to register | |
| 12 | + /** | |
| 13 | + * Stores the strings to translate. | |
| 14 | + * | |
| 15 | + * @var array { | |
| 16 | + * @type string $name A unique name for the string. | |
| 17 | + * @type string $string The actual string to translate. | |
| 18 | + * @type string $context The group in which the string is registered. | |
| 19 | + * @type bool $multiline Whether the string table should display a multiline textarea or a single line input. | |
| 20 | + * } | |
| 21 | + */ | |
| 22 | + protected static $strings = array(); | |
| 14 | 23 | |
| 15 | 24 | /** |
| 25 | + * The strings to register by default. | |
| 26 | + * | |
| 27 | + * @var string[]|null | |
| 28 | + */ | |
| 29 | + protected static $default_strings; | |
| 30 | + | |
| 31 | + /** | |
| 16 | 32 | * Add filters |
| 17 | 33 | * |
| 18 | 34 | * @since 1.6 |
| 35 | + * | |
| 36 | + * @return void | |
| 19 | 37 | */ |
| 20 | 38 | public static function init() { |
| 21 | 39 | // default strings translations sanitization |
| 22 | 40 | add_filter( 'pll_sanitize_string_translation', array( __CLASS__, 'sanitize_string_translation' ), 10, 2 ); |
| @@ -30,16 +48,11 @@ | ||
| 30 | 48 | * @param string $name A unique name for the string |
| 31 | 49 | * @param string $string The string to register |
| 32 | 50 | * @param string $context Optional, the group in which the string is registered, defaults to 'polylang' |
| 33 | 51 | * @param bool $multiline Optional, whether the string table should display a multiline textarea or a single line input, defaults to single line |
| 52 | + * @return void | |
| 34 | 53 | */ |
| 35 | 54 | public static function register_string( $name, $string, $context = 'Polylang', $multiline = false ) { |
| 36 | - // Backward compatibility with Polylang older than 1.1 | |
| 37 | - if ( is_bool( $context ) ) { | |
| 38 | - $multiline = $context; | |
| 39 | - $context = 'Polylang'; | |
| 40 | - } | |
| 41 | - | |
| 42 | 55 | if ( $string && is_scalar( $string ) ) { |
| 43 | 56 | self::$strings[ md5( $string ) ] = compact( 'name', 'string', 'context', 'multiline' ); |
| 44 | 57 | } |
| 45 | 58 | } |