wp-papi / papi

:rocket: WordPress Page Type API with custom fields
https://wp-papi.github.io
MIT License
263 stars 32 forks source link

[text property] - Line break option #116

Closed nlemoine closed 8 years ago

nlemoine commented 9 years ago

Would you agree to add a "convert line breaks to br" setting on this property? Very handy when using textarea and prevent adding a filter manually to achieve this.

I'll submit a PR if you're ok with this feature.

frozzare commented 9 years ago

Text property do save line breaks in the database, so maybe a filter och a function when you get the value would solve this, maybe papi_nl2br would solve this. I don't a setting is necessary for this.

Love that you find bugs and contribute new things to Papi :)

nlemoine commented 9 years ago

Text property do save line breaks in the database

Sure it does but it saves text plain line breaks such as \r \n that won't show up on the HTML front end. The setting I had in mind is about converting into HTML line breaks with nl2br. Something like:

[
    'allow_html' => false,
    'nl2br'      => true,
]

It's ok if you think it's not necessary, I'll keep my filter on ;)

frozzare commented 9 years ago

Hm, yeah maybe it's a good idea. We could add it to 3.0.0, can you do a PR and try to add some tests to it?

nlemoine commented 9 years ago

Thanks for considering this feature. I'll do a PR today or tomorrow.

I also noticed a small bug. I'll open a new issue about it.

frozzare commented 8 years ago

@nlemoine any update about this?

nlemoine commented 8 years ago

Sorry, holidays, changed computer and a bit of work. I will submit a PR this week.