# Pro/Free Code Separation for WordPress.org

## The Issue

WordPress.org only accepts **100% free** plugins. Any code related to premium/paid features should ideally be separated from the free version that's deployed to WordPress.org.

## Current Approach (Gated Code)

Currently, pro features are in the same codebase but hidden behind license checks:

```javascript
if ( ! ultraDevsRandomImageBlock.licensing.is_plan_pro ) {
    <UpgradeMessage />
} else {
    <ProFeature />
}
```

**WP.org Compatibility**: This is generally acceptable IF:
- The plugin is fully functional without payment
- Pro features are enhancements, not core functionality
- Free users aren't tricked into thinking they need to pay

## Recommended Solutions

### Option 1: Freemius Premium Code Module (Recommended)

Freemius allows storing pro code on their servers and loading it dynamically.

**Pros:**
- Clean separation - no pro code in WP.org repo
- Automatic updates from Freemius servers
- WP.org compliant
- Single plugin with dynamic feature loading

**Implementation:**
```php
// In random-image-block.php
udrib_fs()->add_filter('hasPremiumCode', '__return_true');
```

Then move all pro code to a separate module that's loaded from Freemius.

### Option 2: Separate Repository (Pro Plugin Add-on)

Create two separate plugins:
1. **Free Plugin** - Published on WordPress.org
2. **Pro Plugin** - Separate add-on that requires the free plugin

**Pros:**
- Complete separation
- Independent release cycles
- WP.org compliant

**Cons:**
- More complex maintenance
- User needs to install two plugins

### Option 3: Conditional Deployment (Current + Build Process)

Keep everything in one repo, but exclude pro code during WP.org deployment.

**Implementation:**
1. Create a build script that removes pro code before deployment
2. Use `.distignore` patterns to exclude pro files
3. Maintain full code in development, deploy only free to WP.org

## Recommended Action Plan

For your current setup, I recommend **Option 1 (Freemius Premium Code Module)**:

1. Move pro feature code to a separate module
2. Configure Freemius to load pro code dynamically
3. Keep only free features in the main codebase

This maintains the single-plugin experience while keeping WP.org happy.

## Current Pro Features in Codebase

These features should be moved to the premium module:

1. **Image Object Fit** - Currently gated
2. **Caption Over Image** - Currently gated
3. **Tablet/Mobile Image Size** - Partially implemented
4. **Future pro features** - As planned in FEATURES.md

## Free Features (Safe for WP.org)

These are fine to keep in the main plugin:

1. **Link Options** - Just added
2. **Image Filters** - Just added
3. **Random Image Selection** - Core feature
4. **Basic Caption** - Core feature

## Next Steps

Would you like me to:
1. Implement the Freemius Premium Code Module setup?
2. Create a build script that strips pro code for WP.org deployment?
3. Reorganize the codebase to separate pro/free features more clearly?
