Changeset 704528
- Timestamp:
- 04/27/2013 03:01:56 AM (11 years ago)
- Location:
- email-post-changes/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
email-post-changes/trunk/class.email-post-changes.php
r557038 r704528 36 36 37 37 if ( $options['enable'] ) 38 add_action( ' wp_insert_post', array( $this, 'wp_insert_post' ), 10, 2);38 add_action( ' ); 39 39 if ( current_user_can( 'manage_options' ) ) 40 40 add_action( 'admin_menu', array( $this, 'admin_menu' ), 115 ); … … 63 63 64 64 // The meat of the plugin 65 function wp_insert_post( $post_id, $post ) { 66 $options = $this->get_options(); 67 68 if ( ! $options['drafts'] && 'draft' == $post->post_status ) 69 return; 70 71 if ( 'revision' == $post->post_type ) { // Revision is saved first 72 if ( wp_is_post_autosave( $post ) ) 73 return; 74 $this->left_post = $post; 75 } elseif ( !empty( $this->left_post ) && $this->left_post->post_parent == $post->ID ) { // Then new post 76 if ( !in_array( $post->post_type, $options['post_types'] ) ) 77 return; 78 $this->right_post = $post; 65 function post_updated( $post_id, $post_after, $post_before ) { 66 $options = $this->get_options(); 67 // If we're purely saving a draft, and don't have the draft option enabled, skip. If we're transitioning one way or the other, send a notification. 68 if ( 0 == $options['drafts'] && 'draft' == $post_before->post_status && 'draft' == $post_after->post_status ) 69 return; 70 71 if ( wp_is_post_autosave( $post_after ) ) 72 return; 73 74 // Our inputs are just the raw post data from before and after, so the wp_is_post_autosave() check, 75 // which looks for {$post->post_parent}-autosave in the post_name, may not work. Check this too just to be safe. 76 if ( 'auto-draft' == $post_before->post_status || 'auto-draft' == $post_after->post_status ) 77 return; 78 79 if ( !in_array( $post_before->post_type, $options['post_types'] ) ) 80 return; 81 82 $this->left_post = $post_before; 83 $this->right_post = $post_after; 84 85 // If this is a new post, set an empty title for $this->left_post so that it appears in the diff. 86 $child_posts = wp_get_post_revisions( $post_id, array( 'numberposts' => 1 ) ); 87 if ( count( $child_posts ) == 0 ) { 88 $this->left_post->post_title = ''; 79 89 } 80 90 -
email-post-changes/trunk/readme.txt
r557034 r704528 3 3 Tags: email, diff, post, page, change 4 4 Requires at least: 3.2 5 Tested up to: 3. 46 Stable tag: 1. 25 Tested up to: 3. 6 Stable tag: 1. 7 7 8 8 Emails you whenever a change to a post or page is made. … … 28 28 29 29 == Changelog == 30 31 32 30 33 31 34 = 1.2 =
Note: See TracChangeset
for help on using the changeset viewer.