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.7 #33

Merged
merged 11 commits into from
Feb 12, 2025
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
12 changes: 6 additions & 6 deletions admin/Ilove_Img_Compress_Media_List_Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ protected function column_cb( $item ) {
public function get_columns() {
$columns = array(
'cb' => '<input type="checkbox" />', // Render a checkbox instead of text
'file' => 'File',
'post_author' => 'Author',
'post_date' => 'Date',
'status' => 'Status',
'file' => __( 'File', 'iloveimg' ),
'post_author' => __( 'Author', 'iloveimg' ),
'post_date' => __( 'Date', 'iloveimg' ),
'status' => __( 'Status', 'iloveimg' ),
);
return $columns;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ protected function get_sortable_columns() {
*/
protected function get_bulk_actions() {
$actions = array(
'delete' => 'Delete',
'delete' => __( 'Delete', 'iloveimg' ),
);
return $actions;
}
Expand All @@ -148,7 +148,7 @@ public function process_bulk_action() {

// Detect when a bulk action is being triggered...
if ( 'delete' === $this->current_action() ) {
wp_die( 'Items deleted (or they would be if we had items to delete)!' );
wp_die( esc_html__( 'Items deleted (or they would be if we had items to delete)!', 'iloveimg' ) );
}
}

Expand Down
22 changes: 11 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.2.6';
const VERSION = '2.2.7';

/**
* The unique identifier of this plugin.
Expand Down Expand Up @@ -201,7 +201,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 credits';
esc_html_e( 'Try again or buy more credits', 'iloveimg' );
}
}
wp_die();
Expand Down Expand Up @@ -311,10 +311,10 @@ public function async_compress( $attachment_id ) {
* @access public
*/
public function show_notices() {
if ( ! Ilove_Img_Compress_Resources::is_loggued() ) {
if ( ! Ilove_Img_Compress_Resources::is_loggued() && get_current_screen()->parent_base !== 'iloveimg-admin-page' ) {
?>
<div class="notice notice-warning is-dismissible">
<p><strong>iLoveIMG</strong> - Please you need to be logged or registered. <a href="<?php echo esc_url( admin_url( 'admin.php?page=iloveimg-compress-admin-page' ) ); ?>">Go to settings</a></p>
<p><strong>iLoveIMG</strong> - <?php esc_html_e( 'Please you need to be logged or registered.', 'iloveimg' ); ?> <a href="<?php echo esc_url( admin_url( 'admin.php?page=iloveimg-compress-admin-page' ) ); ?>"><?php esc_html_e( 'Go to settings', 'iloveimg' ); ?></a></p>
</div>
<?php
}
Expand All @@ -325,17 +325,17 @@ public function show_notices() {
if ( 'login' === $iloveimg_account_error['action'] ) :
?>
<div class="notice notice-error is-dismissible">
<p>Your email or password is wrong.</p>
<p><?php esc_html_e( 'Your email or password is wrong.', 'iloveimg' ); ?></p>
</div>
<?php endif; ?>
<?php if ( 'register' === $iloveimg_account_error['action'] ) : ?>
<div class="notice notice-error is-dismissible">
<p>This email address has already been taken.</p>
<p><?php esc_html_e( 'This email address has already been taken.', 'iloveimg' ); ?></p>
</div>
<?php endif; ?>
<?php if ( 'register_limit' === $iloveimg_account_error['action'] ) : ?>
<div class="notice notice-error is-dismissible">
<p>You have reached limit of different users to use this WordPress plugin. Please relogin with one of your existing users.</p>
<p><?php esc_html_e( 'You have reached limit of different users to use this WordPress plugin. Please relogin with one of your existing users.', 'iloveimg' ); ?></p>
</div>
<?php endif; ?>
<?php
Expand All @@ -361,7 +361,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 credits. <a href="https://iloveapi.com/pricing" target="_blank">Buy more credits</a></p>
<p><strong>iLoveIMG</strong> - <?php esc_html_e( 'Please you need more credits.', 'iloveimg' ); ?> <a href="https://iloveapi.com/pricing" target="_blank"><?php esc_html_e( 'Buy more credits', 'iloveimg' ); ?></a></p>
</div>
<?php
}
Expand Down Expand Up @@ -488,19 +488,19 @@ public function ilove_img_restore_all() {
public function ilove_img_restore() {

if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) ) ) {
wp_send_json_error( 'Error processing your request. Invalid Nonce code', 401 );
wp_send_json_error( __( 'Error processing your request. Invalid Nonce code', 'iloveimg' ), 401 );
}

if ( ! isset( $_POST['id'] ) ) {
wp_send_json_error( 'Error processing your request. Invalid Image ID', 400 );
wp_send_json_error( __( 'Error processing your request. Invalid Image ID', 'iloveimg' ), 400 );
}

$attachment_id = intval( $_POST['id'] );
$images_restore = null !== get_option( 'iloveimg_images_to_restore', null ) ? json_decode( get_option( 'iloveimg_images_to_restore' ), true ) : array();
$key_founded = array_search( $attachment_id, $images_restore, true );

if ( ! in_array( $attachment_id, $images_restore, true ) ) {
wp_send_json_error( 'Sorry. There is no backup for this file', 404 );
wp_send_json_error( __( 'Sorry. There is no backup for this file', 'iloveimg' ), 404 );
}

Ilove_Img_Compress_Resources::rcopy( ILOVE_IMG_COMPRESS_BACKUP_FOLDER . basename( get_attached_file( $attachment_id ) ), get_attached_file( $attachment_id ) );
Expand Down
4 changes: 2 additions & 2 deletions admin/Ilove_Img_Compress_Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ public function compress( $images_id ) {
update_post_meta( $images_id, 'iloveimg_status_compress', 0 );
error_log('Exception on Compress Method: ' . print_r($e, true)); // phpcs:ignore

$error_msg = 'There was a problem processing your image.';
$error_msg = __( 'There was a problem processing your image.', 'iloveimg' );

if ( 401 === $e->getCode() ) {
$error_msg = 'Check your credentials in the plugin settings page. If you recently deleted a project in your iloveapi account, try switching to another project to correctly save your API Keys.';
$error_msg = __( 'Check your credentials in the plugin settings page. If you recently deleted a project in your iloveapi account, try switching to another project to correctly save your API Keys.', 'iloveimg' );
}

return array(
Expand Down
18 changes: 10 additions & 8 deletions admin/Ilove_Img_Compress_Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function get_type_images() {
$sizes[] = array(
'field_id' => 'full',
'type' => 'checkbox',
'label' => 'Original image',
'label' => __( 'Original image', 'iloveimg' ),
'default' => true,
);
foreach ( get_intermediate_image_sizes() as $_size ) {
Expand Down Expand Up @@ -202,7 +202,9 @@ public static function render_compress_details( $image_id ) {
<div id="iloveimg_detaills_compress_<?php echo (int) $image_id; ?>" style="display:none;">
<table class="table__details__sizes">
<tr>
<th>Name</th><th>Initial</th><th>Compressed</th>
<th><?php esc_html_e( 'Name', 'iloveimg' ); ?></th>
<th><?php esc_html_e( 'Initial', 'iloveimg' ); ?></th>
<th><?php esc_html_e( 'Compressed', 'iloveimg' ); ?></th>
<?php
$total_size = 0;
$total_compressed = 0;
Expand All @@ -225,10 +227,10 @@ public static function render_compress_details( $image_id ) {
<small class="iloveimg__badge__percent">-<?php echo (int) $percent; ?>%</small>
<?php
} else {
echo 'Not compressed';
esc_html_e( 'Not compressed', 'iloveimg' );
}
} else {
echo 'Not compressed';
esc_html_e( 'Not compressed', 'iloveimg' );
}
?>
</td>
Expand Down Expand Up @@ -287,19 +289,19 @@ public static function get_status_of_column( $column_id ) {
<?php if ( self::is_loggued() ) : ?>
<!-- <p><?php echo (int) self::get_sizes_enabled(); ?> sizes to be compressed</p> -->
<?php if ( self::get_sizes_enabled() ) : ?>
<button type="button" class="iloveimg-compress button button-small button-primary" data-imgnonce="<?php echo sanitize_key( wp_unslash( $img_nonce ) ); ?>" data-id="<?php echo (int) $column_id; ?>" <?php echo ( 1 === $status_compress || 3 === $status_compress ) ? 'disabled="disabled"' : ''; ?>>Compress</button>
<button type="button" class="iloveimg-compress button button-small button-primary" data-imgnonce="<?php echo sanitize_key( wp_unslash( $img_nonce ) ); ?>" data-id="<?php echo (int) $column_id; ?>" <?php echo ( 1 === $status_compress || 3 === $status_compress ) ? 'disabled="disabled"' : ''; ?>><?php esc_html_e( 'Compress', 'iloveimg' ); ?></button>
<img class="iloveimg-spinner" src="<?php echo esc_url( plugins_url( '/assets/images/spinner.gif', __DIR__ ) ); ?>" width="20" height="20" style="<?php echo ( 1 === $status_compress || 3 === $status_compress ) ? '' : 'display: none;'; ?>; margin-top: 7px" />
<?php if ( 3 === $status_compress ) : ?>
<!-- <p>In queue...</p> -->
<?php endif; ?>
<?php else : ?>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=iloveimg-compress-admin-page' ) ); ?>" class="iloveimg_link">Go to settings</button>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=iloveimg-compress-admin-page' ) ); ?>" class="iloveimg_link"><?php esc_html_e( 'Go to settings', 'iloveimg' ); ?></button>
<?php
endif;
else :
?>
<p>You need to be registered</p>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=iloveimg-compress-admin-page' ) ); ?>" class="iloveimg_link">Go to settings</button>
<p><?php esc_html_e( 'You need to be registered', 'iloveimg' ); ?></p>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=iloveimg-compress-admin-page' ) ); ?>" class="iloveimg_link"><?php esc_html_e( 'Go to settings', 'iloveimg' ); ?></button>
<?php
endif;
if ( 1 === $status_compress || 3 === $status_compress ) :
Expand Down
12 changes: 6 additions & 6 deletions admin/Ilove_Img_Compress_Submenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function add_options_page() {

add_submenu_page(
'iloveimg-admin-page',
'Compress settings',
'Compress settings',
__( 'Compress settings', 'iloveimg' ),
__( 'Compress settings', 'iloveimg' ),
'manage_options',
'iloveimg-compress-admin-page',
array(
Expand All @@ -63,8 +63,8 @@ public function add_options_page() {

add_submenu_page(
'iloveimg-admin-page',
'Watermark settings',
'Watermark settings',
__( 'Watermark settings', 'iloveimg' ),
__( 'Watermark settings', 'iloveimg' ),
'manage_options',
'iloveimg-watermark-admin-page',
array(
Expand All @@ -75,7 +75,7 @@ public function add_options_page() {

add_media_page(
'iLoveIMG Media',
'Bulk Optimization',
__( 'Bulk Optimization', 'iloveimg' ),
'manage_options',
'iloveimg-media-page',
array(
Expand All @@ -90,6 +90,6 @@ public function add_options_page() {
* Placeholder for the settings page content.
*/
public function settings_page() {
echo 'This is the page content';
esc_html_e( 'This is the page content', 'iloveimg' );
}
}
30 changes: 30 additions & 0 deletions admin/Ilove_Img_Compress_i18n.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
namespace Ilove_Img_Compress;

/**
* Defines internationalization functionality.
*
* @since 2.2.7
*/
class Ilove_Img_Compress_I18n {
/**
*
* Initializes the class.
*
* @since 2.2.7
*/
public function init() {
$this->load_textdomain();
}

/**
* Load the text domain for the plugin.
*
* Loads the text domain for the plugin, allowing for internationalization and localization.
*
* @since 2.2.7
*/
public function load_textdomain() {
load_plugin_textdomain( 'iloveimg', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
}
}
Loading