Skip to content

Commit

Permalink
Merge pull request #208 from NeilWJames/master
Browse files Browse the repository at this point in the history
Updates to WP Document Revisions

I have made the check that if the session is logged on then the key must be that of the user.
  • Loading branch information
NeilWJames committed Mar 14, 2020
2 parents 3092100 + 707b16b commit 60117c4
Show file tree
Hide file tree
Showing 23 changed files with 3,016 additions and 1,031 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

},
"require-dev": {
"phpunit/phpunit": "~8.4",
"phpunit/phpunit": "~8.5",
"wp-cli/wp-cli": "~2.4",
"wp-coding-standards/wpcs": "~2.2",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.6",
"php-coveralls/php-coveralls": "*",
"squizlabs/php_codesniffer": "~3.5"
},
Expand Down
445 changes: 198 additions & 247 deletions composer.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ See [the full documentation](http://ben.balter.com/wp-document-revisions)
* [Where to get Support or Report an Issue](./SUPPORT.md)
* [Translations](./translations.md)
* [Plugin Filters](./filters.md)
* [Plugin Shortcodes and Widget](./shortcodes.md)
* [Useful Plugins and Tools](./useful-plugins-and-tools.md)

### Get Involved
Expand Down
17 changes: 17 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
## Changelog

### 3.3.0

* NEW: Implement Gutenberg Blocks for Shortcodes and Widget. Documentation added.
* NEW: Integrate with either Edit-flow or PublishPress plugins
* FIX: Document Taxonomies using default term counts will use same method as WORKFLOW_STATE, i.e. count all not-trashed documents
* FIX: Review of Rewrite rules with/without trailing slash; also extend file extension length
* FIX: Update code to WP Coding Standards 2.2.1 (and fix new sniff errors)
* FIX: Update coveralls to 2.2, dealerdirect/codesniffer to 0.6, phpunit/phpunit to 8.5 and wp/cli to 2.4.1
* FIX: Suppress excerpt output in feeds to stop information leakage
* FIX: Password-protected document can leak information (by showing next/previous)
* FIX: Remove existing workaround for WP bug 16215 and long time fixed - and made information incorrect
* FIX: Fix error in time difference display when client and server are in different time zones
* FIX: Document directory incorrect test for Absolute/Relative entry on Windows implementations
* FIX: Review documentation.
(#208) @NeilWJames

### 3.2.4

* Address technical debt for WP Document Standards (#192) @NeilWJames
Expand All @@ -11,6 +27,7 @@

### 3.2.3

* Full phpcs 2.2 standardisation, complete filter documentation (#192) @NeilWJames
* On plugin activation, admin warning if user doesn't have edit_documents capability (#180) @NeilWJames
* PHPCS Review (no functional changes) (#179) @NeilWJames
* Review for WP Coding standard 2.1.1 and newer phpunit (#174) @NeilWJames
Expand Down
14 changes: 13 additions & 1 deletion docs/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This plugin makes use of many filters to tailor the delivered processing accordi

Most of them are named with a leading 'document-' but there are a few additional non-standard ones shown at the bottom.

## Filter document_block_taxonomies

In: class-wp-document-revisions-front-end.php

Filters the Document taxonomies (allowing users to select the first three for the block widget.

## Filter document_caps

In: class-wp-document-revisions.php
Expand Down Expand Up @@ -118,7 +124,7 @@ Filters the HTTP headers sent when a file is served through WP Document Revision

In: class-wp-document-revisions.php

Filter to switch off use of Edit_Flow capabilities.
Filter to switch off integration with Edit_Flow/PublishPress statuses.

## Filter document_rewrite_rules

Expand All @@ -144,6 +150,12 @@ In: class-wp-document-revisions.php

Filters the document slug.

## Filter document_taxonomy_term_count

In: class-wp-document-revisions.php

Filter to select which taxonomies with default term count to be modified to count all non-trashed posts.

## Filter document_title

In: class-wp-document-revisions.php
Expand Down
20 changes: 8 additions & 12 deletions docs/frequently-asked-questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ Yes. You can use the [Simple Taxonomy plugin](https://wordpress.org/plugins/simp

### Can I put my documents in folders?

WP Document Revisions doesn't use the traditional folder metaphor to organize files. Instead, the same document can be described multiple ways, or in folder terms, be in multiple folders at once. This gives you more control over your documents and how they are organized. You can add a folder taxonomy with the [Simple Taxonomy](https://wordpress.org/plugins/simple-taxonomy/). Just add the taxonomy with a post type of "Documents", and as the "Hierarchical" set to True.
WP Document Revisions doesn't use the traditional folder metaphor to organize files. Instead, the same document can be described multiple ways, or in folder terms, be in multiple folders at once. This gives you more control over your documents and how they are organized. You can add a folder taxonomy with the [Simple Taxonomy Refreshed](https://wordpress.org/plugins/simple-taxonomy-refreshed/). Just add the taxonomy with a post type of "Documents", and as the "Hierarchical" set to True.

### What if I want even more control over my workflow?

Take a look at the [Edit Flow Plugin](https://wordpress.org/plugins/edit-flow/) which allows you to set up notifications based on roles, in-line comments, assign all sorts of metadata to posts, create a team calendar, budget, etc. WP Document Revisions will detect if [Edit Flow](http://ben.balter.com/2011/10/24/advanced-workflow-management-tools-for-wp-document-revisions/) is installed and activated, and will adapt accordingly (removing the workflow-state dialogs, registering documents with Edit Flow, etc.). If you're looking for even more control over your team's work flow, using the two plugins in conjunction is the way to go.

Equally the [PublishPress Plugin](https://publishpress.com), a fork of Edit Flow, is detected and can be used with WP Document Revisions in exactly the same manner as Edit Flow.

### I want some small changes to the processing, but there are few configuration options. How do I do this?

Yes, there are few Settings. However there are many filters that allows processing to be configured to your requirement. These are described [here](./filters.md). This will need some coding to be done.
Expand All @@ -94,19 +96,13 @@ Yes. Each document has an "owner" which can be changed from a dialog on the edit

### How do I use the documents shortcode?

In a post or page, simply type `[documents]` to display a list of documents. The shortcode accepts *most* [Standard WP_Query parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Parameters) which should allow you to fine tune the output. Parameters are passed in the form of, for example, `[documents numberposts="5"]`. Specifically, the shortcode accepts: `author__in`, `author__not_in`, `author_name`, `author`, `cat`, `category__and`, `category__in`, `category__not_in`, `category_name`, `date_query`, `day`, `has_password`, `hour`, `m`, `meta_compare`, `meta_key`, `meta_query`, `meta_value_num`, `meta_value`, `minute`, `monthnum`, `name`, `numberposts`, `p`, `page_id`, `pagename`, `post__in`, `post__not_in`, `post_name__in`, `post_parent__in`, `post_parent__not_in`, `post_parent`, `post_password`, `post_status`, `s`, `second`, `tag__and`, `tag__in`, `tag__not_in`, `tag_id`, `tag_slug__and`, `tag_slug__in`, `tag`, `tax_query`, `title`, `w` and `year`.

It is also possible to add formatting parameters: `show_edit` that will add a button next to each documument that the user can edit to edit the document; and `new_tab` that will open the document in a new browser tab rather than in the current one. Both of these are boolean variables, but can be simply entered without a value (with default value true).

If you're using a custom taxonomy, you can add the taxonomy name as a parameter in your shortcode. For example, if your custom taxonomy is called "document_categories", you can write insert a shortcode like this:

`[documents numberposts="6" document_categories="category-name"]`

(Where "category-name" is the taxonomy's slug)
In a post or page, simply type `[documents]` to display a list of documents.
More information is on [this](./shortcodes.md) page.

### How do I use the document revisions shortcode?

In a post or page, simply type `[document_revisions id="100"]` where ID is the ID of the document for which you would like to list revisions. You can find the ID in the URL of the edit document page. To limit the number of revisions displayed, passed the "number" argument, e.g., to display the 5 most recent revisions `[document_revisions id="100" number="5"]`.
In a post or page, simply type `[document_revisions id="100"]` where ID is the ID of the document for which you would like to list revisions.
More information is on [this](./shortcodes.md) page.

### How do I use the recently revised documents widget?

Expand All @@ -126,7 +122,7 @@ Yes. There's a plugin in the [WP Document Revisions Code Cookbook](https://githu

### Can I limit access to documents based on workflow state, department, or some other custom taxonomy?

Yes. Download (and optionally customize) the [taxonomy permissions](https://github.com/benbalter/WP-Document-Revisions-Code-Cookbook/blob/master/taxonomy-permissions.php) plugin from the [Code Cookbook](https://github.com/benbalter/WP-Document-Revisions-Code-Cookbook). Out of the box, it will register a "departments" taxonomy (which can be easily changed at the top of the file, if you want to limit access by a different taxonomy), and will create additional permissions based on that taxonomy's terms using WordPress's built-in capabilities system. So for example, instead simply looking at `edit_document` to determine permissions, it will also look at `edit_document_in_marketing`, for example. You can create additional roles and assign capabilities using a plugin like [Members](http://wordpress.org/extend/plugins/members/).
Yes. Download (and optionally customize) the [taxonomy permissions](https://github.com/benbalter/WP-Document-Revisions-Code-Cookbook/blob/master/taxonomy-permissions.php) plugin from the [Code Cookbook](https://github.com/benbalter/WP-Document-Revisions-Code-Cookbook). Out of the box, it will register a "departments" taxonomy (which can be easily changed at the top of the file, if you want to limit access by a different taxonomy), and will create additional permissions based on that taxonomy's terms using WordPress's built-in capabilities system. So for example, instead simply looking at `edit_document` to determine permissions, it will also look at `edit_document_in_marketing`, for example. You can create additional roles and assign capabilities using a plugin like [Members](https://wordpress.org/plugins/members).

### Is it possible to do a bulk import of existing documents / files already on the server?

Expand Down
2 changes: 1 addition & 1 deletion docs/header.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Contributors: benbalter
Tags: documents, uploads, attachments, document management, enterprise, version control, revisions, collaboration, journalism, government, files, revision log, document management, intranet, digital asset management
Requires at least: 4.6
Tested up to: 5.3
Stable tag: 3.2.4
Stable tag: 3.3.0
92 changes: 92 additions & 0 deletions docs/shortcodes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# WP-Documents-Revisions Shortcodes and Widget

These shortcodes and widget are available both in their historic form and as blocks.

Existing shortcodes can be converted to and from their block forms.

They are held in a grouping called `WP Document Revisions`.

## Documents Shortcode

In a post or page, simply type `[documents]` to display a list of documents.

### WP_Query parameters

The shortcode accepts *most* [Standard WP_Query parameters](https://developer.wordpress.org/reference/classes/wp_query/) which should allow you to fine tune the output. Parameters are passed in the form of, for example, `[documents numberposts="5"]`.

Specifically, the shortcode accepts: `author__in`, `author__not_in`, `author_name`, `author`, `cat`, `category__and`, `category__in`, `category__not_in`, `category_name`, `date_query`, `day`, `has_password`, `hour`, `m`, `meta_compare`, `meta_key`, `meta_query`, `meta_value_num`, `meta_value`, `minute`, `monthnum`, `name`, `numberposts`, `order`, `orderby`, `p`, `page_id`, `pagename`, `post__in`, `post__not_in`, `post_name__in`, `post_parent__in`, `post_parent__not_in`, `post_parent`, `post_password`, `post_status`, `s`, `second`, `tag__and`, `tag__in`, `tag__not_in`, `tag_id`, `tag_slug__and`, `tag_slug__in`, `tag`, `tax_query`, `title`, `w` and `year`.

If you're using a custom taxonomy, you can add the taxonomy name as a parameter in your shortcode. For example, if your custom taxonomy is called "document_categories", you can write insert a shortcode like this:

`[documents document_categories="category-name" numberposts="6"]`

(Where "category-name" is the taxonomy term's slug)

Strictly it uses accepts the "query_var" parameter of the taxonomies used for documents. That is, if you have defined a taxonomy for your documents with slug "document_categories". If you have not defined the query_var parameter then you use the slug. However if you have set query_var to "doc_cat", say, then you can insert a shortcode as

`[documents doc_cat="category-name" numberposts="5"]`

Important parameters WP_Query will be the ordering and number of posts to display.

`numberposts` (with a number parameter) will give the maximum number of posts to display.

`order` (with value 'ASC' or 'DESC') gives the ordering,

`orderby` (with a string value) gives the field to order the documents. Common values are "title", "date", "name", "modified" and "ID".

### Display parameters

It is also possible to add formatting parameters:

`show_edit` (with a true/false parameter) that can add a link next to each document shown in the list that the user is able to edit by them. This permits the user to edit the document directly from the list. A value set here will override the default behaviour.

As delivered, administrators will have the show_edit implicitly active. A filter `document_shortcode_show_edit` can be used to set this for additional user roles.

`new_tab` (with a true/false parameter) that will open the document in a new browser tab rather than in the current one.

Both of these boolean variables can be entered without a value (with default value true).

### Block Usage

When using the block version of the shortcode called `Document List`, some compromises have been necessary.

Since queries are often selecting a single taxonomy value, the block provides the possibility to select single values from up to three taxonomies. Since there can be more than three taxomomies attached to documents, a filter `document_block_taxonomies` allows the list of taxonomies to be edited to select the taxonomies to be displayed.

The parameters `numberposts`, `order`, `orderby`, `show_edit` and `new_tab` are directly supported. However, since there are many other parameters are possible, as well as differet structures, additional parameters may be entered as a text field as held in the shortcode.

## Document Revisions Shortcode

In a post or page, simply type `[document_revisions id="100"]` where ID is the ID of the document for which you would like to list revisions.

You can find the ID in the URL of the edit document page.

To limit the number of revisions displayed, passed the "number" argument, e.g., to display the 5 most recent revisions `[document_revisions id="100" number="5"]`.

### Display parameters

It is also possible to add formatting parameters:

`numberposts` (with a number parameter) will give the maximum number of revisions to display.

`summary` (with a true/false parameter) that will add the excerpt for the revision to the output.

`new_tab` (with a true/false parameter) that will open the revision in a new browser tab rather than in the current one.

Both of these boolean variables can be entered without a value (with default value true ).

### Block Usage

When using the block version of the shortcode called `Document Revisions`, a change have been necessary.

`number` is a reserved word within javascript so `numberposts` is also supported even for the shortcode format. `numberposts` is used by the block.

Since the block is dynamically displayed as parameters are entered, if the post number entered is not a document, then an appropriate message will be entered.

## Latest Documents Widget

Go to your theme's widgets page (if your theme supports widgets), and drag the widget to a sidebar of you choice. Once in a sidebar, you will be presented with options to customize the widget's functionality.

### Block Usage

The block version of the widget called `Document Widget`can be used on pages or posts. It cannot be converted to or from a shortcode block.

17 changes: 14 additions & 3 deletions docs/useful-plugins-and-tools.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## Useful plugins and tools

* [Members](https://wordpress.org/plugins/members/)
* [Edit Flow](https://editflow.org)
* [Simple Taxonomy](https://wordpress.org/plugins/simple-taxonomy/)
### Permissions management

* [User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress](https://wordpress.org/plugins/members/)

(Previously called Members)

### Taxonomy management

* [Simple Taxonomy Refreshed](https://wordpress.org/plugins/simple-taxonomy-refreshed/)

### Document workflow management

* [Edit Flow](https://wordpress.org/plugins/edit-flow/)
* [PublishPress](https://wordpress.org/plugins/publishpress/)

0 comments on commit 60117c4

Please sign in to comment.