Skip to content

Commit

Permalink
Merge pull request #39 from ilovepdf/develop
Browse files Browse the repository at this point in the history
v2.1.5
  • Loading branch information
teamcrombie authored Nov 19, 2024
2 parents 026be45 + 516b651 commit b91ebaf
Show file tree
Hide file tree
Showing 29 changed files with 756 additions and 160 deletions.
18 changes: 15 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
=== PDF Compressor & Watermark - iLovePDF ===
Plugin Name: Image Compressor & Optimizer - iLovePDF
Version: 2.1.4
Version: 2.1.5
Author: iLovePDF
Author URI: https://www.ilovepdf.com/
Contributors: iLovePDF
Tags: compress, watermark, optimize, performance, pdf optimizer
Requires at least: 5.3
Tested up to: 6.6.2
Stable tag: 2.1.4
Tested up to: 6.7
Stable tag: 2.1.5
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -81,6 +81,18 @@ We will send you an email before limit is reached. When limit is reached, no mor

== Changelog ==

= 2.1.5 =
Improved
* Update Libraries.
* Improved texts.
* Compatibility with WordPress 6.7
* Sweetalert library removed.
* Improved multisite support.

Fixed
* API call at an unnecessary time when the user is not logged in.
* Directories are now created correctly in multisites.

= 2.1.4 =
Improved
* Update Libraries.
Expand Down
3 changes: 1 addition & 2 deletions admin/Ilove_Pdf_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public function enqueue_scripts() {
global $pagenow;

if ( ( 'upload.php' === $pagenow || 'options-general.php' === $pagenow || 'media-new.php' === $pagenow || 'post.php' === $pagenow ) && get_current_screen()->post_type !== 'product' ) {
wp_enqueue_script( 'ilove-pdf-admin', plugins_url( '/assets/js/main.min.js', __DIR__ ), array( 'wp-color-picker', 'sweetalert-js-ilovepdf' ), '1.0.0', true );
wp_enqueue_script( 'sweetalert-js-ilovepdf', plugins_url( '/assets/js/sweetalert2.all.min.js', __DIR__ ), array(), '11.11.0', true );
wp_enqueue_script( 'ilove-pdf-admin', plugins_url( '/assets/js/main.min.js', __DIR__ ), array( 'wp-color-picker' ), '1.0.0', true );
}
}

Expand Down
4 changes: 0 additions & 4 deletions admin/compress-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
*/
function ilove_pdf_initialize_options_compress() {

if ( false === get_option( 'ilove_pdf_display_settings_compress' ) ) {
add_option( 'ilove_pdf_display_settings_compress' );
}

add_settings_section(
'compress_settings_section',
'',
Expand Down
2 changes: 1 addition & 1 deletion admin/functions-compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function ilove_pdf_handle_file_upload_compress( $attachment_id ) {

</script>
<?php
} elseif ( ! ilove_pdf_is_file_watermarked( $attachment_id ) && get_user_option( 'media_library_mode', get_current_user_id() ) === 'grid' || wp_doing_ajax() ) {
} elseif ( ! ilove_pdf_is_file_watermarked( $attachment_id ) && ( get_user_option( 'media_library_mode', get_current_user_id() ) === 'grid' || wp_doing_ajax() ) ) {
if ( '1' !== $html ) {
$return = array( 'message' => wp_strip_all_tags( $html ) );
wp_send_json_error( $return );
Expand Down
18 changes: 10 additions & 8 deletions admin/functions-processed-files.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @subpackage Ilove_Pdf/admin
*/

use Ilove_Pdf_Includes\Ilove_Pdf;

/**
* Check if file is compressed.
*
Expand Down Expand Up @@ -57,7 +59,7 @@ function ilove_pdf_upload_compress_file( $filename, $attachment_id ) {

if ( get_option( 'ilovepdf_compressed_files' ) || get_option( 'ilovepdf_compressed_files' ) === '0' ) {
$n_compressed_files = intval( get_option( 'ilovepdf_compressed_files' ) ) + 1;
update_option( 'ilovepdf_compressed_files', $n_compressed_files );
Ilove_Pdf::update_option( 'ilovepdf_compressed_files', $n_compressed_files );
} else {
add_option( 'ilovepdf_compressed_files', 1 );
}
Expand Down Expand Up @@ -98,7 +100,7 @@ function ilove_pdf_upload_watermark_file( $filename, $attachment_id ) {

if ( get_option( 'ilovepdf_watermarked_files' ) || get_option( 'ilovepdf_watermarked_files' ) === '0' ) {
$n_watermarked_files = intval( get_option( 'ilovepdf_watermarked_files' ) ) + 1;
update_option( 'ilovepdf_watermarked_files', $n_watermarked_files );
Ilove_Pdf::update_option( 'ilovepdf_watermarked_files', $n_watermarked_files );

} else {
add_option( 'ilovepdf_watermarked_files', 1 );
Expand All @@ -122,7 +124,7 @@ function ilove_pdf_restore_pdf( $attachment_id ) {
if ( get_option( 'ilovepdf_compressed_files' ) === 1 ) {
delete_option( 'ilovepdf_compressed_files' );
} else {
update_option( 'ilovepdf_compressed_files', get_option( 'ilovepdf_compressed_files' ) - 1 );
Ilove_Pdf::update_option( 'ilovepdf_compressed_files', get_option( 'ilovepdf_compressed_files' ) - 1 );
if ( get_option( 'ilovepdf_compressed_files' ) <= '0' ) {
delete_option( 'ilovepdf_compressed_files' ); }
}
Expand All @@ -132,7 +134,7 @@ function ilove_pdf_restore_pdf( $attachment_id ) {
if ( get_option( 'ilovepdf_watermarked_files' ) === 1 ) {
delete_option( 'ilovepdf_watermarked_files' );
} else {
update_option( 'ilovepdf_watermarked_files', get_option( 'ilovepdf_watermarked_files' ) - 1 );
Ilove_Pdf::update_option( 'ilovepdf_watermarked_files', get_option( 'ilovepdf_watermarked_files' ) - 1 );
if ( get_option( 'ilovepdf_watermarked_files' ) <= '0' ) {
delete_option( 'ilovepdf_watermarked_files' ); }
}
Expand Down Expand Up @@ -161,14 +163,14 @@ function ilove_pdf_handle_delete_file( $attachment_id ) {
if ( get_post_meta( $attachment_id, '_wp_attached_original_size', true ) ) {
$result = get_option( 'ilovepdf_initial_pdf_files_size' ) - get_post_meta( $attachment_id, '_wp_attached_original_size', true );
}
update_option( 'ilovepdf_initial_pdf_files_size', $result );
Ilove_Pdf::update_option( 'ilovepdf_initial_pdf_files_size', $result );
$wp_upload_dir = wp_upload_dir();
$file_name = basename( get_attached_file( $attachment_id ) );
if ( ilove_pdf_is_file_compressed( $attachment_id ) ) {
if ( get_option( 'ilovepdf_compressed_files' ) === 1 ) {
delete_option( 'ilovepdf_compressed_files' );
} else {
update_option( 'ilovepdf_compressed_files', get_option( 'ilovepdf_compressed_files' ) - 1 );
Ilove_Pdf::update_option( 'ilovepdf_compressed_files', get_option( 'ilovepdf_compressed_files' ) - 1 );
if ( get_option( 'ilovepdf_compressed_files' ) <= '0' ) {
delete_option( 'ilovepdf_compressed_files' ); }
}
Expand All @@ -178,7 +180,7 @@ function ilove_pdf_handle_delete_file( $attachment_id ) {
if ( get_option( 'ilovepdf_watermarked_files' ) === 1 ) {
delete_option( 'ilovepdf_watermarked_files' );
} else {
update_option( 'ilovepdf_watermarked_files', get_option( 'ilovepdf_watermarked_files' ) - 1 );
Ilove_Pdf::update_option( 'ilovepdf_watermarked_files', get_option( 'ilovepdf_watermarked_files' ) - 1 );
if ( get_option( 'ilovepdf_watermarked_files' ) <= '0' ) {
delete_option( 'ilovepdf_watermarked_files' ); }
}
Expand Down Expand Up @@ -209,7 +211,7 @@ function ilove_pdf_handle_file_upload_compress_watermark( $attachment_id ) {
if ( get_post_mime_type( $attachment_id ) === 'application/pdf' ) {
$options_compress = get_option( 'ilove_pdf_display_settings_compress' );
$options_watermark = get_option( 'ilove_pdf_display_settings_watermark' );
update_option( 'ilovepdf_initial_pdf_files_size', get_option( 'ilovepdf_initial_pdf_files_size' ) + filesize( get_attached_file( $attachment_id ) ) );
Ilove_Pdf::update_option( 'ilovepdf_initial_pdf_files_size', get_option( 'ilovepdf_initial_pdf_files_size' ) + filesize( get_attached_file( $attachment_id ) ) );

if ( isset( $options_compress['ilove_pdf_compress_autocompress_new'] ) && isset( $options_watermark['ilove_pdf_watermark_auto'] ) ) {
$html_compress = ilove_pdf_compress_pdf( $attachment_id, true );
Expand Down
2 changes: 1 addition & 1 deletion admin/functions-watermark.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function ilove_pdf_handle_file_upload_watermark( $attachment_id ) {

</script>
<?php
} elseif ( ! ilove_pdf_is_file_compressed( $attachment_id ) && get_user_option( 'media_library_mode', get_current_user_id() ) === 'grid' || wp_doing_ajax() ) {
} elseif ( ! ilove_pdf_is_file_compressed( $attachment_id ) && ( get_user_option( 'media_library_mode', get_current_user_id() ) === 'grid' || wp_doing_ajax() ) ) {
if ( '1' !== $html ) {
$return = array( 'message' => wp_strip_all_tags( $html ) );
wp_send_json_error( $return );
Expand Down
6 changes: 4 additions & 2 deletions admin/general-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @subpackage Ilove_Pdf/admin
*/

use Ilove_Pdf_Includes\Ilove_Pdf;

/**
* Register Options
*
Expand Down Expand Up @@ -131,8 +133,8 @@ function ilove_pdf_logout_action() {
function ilove_pdf_change_project_action() {
if ( isset( $_GET['action'] ) && 'ilovepdf_change_project' === $_GET['action'] && isset( $_POST['nonce_ilove_pdf_change_project'] ) && wp_verify_nonce( sanitize_key( $_POST['nonce_ilove_pdf_change_project'] ), 'admin-post' ) && isset( $_POST['ilovepdf_select_project'] ) ) {
$stats = ilove_pdf_get_statistics();
update_option( 'ilovepdf_user_private_key', $stats['projects'][ sanitize_text_field( wp_unslash( $_POST['ilovepdf_select_project'] ) ) ]['secret_key'] );
update_option( 'ilovepdf_user_public_key', $stats['projects'][ sanitize_text_field( wp_unslash( $_POST['ilovepdf_select_project'] ) ) ]['public_key'] );
Ilove_Pdf::update_option( 'ilovepdf_user_private_key', $stats['projects'][ sanitize_text_field( wp_unslash( $_POST['ilovepdf_select_project'] ) ) ]['secret_key'] );
Ilove_Pdf::update_option( 'ilovepdf_user_public_key', $stats['projects'][ sanitize_text_field( wp_unslash( $_POST['ilovepdf_select_project'] ) ) ]['public_key'] );
}

wp_safe_redirect( wp_get_referer() );
Expand Down
2 changes: 1 addition & 1 deletion admin/partials/ilove-pdf-settings-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function ilove_pdf_content_page_setting() {
<?php else : ?>
<div class="col-md-6">
<div class="panel" style="margin-right: 10px; height: 350px;">
<h3 style="margin-bottom: 20px;"><?php esc_html_e( 'Register as iLovePDF developer', 'ilove-pdf' ); ?></h3>
<h3 style="margin-bottom: 20px;"><?php esc_html_e( 'Register as iLoveAPI developer', 'ilove-pdf' ); ?></h3>
<form method="post" id="ilovepdf_register_form" name="ilove_pdf_form_settings_section" action="">
<input type="hidden" name="action" value="ilovepdf_register" />
<?php wp_nonce_field( 'admin-post', 'nonce_ilove_pdf_register' ); ?>
Expand Down
2 changes: 1 addition & 1 deletion admin/partials/ilove-pdf-statistics-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function ilove_pdf_content_page_statistics() {

$logo_svg = ILOVE_PDF_ASSETS_PLUGIN_PATH . 'assets/img/logo_ilovepdf.svg';

$stats = ilove_pdf_get_statistics();
$options_general_settings = get_option( 'ilove_pdf_display_general_settings' );
$backup_files_is_active = (int) $options_general_settings['ilove_pdf_general_backup'];

Expand All @@ -29,6 +28,7 @@ function ilove_pdf_content_page_statistics() {
<h2 class="plugin-logo-full"><img src="<?php echo esc_url( $logo_svg ); ?>" alt="logo ilovepdf" /></h2>
<?php if ( get_option( 'ilovepdf_user_id' ) ) : ?>
<?php
$stats = ilove_pdf_get_statistics();
$active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'statistic_statistic'; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
?>

Expand Down
2 changes: 1 addition & 1 deletion assets/css/app.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit b91ebaf

Please sign in to comment.