PO::unpoify() WordPress Method

The PO::unpoify() method is used to remove all PO files from a WordPress installation. This is useful when you want to clean up your installation, or when you need to troubleshoot PO file related issues.

PO::unpoify( string $string ) #

Gives back the original string from a PO-formatted string


Parameters

$string

(string)(Required)PO-formatted string


Top ↑

Return

(string) enascaped string


Top ↑

Source

File: wp-includes/pomo/po.php

		public static function unpoify( $string ) {
			$escapes               = array(
				't'  => "\t",
				'n'  => "\n",
				'r'  => "\r",
				'\\' => '\\',
			);
			$lines                 = array_map( 'trim', explode( "\n", $string ) );
			$lines                 = array_map( array( 'PO', 'trim_quotes' ), $lines );
			$unpoified             = '';
			$previous_is_backslash = false;
			foreach ( $lines as $line ) {
				preg_match_all( '/./u', $line, $chars );
				$chars = $chars[0];
				foreach ( $chars as $char ) {
					if ( ! $previous_is_backslash ) {
						if ( '\\' === $char ) {
							$previous_is_backslash = true;
						} else {
							$unpoified .= $char;
						}
					} else {
						$previous_is_backslash = false;
						$unpoified            .= isset( $escapes[ $char ] ) ? $escapes[ $char ] : $char;
					}
				}
			}

			// Standardize the line endings on imported content, technically PO files shouldn't contain \r.
			$unpoified = str_replace( array( "\r\n", "\r" ), "\n", $unpoified );

			return $unpoified;
		}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.