Created
May 20, 2012 04:21
-
-
Save kovshenin/2745451 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * Plugin Name: Foo Bar | |
| */ | |
| add_action( 'save_post', 'my_save_post' ); | |
| function my_save_post( $post_id ) { | |
| if ( wp_is_post_revision( $post_id ) ) | |
| return; | |
| $post = get_post( $post_id ); | |
| $post->post_content = str_replace( 'foo', 'bar', $post->post_content ); | |
| remove_action( 'save_post', 'my_save_post' ); // избегаем infinite loop | |
| wp_update_post( $post ); | |
| add_action( 'save_post', 'my_save_post' ); // добавляем хук обратно | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment