Skip to content

Commit

Permalink
Feature/v2.0.1 (#10)
Browse files Browse the repository at this point in the history
* config autoloader

* add namespace, rename files, remove class library init

* remove iloveimg-php folder

* add vendor folder with library iloveimg-php

* update plugin to v2.0.1

---------

Co-authored-by: Diego Orellano <[email protected]>
  • Loading branch information
diegocrombie and Diego Orellano authored Nov 14, 2023
1 parent 17537eb commit 6f5d908
Show file tree
Hide file tree
Showing 85 changed files with 1,689 additions and 163 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Check if vendor directory exists and remove it
run: |
if [ -d "vendor" ]; then
echo "Removing existing vendor directory"
rm -rf vendor
fi
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- name: Install Composer Dependencies
run: composer install
run: |
composer install
composer dump-autoload
- name: Run PHPStan
run: vendor/bin/phpstan analyse
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Node/composer artifact files
node_modules/
vendor/
vendor/*
!/vendor/autoload.php
!/vendor/composer/
!/vendor/ilovepdf/
composer.lock
package-lock.json
dev/package-lock.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
namespace Ilove_Img_Compress;

use WP_List_Table;

/**
* Custom table class for managing and displaying compressed media information in the WordPress media library.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace Ilove_Img_Compress;

/**
* The admin-specific functionality of the plugin.
*
Expand All @@ -17,7 +19,7 @@ class Ilove_Img_Compress_Plugin {
* @access public
* @var string VERSION The current version of the plugin.
*/
const VERSION = '2.0.0';
const VERSION = '2.0.1';

/**
* The unique identifier of this plugin.
Expand Down Expand Up @@ -80,12 +82,6 @@ public function admin_init() {
// Display media information in the attachment submit box.
add_action( 'attachment_submitbox_misc_actions', array( $this, 'show_media_info' ) );

// Check if the iLoveIMG library class exists, and initialize it if not.
if ( ! class_exists( 'Ilove_Img_Library_Init' ) ) {
require_once 'class-ilove-img-library-init.php';
new Ilove_Img_Library_Init();
}

// Display admin notices.
add_action( 'admin_notices', array( $this, 'show_notices' ) );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace Ilove_Img_Compress;

use Iloveimg\CompressImageTask;
use Iloveimg\ResizeImageTask;

Expand Down Expand Up @@ -139,7 +141,7 @@ public function compress( $images_id ) {

return false;
}
} catch ( Exception $e ) {
} catch ( \Exception $e ) {
update_post_meta( $images_id, 'iloveimg_status_compress', 0 );
error_log('Exception on Compress Method: ' . print_r($e, true)); // phpcs:ignore
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
namespace Ilove_Img_Compress;

use WP_Query;

/**
* Utility class for managing resources and functionality related to image compression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php
namespace Ilove_Img_Compress;

/**
* Class for handling serialization and management of iLoveIMG plugin settings.
*
* This class is responsible for managing the serialization and deserialization of iLoveIMG plugin settings, including options for compression, login, registration, and project settings. It also handles the validation of nonces and redirects based on user actions.
*
* @since 1.0.0
*/
class Ilove_Img_Compress_Serializer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace Ilove_Img_Compress;

/**
* Class for managing the iLoveIMG plugin's submenu and pages.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package iloveimgcompress
*/

namespace Ilove_Img_Compress;

/**
* Creates the submenu page for the plugin.
*
Expand Down
18 changes: 0 additions & 18 deletions admin/class-ilove-img-library-init.php

This file was deleted.

3 changes: 3 additions & 0 deletions admin/views/compress.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php
use Ilove_Img_Compress\Ilove_Img_Compress_Resources;
?>
<div class="wrap iloveimg_settings">
<h1><img src="<?php echo esc_url( ILOVE_IMG_COMPRESS_PLUGIN_URL . 'assets/images/logo.svg' ); // @phpstan-ignore-line ?>" class="logo" /></h1>

Expand Down
2 changes: 2 additions & 0 deletions admin/views/media-bulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package iloveimgcompress
*/

use Ilove_Img_Compress\Ilove_Img_Compress_Media_List_Table;

// Create an instance of our package class...
$ilove_img_test_list_table = new Ilove_Img_Compress_Media_List_Table();
// Fetch, prepare, sort, and filter our data...
Expand Down
3 changes: 3 additions & 0 deletions admin/views/overview.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php
use Ilove_Img_Compress\Ilove_Img_Compress_Resources;
?>
<div class="iloveimg_settings__overview__statistics">
<h3>Overview</h3>
<div>
Expand Down
32 changes: 14 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"email": "[email protected]"
}
],
"require": {
"ilovepdf/iloveimg-php": "^1.1"
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"szepeviktor/phpstan-wordpress": "^1.3",
Expand All @@ -21,23 +24,16 @@
}
},
"scripts": {
"post-install-cmd": [
"@stan",
"@phpcs",
"@phpcs-summary",
"@phpcbf"
],
"stan": [
"vendor/bin/phpstan analyse --memory-limit=-1 --error-format=table > ../../../phpstan-report-iloveimg.txt"
],
"phpcs-summary": [
"phpcs -s --report=summary --ignore=*/vendor/*,*/iloveimg-php/*,*/.github/*,*/assets/css/* --report-file=../../../condesniffer-report-summary-iloveimg.txt ./"
],
"phpcs": [
"phpcs -s --ignore=*/vendor/*,*/iloveimg-php/*,*/.github/*,*/assets/css/* --report-file=../../../condesniffer-report-iloveimg.txt ./"
],
"phpcbf": [
"phpcbf --ignore=vendor/,iloveimg-php/,.github/ ./"
]
"stan": "vendor/bin/phpstan analyse --memory-limit=-1 --error-format=table > ../../../phpstan-report-iloveimg.txt",
"phpcs-summary": "phpcs -s --report=summary --ignore=*/vendor/*,*/iloveimg-php/*,*/.github/*,*/assets/css/* --report-file=../../../condesniffer-report-summary-iloveimg.txt ./",
"phpcs": "phpcs -s --ignore=*/vendor/*,*/iloveimg-php/*,*/.github/*,*/assets/css/* --report-file=../../../condesniffer-report-iloveimg.txt ./",
"phpcbf": "phpcbf --ignore=vendor/,iloveimg-php/,.github/ ./",
"autoload-dev": "composer dump-autoload",
"autoload-prod": "composer dump-autoload --no-dev"
},
"autoload": {
"psr-4": {
"Ilove_Img_Compress\\": "admin"
}
}
}
15 changes: 7 additions & 8 deletions ilove-img-compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Plugin Name: Image Compressor & Optimizer - iLoveIMG
* Plugin URI: https://developer.iloveimg.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.0.0
* Version: 2.0.1
* Requires at least: 5.3
* Requires PHP: 7.4
* Author: iLoveIMG
Expand All @@ -30,13 +30,12 @@
die;
}

require_once 'admin/class-ilove-img-compress-plugin.php';
require_once 'admin/class-ilove-img-compress-process.php';
require_once 'admin/class-ilove-img-compress-resources.php';
require_once 'admin/class-ilove-img-compress-serializer.php';
require_once 'admin/class-ilove-img-compress-submenu-page.php';
require_once 'admin/class-ilove-img-compress-submenu.php';
require_once 'admin/class-ilove-img-compress-media-list-table.php';
require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php';

use Ilove_Img_Compress\Ilove_Img_Compress_Plugin;
use Ilove_Img_Compress\Ilove_Img_Compress_Serializer;
use Ilove_Img_Compress\Ilove_Img_Compress_Submenu;
use Ilove_Img_Compress\Ilove_Img_Compress_Submenu_Page;

add_action( 'plugins_loaded', 'ilove_img_compress_custom_admin_settings' );

Expand Down
8 changes: 8 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
</property>
</properties>
</rule>
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<severity>0</severity>
</rule>
<rule ref="WordPress.Files.FileName">
<properties>
<property name="strict_class_file_names" value="false"/>
</properties>
</rule>
<rule ref="WordPress"></rule>
<rule ref="Squiz.Commenting.FileComment.Missing">
<severity>0</severity>
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ parameters:
- vendor
- node_modules
analyse:
- iloveimg-php
- vendor/ilovepdf/iloveimg-php
8 changes: 6 additions & 2 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.0.0
Version: 2.0.1
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.4.1
Stable tag: 2.0.0
Stable tag: 2.0.1
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,10 @@ Moreover, all processed files are automatically deleted from our servers after b

== Changelog ==

== 2.0.1 ==
Added
* Improved class loading.

== 2.0.0 ==
Changed
* Minimum Support WP Version to 5.3
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
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.0.0
Version: 2.0.1
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.4.1
Stable tag: 2.0.0
Stable tag: 2.0.1
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -80,6 +80,10 @@ Moreover, all processed files are automatically deleted from our servers after b

== Changelog ==

== 2.0.1 ==
Added
* Improved class loading.

== 2.0.0 ==
Changed
* Minimum Support WP Version to 5.3
Expand Down
25 changes: 25 additions & 0 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit96ba3e56cd403440af21e22afd622759::getLoader();
Loading

0 comments on commit 6f5d908

Please sign in to comment.