Making WordPress.org

Ticket #2919: 2919.patch

File 2919.patch, 1.0 KB (added by SergeyBiryukov, 7 years ago)
  • wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php

     
    406406         * @return mixed
    407407         */
    408408        public function translate_gp_original( $original, $translation, $content ) {
     409                $original = preg_quote( $original, '/' );
     410
    409411                if ( false === strpos( $content, '<' ) ) {
    410                         $content = str_replace( $original, $translation, $content );
     412                        $content = preg_replace( "/\b{$original}\b/", $translation, $content );
    411413                } else {
    412                         $original = preg_quote( $original, '/' );
    413414                        $content  = preg_replace( "/(<([a-z0-9]*)\b[^>]*>){$original}(<\/\\2>)/m", '${1}___TRANSLATION___${3}', $content ); // Don't use $translation, it may contain backreference-like characters.
    414415                        $content  = str_replace( '___TRANSLATION___', $translation, $content );
    415416                }