=== TypeForge CPT and Meta Builder ===
Contributors: darshitrajyaguru97
Tags: custom post type, taxonomy, meta fields, rest api, developer tools
Requires at least: 6.5
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Lightweight, fast custom post type, taxonomy, and meta field builder for WordPress. Perfect for developers.

== Description ==

TypeForge CPT and Meta Builder is a lightweight, performance-optimized WordPress admin interface for creating custom post types, taxonomies, and post meta configurations without writing code. Perfect for developers who want a faster alternative to page builders for content structure setup.

**Why TypeForge?**
- Lightning-fast performance with minimal database overhead
- Zero dependencies - works standalone without ACF or other plugins
- Clean, developer-focused UI
- Export PHP snippets for version control
- Portable JSON configurations for multi-environment workflows
- Full REST API support out of the box
- SEO-friendly with proper WordPress integration

**Key Features:**

* ⚡ **Performance-First Design** - Lightweight codebase, optimized queries, lazy-loaded assets
* 🏗️ **Custom Post Type Builder** - Configure all standard CPT options with live validation
* 📂 **Taxonomy Builder** - Create hierarchical or flat taxonomies, assign to multiple post types
* 🏷️ **Meta Field Builder** - 13 field types including flexible content for repeatable data
* 📱 **Mobile-Ready Forms** - Responsive meta boxes that work on all devices
* 💾 **Code Generation** - Download ready-to-use PHP snippets with proper registration
* 📤 **Portable Config** - Export/import JSON for easy deployment across environments
* 🔌 **REST API Ready** - Built-in REST endpoint support, no additional setup needed
* 🎨 **ACF Compatible** - Generate ACF-compatible JSON when ACF is active
* 🔒 **Secure by Default** - Proper sanitization, nonce verification, capability checks
* ♿ **Accessible** - WCAG-compliant markup and keyboard navigation

The plugin does not bundle or require Advanced Custom Fields. ACF JSON export is a bonus when ACF is active.

== Usage Guide ==

**Getting Started in 5 Minutes:**

1. Activate the plugin
2. Go to TypeForge CPT Builder in admin menu
3. Create your first custom post type (e.g., "Portfolio")
4. Add a taxonomy (e.g., "Portfolio Category")
5. Add custom meta fields (e.g., "Project URL", "Client Name")
6. View live meta box in post editor
7. Export PHP code for production use

= Dashboard =

The dashboard provides a quick overview of your content structures:
- **Post Types Count** - All registered custom post types
- **Taxonomies Count** - All registered taxonomies
- **Meta Fields Count** - All configured meta fields
- **REST Enabled** - Count of REST-enabled structures

Use quick action buttons to create new structures, generate code, or manage configurations.

= Custom Post Types =

**Configuration Fields:**
- **Singular Name** - Grammatically correct singular label (e.g., "Portfolio Item")
- **Plural Name** - Plural form (e.g., "Portfolio Items")
- **Slug** - URL-safe identifier, no spaces or special chars (e.g., "portfolio")
- **Menu Icon** - Choose from 300+ Dashicons
- **Menu Position** - Order in admin menu (5-100)
- **Description** - Helpful text for admin users
- **Supports** - Editor features (title, editor, thumbnail, etc.)
- **Public** - Visible on frontend (affects archive, search, REST)
- **Hierarchical** - Enable parent/child relationships
- **Archive** - Show post type archive page
- **REST Support** - Enable REST API endpoints

**Tips:**
- Archives need "Hierarchical" off and "Archive" enabled
- Public CPTs require "Show UI" and "Public" both enabled
- Change slug-related settings before publishing content
- REST support is recommended for headless/block editor usage

**Example: Portfolio Post Type**
```
Singular: Portfolio Item
Plural: Portfolio Items
Slug: portfolio
Menu Icon: dashicons-images-alt
Supports: title, editor, thumbnail
Public: Yes
Archive: Yes
REST: Yes
```

= Custom Taxonomies =

**Configuration Fields:**
- **Name** - Taxonomy display label (e.g., "Project Categories")
- **Singular** - Singular form (e.g., "Category")
- **Slug** - URL identifier (e.g., "portfolio-category")
- **Hierarchical** - Enable parent/child like categories (vs tags)
- **Post Types** - Assign to one or more CPTs
- **Show in REST** - Enable REST API support
- **Rewrite** - Update URL structure after creation

**Tips:**
- Hierarchical taxonomies work like categories (parent/child)
- Flat taxonomies work like tags (no hierarchy)
- Assign to multiple post types for shared taxonomy
- Visit Settings > Permalinks after slug changes

**Example: Portfolio Tags Taxonomy**
```
Name: Project Tags
Singular: Tag
Slug: portfolio-tag
Hierarchical: No (flat like tags)
Post Types: portfolio (check)
Show in REST: Yes
```

= Meta Fields =

**Field Types Supported:**
- **Text** - Single-line text input
- **Textarea** - Multi-line text editor
- **Number** - Numeric input with validation
- **Email** - Email field with validation
- **URL** - URL field with validation
- **Checkbox** - Boolean true/false
- **Radio** - Single select from options
- **Select** - Dropdown selector
- **Date** - Date picker field
- **Time** - Time picker field
- **Image** - Media library image uploader
- **File** - Media library file uploader
- **Flexible Content** - Repeatable layout blocks (new!)

**Configuration:**
- **Post Type** - Which CPT this field applies to
- **Label** - User-friendly field name
- **Meta Key** - Internal database key (underscore-prefixed recommended)
- **Type** - Choose from 13 field types
- **Options** - For select/radio (one per line)
- **Default Value** - Pre-fill when creating posts
- **Placeholder** - Example text in input
- **Description** - Helper text below field
- **Required** - Mark field as mandatory
- **Show in REST** - Expose to API

**Tips:**
- Use meta keys like `_portfolio_client` (underscore prefix hides from custom fields)
- Required fields work with JavaScript validation
- Flexible content is perfect for modular content blocks
- REST-enabled fields auto-register with proper schema

**Example: Portfolio Meta Fields**
```
1. Client Name (text) - _client_name - Required: Yes
2. Project URL (url) - _project_url - Required: No
3. Project Budget (number) - _project_budget - Show in REST: Yes
4. Case Study (flexible_content) - _case_study
```

= Code Generator =

The Code Generator creates production-ready PHP snippets. Perfect for:
- Version control integration
- Continuous deployment pipelines
- Moving from staging to production
- Sharing configurations across teams
- Local development workflows

**Generated Code Includes:**
- CPT registration with all options
- Taxonomy registration with assignments
- Meta field registration with schema
- REST endpoint examples
- Proper capability checks
- Inline documentation

**Quick Generate Feature:**
Simply enter a name and TypeForge auto-generates slug, singular/plural forms:
- "Event" → slug: event, singular: Event, plural: Events
- "Author" → slug: author, singular: Author, plural: Authors
- "Testimonial" → slug: testimonial, singular: Testimonial, plural: Testimonials

**Export Options:**
- Copy code to clipboard (Ctrl+C ready)
- Download as .php file for version control
- ACF-compatible JSON (when ACF is active)

= Import / Export =

**Use Cases:**
- Backup configurations
- Transfer between environments (local → staging → production)
- Share configurations with team members
- Version control content structures
- Disaster recovery

**Workflow:**
1. Go to Import/Export page
2. Click "Export JSON" to download current configuration
3. On another site, click "Import JSON" and select the file
4. Review configuration preview
5. Click "Import" to activate structures

**JSON Format:**
The exported JSON includes all CPTs, taxonomies, meta fields, and settings. Keep backups in git for version history.

= Troubleshooting =

**Post Type Not Appearing?**
- Check "Show UI" and "Public" are enabled
- Visit Settings > Permalinks and save
- Clear browser cache
- Refresh WordPress admin

**Meta Fields Not Showing?**
- Verify field is assigned to correct post type
- Check post type has meta box support
- Ensure meta field is not hidden (show_in_rest)
- Clear admin bar cache

**REST API Not Working?**
- Enable "Show in REST" on CPT and fields
- Verify REST is not disabled in settings
- Test with REST CLI or Postman
- Check user capabilities allow API access

**Import Failing?**
- Verify JSON file is valid (use online JSON validator)
- Check file size is under 30MB
- Ensure proper permissions
- Try export/import on fresh installation first

**Settings > Permalinks Not Saving?**
- Disable plugins temporarily to check conflicts
- Verify .htaccess is writable
- Try "Plain" permalinks then switch back
- Check with hosting provider for rewrite rules

= ACF Compatible JSON =

TypeForge generates ACF-compatible JSON when Advanced Custom Fields is active. This allows:
- Easy ACF integration for clients
- Switching between ACF and TypeForge
- Export structures for ACF field groups
- Backup ACF fields in portable format

Note: TypeForge is fully independent and works without ACF. ACF compatibility is optional.

== Installation ==

**Automatic Installation (Recommended):**

1. Go to WordPress Admin > Plugins > Add New
2. Search for "TypeForge CPT Meta Builder"
3. Click "Install Now" → "Activate"
4. Open TypeForge from admin menu
5. Start creating structures

**Manual Installation:**

1. Download plugin from WordPress.org
2. Extract to `/wp-content/plugins/typeforge-cpt-meta-builder/`
3. Go to Plugins in WordPress admin
4. Find TypeForge in list, click "Activate"
5. Menu appears immediately

**Configuration Steps:**

1. **Create Post Type** (TypeForge > Post Types)
   - Enter singular/plural names
   - Set slug and menu position
   - Choose supports (editor, thumbnail, etc)
   - Save and visit Permalinks settings > Save

2. **Create Taxonomy** (TypeForge > Taxonomies)
   - Name your taxonomy
   - Assign to post type(s)
   - Enable REST if needed

3. **Add Meta Fields** (TypeForge > Meta Fields)
   - Select post type
   - Add field label and key
   - Choose field type
   - Configure options as needed

4. **Generate & Deploy** (TypeForge > Code Generator)
   - Copy generated PHP snippets
   - Add to theme/plugin for production
   - Keep JSON export as backup

**Post-Installation:**

- ✅ Visit Settings > Permalinks and save to refresh rewrite rules
- ✅ Clear any caching plugins
- ✅ Test new post type edit screen
- ✅ Verify meta fields appear correctly
- ✅ Check REST endpoints if enabled

**Requirements:**
- WordPress 6.5 or higher
- PHP 8.0 or higher
- At least 2 MB free disk space
- Minimum 512 MB available memory

**Browser Support:**
- Chrome/Edge (latest)
- Firefox (latest)
- Safari (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)

== Frequently Asked Questions ==

= Does this plugin require ACF? =

No. TypeForge is completely independent and works standalone. Advanced Custom Fields integration is optional - ACF JSON export appears only when ACF is active.

= Is TypeForge lightweight? =

Yes. TypeForge uses minimal PHP, includes zero JavaScript frameworks, and lazy-loads CSS/JS only on plugin pages. Configuration is cached to reduce database queries. Perfect for performance-focused sites.

= Does uninstall remove my data? =

No, not by default. Plugin configuration stays in the database even after uninstall. Enable "Delete Data On Uninstall" in Settings only if you want automatic cleanup.

= Can I export generated PHP code? =

Yes. Code Generator provides copy and download options for production-ready PHP snippets. Export includes proper registration, sanitization, and capability checks.

= Are REST endpoints generated automatically? =

Yes. Enable "Show in REST" on CPTs and meta fields to automatically register REST endpoints. TypeForge includes permission callbacks for all routes.

= Can I move configurations between sites? =

Yes. Use Export/Import JSON to move full configurations between local, staging, and production sites. Perfect for multi-environment workflows.

= What if I have configuration conflicts? =

TypeForge uses WordPress options API with automatic conflict detection. Similar slugs are prevented by the UI. Import preview shows what will be added/updated.

= How do I version control my content structures? =

Export JSON, commit to git, and deploy via import. Code Generator snippets also work with version control for production themes/plugins.

= Can I use TypeForge with custom post types from other plugins? =

Partially. TypeForge manages its own structures. For third-party CPTs, TypeForge can add meta fields and taxonomies but cannot edit the CPT registration.

= Is TypeForge compatible with page builders? =

Yes. TypeForge creates native WordPress structures that any page builder can access. Use alongside Elementor, Beaver Builder, etc.

= What about WooCommerce compatibility? =

TypeForge is compatible but doesn't provide WooCommerce-specific features. Use for custom post types alongside WooCommerce products.

= Can I use flexible content fields without ACF? =

Yes. Flexible content is a native TypeForge field type - no ACF required. Generate repeatable content blocks for anything.

= How do I report bugs or suggest features? =

Visit the plugin support forums on WordPress.org or open issues on GitHub. Community feedback drives development priorities.

= Can I use TypeForge in a multisite? =

Yes. TypeForge is multisite-compatible. Configurations are stored per-site. Requires admin access on each site.

= What PHP versions are supported? =

TypeForge requires PHP 8.0 or higher. Supports PHP 8.0, 8.1, 8.2, 8.3, and 8.4.

== Screenshots ==

1. Dashboard with counts and quick actions
2. Custom post type builder with all configuration options
3. Taxonomy builder for hierarchical and flat taxonomies
4. Meta field builder with 13 field types
5. Code generator with PHP snippets and quick generate
6. Meta box in post editor showing configured fields
7. Settings panel for uninstall options

== Changelog ==

= 1.0.2 =
* Enhanced documentation with comprehensive usage guide and examples
* Improved error messages with troubleshooting tips
* Better tooltips and inline help text
* Optimized asset loading for improved performance
* Added keyboard shortcuts in admin screens
* Enhanced accessibility (WCAG 2.1 Level AA compliance)
* Improved REST endpoint documentation
* Better handling of slugs and naming conventions
* Added validation hints for configuration fields
* Improved mobile responsiveness of admin interface

= 1.0.1 =
* Added Flexible Content meta field type for repeatable, layout-based content blocks
* Added Quick Generate by Name panels to Code Generator: turn a single name into a complete, ready-to-use post type, taxonomy, or meta field snippet

= 1.0.0 =
* Initial release
* Custom post type builder with all WordPress options
* Taxonomy builder with hierarchical support
* Meta field builder with 12 field types
* Code generator with PHP and ACF JSON export
* JSON import/export for configurations
* REST API support throughout

== Upgrade Notice ==

= 1.0.2 =
Major documentation improvements, better error handling, and accessibility enhancements. Recommended update for all users.

= 1.0.1 =
Adds Flexible Content meta fields and Quick Generate by Name on the Code Generator screen.

= 1.0.0 =
Initial release.

== Support ==

**Need Help?**
- Read the comprehensive FAQ section above
- Check the Troubleshooting guide in Usage section
- Visit WordPress.org support forums
- Report bugs or suggest features via GitHub

**For Developers:**
- Hooks: Use `typeforge_cpt_meta_builder_*` filters
- Configuration: Modify via `typeforge_cpt_meta_builder_config_updated` action
- Extend: Hook into registration functions
- Version control: Export JSON and commit to git

== Performance & Optimization ==

TypeForge is built for speed:

- **Lightweight Code** - ~50KB of PHP, no heavyweight dependencies
- **Efficient Queries** - Configuration cached per-request
- **Smart Asset Loading** - CSS/JS only load on plugin pages
- **Database Optimization** - Uses WordPress options API efficiently
- **REST API Ready** - Automatic REST registration without extra overhead

== Security & Compliance ==

TypeForge follows WordPress security standards:

- ✅ Proper input sanitization and escaping
- ✅ Nonce verification on all forms
- ✅ Capability checking (filterable `manage_options`)
- ✅ PHPCS WordPress-Core standard compliance
- ✅ No external API calls or tracking
- ✅ Privacy-focused (zero user data collection)
- ✅ Regular security audits

== Contributing ==

TypeForge welcomes community contributions. To contribute:

1. Fork the repository
2. Create feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open Pull Request

## Rate & Review

If TypeForge helps your WordPress project, consider leaving a review on WordPress.org. Your feedback helps other developers find this tool.

⭐⭐⭐⭐⭐ **Your review matters!**
