-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new function
wp_get_word_count_type()
- Loading branch information
Showing
3 changed files
with
34 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* PHP and WordPress configuration compatibility functions for the Gutenberg | ||
* editor plugin changes related to i18n. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Override core's wp_get_word_count_type() introduced in WordPress 6.2. | ||
* Originally, get_word_count_type() method of the WP_Locale class is executed, | ||
* but the process is simulated here. | ||
* | ||
* This function should not be backported to core. | ||
*/ | ||
if ( ! function_exists( 'wp_get_word_count_type' ) ) { | ||
/** | ||
* Retrieves the word count type based on the locale. | ||
* | ||
* @return string Locale-specific word count type. | ||
*/ | ||
function wp_get_word_count_type() { | ||
$word_count_type = _x( 'words', 'Word count type. Do not translate!', 'gutenberg' ); | ||
|
||
// Check for valid types. | ||
if ( 'characters_excluding_spaces' !== $word_count_type && 'characters_including_spaces' !== $word_count_type ) { | ||
// Defaults to 'words'. | ||
$word_count_type = 'words'; | ||
} | ||
return $word_count_type; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters