1

I added a function to the filter hook tag 'content_filtered_edit_pre', but it doesn't seem to fire no matter what I do. I am also aware of 'content_edit_pre', but I am curious as to when this filter hook is called. The following does not result in 'filtered ' being added to the front of my post when I open it in the edit screen, even after another filter has been run:

function test_of_content_filtered_edit_pre( $content, $post_id ) {
    return "filtered ".$content;
}
add_filter( 'content_filtered_edit_pre', 'test_of_content_filtered_edit_pre', 10, 2 );

The only documentation I can find on the Internet seems to be from the wordpress codex or copies of it.

  • The Codex says This filter runs in wp-admin when loading a post for editing. – Maruti Mohanty Jan 28 '14 at 8:23
  • I saw that too - in the tests I ran though, only 'content_edit_pre' ran at this time and not 'content_filtered_edit_pre'. Would you be able to provide an example of an instance where it works for you? – bnp887 Jan 28 '14 at 8:41
  • What's the status of the question, is it still unsolved? – birgire Feb 3 '14 at 15:13
  • Your comment to look at the answer by @G.M helped a lot! Sorry, I've been away so didn't mark it as solved yet. – bnp887 Feb 4 '14 at 0:20
1

This is activated within the sanitize_post_field() function:

Calls 'edit_{$field}' and '{$field_no_prefix}_edit_pre' passing $value and $post_id if $context is 'edit' and field name prefix is 'post_'.

So in the case of the post_content_filtered field, the filters are

edit_post_content_filtered

and

content_filtered_edit_pre
| improve this answer | |
  • Thank you for your answer - I tried forcing a call to sanitize_post_field(), and still didn't get it to fire. May because it requires a 'post_' prefix. I'll keep investigating. – bnp887 Jan 28 '14 at 13:54
  • How did you test it? Try for example echo sanitize_post_field( 'post_content_filtered', 'abc', 1 ,'edit' ); – birgire Jan 28 '14 at 15:22
  • ps. check for example this informative answer by @G.M on how the field post_content_filtered is treated in wp_updated_post(). It's filtered but not saved, when you update your post, as far as I understand it. – birgire Jan 28 '14 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.