Changeset 1311121
- Timestamp:
- 12/17/2015 07:46:32 PM (10 years ago)
- Location:
- watchman
- Files:
-
- 34 added
- 5 deleted
- 7 edited
-
assets/screenshot-1.png (modified) (1 prop) (previous)
-
assets/screenshot-2.png (added)
-
tags/0.5 (added)
-
tags/0.5/.editorconfig (added)
-
tags/0.5/LICENSE (added)
-
tags/0.5/lib (added)
-
tags/0.5/lib/class-wm-autoload.php (added)
-
tags/0.5/readme.md (added)
-
tags/0.5/readme.txt (added)
-
tags/0.5/revision (added)
-
tags/0.5/revision/class-wm-revision.php (added)
-
tags/0.5/settings (added)
-
tags/0.5/settings/class-wm-settings.php (added)
-
tags/0.5/tests (added)
-
tags/0.5/tests/bootstrap.php (added)
-
tags/0.5/tests/tests (added)
-
tags/0.5/tests/tests/test-watchman.php (added)
-
tags/0.5/tests/wm-test-case.php (added)
-
tags/0.5/ui (added)
-
tags/0.5/ui/css (added)
-
tags/0.5/ui/css/watchman-icons.css (added)
-
tags/0.5/ui/fonts (added)
-
tags/0.5/ui/fonts/watchman.eot (added)
-
tags/0.5/ui/fonts/watchman.svg (added)
-
tags/0.5/ui/fonts/watchman.ttf (added)
-
tags/0.5/ui/fonts/watchman.woff (added)
-
tags/0.5/watchman.php (added)
-
trunk/.jshintrc (deleted)
-
trunk/.travis.yml (deleted)
-
trunk/bin (deleted)
-
trunk/lib/class-wm-autoload.php (modified) (1 diff)
-
trunk/phpunit.xml (deleted)
-
trunk/readme.md (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/revision/class-wm-revision.php (modified) (4 diffs)
-
trunk/settings/class-wm-settings.php (modified) (4 diffs)
-
trunk/svn-url (deleted)
-
trunk/ui (added)
-
trunk/ui/css (added)
-
trunk/ui/css/watchman-icons.css (added)
-
trunk/ui/fonts (added)
-
trunk/ui/fonts/watchman.eot (added)
-
trunk/ui/fonts/watchman.svg (added)
-
trunk/ui/fonts/watchman.ttf (added)
-
trunk/ui/fonts/watchman.woff (added)
-
trunk/watchman.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
watchman/assets/screenshot-1.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
watchman/trunk/lib/class-wm-autoload.php
r1042891 r1311121 65 65 return 'class-' . strtolower( str_replace( '_', '-', $class_name ) ) . '.php' ; 66 66 } 67 68 67 } 69 68 } -
watchman/trunk/readme.md
r1042939 r1311121 4 4 Watchman is a WordPress plugin which keeps track of revisions for your posts, pages and custom post types as well. 5 5 6 **Contributors:** [desaiuditd](http ://profiles.wordpress.org/desaiuditd)7 **Tags:** [revisions](http ://wordpress.org/plugins/tags/revisions), [post](http://wordpress.org/plugins/tags/post), [page](http://wordpress.org/plugins/tags/page), [custom post types](http://wordpress.org/plugins/tags/custom post types), [WordPress](http://wordpress.org/plugins/tags/WordPress), [history](http://wordpress.org/plugins/tags/history)6 **Contributors:** [desaiuditd](https://profiles.wordpress.org/desaiuditd) 7 **Tags:** [revisions](https://wordpress.org/plugins/tags/revisions), [post](https://wordpress.org/plugins/tags/post), [page](https://wordpress.org/plugins/tags/page), [custom post types](https://wordpress.org/plugins/tags/custom post types), [WordPress](https://wordpress.org/plugins/tags/WordPress), [history](https://wordpress.org/plugins/tags/history) 8 8 **Requires at least:** 3.6 9 **Tested up to:** 4. 09 **Tested up to:** 4.4 10 10 **Stable tag:** master 11 11 **License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html) 12 12 **Donate Link:** Paypal ID : [email protected] 13 14 [](https://travis-ci.org/desaiuditd/watchman) 13 15 14 16 ## Description ## … … 35 37 * [GitHub](http://github.com/desaiuditd/watchman/) - Please mention your wordpress.org username when sending pull requests. 36 38 37 [](https://travis-ci.org/desaiuditd/watchman)38 39 39 ## Installation ## 40 40 … … 55 55  56 56 57 ### Track Post Author in Revisions. User Display Name & User ID of the author is shown. 58 59  60 57 61 ## Changelog ## 62 63 Please visit [Watchman's Roadmap page](http://blog.incognitech.in/watchman/roadmap/ "Visit Watchman's Features page") to get some details about future releases. 64 ### 0.5 December 17, 2015 ### 65 * Post Author tracking added. 66 * This update is coming after a long time & I've got this breakthrough to track the restricted fields as well. 67 * So I hope to get more updates soon with proposed features. Kudos! 58 68 59 69 ### 0.4 December 12, 2014 ### -
watchman/trunk/readme.txt
r1042939 r1311121 4 4 Tags: revisions, post, page, custom post types, WordPress, history 5 5 Requires at least: 3.6 6 Tested up to: 4. 06 Tested up to: 4.4 7 7 Stable tag: master 8 8 License: GPLv2 or later … … 49 49 50 50 1. Watchman Settings Page 51 2. Track Post Author in Revisions. User Display Name & User ID of the author is shown. 51 52 52 53 … … 70 71 Please visit [Watchman's Roadmap page](http://blog.incognitech.in/watchman/roadmap/ "Visit Watchman's Features page") to get some details about future releases. 71 72 73 = 0.5 December 17, 2015 = 74 * Post Author tracking added. 75 * This update is coming after a long time & I've got this breakthrough to track the restricted fields as well. 76 * So I hope to get more updates soon with proposed features. Kudos! 77 72 78 = 0.4 December 12, 2014 = 73 79 * Screenshot added -
watchman/trunk/revision/class-wm-revision.php
r1042891 r1311121 14 14 if ( ! class_exists( 'WM_Revision' ) ) { 15 15 16 /** 17 * Class WM_Revision 18 * 19 * Handles all the functionality to track custom fields 20 * 21 * @since 0.4 22 */ 16 23 class WM_Revision { 17 24 25 /** 26 * @since 0.4 27 */ 18 28 function __construct() { 19 29 … … 25 35 * 26 36 */ 27 add_action( '_wp_put_post_revision', array( $this, 'post_revision_process' ) );37 add_action( '_wp_put_post_revision', array( $this, 'post_revision_process' ), 10, 1 ); 28 38 29 39 /** … … 35 45 * We will take care of our own fields and pass on the flag. 36 46 */ 37 add_filter( 'wp_save_post_revision_ check_for_changes', array( $this, 'check_for_changes' ), 10, 3 );47 add_filter( 'wp_save_post_revision_post_has_changed', array( $this, 'check_for_changes' ), 10, 3 ); 38 48 39 49 /** 40 50 * We may have to call this dynamically within a for loop. depending upon how many custom fields that we are supporting. 41 * 42 * TODO Check for this. 43 */ 44 $field = ''; 45 add_filter( '_wp_post_revision_field_'.$field, array( $this, 'revision_field_content' ) ); 51 */ 52 foreach ( array_keys( $this->get_custom_revision_fields() ) as $field ) { 53 add_filter( '_wp_post_revision_field_'.$field, array( $this, 'revision_field_content' ), 10, 4 ); 54 } 55 56 /** 57 * This adds custom diff ui for custom revision fields 58 */ 59 add_filter( 'wp_get_revision_ui_diff', array( $this, 'revision_ui_diff' ), 10, 3 ); 60 } 61 62 /** 63 * @return array $revision_fields 64 * @since 0.5 65 */ 66 function get_custom_revision_fields() { 67 $revision_fields = array( 68 'post_author' => array( 69 'label' => __( 'Post Author' ), 70 'meta_key' => '_wm_post_author', 71 'meta_value' => function( $post ) { 72 $author = new WP_User( $post->post_author ); 73 return $author->display_name . ' (' . $post->post_author . ')'; 74 }, 75 ), 76 ); 77 return $revision_fields; 46 78 } 47 79 48 80 /** 49 81 * @param $revision_id 82 * @since 0.4 50 83 */ 51 84 function post_revision_process( $revision_id ) { 52 85 53 } 54 55 /** 56 * @param $check_flag 86 $revision = get_post( $revision_id ); 87 $post = get_post( $revision->post_parent ); 88 89 foreach ( $this->get_custom_revision_fields() as $field => $fieldmeta ) { 90 update_post_meta( $post->ID, $fieldmeta['meta_key'] . '_' . $revision_id , call_user_func( $fieldmeta['meta_value'], $post ) ); 91 } 92 93 } 94 95 /** 96 * @param $post_has_changed 57 97 * @param $last_revision 58 98 * @param $post 59 99 * 60 100 * @return mixed 61 */ 62 function check_for_changes( $check_flag, $last_revision, $post ) { 63 return $check_flag; 101 * @since 0.4 102 */ 103 function check_for_changes( $post_has_changed, $last_revision, $post ) { 104 105 foreach ( array_keys( $this->get_custom_revision_fields() ) as $field ) { 106 107 $post_value = normalize_whitespace( $post->$field ); 108 $revision_value = normalize_whitespace( apply_filters( "_wp_post_revision_field_$field", $last_revision->$field, $field, $last_revision, 'from' ) ); 109 110 if ( $post_value != $revision_value ) { 111 112 $post_has_changed = true; 113 break; 114 115 } 116 } 117 118 return $post_has_changed; 64 119 } 65 120 … … 76 131 * 77 132 * @return string $value 133 * @since 0.4 78 134 */ 79 135 function revision_field_content( $value, $field, $post, $context ) { 136 137 $revision_fields = $this->get_custom_revision_fields(); 138 139 if ( array_key_exists( $field, $revision_fields ) ) { 140 141 $value = get_post_meta( $post->post_parent, $revision_fields[ $field ]['meta_key'] . '_' . $post->ID, true ); 142 143 } 144 80 145 return $value; 81 146 } 82 147 148 /** 149 * Filter the fields displayed in the post revision diff UI. 150 * 151 * @since 4.1.0 152 * 153 * @param array $return Revision UI fields. Each item is an array of id, name and diff. 154 * @param WP_Post $compare_from The revision post to compare from. 155 * @param WP_Post $compare_to The revision post to compare to. 156 * 157 * @return array $return 158 * @since 0.5 159 */ 160 function revision_ui_diff( $return, $compare_from, $compare_to ) { 161 162 foreach ( $this->get_custom_revision_fields() as $field => $fieldmeta ) { 163 /** 164 * Contextually filter a post revision field. 165 * 166 * The dynamic portion of the hook name, `$field`, corresponds to each of the post 167 * fields of the revision object being iterated over in a foreach statement. 168 * 169 * @since 3.6.0 170 * 171 * @param string $compare_from->$field The current revision field to compare to or from. 172 * @param string $field The current revision field. 173 * @param WP_Post $compare_from The revision post object to compare to or from. 174 * @param string null The context of whether the current revision is the old 175 * or the new one. Values are 'to' or 'from'. 176 */ 177 $content_from = $compare_from ? apply_filters( "_wp_post_revision_field_$field", $compare_from->$field, $field, $compare_from, 'from' ) : ''; 178 179 /** This filter is documented in wp-admin/includes/revision.php */ 180 $content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' ); 181 182 $args = array( 183 'show_split_view' => true, 184 ); 185 186 /** 187 * Filter revisions text diff options. 188 * 189 * Filter the options passed to {@see wp_text_diff()} when viewing a post revision. 190 * 191 * @since 4.1.0 192 * 193 * @param array $args { 194 * Associative array of options to pass to {@see wp_text_diff()}. 195 * 196 * @type bool $show_split_view True for split view (two columns), false for 197 * un-split view (single column). Default true. 198 * } 199 * @param string $field The current revision field. 200 * @param WP_Post $compare_from The revision post to compare from. 201 * @param WP_Post $compare_to The revision post to compare to. 202 */ 203 $args = apply_filters( 'revision_text_diff_options', $args, $field, $compare_from, $compare_to ); 204 205 $diff = wp_text_diff( $content_from, $content_to, $args ); 206 207 if ( $diff ) { 208 $return[] = array( 209 'id' => $field, 210 'name' => $fieldmeta['label'], 211 'diff' => $diff, 212 ); 213 } 214 } 215 216 return $return; 217 } 83 218 } 84 219 -
watchman/trunk/settings/class-wm-settings.php
r1042891 r1311121 45 45 } 46 46 47 function show_message( $message, $type = 'info' ) { ?> 47 function show_message( $message, $type = 'info' ) { 48 ?> 48 49 <div class="<?php echo $type; ?>"><?php echo $message; ?></div> 49 <?php } 50 <?php 51 } 50 52 51 53 function display_admin_notices() { … … 148 150 } 149 151 150 function revision_limit_section_callback() { ?> 152 function revision_limit_section_callback() { 153 ?> 151 154 <p class="description"> 152 155 <?php _e( 'This section lets you control revision limits on your post types. Leave blank in case of unlimited revisions.', WM_TEXT_DOMAIN ); ?><br /> … … 154 157 <?php _e( 'Please make sure the post type you want to monitor declares revision support in registration.', WM_TEXT_DOMAIN ); ?> 155 158 </p> 156 <?php } 159 <?php 160 } 157 161 158 function revision_limit_callback( $args ) { ?> 162 function revision_limit_callback( $args ) { 163 ?> 159 164 <input type="text" name="<?php echo self::$revision_limit_key . $args['post_type']; ?>" id="<?php echo self::$revision_limit_key . $args['post_type']; ?>" value="<?php echo get_option( self::$revision_limit_key . $args['post_type'] ); ?>" /> 160 <?php } 165 <?php 166 } 161 167 162 function render_settings_page() { ?> 168 function render_settings_page() { 169 ?> 163 170 <div class="wrap"> 164 171 … … 175 182 </form> 176 183 </div> 177 <?php }178 184 <?php 185 } 179 186 } 180 187 -
watchman/trunk/watchman.php
r1042939 r1311121 4 4 * Plugin URI: http://blog.incognitech.in/watchman 5 5 * Description: A WordPress plugin to track revisions of your posts, pages and custom posts 6 * Version: 0. 46 * Version: 0.5 7 7 * Author: desaiuditd 8 8 * Author URI: http://blog.incognitech.in … … 86 86 // Defines WM_VERSION if it does not exits. 87 87 if ( ! defined( 'WM_VERSION' ) ) { 88 define( 'WM_VERSION', '0. 1' );88 define( 'WM_VERSION', '0.5' ); 89 89 } 90 90 … … 156 156 157 157 } 158 159 158 } 160 159
Note: See TracChangeset
for help on using the changeset viewer.