-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from NeilWJames/master
Implement Members Role based Permissions into WP Document Revisions and update to WPCS 3.0
- Loading branch information
Showing
25 changed files
with
591 additions
and
189 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Based on https://github.com/wp-document-revisions/wp-document-revisions | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
phpcs: | ||
runs-on: ubuntu-latest | ||
env: | ||
TRAVIS_BUILD_DIR: ${{ github.workspace }} | ||
strategy: | ||
matrix: | ||
php_version: [7.4] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php_version }} | ||
extensions: mysqli | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: phpcs | ||
run: scripts/phpcs |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "wp-document-revisions/wp-document-revisions-code-cookbook", | ||
"description": "Sample Code for Common WP Document Revision Implementations.", | ||
"license": "GPLv3", | ||
"authors": [ | ||
{ | ||
"name": "Ben Balter", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
}, | ||
"require-dev": { | ||
"phpcsstandards/phpcsutils": "^1.0", | ||
"phpcsstandards/phpcsextra": "^1.1.0", | ||
"wp-coding-standards/wpcs": "~3.0", | ||
"dealerdirect/phpcodesniffer-composer-installer": "^1.0", | ||
"yoast/phpunit-polyfills": "*", | ||
"phpcompatibility/php-compatibility": "*", | ||
"phpcompatibility/phpcompatibility-paragonie": "*", | ||
"phpcompatibility/phpcompatibility-wp": "*" | ||
}, | ||
"config": { | ||
"bin-dir": "bin", | ||
"vendor-dir": "vendor", | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
<?php | ||
/* | ||
Plugin Name: WP Document Revisions - Recently Revised Widget | ||
Plugin URI: https://github.com/benbalter/WP-Document-Revisions-Code-Cookbook | ||
Description: Code sample to demonstrate a widget of recently revised files | ||
Version: 1.0 | ||
Author: Benjamin J. Balter | ||
Author URI: http://ben.balter.com | ||
License: GPL2 | ||
*/ | ||
|
||
|
||
/** | ||
* Plugin Name: WP Document Revisions - Recently Revised Widget | ||
* Plugin URI: https://github.com/wp-document-revisions/WP-Document-Revisions-Code-Cookbook | ||
* Description: Code sample to demonstrate a widget of recently revised files | ||
* Version: 1.0 | ||
* Author: Benjamin J. Balter | ||
* Author URI: http://ben.balter.com | ||
* License: GPL2 | ||
* | ||
* @package WP-Document-Revisions-Code-Cookbook | ||
*/ | ||
|
||
/** | ||
* NOTE: An updated version of this widget is now included with WP Document Revisions by default | ||
* As a result, this file is no longer maintained | ||
* | ||
*/ | ||
|
||
// phpcs:disable | ||
class wpdr_recently_revised_widget extends WP_Widget { | ||
|
||
function __construct() { | ||
public function __construct() { | ||
parent::WP_Widget( 'wpdr_recently_revised_documents', $name = 'Recently Revised Documents' ); | ||
add_action( 'widgets_init', create_function( '', 'return register_widget("wpdr_recently_revised_documents");' ) ); | ||
} | ||
function widget( $args, $instance ) { | ||
|
||
public function widget( $args, $instance ) { | ||
|
||
$wpdr = Document_Revisions::$instance; | ||
|
||
extract( $args ); | ||
echo $before_widget; | ||
|
||
echo $before_widget; | ||
|
||
echo $before_title . 'Recently Revised Documents' . $after_title; | ||
|
||
$query = array( | ||
'post_type' => 'document', | ||
'orderby' => 'modified', | ||
'order' => 'DESC', | ||
'post_type' => 'document', | ||
'orderby' => 'modified', | ||
'order' => 'DESC', | ||
'numberposts' => '5', | ||
'post_status' => array( 'private', 'publish', 'draft' ), | ||
); | ||
|
||
$documents = get_posts( $query ); | ||
|
||
echo "<ul>\n"; | ||
foreach ( $documents as $document ) { | ||
|
||
//use our function to get post data to correct WP's author bug | ||
$revision = $wpdr->get_latest_revision( $document->ID ); | ||
|
||
?> | ||
?> | ||
<li><a href="<?php echo get_edit_post_link( $revision->ID ); ?>"><?php echo $revision->post_title; ?></a><br /> | ||
<?php echo human_time_diff( strtotime( $revision->post_modified_gmt ) ); ?> ago by <?php echo get_the_author_meta( 'display_name', $revision->post_author ); ?> | ||
</li> | ||
<?php } | ||
|
||
<?php | ||
} | ||
|
||
echo "</ul>\n"; | ||
|
||
echo $after_widget; | ||
|
||
} | ||
|
||
} | ||
|
||
new wpdr_recently_revised_documents; | ||
new wpdr_recently_revised_documents(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
Plugin Name: WP Document Revisions - Remove Dates from Permalinks | ||
Plugin URI: https://github.com/wp-document-revisions/WP-Document-Revisions-Code-Cookbook | ||
Description: Removes the year and month from document permalinks | ||
Version: 1.0 | ||
Author: Benjamin J. Balter | ||
Author URI: http://ben.balter.com | ||
License: GPL2 | ||
* | ||
* @package WP Document Revisions Code Cookbook | ||
*/ | ||
|
||
/** | ||
* Strip date from permalink | ||
* | ||
* @param string $link Permalink URL. | ||
* @param WP_Post $post The ID of the document being saved. | ||
*/ | ||
function wpdr_remove_dates_from_permalink_filter( $link, $post ) { | ||
|
||
$timestamp = '/' . substr( $post->post_date, 0, 7 ) . '/'; | ||
return str_replace( $timestamp, '/', $link ); | ||
} | ||
|
||
add_filter( 'document_permalink', 'wpdr_remove_dates_from_permalink_filter', 10, 2 ); | ||
|
||
// Existing rules match documents with or without year/month parts. |
This file contains 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
Oops, something went wrong.