Skip to content

Commit

Permalink
fixed deprected PHP 8 notices
Browse files Browse the repository at this point in the history
  • Loading branch information
petenelson committed Jan 13, 2025
1 parent 333708b commit fda2705
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 87 deletions.
17 changes: 14 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ module.exports = function( grunt ) {
wp: [ "release" ]
},

wp_readme_to_markdown: {
options: {
screenshot_url: "https://raw.githubusercontent.com/petenelson/wp-revision-list/trunk/assets/{screenshot}.png",
},
your_target: {
files: {
'README.md': 'readme.txt'
}
},
},

copy: {

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

} ); // grunt.initConfig


// Load tasks
var tasks = [
'grunt-contrib-clean',
'grunt-contrib-copy',
'grunt-wp-readme-to-markdown',
'grunt-wp-i18n'
];

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


// Register tasks
// Register tasks
grunt.registerTask( 'readme', ['wp_readme_to_markdown'] );

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

grunt.util.linefeed = '\n';

};
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require-dev": {
"phpunit/phpunit": "^6.5.6"
"yoast/phpunit-polyfills": "^3.1"
}
}
4 changes: 3 additions & 1 deletion includes/class-wp-revision-list-screen-options.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use function WPRevisionList\Sanitizers\sanitized_post_field;

if (!defined( 'ABSPATH' )) exit('restricted access');

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

$post_type = sanitize_key( filter_input( INPUT_POST, 'wp_rev_list_post_type_screen_option', FILTER_SANITIZE_STRING ) );
$post_type = sanitized_post_field( 'wp_rev_list_post_type_screen_option' );

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

Expand Down
4 changes: 3 additions & 1 deletion includes/class-wp-revision-list-settings.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use function WPRevisionList\Sanitizers\sanitized_get_field;

if ( ! defined( 'ABSPATH' ) ) die( 'restricted access' );

if ( ! class_exists( 'WP_Revision_List_Settings' ) ) {
Expand Down Expand Up @@ -258,7 +260,7 @@ public function options_page() {


private function current_tab() {
$current_tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_STRING );
$current_tab = sanitized_get_field( 'tab' );
return empty( $current_tab ) ? $this->settings_key_general : $current_tab;
}

Expand Down
6 changes: 4 additions & 2 deletions includes/class-wp-revision-list-table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use function WPRevisionList\Sanitizers\sanitized_get_field;

if ( !defined( 'ABSPATH' ) ) exit( 'restricted access' );

if ( !class_exists( 'WP_Revision_List_Table' ) ) {
Expand Down Expand Up @@ -38,8 +40,8 @@ public function the_posts( $posts ) {
private function add_revisions_to_posts( $posts ) {

$new_post_list = array();
$screen = get_current_screen();
$is_trash = filter_input( INPUT_GET, 'post_status', FILTER_SANITIZE_STRING );
$screen = get_current_screen();
$is_trash = sanitized_get_field( 'post_status');

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

Expand Down
2 changes: 1 addition & 1 deletion includes/partials/admin-help.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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

<h3 class="title"><?php _e( 'Contact', 'wp-revision-list' ); ?></h3>
<h3 class="title"><?php esc_html_e( 'Contact', 'wp-revision-list' ); ?></h3>
<p>
<?php esc_html_e( 'E-Mail', 'wp-revision-list' ) ?>: <a href="mailto:[email protected]">[email protected]</a><br/>
<?php esc_html_e( 'Twitter', 'wp-revision-list' ) ?>: <a href="https://twitter.com/CodeGeekATX">@CodeGeekATX</a><br/>
Expand Down
79 changes: 79 additions & 0 deletions includes/sanitizers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* Sanitize helper function to retrive values from $_GET, $_POST, etc.
*/

namespace WPRevisionList\Sanitizers;

/**
* Gets a sanitized text field from an array. Defaults to sanitize_text_field().
*
* @param string $field The field name.
* @param array $array The request array ($_POST, $_GET, etc).
* @param mixed $sanitizer The filter constant or array with callback options.
* @return string
*/
function sanitized_array_field( $field, $array, $sanitizer = false ) {

if ( false === $sanitizer ) {
$sanitizer = filter_sanitize_text_field();
}

$request = filter_var_array( $array, [ $field => $sanitizer ] );
return $request[ $field ];
}

/**
* Callback filter for filter_var_array() to sanitize a text field.
*
* @return array
*/
function filter_sanitize_text_field() {
return [
'filter' => FILTER_CALLBACK,
'options' => '\sanitize_text_field',
];
}

/**
* Gets a sanitized text field from the $_POST variable.
*
* @param string $field The POST field name.
* @return string
*/
function sanitized_post_field( $field ) {
return sanitized_array_field( $field, $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
}

/**
* Gets a sanitized text field from the $_GET variable.
*
* @param string $field The GET field name.
* @return string
*/
function sanitized_get_field( $field ) {
return sanitized_array_field( $field, $_GET ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}

/**
* Gets the REQUEST_URI from the $_SERVER variable.
*
* @return string
*/
function get_request_uri() {
return sanitized_array_field( 'REQUEST_URI', $_SERVER );
}

/**
* Gets a sanitized text array from the $_POST variable.
*
* @param string $field The POST field name.
* @return string
*/
function sanitized_post_array( $field ) {
$filter_string = filter_sanitize_text_field();
$filter_string['flags'] = FILTER_REQUIRE_ARRAY;

$array = sanitized_array_field( $field, $_POST, $filter_string ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
return is_array( $array ) ? $array : [];
}
36 changes: 18 additions & 18 deletions lang/wp-revision-list.pot
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
# Copyright (C) 2018 Pete Nelson <a href="https://twitter.com/CodeGeekATX">(@CodeGeekATX)</a>
# Copyright (C) 2025 Pete Nelson <a href="https://twitter.com/CodeGeekATX">(@CodeGeekATX)</a>
# This file is distributed under the same license as the WP Revision List package.
msgid ""
msgstr ""
"Project-Id-Version: WP Revision List 1.1.8\n"
"Project-Id-Version: WP Revision List 1.1.9\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-revision-list\n"
"POT-Creation-Date: 2018-12-16 16:27:38+00:00\n"
"POT-Creation-Date: 2025-01-13 20:56:54+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2025-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"X-Generator: grunt-wp-i18n1.0.2\n"
"X-Generator: grunt-wp-i18n 1.0.3\n"

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

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

#: includes/class-wp-revision-list-settings.php:68
#: includes/class-wp-revision-list-settings.php:70
#: release/includes/class-wp-revision-list-settings.php:68
msgid "General"
msgstr ""

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

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

#: includes/class-wp-revision-list-settings.php:79
#: includes/class-wp-revision-list-settings.php:81
#: release/includes/class-wp-revision-list-settings.php:79
msgid "Prefix title with"
msgstr ""

#: includes/class-wp-revision-list-settings.php:82
#: includes/class-wp-revision-list-settings.php:84
#: release/includes/class-wp-revision-list-settings.php:82
msgid "Suffix title with"
msgstr ""

#: includes/class-wp-revision-list-settings.php:93
#: includes/class-wp-revision-list-settings.php:94
#: includes/class-wp-revision-list-settings.php:95
#: includes/class-wp-revision-list-settings.php:96
#: release/includes/class-wp-revision-list-settings.php:93
#: release/includes/class-wp-revision-list-settings.php:94
msgid "Post Types"
msgstr ""

#: includes/class-wp-revision-list-settings.php:111
#: includes/class-wp-revision-list-settings.php:113
#: release/includes/class-wp-revision-list-settings.php:111
msgid "Help"
msgstr ""

#: includes/class-wp-revision-list-settings.php:237
#: includes/class-wp-revision-list-settings.php:268
#: includes/class-wp-revision-list-settings.php:239
#: includes/class-wp-revision-list-settings.php:270
#: release/includes/class-wp-revision-list-settings.php:237
#: release/includes/class-wp-revision-list-settings.php:268
msgid "WP Revision List Settings"
Expand All @@ -73,7 +73,7 @@ msgstr ""
msgid "WP Revision List"
msgstr ""

#: includes/class-wp-revision-list-settings.php:251
#: includes/class-wp-revision-list-settings.php:253
#: release/includes/class-wp-revision-list-settings.php:251
msgid "Save Settings"
msgstr ""
Expand Down
56 changes: 29 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
{
"name": "wp-revision-list",
"version": "1.1.5",
"description": "WordPress plugin to show revisions when viewing lists of posts, pages, or custom post types in the admin dashboard",
"main": "Gruntfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/petenelson/wp-revision-list.git"
},
"keywords": [
"wordpress",
"dashboard"
],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/petenelson/wp-revision-list/issues"
},
"homepage": "https://github.com/petenelson/wp-revision-list",
"devDependencies": {
"grunt": "^1",
"grunt-contrib-clean": "^2",
"grunt-contrib-copy": "^1",
"grunt-wp-i18n": "^1"
}
"name": "wp-revision-list",
"version": "1.1.5",
"description": "WordPress plugin to show revisions when viewing lists of posts, pages, or custom post types in the admin dashboard",
"main": "Gruntfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/petenelson/wp-revision-list.git"
},
"keywords": [
"wordpress",
"dashboard"
],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/petenelson/wp-revision-list/issues"
},
"homepage": "https://github.com/petenelson/wp-revision-list",
"devDependencies": {
"grunt": "^1.6.1",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-potomo": "^3.5.0",
"grunt-wp-i18n": "^1.0.3",
"grunt-wp-readme-to-markdown": "^2.1.0"
}
}
Loading

0 comments on commit fda2705

Please sign in to comment.