# CPT Meta Size Analyzer

**CPT Meta Size Analyzer** helps you analyze the total size of post meta and content data for selected post types. It's useful for identifying large entries in your database that could impact performance.

---

## 🧩 Plugin Info

- **Contributors**: hiteshtalpada, praful2111, krishaweb  
- **Requires at least**: WordPress 5.9  
- **Tested up to**: WordPress 6.7  
- **Requires PHP**: 7.2+  
- **Stable tag**: 1.0.1  
- **License**: GPLv2 or later  
- **License URI**: [https://www.gnu.org/licenses/gpl-2.0.html](https://www.gnu.org/licenses/gpl-2.0.html)

---

## 🚀 Features

- 📊 **Meta Size Table** – Displays total post meta entries and size (Bytes, KB, MB)
- 📝 **Content Size Table** – Displays total content size per post type
- 🧮 **Size Unit Options** – Select default unit (Bytes, KB, MB)
- 📌 **Per Post Meta Column** – Adds “Meta Size” column in post listings
- 🧷 **Post Type Enable/Disable** – Choose which post types are analyzed
- ♻️ **Clear Cache** – Force fresh recalculations for latest data

---

## 🛠 Installation

1. Upload to `/wp-content/plugins/cpt-meta-size-analyzer/`
2. Activate via **Plugins > Installed Plugins**
4. Configure under **Meta Analyzer > Meta Setting**
3. Access analysis via **Meta Analyzer > Sizes Table**

---

## 🛠 Development & Build Setup

This plugin uses the [@wordpress/scripts](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) package and modular JS structure for building assets.

### 📦 Requirements

- Node.js >= 14
- npm
- Composer (for PHP autoloading)

### 🔧 Build Commands

```bash
# Install dependencies
npm install
composer install

# Build all JS files
npm run build:all

# OR build individual files
npm run file:index         # Builds src/index.js
npm run file:index-table   # Builds src/index-table.js
npm run file:action        # Builds src/index-action.js

```
---

### ⚙️ React Compatibility for WordPress 5.9–6.5.x

To ensure compatibility with WordPress versions **5.9 through 6.5.x**, this plugin conditionally loads **locally bundled React libraries**:

- `react.min.js`
- `react-dom.min.min.js`
- `react-jsx-runtime.min.js`

These files are included in the plugin under `assets/js/vendor/`, sourced from the latest official WordPress distribution to mirror the React version used in modern builds.

#### 🔍 How it works

- If the current WordPress version is **greater than or equal to 5.9** and **less than or equal to 6.5.5**, the plugin will enqueue these local scripts instead of relying on WordPress core.
- This ensures React-based components work reliably across older installations, even when WordPress doesn't bundle or expose modern React builds.
- For WordPress **6.5 and above**, the plugin does **not** enqueue these files to avoid script conflicts and reduce redundancy.

```php
if ( version_compare( $wp_version, '5.9', '>=' ) && version_compare( $wp_version, '6.5.5', '<=' ) ) {
    // Enqueue local React scripts
}
```

## 🪟 Full-Screen Action Modal Support (WordPress 6.4+)


In WordPress **6.4 and above**, the plugin adds a **full-screen icon button** inside the action modal. This icon enables users to toggle the modal into full-screen mode for a better and more focused experience.

