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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -49,7 +49,6 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
|
||||
// Account.
|
||||
'imagify_signup',
|
||||
'imagify_check_api_key_validity',
|
||||
'imagify_get_admin_bar_profile',
|
||||
'imagify_get_prices',
|
||||
'imagify_check_coupon',
|
||||
'imagify_get_discount',
|
||||
@@ -220,13 +219,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 +236,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;
|
||||
@@ -829,83 +828,6 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get admin bar profile output.
|
||||
*
|
||||
* @since 1.6.11
|
||||
*/
|
||||
public function imagify_get_admin_bar_profile_callback() {
|
||||
imagify_check_nonce( 'imagify-get-admin-bar-profile', 'imagifygetadminbarprofilenonce' );
|
||||
|
||||
if ( ! imagify_get_context( 'wp' )->current_user_can( 'manage' ) ) {
|
||||
imagify_die();
|
||||
}
|
||||
|
||||
$user = new Imagify_User();
|
||||
$views = Imagify_Views::get_instance();
|
||||
$unconsumed_quota = $views->get_quota_percent();
|
||||
$message = '';
|
||||
|
||||
if ( $unconsumed_quota <= 20 ) {
|
||||
$message = '<div class="imagify-error">';
|
||||
$message .= '<p><i class="dashicons dashicons-warning" aria-hidden="true"></i><strong>' . __( 'Oops, It\'s almost over!', 'imagify' ) . '</strong></p>';
|
||||
/* translators: %s is a line break. */
|
||||
$message .= '<p>' . sprintf( __( 'You have almost used all your credit.%sDon\'t forget to upgrade your subscription to continue optimizing your images.', 'imagify' ), '<br/><br/>' ) . '</p>';
|
||||
$message .= '<p class="center txt-center text-center"><a class="btn imagify-btn-ghost" href="' . esc_url( imagify_get_external_url( 'subscription' ) ) . '" target="_blank">' . __( 'View My Subscription', 'imagify' ) . '</a></p>';
|
||||
$message .= '</div>';
|
||||
}
|
||||
|
||||
if ( 0 === $unconsumed_quota ) {
|
||||
$message = '<div class="imagify-error">';
|
||||
$message .= '<p><i class="dashicons dashicons-warning" aria-hidden="true"></i><strong>' . __( 'Oops, It\'s Over!', 'imagify' ) . '</strong></p>';
|
||||
$message .= '<p>' . sprintf(
|
||||
/* translators: 1 is a data quota, 2 is a date. */
|
||||
__( 'You have consumed all your credit for this month. You will have <strong>%1$s back on %2$s</strong>.', 'imagify' ),
|
||||
imagify_size_format( $user->quota * pow( 1024, 2 ) ),
|
||||
date_i18n( get_option( 'date_format' ), strtotime( $user->next_date_update ) )
|
||||
) . '</p>';
|
||||
$message .= '<p class="center txt-center text-center"><a class="btn imagify-btn-ghost" href="' . esc_url( imagify_get_external_url( 'subscription' ) ) . '" target="_blank">' . __( 'Upgrade My Subscription', 'imagify' ) . '</a></p>';
|
||||
$message .= '</div>';
|
||||
}
|
||||
|
||||
// Custom HTML.
|
||||
$quota_section = '<div class="imagify-admin-bar-quota">';
|
||||
$quota_section .= '<div class="imagify-abq-row">';
|
||||
|
||||
if ( 1 === $user->plan_id ) {
|
||||
$quota_section .= '<div class="imagify-meteo-icon">' . $views->get_quota_icon() . '</div>';
|
||||
}
|
||||
|
||||
$quota_section .= '<div class="imagify-account">';
|
||||
$quota_section .= '<p class="imagify-meteo-title">' . __( 'Account status', 'imagify' ) . '</p>';
|
||||
$quota_section .= '<p class="imagify-meteo-subs">' . __( 'Your subscription:', 'imagify' ) . ' <strong class="imagify-user-plan">' . $user->plan_label . '</strong></p>';
|
||||
$quota_section .= '</div>'; // .imagify-account
|
||||
$quota_section .= '</div>'; // .imagify-abq-row
|
||||
|
||||
if ( 1 === $user->plan_id ) {
|
||||
$quota_section .= '<div class="imagify-abq-row">';
|
||||
$quota_section .= '<div class="imagify-space-left">';
|
||||
/* translators: %s is a data quota. */
|
||||
$quota_section .= '<p>' . sprintf( __( 'You have %s space credit left', 'imagify' ), '<span class="imagify-unconsumed-percent">' . $unconsumed_quota . '%</span>' ) . '</p>';
|
||||
$quota_section .= '<div class="' . $views->get_quota_class() . '">';
|
||||
$quota_section .= '<div style="width: ' . $unconsumed_quota . '%;" class="imagify-unconsumed-bar imagify-progress"></div>';
|
||||
$quota_section .= '</div>'; // .imagify-bar-{negative|neutral|positive}
|
||||
$quota_section .= '</div>'; // .imagify-space-left
|
||||
$quota_section .= '</div>'; // .imagify-abq-row
|
||||
}
|
||||
|
||||
$quota_section .= '<p class="imagify-abq-row">';
|
||||
$quota_section .= '<a class="imagify-account-link" href="' . esc_url( imagify_get_external_url( 'subscription' ) ) . '" target="_blank">';
|
||||
$quota_section .= '<span class="dashicons dashicons-admin-users"></span>';
|
||||
$quota_section .= '<span class="button-text">' . __( 'View my subscription', 'imagify' ) . '</span>';
|
||||
$quota_section .= '</a>'; // .imagify-account-link
|
||||
$quota_section .= '</p>'; // .imagify-abq-row
|
||||
$quota_section .= '</div>'; // .imagify-admin-bar-quota
|
||||
$quota_section .= $message;
|
||||
|
||||
wp_send_json_success( $quota_section );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pricings from API for Onetime and Plans at the same time.
|
||||
*
|
||||
@@ -1148,7 +1070,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 +1137,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 +1168,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 +1184,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';
|
||||
}
|
||||
|
||||
@@ -186,7 +186,8 @@ class Imagify_Assets extends Imagify_Assets_Deprecated {
|
||||
|
||||
$this->register_script( 'sweetalert', 'sweetalert2', [ 'promise-polyfill' ], '4.6.6' )->localize( 'imagifySwal' );
|
||||
|
||||
$this->register_script( 'chart', 'chart', [], '2.7.1.0' );
|
||||
$this->register_bud_script( 'runtime', 'runtime' );
|
||||
$this->register_bud_script( 'chart', 'chart', [ 'runtime' ], '4.4.0' );
|
||||
|
||||
$this->register_script( 'event-move', 'jquery.event.move', [ 'jquery' ], '2.0.1' );
|
||||
|
||||
@@ -211,7 +212,7 @@ class Imagify_Assets extends Imagify_Assets_Deprecated {
|
||||
|
||||
$this->register_script( 'async', 'imagify-gulp' );
|
||||
|
||||
$this->register_script( 'bulk', 'bulk', [ 'jquery', 'beat', 'underscore', 'chart', 'sweetalert', 'async', 'admin' ] )->defer_localization( 'imagifyBulk' );
|
||||
$this->register_bud_script( 'bulk', 'bulk', [ 'jquery', 'beat', 'underscore', 'chart', 'sweetalert', 'async', 'admin' ] )->defer_localization( 'imagifyBulk' );
|
||||
|
||||
$this->register_script( 'options', 'options', [ 'jquery', 'beat', 'sweetalert', 'underscore', 'admin' ] )->defer_localization( 'imagifyOptions' );
|
||||
|
||||
@@ -459,6 +460,42 @@ class Imagify_Assets extends Imagify_Assets_Deprecated {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a script.
|
||||
*
|
||||
* @since 1.6.10
|
||||
*
|
||||
* @param string $handle Name of the script. Should be unique.
|
||||
* @param string|null $file_name The file name, without the extension. If null, $handle is used.
|
||||
* @param array $dependencies An array of registered script handles this script depends on.
|
||||
* @param string|null $version String specifying script version number. If set to null, the plugin version is used. If SCRIPT_DEBUG is true, a random string is used.
|
||||
* @return object This class instance.
|
||||
*/
|
||||
public function register_bud_script( $handle, $file_name = null, $dependencies = [], $version = null ) {
|
||||
// If we register it, it's one of our scripts.
|
||||
$this->scripts[ $handle ] = 1;
|
||||
// Set the current handler and handler type.
|
||||
$this->current_handle = $handle;
|
||||
$this->current_handle_type = 'js';
|
||||
|
||||
$file_name = $file_name ? $file_name : $handle;
|
||||
$version = $version ? $version : IMAGIFY_VERSION;
|
||||
$version = $this->is_debug() ? self::$version : $version;
|
||||
$extension = '.js';
|
||||
$handle = self::JS_PREFIX . $handle;
|
||||
$dependencies = $this->prefix_dependencies( $dependencies );
|
||||
|
||||
wp_register_script(
|
||||
$handle,
|
||||
IMAGIFY_URL . 'assets/admin/js/' . $file_name . $extension,
|
||||
$dependencies,
|
||||
$version,
|
||||
true
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue a script.
|
||||
*
|
||||
|
||||
@@ -159,18 +159,20 @@ class Imagify_DB {
|
||||
* It returns an empty string if the database has no attachments without the required metadada.
|
||||
* It also triggers Imagify_DB::unlimit_joins().
|
||||
*
|
||||
* @since 1.7
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $id_field An ID field to match the metadata ID against in the JOIN clause.
|
||||
* @param string $id_field An ID field to match the metadata ID against in the JOIN clause.
|
||||
* Default is the posts table `ID` field, using the `p` alias: `p.ID`.
|
||||
* In case of "false" value or PEBKAC, fallback to the same field without alias.
|
||||
* @param bool $matching Set to false to get a query to fetch metas NOT matching the file extensions.
|
||||
* @param bool $test Test if the site has attachments without required metadata before returning the query. False to bypass the test and get the query anyway.
|
||||
* @param bool $matching Set to false to get a query to fetch metas NOT matching the file extensions.
|
||||
* @param bool $test Test if the site has attachments without required metadata before returning the query. False to bypass the test and get the query anyway.
|
||||
* @param string $special_join_conditions Special conditions to apply on the join.
|
||||
*
|
||||
* @return string
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @since 1.7
|
||||
* @access public
|
||||
*/
|
||||
public static function get_required_wp_metadata_join_clause( $id_field = 'p.ID', $matching = true, $test = true ) {
|
||||
public static function get_required_wp_metadata_join_clause( $id_field = 'p.ID', $matching = true, $test = true, $special_join_conditions = '' ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( $test && ! imagify_has_attachments_without_required_metadata() ) {
|
||||
@@ -186,7 +188,16 @@ class Imagify_DB {
|
||||
|
||||
$join = $matching ? 'INNER' : 'LEFT';
|
||||
|
||||
$first = true;
|
||||
|
||||
foreach ( self::get_required_wp_metadata_aliases() as $meta_name => $alias ) {
|
||||
if ( $first ) {
|
||||
$first = false;
|
||||
$clause .= "
|
||||
$join JOIN $wpdb->postmeta AS $alias
|
||||
ON ( $id_field = $alias.post_id AND $alias.meta_key = '$meta_name' $special_join_conditions )";
|
||||
continue;
|
||||
}
|
||||
$clause .= "
|
||||
$join JOIN $wpdb->postmeta AS $alias
|
||||
ON ( $id_field = $alias.post_id AND $alias.meta_key = '$meta_name' )";
|
||||
@@ -299,6 +310,9 @@ class Imagify_DB {
|
||||
$extensions = array_keys( imagify_get_mime_types() );
|
||||
$extensions = implode( '|', $extensions );
|
||||
$extensions = explode( '|', $extensions );
|
||||
$extensions = array_map(function ( $ex ) {
|
||||
return strrev( $ex );
|
||||
}, $extensions);
|
||||
}
|
||||
|
||||
if ( ! $alias ) {
|
||||
@@ -312,10 +326,12 @@ class Imagify_DB {
|
||||
return $prepared ? str_replace( '%', '%%', $query[ $key ] ) : $query[ $key ];
|
||||
}
|
||||
|
||||
$regex = '^' . implode( '\..*|^', $extensions ) . '\..*';
|
||||
|
||||
if ( $matching ) {
|
||||
$query[ $key ] = "AND ( LOWER( $alias.meta_value ) LIKE '%." . implode( "' OR LOWER( $alias.meta_value ) LIKE '%.", $extensions ) . "' )";
|
||||
$query[ $key ] = "AND REVERSE (LOWER( $alias.meta_value )) REGEXP '$regex'";
|
||||
} else {
|
||||
$query[ $key ] = "OR ( LOWER( $alias.meta_value ) NOT LIKE '%." . implode( "' AND LOWER( $alias.meta_value ) NOT LIKE '%.", $extensions ) . "' )";
|
||||
$query[ $key ] = "AND REVERSE (LOWER( $alias.meta_value )) NOT REGEXP '$regex'";
|
||||
}
|
||||
|
||||
return $prepared ? str_replace( '%', '%%', $query[ $key ] ) : $query[ $key ];
|
||||
|
||||
@@ -62,7 +62,7 @@ class Imagify_Files_Iterator extends FilterIterator {
|
||||
*
|
||||
* @return bool Returns whether the current element of the iterator is acceptable through this filter.
|
||||
*/
|
||||
public function accept() {
|
||||
public function accept(): bool {
|
||||
static $extensions, $has_extension_method;
|
||||
|
||||
$file_path = $this->current()->getPathname();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -52,7 +52,7 @@ class Imagify_Files_Recursive_Iterator extends RecursiveFilterIterator {
|
||||
*
|
||||
* @return bool Returns whether the current element of the iterator is acceptable through this filter.
|
||||
*/
|
||||
public function accept() {
|
||||
public function accept(): bool {
|
||||
static $extensions, $has_extension_method;
|
||||
|
||||
$file_path = $this->current()->getPathname();
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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 ========================================================================== */
|
||||
|
||||
@@ -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 we’re 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 we’re 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 we’re 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 we’re 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 we’re 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.
|
||||
|
||||
@@ -436,6 +436,19 @@ class Imagify {
|
||||
return new WP_Error( 'curl', 'cURL isn\'t installed on the server.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to mock Imagify calls to the API.
|
||||
*
|
||||
* @param stdClass|null $response Response from the call.
|
||||
* @param string $url URL from the call.
|
||||
* @param array $args Arguments from the call.
|
||||
*/
|
||||
$response = apply_filters( 'pre_imagify_request', null, $url, $args );
|
||||
|
||||
if ( $response ) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
try {
|
||||
$url = self::API_ENDPOINT . $url;
|
||||
$ch = curl_init();
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 ) {
|
||||
/**
|
||||
@@ -33,7 +33,10 @@ function imagify_count_attachments() {
|
||||
|
||||
$mime_types = Imagify_DB::get_mime_types();
|
||||
$statuses = Imagify_DB::get_post_statuses();
|
||||
$nodata_join = Imagify_DB::get_required_wp_metadata_join_clause();
|
||||
$nodata_join = Imagify_DB::get_required_wp_metadata_join_clause('p.ID', true, true,
|
||||
"AND p.post_mime_type IN ( $mime_types )
|
||||
AND p.post_type = 'attachment'
|
||||
AND p.post_status IN ( $statuses )");
|
||||
$nodata_where = Imagify_DB::get_required_wp_metadata_where_clause();
|
||||
$count = (int) $wpdb->get_var( // WPCS: unprepared SQL ok.
|
||||
"
|
||||
|
||||
@@ -42,6 +42,7 @@ function get_imagify_attachment_optimization_text( $process ) {
|
||||
}
|
||||
|
||||
$data = $process->get_data();
|
||||
$optimized_data = $data->get_optimization_data();
|
||||
$attachment_id = $media->get_id();
|
||||
$optimization_level = imagify_get_optimization_level_label( $data->get_optimization_level() );
|
||||
|
||||
@@ -49,6 +50,10 @@ function get_imagify_attachment_optimization_text( $process ) {
|
||||
$output .= $output_before . '<span class="data">' . __( 'New Filesize:', 'imagify' ) . '</span> <strong class="big">' . $data->get_optimized_size() . '</strong>' . $output_after;
|
||||
}
|
||||
|
||||
if ( key_exists( 'message', $optimized_data ) && $optimized_data['message'] ) {
|
||||
$output .= $output_before . '<span class="data">' . __( 'Convert:', 'imagify' ) . '</span> <strong class="big">' . $optimized_data['message'] . '</strong>' . $output_after;
|
||||
}
|
||||
|
||||
$chart = '';
|
||||
|
||||
if ( ! $is_media_page ) {
|
||||
@@ -90,6 +95,10 @@ function get_imagify_attachment_optimization_text( $process ) {
|
||||
|
||||
if ( $media->is_image() ) {
|
||||
$has_webp = $process->has_webp() ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' );
|
||||
|
||||
if ( $process->has_webp() ) {
|
||||
$has_webp = $process->is_full_webp() ? __( 'Yes', 'imagify' ) : __( 'Partially', 'imagify' );
|
||||
}
|
||||
$output .= $output_before . '<span class="data">' . __( 'WebP generated:', 'imagify' ) . '</span> <strong class="big">' . esc_html( $has_webp ) . '</strong>' . $output_after;
|
||||
|
||||
$total_optimized_thumbnails = $data->get_optimized_sizes_count();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ function get_imagify_max_image_size() {
|
||||
*/
|
||||
function imagify_translate_api_message( $message ) {
|
||||
if ( ! $message ) {
|
||||
return imagify_translate_api_message( 'Unknown error occurred' );
|
||||
$message = 'Unknown error occurred';
|
||||
}
|
||||
|
||||
if ( is_wp_error( $message ) ) {
|
||||
@@ -199,6 +199,7 @@ function imagify_translate_api_message( $message ) {
|
||||
'</a>'
|
||||
),
|
||||
'Your image is too big to be uploaded on our server' => __( 'Your file is too big to be uploaded on our server.', 'imagify' ),
|
||||
'Webp is less performant than original' => __( 'WebP file is larger than the original image', 'imagify' ),
|
||||
'Our server returned an invalid response' => __( 'Our server returned an invalid response.', 'imagify' ),
|
||||
'cURL isn\'t installed on the server' => __( 'cURL is not available on the server.', 'imagify' ),
|
||||
// API messages.
|
||||
|
||||
@@ -115,7 +115,14 @@ function imagify_has_attachments_without_required_metadata() {
|
||||
|
||||
$mime_types = Imagify_DB::get_mime_types();
|
||||
$statuses = Imagify_DB::get_post_statuses();
|
||||
$nodata_join = Imagify_DB::get_required_wp_metadata_join_clause( 'p.ID', false, false );
|
||||
$nodata_join = Imagify_DB::get_required_wp_metadata_join_clause(
|
||||
'p.ID',
|
||||
false,
|
||||
false,
|
||||
"AND p.post_mime_type IN ( $mime_types )
|
||||
AND p.post_type = 'attachment'
|
||||
AND p.post_status IN ( $statuses )"
|
||||
);
|
||||
$nodata_where = Imagify_DB::get_required_wp_metadata_where_clause( array(
|
||||
'matching' => false,
|
||||
'test' => false,
|
||||
|
||||
Reference in New Issue
Block a user