Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

removed wpautop filter not persistent in Customizer Editor #127

Closed
bsusala opened this issue May 3, 2016 · 11 comments
Closed

removed wpautop filter not persistent in Customizer Editor #127

bsusala opened this issue May 3, 2016 · 11 comments

Comments

@bsusala
Copy link

bsusala commented May 3, 2016

Using WP Edit Plugin for editing html in Text Mode in Edit Post/Page, with the setting disable wpautop, globally and/or per Page/Post.

But when editing the Page/Post in Customizer, it sanitizes the content, making the process unusable.

@westonruter
Copy link
Contributor

@bsusala to clarify, the issue is that Customize Posts forces the visual editor to be used initially as opposed to the text editor, and so when switching from visual to text the content is corrupted?

@westonruter
Copy link
Contributor

@bsusala From your support forum comment:

This, and the possibility to remove wpautop filter, will force me to almost never quit Customizer, making it a de facto web editor.

So, I was about to open another thread, but since I mentioned above, here it is:

I use WP Edit for code editing style, and also for being able to manage wpautop. However, after I try to edit the page in Customizer, the Editor sanitizes the content, making the process useless. Is there a way to preserve the WP Edit setting, or (if you ask me, since Text Tab is basically html/code editing) to automatically remove wpautop globally.

I understand this must accomodate the general WP behaviour, which is disputable in regard to wpautop. One way may be a checkbox near the Open Editor button to allow/deny wpautop?

@bsusala
Copy link
Author

bsusala commented May 3, 2016

The exact behaviour is:

  • Text in Page is edited and added <p> tags with WP Edit and wpautop checkbox checked (disables wpautop, this is a WP Edit feature, available per Page/Post)
  • Customizer > Pages > Click on Page; all ok, text formatted as it should
  • click Open Editor, Editor opens up, format still ok
  • BUT as soon as I click inside the window, be it Visual (well, it is anyways initially), or Text, content is sanitized

@westonruter
Copy link
Contributor

OK, I didn't realize you were referring to a plugin called “WP Edit”.

@bsusala
Copy link
Author

bsusala commented May 3, 2016

@westonruter sorry, yes, it's the Plugin. But this behaviour is also present if I remove the filter through functions.php, I just mentioned the actual environment (if it's of any worth).

@westonruter
Copy link
Contributor

@bsusala It sounds like the issue is rooted in this line:

editor.setContent( wp.editor.autop( newPostData.post_content ) );

And the converse lines that call wp.editor.removep().

I tried commenting out from default-filters.php:

add_filter( 'the_content', 'wpautop'                           );

And I added two line breaks in the editor and confirmed that paragraphs weren't added on the frontend. Nevertheless, the paragraphs were still automatically getting added in the normal visual editor. Is this a feature of WP Edit to disable the autop functionality in the core visual editor?

@bsusala
Copy link
Author

bsusala commented May 3, 2016

Yes, it applies to any instance of core Editor, be it in Page, Post, or even every Section in GeneratePress :)

I activate by this checkbox:
wpautop

@westonruter
Copy link
Contributor

@bsusala ok, so this is a plugin-specific feature that they'll need to add support for in the Customizer.

To start, they can add to wp_edit_class::add_page():

add_action( 'customize_controls_enqueue_scripts', array($this, 'admin_scripts') );
add_action( 'customize_controls_enqueue_scripts', array($this, 'admin_styles') );

But then they'll need to add a UI for toggling whether to disable wpautop.

@bsusala
Copy link
Author

bsusala commented May 3, 2016

Ok, but just an opinion: couldn't this be something coded by YOUR plugin? It's true that WP Edit is commonplace for trying to mimic code-editors in WP, but, actually, the most important feature is that wpautop (and line numbers, okay :) ). Couldn't implement yourself that? I think will help alot, in the direction of trying to edit as much as possible in Customizer.

@westonruter
Copy link
Contributor

I think it is out of scope for Customize Posts. I've personally never come across turning off wpautop in the editor and it's not a capability in Core without a plugin. Since Customize Posts is being developed for core merge, having special support for community plugins needs to be minimized.

@joshlobe
Copy link

joshlobe commented May 6, 2016

Hi, I'm the author of WP Edit. I have been absent a few days; but will give this issue some attention and see if we can't find a simple fix.

@bsusala, please refer to the thread on the WP forums for further info. We will come back here once we know more about the issue. Thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants