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:
@@ -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';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user