Skip to content

Commit 82b2e6f

Browse files
authored
Merge pull request #14 from NeilWJames/master
Address file-taxonomy issue
2 parents 65e0bdb + 7de6e85 commit 82b2e6f

5 files changed

Lines changed: 10 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
TRAVIS_BUILD_DIR: ${{ github.workspace }}
1616
strategy:
1717
matrix:
18-
php_version: [7.4]
18+
php_version: [8.1]
1919
steps:
2020
- uses: actions/checkout@v4
2121

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"require-dev": {
1414
"phpcsstandards/phpcsutils": "^1.0",
1515
"phpcsstandards/phpcsextra": "^1.2.0",
16+
"squizlabs/php_codesniffer": "^3.11.1",
1617
"wp-coding-standards/wpcs": "~3.1",
1718
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
1819
"yoast/phpunit-polyfills": "*",

document-parent/js/indicator.gif

-1.52 KB
Binary file not shown.

filetype-taxonomy.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: WP Document Revisions - Filtering by Filetype
44
Plugin URI: https://github.com/wp-document-revisions/WP-Document-Revisions-Code-Cookbook
55
Description: Code sample to demonstrate how to build a filter by filetype taxonomy
6-
Version: 1.0
6+
Version: 2.0
77
Author: Benjamin J. Balter
88
Author URI: http://ben.balter.com
99
License: GPL2
@@ -33,7 +33,7 @@ function wpdr_register_filetype_taxonomy() {
3333
}
3434
}
3535

36-
add_action( 'init', 'wpdr_register_filetype_taxonomy' );
36+
add_action( 'init', 'wpdr_register_filetype_taxonomy', 99 );
3737

3838
/**
3939
* Saves the filetype terms from the post.
@@ -54,14 +54,15 @@ function wpdr_update_type( $post_ID ) {
5454

5555
$post = get_post( $post_ID );
5656
// is there an attachment (new post).
57-
if ( empty( $post->post_content ) || ! is_numeric( $post->post_content ) ) {
57+
$attach = $wpdr->extract_document_id( $post->post_content );
58+
if ( ! $attach ) {
5859
return;
5960
}
6061

61-
$attachment = get_post( $post->post_content );
62-
$extensions = array( $wpdr->get_extension( get_attached_file( $attachment->ID ) ) );
62+
// find the attachment filetype.
63+
$extensions = array( $wpdr->get_extension( get_attached_file( $attach ) ) );
6364

6465
wp_set_post_terms( $post_ID, $extensions, 'filetype', false );
6566
}
6667

67-
add_action( 'save_post', 'wpdr_update_type', 10, 1 );
68+
add_action( 'save_post_document', 'wpdr_update_type', 10, 1 );

wpdr-role-permissions/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: documents, document management, access, roles
44
Requires at least: 4.9
55
Requires PHP: 7.4
66
Requires Plugins: wp-document-revisions, members
7-
Tested up to: 6.5
7+
Tested up to: 6.8
88
Stable tag: 1.0
99
License: GPLv3 or later
1010
License URI: http://www.gnu.org/licenses/gpl-3.0.html

0 commit comments

Comments
 (0)