Title: PO::poify
Published: April 25, 2014
Last modified: May 20, 2026

---

# PO::poify( string $input_string ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/po/poify/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/po/poify/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/po/poify/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/po/poify/?output_format=md#related)

[ Back to top](https://developer.wordpress.org/reference/classes/po/poify/?output_format=md#wp--skip-link--target)

Formats a string in PO-style

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/po/poify/?output_format=md#parameters)󠁿

 `$input_string`stringrequired

the string to format

## 󠀁[Return](https://developer.wordpress.org/reference/classes/po/poify/?output_format=md#return)󠁿

 string the poified string

## 󠀁[Source](https://developer.wordpress.org/reference/classes/po/poify/?output_format=md#source)󠁿

    ```php
    public static function poify( $input_string ) {
    	$quote   = '"';
    	$slash   = '\\';
    	$newline = "\n";

    	$replaces = array(
    		"$slash" => "$slash$slash",
    		"$quote" => "$slash$quote",
    		"\t"     => '\t',
    	);

    	$input_string = str_replace( array_keys( $replaces ), array_values( $replaces ), $input_string );

    	$po = $quote . implode( "{$slash}n{$quote}{$newline}{$quote}", explode( $newline, $input_string ) ) . $quote;
    	// Add empty string on first line for readability.
    	if ( str_contains( $input_string, $newline ) &&
    		( substr_count( $input_string, $newline ) > 1 || substr( $input_string, -strlen( $newline ) ) !== $newline ) ) {
    		$po = "$quote$quote$newline$po";
    	}
    	// Remove empty strings.
    	$po = str_replace( "$newline$quote$quote", '', $po );
    	return $po;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/pomo/po.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/pomo/po.php#L106)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/pomo/po.php#L106-L128)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/po/poify/?output_format=md#related)󠁿

| Used by | Description | 
| [PO::export_headers()](https://developer.wordpress.org/reference/classes/po/export_headers/)`wp-includes/pomo/po.php` |

Exports headers to a PO entry

  | 
| [PO::export_entry()](https://developer.wordpress.org/reference/classes/po/export_entry/)`wp-includes/pomo/po.php` |

Builds a string from the entry for inclusion in PO file

  |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fpo%2Fpoify%2F)
before being able to contribute a note or feedback.