Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/v2.2.0 #18

Merged
merged 9 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions admin/Ilove_Img_Compress_Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Ilove_Img_Compress_Plugin {
* @access public
* @var string VERSION The current version of the plugin.
*/
const VERSION = '2.1.0';
const VERSION = '2.2.0';

/**
* The unique identifier of this plugin.
Expand Down Expand Up @@ -200,7 +200,7 @@ public function ilove_img_compress_library_is_compressed() {
} elseif ( 2 === (int) $status_compress ) {
Ilove_Img_Compress_Resources::render_compress_details( $attachment_id );
} elseif ( 0 === (int) $status_compress && ! $status_compress ) {
echo 'Try again or buy more files';
echo 'Try again or buy more credits';
}
}
wp_die();
Expand Down Expand Up @@ -258,7 +258,10 @@ public function column_id_row( $column_name, $column_id ) {
*/
public function process_attachment( $metadata, $attachment_id ) {
update_post_meta( $attachment_id, 'iloveimg_status_compress', 0 ); // status no compressed
if ( (int) Ilove_Img_Compress_Resources::is_auto_compress() === 1 && Ilove_Img_Compress_Resources::is_loggued() && (int) Ilove_Img_Compress_Resources::is_activated() === 1 ) {

$images_restore = null !== get_option( 'iloveimg_images_to_restore', null ) ? json_decode( get_option( 'iloveimg_images_to_restore' ), true ) : array();

if ( (int) Ilove_Img_Compress_Resources::is_auto_compress() === 1 && Ilove_Img_Compress_Resources::is_loggued() && (int) Ilove_Img_Compress_Resources::is_activated() === 1 && ! in_array( $attachment_id, $images_restore, true ) ) {
wp_update_attachment_metadata( $attachment_id, $metadata );
$this->async_compress( $attachment_id );
}
Expand Down Expand Up @@ -351,7 +354,7 @@ public function show_notices() {
( isset( $account['subscription_files_used'] ) && (int) $account['subscription_files_used'] >= (int) $account['subscription_files_limit'] ) ) {
?>
<div class="notice notice-warning is-dismissible">
<p><strong>iLoveIMG</strong> - Please you need more files. <a href="https://developer.iloveimg.com/pricing" target="_blank">Buy more files</a></p>
<p><strong>iLoveIMG</strong> - Please you need more credits. <a href="https://iloveapi.com/pricing" target="_blank">Buy more credits</a></p>
</div>
<?php
}
Expand Down Expand Up @@ -448,20 +451,21 @@ public static function check_iloveimg_plugins_is_activated() {
*/
public function ilove_img_restore_all() {
if ( is_dir( ILOVE_IMG_COMPRESS_BACKUP_FOLDER ) ) {
$folders = array_diff( scandir( ILOVE_IMG_COMPRESS_BACKUP_FOLDER ), array( '..', '.' ) );

foreach ( $folders as $key => $folder ) {
Ilove_Img_Compress_Resources::rcopy( ILOVE_IMG_COMPRESS_BACKUP_FOLDER . $folder, ILOVE_IMG_COMPRESS_UPLOAD_FOLDER . '/' . $folder );
}

$images_restore = json_decode( get_option( 'iloveimg_images_to_restore' ), true );
$images_restore = json_decode( get_option( 'iloveimg_images_to_restore', array() ), true );

foreach ( $images_restore as $key => $value ) {
Ilove_Img_Compress_Resources::rcopy( ILOVE_IMG_COMPRESS_BACKUP_FOLDER . basename( get_attached_file( $value ) ), get_attached_file( $value ) );

delete_post_meta( $value, 'iloveimg_status_watermark' );
delete_post_meta( $value, 'iloveimg_watermark' );
delete_post_meta( $value, 'iloveimg_status_compress' );
delete_post_meta( $value, 'iloveimg_compress' );

wp_delete_file( ILOVE_IMG_COMPRESS_BACKUP_FOLDER . basename( get_attached_file( $value ) ) );

delete_option( 'iloveimg_images_to_restore' );

}
}

Expand Down Expand Up @@ -502,8 +506,10 @@ public function ilove_img_restore() {
delete_post_meta( $attachment_id, 'iloveimg_status_compress' );
delete_post_meta( $attachment_id, 'iloveimg_compress' );

if ( ! $key_founded ) {
if ( false !== $key_founded ) {
unset( $images_restore[ $key_founded ] );
wp_delete_file( ILOVE_IMG_COMPRESS_BACKUP_FOLDER . basename( get_attached_file( $attachment_id ) ) );
update_option( 'iloveimg_images_to_restore', wp_json_encode( $images_restore ) );
}

wp_send_json_success( __( 'It was restored correctly', 'iloveimg' ), 200 );
Expand Down
2 changes: 1 addition & 1 deletion admin/Ilove_Img_Compress_Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function compress( $images_id ) {

$images_restore = array_unique( $images_restore );

update_option( 'iloveimg_images_to_restore', wp_json_encode( $images_restore ) );
update_option( 'iloveimg_images_to_restore', wp_json_encode( $images_restore, JSON_FORCE_OBJECT ) );
}

foreach ( $_sizes as $_size ) {
Expand Down
1 change: 1 addition & 0 deletions admin/Ilove_Img_Compress_Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function save() {
);
if ( wp_remote_retrieve_response_code( $response ) === 200 ) {
update_option( 'iloveimg_account', $response['body'] );
update_option( 'iloveimg_user_is_migrated', 1 );
$options = json_decode( get_option( 'iloveimg_options_compress' ), true );
$options['iloveimg_field_compress_activated'] = 1;
$options['iloveimg_field_autocompress'] = 1;
Expand Down
29 changes: 22 additions & 7 deletions admin/views/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
$ilove_img_account = array();

if ( get_option( 'iloveimg_account' ) ) {

if ( ! get_option( 'iloveimg_user_is_migrated' ) ) {

delete_option( 'iloveimg_account' );
delete_option( 'iloveimg_proyect' );
$ilove_img_options = json_decode( get_option( 'iloveimg_options_compress' ), true );
unset( $ilove_img_options['iloveimg_field_compress_activated'] );
unset( $ilove_img_options['iloveimg_field_autocompress'] );
unset( $ilove_img_options['iloveimg_field_resize_full'] );
update_option( 'iloveimg_options_compress', wp_json_encode( $ilove_img_options ) );

wp_safe_redirect( admin_url( 'admin.php?page=iloveimg-compress-admin-page' ) );
exit();
}

$ilove_img_account = json_decode( get_option( 'iloveimg_account' ), true );

$ilove_img_is_logged = true;
Expand Down Expand Up @@ -41,7 +56,7 @@
<div>
<input type="password" class="iloveimg_field_password" name="iloveimg_field_password" placeholder="Password" required/>
</div>
<a class="forget" href="https://developer.iloveimg.com/login/reset" target="_blank">Forget Password?</a>
<a class="forget" href="https://iloveapi.com/login/reset" target="_blank">Forget Password?</a>
<?php
wp_nonce_field();
submit_button( 'Login' );
Expand Down Expand Up @@ -98,7 +113,7 @@
<div class="iloveimg_percent <?php echo ( $ilove_img_percent >= 100 ) ? 'iloveimg_percent-exceeded' : ''; ?> <?php echo ( $ilove_img_percent >= 90 && $ilove_img_percent < 100 ) ? 'iloveimg_percent-warning' : ''; ?>">
<div class="iloveimg_percent-total" style="width: <?php echo (float) $ilove_img_percent; ?>%;"></div>
</div>
<p><?php echo (int) $ilove_img_account['files_used']; ?>/<?php echo (int) $ilove_img_account['free_files_limit']; ?> processed files this month. Free Tier.</p>
<p><?php echo (int) $ilove_img_account['files_used']; ?>/<?php echo (int) $ilove_img_account['free_files_limit']; ?> credits used this month. Free Tier.</p>
<?php if ( $ilove_img_account['subscription_files_limit'] ) : ?>
<h4>Subscription files</h4>
<?php
Expand All @@ -110,21 +125,21 @@
<div class="iloveimg_percent <?php echo ( $ilove_img_percent >= 100 ) ? 'iloveimg_percent-exceeded' : ''; ?> <?php echo ( $ilove_img_percent >= 90 && $ilove_img_percent < 100 ) ? 'iloveimg_percent-warning' : ''; ?>">
<div class="iloveimg_percent-total" style="width: <?php echo (float) $ilove_img_percent; ?>%;"></div>
</div>
<p><?php echo ( isset( $ilove_img_account['subscription_files_used'] ) ) ? (int) $ilove_img_account['subscription_files_used'] : 0; ?>/<?php echo (int) $ilove_img_account['subscription_files_limit']; ?> processed files this month.</p>
<p><?php echo ( isset( $ilove_img_account['subscription_files_used'] ) ) ? (int) $ilove_img_account['subscription_files_used'] : 0; ?>/<?php echo (int) $ilove_img_account['subscription_files_limit']; ?> credits used this month.</p>
<?php endif; ?>
<?php if ( $ilove_img_account['package_files_limit'] ) : ?>
<h4>Package files</h4>
<?php $ilove_img_percent = ( ( $ilove_img_account['package_files_used'] * 100 ) / $ilove_img_account['package_files_limit'] ); ?>
<div class="iloveimg_percent <?php echo ( $ilove_img_percent >= 100 ) ? 'iloveimg_percent-exceeded' : ''; ?> <?php echo ( $ilove_img_percent >= 90 && $ilove_img_percent < 100 ) ? 'iloveimg_percent-warning' : ''; ?>">
<div class="iloveimg_percent-total" style="width: <?php echo (float) $ilove_img_percent; ?>%;"></div>
</div>
<p><?php echo (int) $ilove_img_account['package_files_used']; ?>/<?php echo (int) $ilove_img_account['package_files_limit']; ?> processed files this month.</p>
<p><?php echo (int) $ilove_img_account['package_files_used']; ?>/<?php echo (int) $ilove_img_account['package_files_limit']; ?> credits used this month.</p>
<?php endif; ?>
</div>
<div class="iloveimg_settings__overview__account-logged__column_left__details">
<p style="margin-top: 22px;">Every month since your registry you will get <?php echo (int) $ilove_img_account['free_files_limit']; ?> free file processes to use to compress or stamp your images.</p>
<p>To increase your file processes amount you can either open one of our <a href="https://developer.iloveimg.com/pricing" target="_blank">subscription plans</a> to get a fixed amount of additional processes per month or buy a <a href="https://developer.iloveimg.com/pricing" target="_blank">single package</a> of file processes.</p>
<a class="button button-secondary" href="https://developer.iloveimg.com/pricing" target="_blank">Buy more files</a>
<p style="margin-top: 22px;">Every month since your registry you will get <?php echo (int) $ilove_img_account['free_files_limit']; ?> free credits to use to compress or stamp your images.</p>
<p>To increase your credits amount you can either open one of our <a href="https://iloveapi.com/pricing" target="_blank">subscription plans</a> to get a fixed amount of additional credits per month or buy a <a href="https://iloveapi.com/pricing" target="_blank">single package</a> of credits.</p>
<a class="button button-secondary" href="https://iloveapi.com/pricing" target="_blank">Buy more credits</a>
</div>
</div>
<div class="iloveimg_settings__overview__account-logged__column_right">
Expand Down
2 changes: 1 addition & 1 deletion admin/views/compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="iloveimg_settings__info">
<h3>The power of iLoveIMG in your WordPress!</h3>
<p>Optimize your website images and improve your page load speed. Reduce the file size of your photos and gain maximum compression while keeping sharp images. Compress your WordPress images to improve the positioning of your site, boost visitor’s engagement and ultimately increase sales.</p>
<p>Register now to get 500 free uses and start working with iLoveIMG plugin now!</p>
<p>Register now to get 2500 free credits and start working with iLoveIMG plugin now!</p>
</div>
<?php endif ?>

Expand Down
2 changes: 1 addition & 1 deletion admin/views/watermark.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="iloveimg_settings__info">
<h3>The power of iLoveIMG in your WordPress!</h3>
<p>Optimize your website images and improve your page load speed. Reduce the file size of your photos and gain maximum compression while keeping sharp images. Compress your WordPress images to improve the positioning of your site, boost visitor’s engagement and ultimately increase sales.</p>
<p>Register now to get 500 free uses and start working with iLoveIMG plugin now!</p>
<p>Register now to get 2500 free credits and start working with iLoveIMG plugin now!</p>
</div>
<?php endif ?>

Expand Down
10 changes: 5 additions & 5 deletions ilove-img-compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*
* @wordpress-plugin
* Plugin Name: Image Compressor & Optimizer - iLoveIMG
* Plugin URI: https://developer.iloveimg.com/
* Plugin URI: https://iloveapi.com/
* Description: Get your images delivered quickly. Now you can get a powerful, easy to use, and reliable image compression plugin for your image optimization needs. With full automation and powerful features, iLoveIMG makes it easy to speed up your website by lightening past and new images with just a click. Compress JPG, PNG and GIF images in your WordPress to improve the positioning of your site, boost visitor’s engagement and ultimately increase sales.
* Version: 2.1.0
* Version: 2.2.0
* Requires at least: 5.3
* Requires PHP: 7.4
* Author: iLoveIMG
Expand All @@ -38,9 +38,9 @@

$ilove_img_compress_upload_path = wp_upload_dir();

define( 'ILOVE_IMG_COMPRESS_REGISTER_URL', 'https://api.iloveimg.com/v1/user' );
define( 'ILOVE_IMG_COMPRESS_LOGIN_URL', 'https://api.iloveimg.com/v1/user/login' );
define( 'ILOVE_IMG_COMPRESS_USER_URL', 'https://api.iloveimg.com/v1/user' );
define( 'ILOVE_IMG_COMPRESS_REGISTER_URL', 'https://api.ilovepdf.com/v1/user' );
define( 'ILOVE_IMG_COMPRESS_LOGIN_URL', 'https://api.ilovepdf.com/v1/user/login' );
define( 'ILOVE_IMG_COMPRESS_USER_URL', 'https://api.ilovepdf.com/v1/user' );
define( 'ILOVE_IMG_COMPRESS_NUM_MAX_FILES', 2 );
define( 'ILOVE_IMG_COMPRESS_DB_VERSION', '1.1' );
define( 'ILOVE_IMG_COMPRESS_UPLOAD_FOLDER', $ilove_img_compress_upload_path['basedir'] );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"gulp-sass": "^5.1.0",
"gulp-uglify": "^3.0.2",
"merge-stream": "^2.0.0",
"sass": "^1.77.2"
"sass": "^1.77.8"
}
}
22 changes: 16 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
=== Image Compressor & Optimizer - iLoveIMG ===
Plugin Name: Image Compressor & Optimizer - iLoveIMG
Version: 2.1.0
Version: 2.2.0
Author: iLovePDF
Author URI: https://www.iloveimg.com/
Contributors: iLovePDF
Tags: compress, image, optimize, performance, image optimizer
Requires at least: 5.3
Tested up to: 6.5.3
Stable tag: 2.1.0
Tested up to: 6.6
Stable tag: 2.2.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -36,7 +36,7 @@ Trust reliable developers. **iLoveIMG Image Compressor** is brought to you by th
- **Good for eCommerce** - Works great for eCommerce websites using WooCommerce, NextGen Gallery and other plugins for e-commerce.
- **Security first** - Your data is not stored nor collect on our services. We are GDPR compliant.
- **Robust and frequently updated**
- **Freemium service** - Freely process up to 500 images per month. Need more? Subscribe our [Premium plan](https://developer.iloveimg.com/pricing) or buy a [prepaid package](https://developer.iloveimg.com/pricing) to use at your convenience.
- **Freemium service** - Freely up to 2500 credits per month. Need more? Subscribe our [Premium plan](https://iloveapi.com/pricing) or buy a [prepaid package](https://iloveapi.com/pricing) to use at your convenience.

iLoveIMG optimizes your visual assets to improve your page load speed, delivering high-quality images rescaled for every device. With a quick and easy installation, you can start enhancing the user experience of your site.

Expand All @@ -50,7 +50,7 @@ iLoveIMG optimizes your visual assets to improve your page load speed, deliverin

**Can I use the plugin for free?**

Absolutely. As a free user, you can optimise a maximum of 500 images per month. Once this limit is reached, you cannot compress new images until next month unless you purchase credits.
Absolutely. As a free user, we let you process your first 2500 monthly credits. Once this limit is reached, you cannot compress new images until next month unless you purchase credits.

**Can I make a one-time payment?**

Expand All @@ -70,7 +70,7 @@ iLoveIMG Compression plugin can optimize images in JPG, PNG and GIF format.

**Do you have an API REST?**

Yes, in fact this plugin is powered by our API. And you can integrate our image optimization tools into your software apps too! Learn more about [iLoveIMG API for developers](https://developer.iloveimg.com).
Yes, in fact this plugin is powered by our API. And you can integrate our image optimization tools into your software apps too! Learn more about [iLoveIMG API for developers](https://iloveapi.com).

**Do you care about the privacy of my images?**

Expand All @@ -81,6 +81,16 @@ Moreover, all processed files are automatically deleted from our servers after b

== Changelog ==

== 2.2.0 ==
Improved
* Update Libraries.
* Now IloveIMG will use credits to process the files.
* Now iloveimg accounts have been migrated to ilovepdf.
* Improved the function to restore all files.

Fixed
* When autocompress is activated and you wanted to restore a specific file, it was compressed again.

== 2.1.0 ==
Added
* New Backup option added in General Settings.
Expand Down
Loading
Loading