=== Native Content Relationships === Contributors: chetanupare Tags: relationships, content modeling, posts, users, terms Requires at least: 5.0 Tested up to: 6.9 Requires PHP: 7.4 Stable tag: 1.0.23 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Donate link: https://buymeacoffee.com/chetanupare A native relational modeling layer for WordPress with enforced schema, integrity validation, and scalable performance. == Description == WordPress does not provide a first-class way to model real relationships between posts, users, and taxonomy terms. Most implementations rely on post meta or taxonomies, which become difficult to query, validate, and scale over time. Native Content Relationships introduces a structured, indexed, and enforceable relationship layer designed for long-term maintainability and high-volume datasets. This plugin is infrastructure-focused, developer-friendly, and aligned with WordPress core patterns. == What This Plugin Solves == • True many-to-many relationships • Structured relationship types with schema validation • Clean querying without post meta abuse • Enforced direction and connection constraints • Integrity auditing and repair tooling • Predictable performance at scale == Supported Relationship Types == • Post ↔ Post • Post ↔ User • Post ↔ Term • User ↔ Post • Term ↔ Post Relationship types are formally registered and validated through a schema registry. == Reliability & Integrity == • Registry-enforced relationship definitions • One-way and bidirectional relationship support • Optional connection constraints (one-to-one / one-to-many) • Standardized error handling (ncr_ prefixed codes) • Built-in Relationship Integrity Engine • Streaming WP-CLI audit and repair commands • Schema version guard for safe upgrades • Lightweight Site Health integration == Performance & Scale == Native Content Relationships is engineered for high-volume WordPress sites. • Composite covering indexes for fast lookups • SQL-native validation logic • Chunked integrity processing • Streaming WP-CLI operations • Bounded memory usage (<5MB during full scans) Benchmarks confirm stable performance with 1,000,000+ relationship rows under InnoDB. [View Full Performance Report](https://github.com/chetanupare/WP-Native-Content-Relationships/blob/main/docs/PERFORMANCE.md) == Admin Interface == • Relationship management in post editor • User profile relationship management • Term editor relationship support • AJAX-powered search for large datasets • UI aligned with WordPress admin patterns == Integrations == • WooCommerce (product relationships) • WPML / Polylang (relationship mirroring) • Elementor (dynamic tags support) • Gutenberg (related content block) • WP-CLI All integrations are optional and load only when detected. == Developer Guide == = Core API = Add a relationship: wp_add_relation( $from_id, $to_id, $type ); Get related items: wp_get_related( $id, $type ); Check relationship: wp_is_related( $from_id, $to_id, $type ); Remove relationship: wp_remove_relation( $from_id, $to_id, $type ); = Register Relationship Types = Register a relationship type: ncr_register_relation_type( $args ); Retrieve registered types: ncr_get_registered_relation_types(); = WP_Query Integration = $query = new WP_Query( array( 'post_type' => 'post', 'content_relation' => array( 'post_id' => 123, 'type' => 'related_to', 'direction' => 'outgoing', ), ) ); = REST API = Namespace: /wp-json/naticore/v1/ Available endpoints: • Create relationships • Fetch related content • Delete relationships • Retrieve registered types = WP-CLI = Audit integrity: wp content-relations check Repair issues: wp content-relations check --fix --verbose == Installation == 1. Upload the plugin to /wp-content/plugins/native-content-relationships/ 2. Activate the plugin from the Plugins menu 3. Database tables and indexes are created automatically 4. Configure settings under Settings → Content Relationships == Frequently Asked Questions == = Does this replace WooCommerce linked products? = No. It complements WooCommerce and can optionally sync relationships. = Can I migrate from ACF relationship fields? = Yes. A one-time migration tool is included. = Does this support users and terms? = Yes. Full support for post–user and post–term relationships is included. = Does this send data externally? = No. All data is stored locally in your WordPress database. == Changelog == = 1.0.23 = * Clean Release: Removed development artifacts (docs, tests, benchmarks) from distribution. * Documentation: Updated readme to link to external performance report. * Infrastructure: Verified 1M row benchmarks (see GitHub). = 1.0.22 = * Infrastructure-Grade Benchmarks: Refined docs/PERFORMANCE.md with high-fidelity metrics. * Enhanced Benchmarking Suite: Support for Mean/P95 latency and buffer pool warming. * Performance: Validated sub-2ms P95 latency at 1M rows. = 1.0.21 = * Public Performance Documentation: 100k vs 1M row benchmarks. * Automated Regression Suite: Validates constraints, directionality, and integrity. * Enhanced Developer API: Global ncr_add_relation() and ncr_get_relations() helpers. * Core: Standardized index provisioning results. = 1.0.20 = * Schema versioning guard (NCR_SCHEMA_VERSION 1.1) * Optimized composite and covering indexes * Lightweight Site Health integration = 1.0.19 = * Chunked integrity processing * SQL-native validation logic * Streaming WP-CLI output * Improved SVN deployment stability = 1.0.18 = * Relationship Integrity Engine * Modular integrity helpers = 1.0.17 = * Standardized ncr_ error codes * Registry locking after init = 1.0.16 = * Enforced registry logic * Connection constraints (max_connections) * REST endpoint for registered types = 1.0.15 = * Relationship Type Registration API = 1.0.0 = * Initial release == License == GPLv2 or later