=== Image Resizer & Compressor by MP ===
Contributors: imageoptimizer
Tags: images, optimization, compression, performance, media
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Optimize images, videos, CSS, and JavaScript to improve website performance and loading speed.

== Description ==

**Image Resizer & Compressor by MP** (MP stands for **MakkPress Technologies**) helps improve website speed and performance by optimizing images, videos, and front-end assets. It is designed for e-commerce and content-heavy websites that want faster load times, improved Core Web Vitals, and a better user experience without complex configuration.

The plugin supports bulk optimization of product, category, and brand images, along with optional manual optimization of videos, CSS, and JavaScript files. Automation helps reduce file sizes while preserving visual quality, resulting in faster pages and improved performance metrics.

**Image Resizer & Compressor by MP** is powered by **ImageOptimizerPro.ai**, a cloud-based optimization service that processes and returns optimized assets securely and efficiently. This plugin is developed and maintained by **MakkPress Technologies**.

== Features ==

**Image Compression**  
Bulk-optimize images and reduce file sizes by up to 80% while preserving visual quality. Supports modern formats such as WebP.

**Video Compression**  
Reduce video file sizes for faster playback and lower bandwidth usage, ideal for product demos and landing pages.

**CSS & JavaScript Minification**  
Minify CSS and JavaScript files to reduce page weight and improve load times without affecting layout or functionality.

**One-Click Optimization**  
Optimize images and assets in bulk with a single click to save time and simplify performance management.

== Why Choose Image Resizer & Compressor by MP? ==

- **Improve Performance & SEO**  
  Smaller assets contribute to better Core Web Vitals and faster load times.

- **Faster User Experience**  
  Optimized files help reduce bounce rates and improve visitor engagement.

- **Resource Efficient**  
  Reduced file sizes help lower bandwidth usage and hosting costs.

- **All-in-One Optimization**  
  Manage image, video, and asset optimization from one dashboard.

- **Safe & Reversible**  
  Original files remain untouched and can be restored if needed.

== Setup & Support ==

Install **Image Resizer & Compressor by MP** from the WordPress Plugin Directory and activate it from your WordPress dashboard.  
A free plan is available, with optional upgrades.  
You can reach out to support anytime at support@imageoptimizerpro.ai

Ideal for e-commerce websites, media-rich sites, and anyone prioritizing speed and SEO with no-code optimization.

== External Service Disclosure ==

This plugin connects to an external optimization service provided by **ImageOptimizerPro.ai** to process optimizations and manage service connectivity.

**What the service does:**  
The service provides image, video, CSS, and JavaScript optimization. Media files are transmitted securely to the service for processing, and optimized versions are returned.

**When the plugin connects to the service:**
* **On plugin activation/deactivation:** Optional tracking (OFF by default, requires user opt-in) - see Plugin Status Webhook below
* **During service connection:** When you click "Start with Image Resizer & Compressor by MP" to connect your site
* **During optimization:** When images, videos, CSS, or JS files are being optimized
* **For statistics:** When fetching optimization statistics and metrics

**What data is sent and to which endpoints:**

1. **Plugin Status Webhook** (`https://imageoptimizerpro.ai/webhook/plugin-status.php`)
  * **When:** On plugin activation and deactivation to track successful plugin installation
  * **Data sent:** Site URL, admin email address and timestamp
  * **Purpose:** To track successful plugin installation and help provide service and support
  * **Default Status:** This webhook is **OFF by default** and will not send any data until you connect your site.
  * **Auto-enable:** This webhook is automatically enabled when you click the "Start with Image Resizer & Compressor by MP" button to connect your site for auto-login. This ensures we can track successful installations and provide better support.

2. **Service Registration** (`https://imageoptimizerpro.ai/api/register_wordpress.php`)
  * **When:** When you connect your WordPress site to the service
  * **Data sent:** Site URL, REST API endpoints, authentication tokens, admin email, site/store IDs, admin name
  * **Purpose:** To establish the connection between your WordPress site and the service

3. **Statistics API** (`https://imageoptimizerpro.ai/api/get-stats.php`)
  * **When:** When fetching optimization statistics in the admin dashboard
  * **Data sent:** Site URL, API key
  * **Purpose:** To retrieve optimization statistics and metrics

4. **CDN Service for Optimized Assets** (ImageOptimizerPro.ai CDN)
  **Optimized Assets URL**: https://mediacompresser-storage.b-cdn.net/
  - This is the storage zone where the optimized images, CSS, and JS files are hosted after being processed.
  **Before Optimization URL**: https://mediacompressor.b-cdn.net/
  - This is the storage zone where original images are kept, before any optimization is done.
  **Security & Backup**: We use two different storage zones for security and backup purposes—one for the original images and one for the optimized versions.
  **Purpose**: Deliver optimized images, CSS, JS via global CDN PoPs.  
  **Data sent**: Asset URLs and your site domain when URLs are rewritten for CDN.  
  **When**: When assets are served through the CDN for optimization.  
  **Provider Policies**: Bunny.net Privacy https://bunny.net/privacy , Terms https://bunny.net/tos/

**Service Links:**
* **Plugin Developer:** MakkPress Technologies
* **Plugin Website:** https://makkpress.com/
* **Service Website:** https://imageoptimizerpro.ai/
* **Privacy Policy:** https://imageoptimizerpro.ai/privacy-policy
* **Terms of Service:** https://imageoptimizerpro.ai/terms-and-conditions

**Account Required:**
Yes, an account with the ImageOptimizerPro.ai service (the optimization service provider) is required to use this plugin. You will be redirected to and auto-log in to your account when connecting the plugin.

**By using this plugin, you acknowledge that you have read and agree to the service's Privacy Policy and Terms of Service.**

== Key Features ==

- Automatic optimization for product, category, and brand images  
- Manual optimization of images, videos, CSS, and JavaScript  
- Safe originals by default (optimized assets replace heavier versions)  
- Compatible with common e-commerce setups (e.g., WooCommerce images)  
- Secure portal-based authentication


== Development & Code Quality ==

= Human-readable source code (no build tools) =

This plugin **does not use npm or build tools**. Human-readable first-party sources are shipped **inside the plugin**:

- **First-party PHP** (readable): All plugin code is human-readable and follows WordPress coding standards
  - `imageoptimizerpro.php` - Main plugin file
  - `includes/class-iop-settings.php` - Admin settings and UI
  - `includes/class-iop-rest.php` - REST API endpoints
  - `includes/helpers.php` - Helper functions

- **Inline CSS** (readable): All CSS is added via `wp_add_inline_style()` and contains only static, human-readable CSS code

- **Inline JavaScript** (readable): All JavaScript is added via `wp_add_inline_script()` and contains only static, human-readable JavaScript code

= Script and style loading (WordPress-native) =

All admin assets are registered and enqueued using WordPress APIs:

  - `wp_register_script()`, `wp_enqueue_script()`, `wp_add_inline_script()`
  - `wp_register_style()`, `wp_enqueue_style()`, `wp_add_inline_style()`

No raw `<script>`/`<style>` tags are echoed directly. All assets are properly enqueued through WordPress hooks (`admin_enqueue_scripts`).

= Data storage & paths =

  - Plugin settings are stored using WordPress Options API: `iopfplpro_settings`, `iopfplpro_api_tokens`
  - Temporary tokens are stored using WordPress Transients API: `iopfplpro_connect_token_*`
  - We use `plugin_dir_path()`, `plugin_dir_url()`, and `plugins_url()` for plugin paths/URLs
  - We use `wp_upload_dir()` for any file operations
  - We do not modify core WordPress files (wp-config.php, .htaccess, etc.)
  - Optimized media files replace originals in WordPress media library using standard WordPress functions

= Security & REST API =

  - All custom REST routes use a `permission_callback` function (`verify_bearer_token()`)
  - Token-based authentication is implemented for REST API endpoints
  - Nonces are validated using `wp_verify_nonce()` with proper sanitization (`sanitize_text_field(wp_unslash())`)
  - User capabilities are checked using `current_user_can('manage_options')`
  - All dynamic output is escaped late using `esc_html()`, `esc_attr()`, `esc_url()`, `esc_js()`
  - JSON responses use `wp_json_encode()`
  - All user inputs are sanitized using appropriate WordPress sanitization functions
  - SQL queries use WordPress database abstraction layer (no direct SQL)

== Installation ==

1. Install the plugin using the WordPress Plugin Installer or upload the ZIP file to `/wp-content/plugins/`.
2. Activate the plugin from the **Plugins** menu in WordPress.  
   (A new menu item named **Image Resizer & Compressor by MP** will appear.)
3. Open **Image Resizer & Compressor by MP** from the admin menu.
4. The dashboard will display image and asset statistics for your site. Click **Start Optimization** to begin the automated process.
5. (Optional) Manually optimize images, videos, CSS, and JavaScript from the connected optimization portal.

== Frequently Asked Questions ==

= Does this plugin send data to a third-party service? =  
Yes. To provide optimization functionality, the plugin communicates with the ImageOptimizerPro.ai service. Site metadata may be sent during activation, and media files are transmitted only when optimization is performed.

= Will it modify my database or theme files? =  
No. The plugin operates at the media and asset level. Your database schema, theme files, and existing code remain unchanged.

= What is optimized automatically? =  
Product, category, and brand images. You can also manually optimize images, videos, CSS, and JavaScript.

= Is it compatible with WooCommerce? =  
Yes. The plugin supports common WooCommerce image workflows for products and categories.

= Can I restore original files? =  
Yes. Original files are preserved and can be restored at any time.

== Screenshots ==

1. Image Resizer & Compressor by MP dashboard overview  
2. Bulk image optimization workflow  
3. WebP image conversion  
4. Video optimization  
5. JavaScript minification  
6. CSS minification  
7. Improved site performance results

== Privacy ==

This plugin connects to an external optimization service. The service may process your media files and receive limited site metadata (such as site URL, admin email, and timestamps) to operate correctly. You are responsible for ensuring you have the right to optimize the media you submit and that your usage complies with applicable privacy laws.

== Changelog ==

= 1.0.0 =
- Initial release with automated image optimization, manual optimization for images, videos, CSS, and JavaScript, secure service authentication, and activation/deactivation handling.

== Upgrade Notice ==

= 1.0.0 =
First public release. Authenticate with the external service after upgrading to enable automation.

