OSDN Git Service

Apply default filters in content in `wp post edit`
authorgoldenapples <goldenapplesdesign@gmail.com>
Fri, 27 Sep 2013 19:09:20 +0000 (12:09 -0700)
committergoldenapples <goldenapplesdesign@gmail.com>
Fri, 27 Sep 2013 19:20:18 +0000 (12:20 -0700)
I noticed that without applying the `the_editor_content` and
`content_save_pre` filters to the post content being edited, unexpected
things could happen when editing posts with the system editor. For
example, the Syntaxhighlighter Extended plugin uses these filters cto
decode entities when retrieving a post from that database to edit, and
then re-encode them on save.

There may be some extra thought required as to what the expected behavior
should be, but this apporach seems to make the most sense to me.

php/commands/post.php

index d946293..51e288f 100644 (file)
@@ -123,7 +123,9 @@ class Post_Command extends \WP_CLI\CommandWithDBObject {
        }
 
        protected function _edit( $content, $title ) {
-               return \WP_CLI\Utils\launch_editor_for_input( $content, $title );
+               $content = apply_filters( 'the_editor_content', $content );
+               $output = \WP_CLI\Utils\launch_editor_for_input( $content, $title );
+               return apply_filters( 'content_save_pre', $output );
        }
 
        /**