rebase code on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:51:46 -04:00
parent b16ad94b69
commit 8f1a2c3a66
2197 changed files with 184921 additions and 35568 deletions

View File

@@ -4,54 +4,62 @@ defined( 'ABSPATH' ) || die( 'Cheatin uh?' );
/**
* Class that display the "custom folders" files.
*
* @since 1.7
* @package Imagify
* @since 1.7
* @author Grégory Viguier
*/
class Imagify_Files_List_Table extends WP_List_Table {
/**
* Class version.
*
* @var string
* @var string
* @since 1.7
* @author Grégory Viguier
*/
const VERSION = '1.1';
/**
* Class version.
*
* @var string
* @var string
* @since 1.7
* @author Grégory Viguier
*/
const PER_PAGE_OPTION = 'imagify_files_per_page';
/**
* List of the folders containing the listed files.
*
* @var array
* @since 1.7
* @var array
* @since 1.7
* @author Grégory Viguier
*/
protected $folders = array();
/**
* Filesystem object.
*
* @var Imagify_Filesystem
* @since 1.7.1
* @var object Imagify_Filesystem
* @since 1.7.1
* @author Grégory Viguier
*/
protected $filesystem;
/**
* Views object.
*
* @var Imagify_Views
* @since 1.9
* @var object Imagify_Views
* @since 1.9
* @author Grégory Viguier
*/
protected $views;
/**
* Constructor.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param array $args An associative array of arguments.
*/
@@ -72,7 +80,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Prepares the list of items for displaying.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*/
public function prepare_items() {
global $wpdb;
@@ -99,8 +108,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
$file_ids = array();
$where = '';
$sent_orderby = isset( $_GET['orderby'] ) ? htmlspecialchars( wp_unslash( $_GET['orderby'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
$sent_order = isset( $_GET['order'] ) ? htmlspecialchars( wp_unslash( $_GET['order'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
$sent_orderby = filter_input( INPUT_GET, 'orderby', FILTER_SANITIZE_STRING );
$sent_order = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_STRING );
$folder_filter = self::get_folder_filter();
$status_filter = self::get_status_filter();
@@ -218,7 +227,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Message to be displayed when there are no items.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*/
public function no_items() {
if ( self::get_status_filter() ) {
@@ -285,7 +295,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Display views.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*/
public function views() {
global $wpdb;
@@ -401,7 +412,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Get an associative array ( option_name => option_title ) with the list of bulk actions available on this table.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @return array
*/
@@ -415,7 +427,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
* Get a list of columns. The format is:
* 'internal-name' => 'Title'
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @return array
*/
@@ -439,7 +452,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
*
* The second format will make the initial sorting order be descending.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @return array
*/
@@ -455,7 +469,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Get a column contents.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param string $column The column "name": "cb", "title", "optimization_level", etc.
* @param object $item The current item. It must contain at least a $process property.
@@ -474,7 +489,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Handles the checkbox column output.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -489,7 +505,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Handles the title column output.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -538,7 +555,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Handles the parent folder column output.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -572,7 +590,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Handles the optimization data column output.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -623,7 +642,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Handles the status column output.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -657,7 +677,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Handles the optimization level column output.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -672,7 +693,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Handles the actions column output.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -708,7 +730,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Prints a button to optimize the file.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -735,7 +758,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Prints a button to retry to optimize the file.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -765,7 +789,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Prints buttons to re-optimize the file to other levels.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -808,7 +833,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Prints a button to generate WebP versions if they are missing.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -823,7 +849,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Prints a button to delete WebP versions when the status is "already_optimized".
*
* @since 1.9.6
* @since 1.9.6
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -838,7 +865,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Prints a button to restore the file.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -860,7 +888,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Prints a button to check if the file has been modified or not.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -876,7 +905,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Prints a button for the comparison tool (before / after optimization).
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
*/
@@ -922,7 +952,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
* Add the folder_id and folder_path properties to the $item if not set yet.
* It may happen if the $item doesn't come from the prepare() method.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param object $item The current item. It must contain at least a $process property.
* @return object The current item.
@@ -957,7 +988,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Get the name of the default primary column.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @return string Name of the default primary column, in this case, 'title'.
*/
@@ -968,7 +1000,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Get a list of CSS classes for the WP_List_Table table tag.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @return array List of CSS classes for the table tag.
*/
@@ -979,7 +1012,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Allow to save the screen options when submitted by the user.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @param bool|int $status Screen option value. Default false to skip.
* @param string $option The option name.
@@ -997,7 +1031,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Get the requested folder filter.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @return string
*/
@@ -1015,7 +1050,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
/**
* Get the requested status filter.
*
* @since 1.7
* @since 1.7
* @author Grégory Viguier
*
* @return string
*/
@@ -1031,7 +1067,7 @@ class Imagify_Files_List_Table extends WP_List_Table {
'unoptimized' => 1,
'errors' => 1,
);
$filter = isset( $_GET['status-filter'] ) ? trim( htmlspecialchars( wp_unslash( $_GET['status-filter'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
$filter = trim( filter_input( INPUT_GET, 'status-filter', FILTER_SANITIZE_STRING ) );
$filter = isset( $values[ $filter ] ) ? $filter : '';
return $filter;