Opened 9 years ago
Closed 8 years ago
#2949 closed defect (bug) (worksforme)
When 'the_content' filter applied and bbpress shortcode added to Admin Editor of Wordpress post, bbPress un-registers (or prevents WP from registering) the dashicons, and the editor.min.css stylesheet
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.2 |
Component: | Appearance - Theme Compatibility | Keywords: | reporter-feedback close |
Cc: |
Description
When 'the_content' filter is applied to the Admin Editor of a Wordpress page or post, bbPress un-registers (or prevents WP from registering) the dashicons, and the editor.min.css stylesheet. This occurs when you put a bbpress SHORTCODE in a post.
This results in a messed up Editing screen as can be seen in the bellow image:
Change History (9)
#2
@
9 years ago
- Component changed from General to Appearance - Theme Compatibility
- Keywords reporter-feedback close added
- Version changed from 2.5.9 to 2.2
I'm not able to duplicate this in vanilla WordPress using bbPress trunk.
Applying the the_content
filter to the admin editor content sounds like it will break all kinds of things, not just bbPress. Can you provide more context into what you're trying to do, or what plugin is causing the conflict that you've identified?
I'm going to add the "close" keyword to this ticket. I have a hunch this isn't something we can safeguard against very easily.
#3
follow-up:
↓ 4
@
9 years ago
title, content, excerpt, etc. filters in WP are made to be applied to resolve shortcodes etc. There's nothing "dangerous" about them at all - it's quite normal, actually. If you need to expand the $post->post_content for example, you apply 'the_content' filter. The problem is that when you do this on the admin side, *and* bbPress is configured to include the editor, it screws up WP dashicons and the editor.min.css enqueue. I suspect the reason why you couldn't duplicate the problem is that you weren't applying the filter on from an admin post editing page. Try hooking 'admin_init' for your test.
js.
#4
in reply to:
↑ 3
@
9 years ago
Replying to jsmoriss:
title, content, excerpt, etc. filters in WP are made to be applied to resolve shortcodes etc. There's nothing "dangerous" about them at all - it's quite normal, actually. If you need to expand the $post->post_content for example, you apply 'the_content' filter. The problem is that when you do this on the admin side, *and* bbPress is configured to include the editor, it screws up WP dashicons and the editor.min.css enqueue. I suspect the reason why you couldn't duplicate the problem is that you weren't applying the filter on from an admin post editing page. Try hooking 'admin_init' for your test.
I think you are misunderstanding my question, and it's not really fair to assume/suggest that we don't understand how filters work and are applied. I never said filters were dangerous (though they certainly can be) – I said (paraphrasing now) that using the incorrect ones in the incorrect places can produce undesirable results in an unpredictable filter stack.
I understand the end result you've come to. I need to better understand how and why you're getting to this point.
WordPress does not use the the_content
filter inside of the post editor, and it's arguably the wrong filter to use in that context, which is why you're experiencing this problem. For example: If all you need to do is process shortcodes, use do_shortcodes
.
If you can include a snippet of code to reproduce the problem, maybe we can help you use the correct filters, or better identify how bbPress can better predict what seems to me to be a somewhat unorthodox approach to formatting editable content.
#5
follow-up:
↓ 6
@
9 years ago
Well, so be it -- at least we reported the issue -- do with it what you will. The work-around for this bug is listed above, if anyone else needs it.
js.
#6
in reply to:
↑ 5
@
9 years ago
Replying to jsmoriss:
Well, so be it -- at least we reported the issue -- do with it what you will. The work-around for this bug is listed above, if anyone else needs it.
A work-around is less helpful than example code to reproduce the situation you're experiencing, which is the only way to confirm whether this is a bbPress bug, or something else.
#7
@
9 years ago
add_action( 'current_screen', 'bbpress_editor_bug_example' ); function bbpress_editor_bug_example( $screen ) { if ( ! isset( $screen->id ) || ! isset( $_GET['post'] ) ) return; switch ( $screen->id ) { case 'post': case 'page': $post_id = sanitize_key( $_GET['post'] ); $content = get_post_field( 'post_content', $post_id ); $content = do_shortcode( $content ); break; } }
The problem is with the "Post Formatting" option. I hooked 'bbp_use_wp_editor' before applying the_content filter to return false, and this fixed the problem. For example:
I think a better option would be for bbPress to test for https://codex.wordpress.org/Function_Reference/doing_filter (for example) and skip the use of wp editor in that case.
js.