⚡ NEW: Changeset/ - Uncensored 2025

Changeset 1311121


Ignore:
Timestamp:
12/17/2015 07:46:32 PM (10 years ago)
Author:
desaiuditd
Message:

Update to commit f73858a from git@…:desaiuditd/watchman.git

Location:
watchman
Files:
34 added
5 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • watchman/assets/screenshot-1.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • watchman/trunk/lib/class-wm-autoload.php

    r1042891 r1311121  
    6565            return 'class-' . strtolower( str_replace( '_', '-', $class_name ) ) . '.php' ;
    6666        }
    67 
    6867    }
    6968}
  • watchman/trunk/readme.md

    r1042939 r1311121  
    44Watchman is a WordPress plugin which keeps track of revisions for your posts, pages and custom post types as well.
    55
    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) 
    88**Requires at least:** 3.6 
    9 **Tested up to:** 4.0 
     9**Tested up to:** 4.4 
    1010**Stable tag:** master 
    1111**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html) 
    1212**Donate Link:** Paypal ID : [email protected] 
     13
     14[![Build Status](https://travis-ci.org/desaiuditd/watchman.png?branch=master)](https://travis-ci.org/desaiuditd/watchman)
    1315
    1416## Description ##
     
    3537* [GitHub](http://github.com/desaiuditd/watchman/) - Please mention your wordpress.org username when sending pull requests.
    3638
    37 [![Build Status](https://travis-ci.org/desaiuditd/watchman.png?branch=master)](https://travis-ci.org/desaiuditd/watchman)
    38 
    3939## Installation ##
    4040
     
    5555![Watchman Settings Page](assets/screenshot-1.png)
    5656
     57### Track Post Author in Revisions. User Display Name & User ID of the author is shown.
     58
     59![Track Post Author in Revisions. User Display Name & User ID of the author is shown.](assets/screenshot-2.png)
     60
    5761## Changelog ##
     62
     63Please 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!
    5868
    5969### 0.4 December 12, 2014 ###
  • watchman/trunk/readme.txt

    r1042939 r1311121  
    44Tags:              revisions, post, page, custom post types, WordPress, history
    55Requires at least: 3.6
    6 Tested up to:      4.0
     6Tested up to:      4.4
    77Stable tag:        master
    88License:           GPLv2 or later
     
    4949
    50501. Watchman Settings Page
     512. Track Post Author in Revisions. User Display Name & User ID of the author is shown.
    5152
    5253
     
    7071Please visit [Watchman's Roadmap page](http://blog.incognitech.in/watchman/roadmap/ "Visit Watchman's Features page") to get some details about future releases.
    7172
     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
    7278= 0.4 December 12, 2014 =
    7379* Screenshot added
  • watchman/trunk/revision/class-wm-revision.php

    r1042891 r1311121  
    1414if ( ! class_exists( 'WM_Revision' ) ) {
    1515
     16    /**
     17     * Class WM_Revision
     18     *
     19     * Handles all the functionality to track custom fields
     20     *
     21     * @since 0.4
     22     */
    1623    class WM_Revision {
    1724
     25        /**
     26         * @since 0.4
     27         */
    1828        function __construct() {
    1929
     
    2535             *
    2636             */
    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 );
    2838
    2939            /**
     
    3545             * We will take care of our own fields and pass on the flag.
    3646             */
    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 );
    3848
    3949            /**
    4050             * 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;
    4678        }
    4779
    4880        /**
    4981         * @param $revision_id
     82         * @since 0.4
    5083         */
    5184        function post_revision_process( $revision_id ) {
    5285
    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
    5797         * @param $last_revision
    5898         * @param $post
    5999         *
    60100         * @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;
    64119        }
    65120
     
    76131         *
    77132         * @return string $value
     133         * @since 0.4
    78134         */
    79135        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
    80145            return $value;
    81146        }
    82147
     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        }
    83218    }
    84219
  • watchman/trunk/settings/class-wm-settings.php

    r1042891 r1311121  
    4545        }
    4646
    47         function show_message( $message, $type = 'info' ) { ?>
     47        function show_message( $message, $type = 'info' ) {
     48            ?>
    4849            <div class="<?php echo $type; ?>"><?php echo $message; ?></div>
    49         <?php }
     50            <?php
     51        }
    5052
    5153        function display_admin_notices() {
     
    148150        }
    149151
    150         function revision_limit_section_callback() { ?>
     152        function revision_limit_section_callback() {
     153            ?>
    151154            <p class="description">
    152155                <?php _e( 'This section lets you control revision limits on your post types. Leave blank in case of unlimited revisions.', WM_TEXT_DOMAIN ); ?><br />
     
    154157                <?php _e( 'Please make sure the post type you want to monitor declares revision support in registration.', WM_TEXT_DOMAIN ); ?>
    155158            </p>
    156         <?php }
     159            <?php
     160        }
    157161
    158         function revision_limit_callback( $args ) { ?>
     162        function revision_limit_callback( $args ) {
     163            ?>
    159164            <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        }
    161167
    162         function render_settings_page() { ?>
     168        function render_settings_page() {
     169            ?>
    163170            <div class="wrap">
    164171
     
    175182                </form>
    176183            </div>
    177         <?php }
    178 
     184            <?php
     185        }
    179186    }
    180187
  • watchman/trunk/watchman.php

    r1042939 r1311121  
    44 * Plugin URI: http://blog.incognitech.in/watchman
    55 * Description: A WordPress plugin to track revisions of your posts, pages and custom posts
    6  * Version: 0.4
     6 * Version: 0.5
    77 * Author: desaiuditd
    88 * Author URI: http://blog.incognitech.in
     
    8686            // Defines WM_VERSION if it does not exits.
    8787            if ( ! defined( 'WM_VERSION' ) ) {
    88                 define( 'WM_VERSION', '0.1' );
     88                define( 'WM_VERSION', '0.5' );
    8989            }
    9090
     
    156156
    157157        }
    158 
    159158    }
    160159
Note: See TracChangeset for help on using the changeset viewer.