Skip to content

Commit fda2705

Browse files
committed
fixed deprected PHP 8 notices
1 parent 333708b commit fda2705

12 files changed

+228
-87
lines changed

Gruntfile.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ module.exports = function( grunt ) {
1616
wp: [ "release" ]
1717
},
1818

19+
wp_readme_to_markdown: {
20+
options: {
21+
screenshot_url: "https://raw.githubusercontent.com/petenelson/wp-revision-list/trunk/assets/{screenshot}.png",
22+
},
23+
your_target: {
24+
files: {
25+
'README.md': 'readme.txt'
26+
}
27+
},
28+
},
29+
1930
copy: {
2031

2132
// create release for WordPress repository
@@ -43,24 +54,24 @@ module.exports = function( grunt ) {
4354

4455
} ); // grunt.initConfig
4556

46-
4757
// Load tasks
4858
var tasks = [
4959
'grunt-contrib-clean',
5060
'grunt-contrib-copy',
61+
'grunt-wp-readme-to-markdown',
5162
'grunt-wp-i18n'
5263
];
5364

5465
for ( var i = 0; i < tasks.length; i++ ) {
5566
grunt.loadNpmTasks( tasks[ i ] );
5667
};
5768

58-
5969
// Register tasks
70+
// Register tasks
71+
grunt.registerTask( 'readme', ['wp_readme_to_markdown'] );
6072

6173
// create release for WordPress repository
6274
grunt.registerTask( 'wp', [ 'makepot', 'clean', 'copy' ] );
6375

6476
grunt.util.linefeed = '\n';
65-
6677
};

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"require-dev": {
3-
"phpunit/phpunit": "^6.5.6"
3+
"yoast/phpunit-polyfills": "^3.1"
44
}
55
}

includes/class-wp-revision-list-screen-options.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use function WPRevisionList\Sanitizers\sanitized_post_field;
4+
35
if (!defined( 'ABSPATH' )) exit('restricted access');
46

57
if (!class_exists('WP_Revision_List_Screen_Options')) {
@@ -56,7 +58,7 @@ public function save_user_meta( $action, $result ) {
5658
// see if this is coming from a screen option 'Apply'
5759
// the first step in misc/set_screen_options() is check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
5860

59-
$post_type = sanitize_key( filter_input( INPUT_POST, 'wp_rev_list_post_type_screen_option', FILTER_SANITIZE_STRING ) );
61+
$post_type = sanitized_post_field( 'wp_rev_list_post_type_screen_option' );
6062

6163
if ( $action === 'screen-options-nonce' && $result === 1 && ! empty( $post_type ) ) {
6264

includes/class-wp-revision-list-settings.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use function WPRevisionList\Sanitizers\sanitized_get_field;
4+
35
if ( ! defined( 'ABSPATH' ) ) die( 'restricted access' );
46

57
if ( ! class_exists( 'WP_Revision_List_Settings' ) ) {
@@ -258,7 +260,7 @@ public function options_page() {
258260

259261

260262
private function current_tab() {
261-
$current_tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_STRING );
263+
$current_tab = sanitized_get_field( 'tab' );
262264
return empty( $current_tab ) ? $this->settings_key_general : $current_tab;
263265
}
264266

includes/class-wp-revision-list-table.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use function WPRevisionList\Sanitizers\sanitized_get_field;
4+
35
if ( !defined( 'ABSPATH' ) ) exit( 'restricted access' );
46

57
if ( !class_exists( 'WP_Revision_List_Table' ) ) {
@@ -38,8 +40,8 @@ public function the_posts( $posts ) {
3840
private function add_revisions_to_posts( $posts ) {
3941

4042
$new_post_list = array();
41-
$screen = get_current_screen();
42-
$is_trash = filter_input( INPUT_GET, 'post_status', FILTER_SANITIZE_STRING );
43+
$screen = get_current_screen();
44+
$is_trash = sanitized_get_field( 'post_status');
4345

4446
$revisions = $this->get_revisions_for_posts( $posts, $screen->post_type );
4547

includes/partials/admin-help.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<div class="wp-revision-list-help">
1717

18-
<h3 class="title"><?php _e( 'Contact', 'wp-revision-list' ); ?></h3>
18+
<h3 class="title"><?php esc_html_e( 'Contact', 'wp-revision-list' ); ?></h3>
1919
<p>
2020
<?php esc_html_e( 'E-Mail', 'wp-revision-list' ) ?>: <a href="mailto:pete@petenelson.com">pete@petenelson.com</a><br/>
2121
<?php esc_html_e( 'Twitter', 'wp-revision-list' ) ?>: <a href="https://twitter.com/CodeGeekATX">@CodeGeekATX</a><br/>

includes/sanitizers.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Sanitize helper function to retrive values from $_GET, $_POST, etc.
4+
*/
5+
6+
namespace WPRevisionList\Sanitizers;
7+
8+
/**
9+
* Gets a sanitized text field from an array. Defaults to sanitize_text_field().
10+
*
11+
* @param string $field The field name.
12+
* @param array $array The request array ($_POST, $_GET, etc).
13+
* @param mixed $sanitizer The filter constant or array with callback options.
14+
* @return string
15+
*/
16+
function sanitized_array_field( $field, $array, $sanitizer = false ) {
17+
18+
if ( false === $sanitizer ) {
19+
$sanitizer = filter_sanitize_text_field();
20+
}
21+
22+
$request = filter_var_array( $array, [ $field => $sanitizer ] );
23+
return $request[ $field ];
24+
}
25+
26+
/**
27+
* Callback filter for filter_var_array() to sanitize a text field.
28+
*
29+
* @return array
30+
*/
31+
function filter_sanitize_text_field() {
32+
return [
33+
'filter' => FILTER_CALLBACK,
34+
'options' => '\sanitize_text_field',
35+
];
36+
}
37+
38+
/**
39+
* Gets a sanitized text field from the $_POST variable.
40+
*
41+
* @param string $field The POST field name.
42+
* @return string
43+
*/
44+
function sanitized_post_field( $field ) {
45+
return sanitized_array_field( $field, $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
46+
}
47+
48+
/**
49+
* Gets a sanitized text field from the $_GET variable.
50+
*
51+
* @param string $field The GET field name.
52+
* @return string
53+
*/
54+
function sanitized_get_field( $field ) {
55+
return sanitized_array_field( $field, $_GET ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
56+
}
57+
58+
/**
59+
* Gets the REQUEST_URI from the $_SERVER variable.
60+
*
61+
* @return string
62+
*/
63+
function get_request_uri() {
64+
return sanitized_array_field( 'REQUEST_URI', $_SERVER );
65+
}
66+
67+
/**
68+
* Gets a sanitized text array from the $_POST variable.
69+
*
70+
* @param string $field The POST field name.
71+
* @return string
72+
*/
73+
function sanitized_post_array( $field ) {
74+
$filter_string = filter_sanitize_text_field();
75+
$filter_string['flags'] = FILTER_REQUIRE_ARRAY;
76+
77+
$array = sanitized_array_field( $field, $_POST, $filter_string ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
78+
return is_array( $array ) ? $array : [];
79+
}

lang/wp-revision-list.pot

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
1-
# Copyright (C) 2018 Pete Nelson <a href="https://twitter.com/CodeGeekATX">(@CodeGeekATX)</a>
1+
# Copyright (C) 2025 Pete Nelson <a href="https://twitter.com/CodeGeekATX">(@CodeGeekATX)</a>
22
# This file is distributed under the same license as the WP Revision List package.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: WP Revision List 1.1.8\n"
5+
"Project-Id-Version: WP Revision List 1.1.9\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-revision-list\n"
7-
"POT-Creation-Date: 2018-12-16 16:27:38+00:00\n"
7+
"POT-Creation-Date: 2025-01-13 20:56:54+00:00\n"
88
"MIME-Version: 1.0\n"
99
"Content-Type: text/plain; charset=utf-8\n"
1010
"Content-Transfer-Encoding: 8bit\n"
11-
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
11+
"PO-Revision-Date: 2025-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language-Team: LANGUAGE <LL@li.org>\n"
14-
"X-Generator: grunt-wp-i18n1.0.2\n"
14+
"X-Generator: grunt-wp-i18n 1.0.3\n"
1515

16-
#: includes/class-wp-revision-list-screen-options.php:38
16+
#: includes/class-wp-revision-list-screen-options.php:40
1717
#: release/includes/class-wp-revision-list-screen-options.php:38
1818
msgid "Number of revisions to display:"
1919
msgstr ""
2020

21-
#: includes/class-wp-revision-list-settings.php:46
21+
#: includes/class-wp-revision-list-settings.php:48
2222
#: release/includes/class-wp-revision-list-settings.php:46
2323
msgid ""
2424
"<strong>Revision List activated!</strong> Please <a href=\"%s\">visit the "
2525
"Settings page</a> to customize your revision list."
2626
msgstr ""
2727

28-
#: includes/class-wp-revision-list-settings.php:68
28+
#: includes/class-wp-revision-list-settings.php:70
2929
#: release/includes/class-wp-revision-list-settings.php:68
3030
msgid "General"
3131
msgstr ""
3232

33-
#: includes/class-wp-revision-list-settings.php:76
33+
#: includes/class-wp-revision-list-settings.php:78
3434
#: release/includes/class-wp-revision-list-settings.php:76
3535
msgid "Default number of revisions to display"
3636
msgstr ""
3737

38-
#: includes/class-wp-revision-list-settings.php:77
38+
#: includes/class-wp-revision-list-settings.php:79
3939
#: release/includes/class-wp-revision-list-settings.php:77
4040
msgid "Users can chose their own setting in Screen Options"
4141
msgstr ""
4242

43-
#: includes/class-wp-revision-list-settings.php:79
43+
#: includes/class-wp-revision-list-settings.php:81
4444
#: release/includes/class-wp-revision-list-settings.php:79
4545
msgid "Prefix title with"
4646
msgstr ""
4747

48-
#: includes/class-wp-revision-list-settings.php:82
48+
#: includes/class-wp-revision-list-settings.php:84
4949
#: release/includes/class-wp-revision-list-settings.php:82
5050
msgid "Suffix title with"
5151
msgstr ""
5252

53-
#: includes/class-wp-revision-list-settings.php:93
54-
#: includes/class-wp-revision-list-settings.php:94
53+
#: includes/class-wp-revision-list-settings.php:95
54+
#: includes/class-wp-revision-list-settings.php:96
5555
#: release/includes/class-wp-revision-list-settings.php:93
5656
#: release/includes/class-wp-revision-list-settings.php:94
5757
msgid "Post Types"
5858
msgstr ""
5959

60-
#: includes/class-wp-revision-list-settings.php:111
60+
#: includes/class-wp-revision-list-settings.php:113
6161
#: release/includes/class-wp-revision-list-settings.php:111
6262
msgid "Help"
6363
msgstr ""
6464

65-
#: includes/class-wp-revision-list-settings.php:237
66-
#: includes/class-wp-revision-list-settings.php:268
65+
#: includes/class-wp-revision-list-settings.php:239
66+
#: includes/class-wp-revision-list-settings.php:270
6767
#: release/includes/class-wp-revision-list-settings.php:237
6868
#: release/includes/class-wp-revision-list-settings.php:268
6969
msgid "WP Revision List Settings"
@@ -73,7 +73,7 @@ msgstr ""
7373
msgid "WP Revision List"
7474
msgstr ""
7575

76-
#: includes/class-wp-revision-list-settings.php:251
76+
#: includes/class-wp-revision-list-settings.php:253
7777
#: release/includes/class-wp-revision-list-settings.php:251
7878
msgid "Save Settings"
7979
msgstr ""

package.json

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
{
2-
"name": "wp-revision-list",
3-
"version": "1.1.5",
4-
"description": "WordPress plugin to show revisions when viewing lists of posts, pages, or custom post types in the admin dashboard",
5-
"main": "Gruntfile.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8-
},
9-
"repository": {
10-
"type": "git",
11-
"url": "https://github.com/petenelson/wp-revision-list.git"
12-
},
13-
"keywords": [
14-
"wordpress",
15-
"dashboard"
16-
],
17-
"author": "",
18-
"license": "ISC",
19-
"bugs": {
20-
"url": "https://github.com/petenelson/wp-revision-list/issues"
21-
},
22-
"homepage": "https://github.com/petenelson/wp-revision-list",
23-
"devDependencies": {
24-
"grunt": "^1",
25-
"grunt-contrib-clean": "^2",
26-
"grunt-contrib-copy": "^1",
27-
"grunt-wp-i18n": "^1"
28-
}
2+
"name": "wp-revision-list",
3+
"version": "1.1.5",
4+
"description": "WordPress plugin to show revisions when viewing lists of posts, pages, or custom post types in the admin dashboard",
5+
"main": "Gruntfile.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/petenelson/wp-revision-list.git"
12+
},
13+
"keywords": [
14+
"wordpress",
15+
"dashboard"
16+
],
17+
"author": "",
18+
"license": "ISC",
19+
"bugs": {
20+
"url": "https://github.com/petenelson/wp-revision-list/issues"
21+
},
22+
"homepage": "https://github.com/petenelson/wp-revision-list",
23+
"devDependencies": {
24+
"grunt": "^1.6.1",
25+
"grunt-contrib-clean": "^2.0.1",
26+
"grunt-contrib-copy": "^1.0.0",
27+
"grunt-potomo": "^3.5.0",
28+
"grunt-wp-i18n": "^1.0.3",
29+
"grunt-wp-readme-to-markdown": "^2.1.0"
30+
}
2931
}

0 commit comments

Comments
 (0)