Skip to content

Commit

Permalink
text consistency fix
Browse files Browse the repository at this point in the history
  • Loading branch information
suvedisamyog committed Oct 8, 2024
1 parent 3d5e037 commit 73d0825
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion includes/functions-ur-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -6150,8 +6150,15 @@ function ur_settings_text_format( $args ) {
}

foreach ( $fields_to_format as $field ) {

if ( isset( $arg[ $field ] ) ) {
$arg[ $field ] = ucfirst( strtolower( $arg[ $field ] ) );
if ( strpos( trim( $arg[ $field ] ), '<div' ) !== 0 ) {
strpos( trim( $arg[ $field ] ), '<div' );
$arg[ $field ] = ur_format_sentence_case( strtolower( $arg[ $field ] ) );

} else {
$arg[ $field ] = $arg[ $field ];
}
}
}

Expand All @@ -6165,6 +6172,21 @@ function ur_settings_text_format( $args ) {
return $args;
}
}
if ( ! function_exists( 'ur_format_sentence_case' ) ) {
/**
* Capitalizes the first letter of the initial word and each word after a period.
*
* @param string $string
* @return string
*/
function ur_format_sentence_case( $string ) {
$sentences = preg_split( '/(\.\s+)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
foreach ( $sentences as &$sentence ) {
$sentence = ucfirst( trim( $sentence ) );
}
return implode( '', $sentences );
}
}

if ( ! function_exists( 'ur_get_capitalized_words' ) ) {
/**
Expand Down

0 comments on commit 73d0825

Please sign in to comment.