Merged in feature/MAW-855-import-code-into-aws (pull request #2)

code import from pantheon

* code import from pantheon
This commit is contained in:
Tony Volpe
2023-12-04 23:08:14 +00:00
parent 8c9b1312bc
commit 8f4b5efda6
4766 changed files with 185592 additions and 239967 deletions

View File

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