PO::match_begin_and_end_newlines() WordPress Method
The match_begin_and_end_newlines() method is a Wordpress function that is used to match the beginning and end of newlines in a string. This function is useful for doing things like matching the beginning and end of a paragraph.
PO::match_begin_and_end_newlines( $translation, $original ) #
Source
File: wp-includes/pomo/po.php
public static function match_begin_and_end_newlines( $translation, $original ) { if ( '' === $translation ) { return $translation; } $original_begin = "\n" === substr( $original, 0, 1 ); $original_end = "\n" === substr( $original, -1 ); $translation_begin = "\n" === substr( $translation, 0, 1 ); $translation_end = "\n" === substr( $translation, -1 ); if ( $original_begin ) { if ( ! $translation_begin ) { $translation = "\n" . $translation; } } elseif ( $translation_begin ) { $translation = ltrim( $translation, "\n" ); } if ( $original_end ) { if ( ! $translation_end ) { $translation .= "\n"; } } elseif ( $translation_end ) { $translation = rtrim( $translation, "\n" ); } return $translation; }
Expand full source codeCollapse full source codeView on TracView on GitHub