rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -123,7 +123,9 @@ function _imagify_sort_attachments_by_status( $vars ) {
),
) );
$vars['post_mime_type'] = imagify_get_mime_types();
if ( ! key_exists( 'post_mime_type', $vars ) ) {
$vars['post_mime_type'] = imagify_get_mime_types();
}
return $vars;
}

View File

@@ -18,6 +18,13 @@ abstract class Imagify_Abstract_Background_Process extends Imagify_WP_Background
*/
protected $prefix = 'imagify';
/**
* URL to query on.
*
* @var string
*/
protected $query_url = '';
/**
* Set to true to automatically displatch at the end of the page.
*

View File

@@ -1,6 +1,7 @@
<?php
use Imagify\Traits\InstanceGetterTrait;
use Imagify\User\User;
/**
* Class that handles admin ajax/post callbacks.
@@ -220,13 +221,13 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
$process = imagify_get_optimization_process( $media_id, $context );
if ( ! $process->is_valid() ) {
return new \WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
return new WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
}
$data = $process->get_data();
if ( ! $data->is_already_optimized() ) {
return new \WP_Error( 'not_already_optimized', __( 'This media does not have the right optimization status.', 'imagify' ) );
return new WP_Error( 'not_already_optimized', __( 'This media does not have the right optimization status.', 'imagify' ) );
}
if ( ! $process->has_webp() ) {
@@ -237,7 +238,7 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
$deleted = $process->delete_webp_files();
if ( is_wp_error( $deleted ) ) {
return new \WP_Error( 'webp_not_deleted', __( 'Previous WebP files could not be deleted.', 'imagify' ) );
return new WP_Error( 'webp_not_deleted', __( 'Previous WebP files could not be deleted.', 'imagify' ) );
}
return true;
@@ -841,7 +842,7 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
imagify_die();
}
$user = new Imagify_User();
$user = new User();
$views = Imagify_Views::get_instance();
$unconsumed_quota = $views->get_quota_percent();
$message = '';
@@ -1148,7 +1149,7 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
imagify_die();
}
$notice = filter_input( INPUT_GET, 'ad', FILTER_SANITIZE_STRING );
$notice = htmlspecialchars( wp_unslash( $_GET['ad'] ) );
if ( ! $notice ) {
imagify_maybe_redirect();
@@ -1215,8 +1216,8 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
* @return string
*/
public function get_context( $method = 'GET', $parameter = 'context' ) {
$method = 'POST' === $method ? INPUT_POST : INPUT_GET;
$context = filter_input( $method, $parameter, FILTER_SANITIZE_STRING );
$context = 'POST' === $method ? wp_unslash( $_POST[ $parameter ] ) : wp_unslash( $_GET[ $parameter ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
$context = htmlspecialchars( $context );
return imagify_sanitize_context( $context );
}
@@ -1246,14 +1247,15 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
*
* @since 1.9
*
* @param string $method The method used: 'GET' (default), or 'POST'.
* @param string $parameter The name of the parameter to look for.
* @param string $method The method used: 'GET' (default), or 'POST'.
* @param string $parameter The name of the parameter to look for.
*
* @return string
*/
public function get_folder_type( $method = 'GET', $parameter = 'folder_type' ) {
$method = 'POST' === $method ? INPUT_POST : INPUT_GET;
$folder_type = 'POST' === $method ? wp_unslash( $_POST[ $parameter ] ) : wp_unslash( $_GET[ $parameter ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
return filter_input( $method, $parameter, FILTER_SANITIZE_STRING );
return htmlspecialchars( $folder_type );
}
/**
@@ -1261,13 +1263,14 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
*
* @since 1.9
*
* @param string $method The method used: 'GET' (default), or 'POST'.
* @param string $parameter The name of the parameter to look for.
* @param string $method The method used: 'GET' (default), or 'POST'.
* @param string $parameter The name of the parameter to look for.
*
* @return string
*/
public function get_imagify_action( $method = 'GET', $parameter = 'imagify_action' ) {
$method = 'POST' === $method ? INPUT_POST : INPUT_GET;
$action = filter_input( $method, $parameter, FILTER_SANITIZE_STRING );
$action = 'POST' === $method ? wp_unslash( $_POST[ $parameter ] ) : wp_unslash( $_GET[ $parameter ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
$action = htmlspecialchars( $action );
return $action ? $action : 'optimize';
}

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;

View File

@@ -1,4 +1,7 @@
<?php
use Imagify\User\User;
defined( 'ABSPATH' ) || die( 'Cheatin uh?' );
/**
@@ -303,7 +306,7 @@ class Imagify_Requirements {
return self::$supports['over_quota'];
}
$user = new Imagify_User();
$user = new User();
self::$supports['over_quota'] = $user->get_error() ? false : $user->is_over_quota();

View File

@@ -131,9 +131,12 @@ class Imagify_Settings {
* @return bool
*/
public function is_form_submit() {
return filter_input( INPUT_POST, 'option_page', FILTER_SANITIZE_STRING ) === $this->settings_group && filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING ) === 'update';
}
if ( ! isset( $_POST['option_page'], $_POST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
return false;
}
return htmlspecialchars( wp_unslash( $_POST['option_page'] ) ) === $this->settings_group && htmlspecialchars( wp_unslash( $_POST['action'] ) ) === 'update'; // phpcs:ignore WordPress.Security.NonceVerification.Missing
}
/** ----------------------------------------------------------------------------------------- */
/** ON FORM SUBMIT ========================================================================== */

View File

@@ -1,18 +1,20 @@
<?php
use Imagify\User\User;
defined( 'ABSPATH' ) || die( 'Cheatin uh?' );
/**
* Class that handles templates and menus.
*
* @since 1.7
* @author Grégory Viguier
* @since 1.7
*/
class Imagify_Views {
/**
* Class version.
*
* @var string
* @var string
* @since 1.7
*/
const VERSION = '1.1';
@@ -20,64 +22,56 @@ class Imagify_Views {
/**
* Slug used for the settings page URL.
*
* @var string
* @since 1.7
* @access protected
* @var string
* @since 1.7
*/
protected $slug_settings;
/**
* Slug used for the bulk optimization page URL.
*
* @var string
* @since 1.7
* @access protected
* @var string
* @since 1.7
*/
protected $slug_bulk;
/**
* Slug used for the "custom folders" page URL.
*
* @var string
* @since 1.7
* @access protected
* @var string
* @since 1.7
*/
protected $slug_files;
/**
* A list of JS templates to print at the end of the page.
*
* @var array
* @since 1.9
* @access protected
* @var array
* @since 1.9
*/
protected $templates_in_footer = [];
/**
* Stores the "custom folders" files list instance.
*
* @var object Imagify_Files_List_Table
* @since 1.7
* @access protected
* @var Imagify_Files_List_Table
* @since 1.7
*/
protected $list_table;
/**
* Filesystem object.
*
* @var object Imagify_Filesystem
* @since 1.7.1
* @access protected
* @author Grégory Viguier
* @var Imagify_Filesystem
* @since 1.7.1
*/
protected $filesystem;
/**
* The single instance of the class.
*
* @var object
* @since 1.7
* @access protected
* @var object
* @since 1.7
*/
protected static $_instance;
@@ -89,9 +83,7 @@ class Imagify_Views {
/**
* The constructor.
*
* @since 1.7
* @author Grégory Viguier
* @access protected
* @since 1.7
*/
protected function __construct() {
$this->slug_settings = IMAGIFY_SLUG;
@@ -103,9 +95,7 @@ class Imagify_Views {
/**
* Get the main Instance.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*
* @return object Main instance.
*/
@@ -120,9 +110,7 @@ class Imagify_Views {
/**
* Launch the hooks.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*/
public function init() {
// Menu items.
@@ -152,9 +140,7 @@ class Imagify_Views {
/**
* Add sub-menus for all sites.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*/
public function add_site_menus() {
$wp_context = imagify_get_context( 'wp' );
@@ -187,9 +173,7 @@ class Imagify_Views {
/**
* Add menu and sub-menus in the network admin when Imagify is network-activated.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*/
public function add_network_menus() {
global $submenu;
@@ -232,9 +216,7 @@ class Imagify_Views {
/**
* Add links to the plugin row in the plugins list.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*
* @param array $actions An array of action links.
* @return array
@@ -254,9 +236,7 @@ class Imagify_Views {
/**
* The main settings page.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*/
public function display_settings_page() {
$this->print_template( 'page-settings' );
@@ -265,9 +245,7 @@ class Imagify_Views {
/**
* The bulk optimization page.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*/
public function display_bulk_page() {
$types = array();
@@ -363,9 +341,7 @@ class Imagify_Views {
/**
* The page displaying the "custom folders" files.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*/
public function display_files_list() {
$this->print_template( 'page-files-list' );
@@ -374,9 +350,7 @@ class Imagify_Views {
/**
* Initiate the "custom folders" list table data.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*/
public function load_files_list() {
// Instantiate the list.
@@ -396,9 +370,7 @@ class Imagify_Views {
/**
* Get the settings page slug.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*
* @return string
*/
@@ -409,9 +381,7 @@ class Imagify_Views {
/**
* Get the bulk optimization page slug.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*
* @return string
*/
@@ -422,9 +392,7 @@ class Imagify_Views {
/**
* Get the "custom folders" files page slug.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*
* @return string
*/
@@ -440,16 +408,14 @@ class Imagify_Views {
/**
* Tell if were displaying the settings page.
*
* @since 1.9
* @author Grégory Viguier
* @access public
* @since 1.9
*
* @return bool
*/
public function is_settings_page() {
global $pagenow;
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
$page = htmlspecialchars( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
if ( $this->get_settings_page_slug() !== $page ) {
return false;
@@ -465,16 +431,14 @@ class Imagify_Views {
/**
* Tell if were displaying the bulk optimization page.
*
* @since 1.9
* @author Grégory Viguier
* @access public
* @since 1.9
*
* @return bool
*/
public function is_bulk_page() {
global $pagenow;
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
$page = htmlspecialchars( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
return 'upload.php' === $pagenow && $this->get_bulk_page_slug() === $page;
}
@@ -482,16 +446,14 @@ class Imagify_Views {
/**
* Tell if were displaying the custom files list page.
*
* @since 1.9
* @author Grégory Viguier
* @access public
* @since 1.9
*
* @return bool
*/
public function is_files_page() {
global $pagenow;
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
$page = htmlspecialchars( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
return 'upload.php' === $pagenow && $this->get_files_page_slug() === $page;
}
@@ -499,26 +461,20 @@ class Imagify_Views {
/**
* Tell if were displaying the WP media library page.
*
* @since 1.9
* @author Grégory Viguier
* @access public
* @since 1.9
*
* @return bool
*/
public function is_wp_library_page() {
global $pagenow;
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
return 'upload.php' === $pagenow && ! $page;
return 'upload.php' === $pagenow && ! isset( $_GET['page'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
/**
* Tell if were displaying a media page.
*
* @since 1.9
* @author Grégory Viguier
* @access public
* @since 1.9
*
* @return bool
*/
@@ -536,9 +492,7 @@ class Imagify_Views {
/**
* Get the remaining quota in percent.
*
* @since 1.8.1
* @author Grégory Viguier
* @access public
* @since 1.8.1
*
* @return int
*/
@@ -549,7 +503,7 @@ class Imagify_Views {
return $quota;
}
$user = new Imagify_User();
$user = new User();
$quota = $user->get_percent_unconsumed_quota();
return $quota;
@@ -558,9 +512,7 @@ class Imagify_Views {
/**
* Get the HTML class used for the quota (to change the color when out of quota for example).
*
* @since 1.8.1
* @author Grégory Viguier
* @access public
* @since 1.8.1
*
* @return string
*/
@@ -588,9 +540,7 @@ class Imagify_Views {
/**
* Get the HTML tag used for the quota (the weather-like icon).
*
* @since 1.8.1
* @author Grégory Viguier
* @access public
* @since 1.8.1
*
* @return string
*/
@@ -622,9 +572,7 @@ class Imagify_Views {
/**
* Get a template contents.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*
* @param string $template The template name.
* @param mixed $data Some data to pass to the template.
@@ -648,9 +596,7 @@ class Imagify_Views {
/**
* Print a template.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*
* @param string $template The template name.
* @param mixed $data Some data to pass to the template.
@@ -662,9 +608,7 @@ class Imagify_Views {
/**
* Add a template to the list of JS templates to print at the end of the page.
*
* @since 1.7
* @author Grégory Viguier
* @access public
* @since 1.7
*
* @param string $template The template name.
*/
@@ -691,9 +635,7 @@ class Imagify_Views {
/**
* Print the JS templates that have been added to the "queue".
*
* @since 1.9
* @author Grégory Viguier
* @access public
* @since 1.9
*/
public function print_js_templates() {
if ( ! $this->templates_in_footer ) {
@@ -717,9 +659,7 @@ class Imagify_Views {
/**
* Create HTML attributes from an array.
*
* @since 1.9
* @access public
* @author Grégory Viguier
* @since 1.9
*
* @param array $attributes A list of attribute pairs.
* @return string HTML attributes.

View File

@@ -1,4 +1,7 @@
<?php
use Imagify\User\User;
defined( 'ABSPATH' ) || die( 'Cheatin uh?' );
if ( class_exists( 'C_NextGEN_Bootstrap' ) && class_exists( 'Mixin' ) && get_site_option( 'ngg_options' ) ) :
@@ -60,7 +63,7 @@ if ( class_exists( 'C_NextGEN_Bootstrap' ) && class_exists( 'Mixin' ) && get_sit
add_filter( 'imagify_count_saving_data', 'imagify_ngg_count_saving_data', 8 );
$saving_data = imagify_count_saving_data();
$user = new Imagify_User();
$user = new User();
$response['imagify_bulk_data'] = array(
// User account.

View File

@@ -1,9 +1,10 @@
<?php
/**
* Imagify User class.
* Deprecated class that handles Imagify User class.
*
* @since 1.0
* @deprecated
*/
class Imagify_User {
/**
@@ -153,7 +154,6 @@ class Imagify_User {
*/
public function get_percent_consumed_quota() {
static $done = false;
if ( $this->get_error() ) {
return 0;
}
@@ -176,12 +176,15 @@ class Imagify_User {
$percent = (float) $percent;
$percent = 100;
if ( $done ) {
return $percent;
}
$previous_percent = Imagify_Data::get_instance()->get( 'previous_quota_percent' );
// Percent is not 100% anymore.
if ( 100.0 === (float) $previous_percent && $percent < 100 ) {
/**

View File

@@ -1,5 +1,6 @@
<?php
use Imagify\Notices\Notices;
use Imagify\User\User;
defined( 'ABSPATH' ) || die( 'Cheatin uh?' );
@@ -400,7 +401,7 @@ function imagify_cache_user() {
return false;
}
$user = new Imagify_User();
$user = new User();
$data = (object) get_object_vars( $user );
$methods = get_class_methods( $user );