Skip to content

courtneyr-dev/link-extension-for-xfn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Link Extension for XFN

Extends the native WordPress block editor link interface to include XFN (XHTML Friends Network) relationship options across all blocks that support links.

WordPress PHP License

User documentation

User documentation: Read the complete Link Extension for XFN documentation

Key pages:

The docs site builds from docs/ with Astro Starlight — see docs/MAINTAINING.md to update it.

Overview

The Link Extension for XFN seamlessly integrates XFN (XHTML Friends Network) relationship options into WordPress's native link interface. This plugin enhances every block that supports links—including Paragraph, Button, Navigation, List, Embed, and more—with comprehensive relationship tagging capabilities through an intuitive collapsible interface.

XFN is a simple way to represent human relationships using hyperlinks. By adding XFN relationships to your links, you can indicate how you're connected to the people and organizations you link to, creating a more semantic and meaningful web.

🎮 Try It Live

Launch WordPress Playground Demo - Try the plugin instantly in your browser! Click the "Preview" button to:

  • See XFN in action with pre-configured examples
  • Test buttons, embeds, and inline links with XFN attributes
  • Follow step-by-step testing instructions
  • Inspect XFN relationships in browser DevTools

No installation or setup required - the demo runs entirely in your browser!

Features

Complete XFN 1.1 Specification Support

This plugin implements the full XFN 1.1 specification with all relationship categories:

  • Friendship: contact, acquaintance, friend
  • Physical: met (have you met this person?)
  • Professional: co-worker, colleague
  • Geographical: co-resident, neighbor
  • Family: child, parent, sibling, spouse, kin
  • Romantic: muse, crush, date, sweetheart
  • Identity: me (link to yourself)

Dual Interface Integration

The plugin provides XFN controls in two convenient locations:

  1. Link Advanced Panel (Always enabled) - Collapsible XFN section in the link popover for inline paragraph links
  2. Inspector Controls (Optional) - Panel in the block sidebar for Button, Image, Navigation, and Embed blocks - opens by default when enabled

Note: Inspector Controls can be enabled in Settings → Link Extension for XFN. The Link Advanced Panel is always available for inline links.

Modern Collapsible Interface

  • Collapsible XFN sections with clean toggle buttons and smooth animations
  • Visual relationship pills showing active relationships at a glance
  • Count badges indicating number of active relationships
  • Button groups for easy relationship selection with mutual exclusivity support
  • Real-time validation preventing invalid relationship combinations

Screenshot

Link Extension for XFN interface showing collapsible sections, relationship selection buttons organized by category, and visual relationship pills displaying active selections

The XFN interface in action: Collapsible relationship categories with button groups for easy selection, and visual pills showing active relationships at a glance.

Documentation

Comprehensive user guides are available in the docs/ directory:

Requirements

  • WordPress: 6.4 or higher
  • PHP: 8.2 or higher
  • Modern browser with ES6 support

Installation

For Users

  1. Download the plugin ZIP file from WordPress.org or GitHub releases
  2. Go to WordPress admin → Plugins → Add New → Upload Plugin
  3. Upload the ZIP file and click Install Now
  4. Activate the plugin
  5. XFN options will immediately appear in the block editor

For Developers

# Clone the repository
git clone https://github.com/courtneyr-dev/link-extension-for-xfn.git
cd link-extension-for-xfn

# Install dependencies
npm install

# Build the plugin
npm run build

# Start development with watch mode
npm run start

Usage

Quick Start

After installation, XFN options are immediately available in the Link Advanced Panel for inline links (links within paragraphs, headings, lists, etc.).

To enable XFN for Button, Image, and Navigation blocks:

  1. Go to Settings → Link Extension for XFN
  2. Enable Inspector Controls (recommended)
  3. Click Save Changes

Adding XFN to Inline Links (Paragraphs, Lists, etc.)

  1. Select text and create a link (Cmd/Ctrl+K)
  2. Click the link to open the popover
  3. Click "Advanced" to expand advanced options
  4. Find the "XFN" section and expand it
  5. Select your relationships
  6. Click "Apply" to save

Adding XFN to Button/Image/Navigation Blocks

With Inspector Controls enabled:

  1. Select the Button/Image/Navigation block
  2. Look in the right sidebar (Inspector)
  3. Find "XFN Relationships" panel (opens by default)
  4. Select relationships - they save automatically

Development

Project Structure

link-extension-for-xfn/
├── link-extension-for-xfn.php  # Main plugin file
├── readme.txt               # WordPress.org documentation
├── README.md                # GitHub documentation (this file)
├── CHANGELOG.md             # Version history
├── LICENSE                  # GPL v2+ license
├── package.json             # Node dependencies
├── .gitignore              # Git exclusions
├── .distignore             # Distribution exclusions
│
├── src/                    # Source files (not in ZIP)
│   ├── index.js           # Main JavaScript entry point
│   ├── edit.js            # Block edit component
│   ├── save.js            # Block save component
│   ├── view.js            # Frontend JavaScript
│   ├── editor.scss        # Editor styles
│   ├── style.scss         # Frontend styles
│   └── block.json         # Block metadata
│
├── build/                 # Compiled assets (in ZIP)
│   ├── index.js          # Compiled JavaScript
│   ├── index.css         # Compiled CSS
│   ├── editor.css        # Compiled editor styles
│   └── block.json        # Block metadata (copy)
│
└── .wordpress-org/        # WordPress.org assets (not in ZIP)
    ├── icon-256x256.png
    ├── banner-772x250.png
    ├── banner-1544x500.png
    ├── screenshot-1.png
    └── ...

Build Commands

# Development build with watch mode
npm run start

# Production build (minified)
npm run build

# Lint JavaScript
npm run lint:js

# Lint CSS
npm run lint:css

# Format code
npm run format

# Create plugin ZIP
npm run plugin-zip

Coding Standards

This plugin follows WordPress coding standards:

Architecture

The plugin uses a singleton pattern for the main class and hooks into WordPress's block editor via JavaScript filters:

  • PHP Class: XFN_Link_Extension handles plugin initialization, asset enqueuing, and server-side functionality
  • JavaScript: Extends the block editor's BlockEdit component to add XFN controls
  • Hooks System: Uses WordPress hooks to integrate with the link interface without modifying core functionality

Key Functions

PHP Functions

// Get XFN relationship definitions
$relationships = xfn_get_relationships();

// Parse rel attribute to separate XFN from other values
$parsed = xfn_parse_rel_attribute( 'friend met nofollow' );
// Returns: ['xfn' => ['friend', 'met'], 'other' => ['nofollow']]

// Combine XFN and other rel values
$rel = xfn_combine_rel_values( ['friend', 'met'], ['nofollow'] );
// Returns: 'nofollow friend met'

// Validate XFN relationship combinations
$valid = xfn_validate_relationships( ['friend', 'acquaintance'] );
// Returns: false (mutually exclusive)

// Sanitize rel attribute value
$clean_rel = xfn_sanitize_rel_attribute( 'friend  met   nofollow' );
// Returns: 'nofollow friend met'

Developer Hooks

This plugin provides hooks for extensibility:

Filters

xfn_feature_flag_{$flag}

Override a feature flag value programmatically. Return a boolean to force-enable or force-disable a feature, or null to fall back to the saved option / default.

Available flags: abilities_api, meta_mirror, interactivity, blocks

// Force-disable the Interactivity API features.
add_filter( 'xfn_feature_flag_interactivity', '__return_false' );

// Force-enable the Abilities API regardless of saved settings.
add_filter( 'xfn_feature_flag_abilities_api', '__return_true' );

Priority order: filter return > saved option (xfn_feature_flags) > built-in default (true).

Technical Details

Rel Attribute Management

The plugin intelligently manages the HTML rel attribute:

  • Combines XFN relationships with existing rel values (nofollow, noopener, noreferrer)
  • Validates relationship combinations according to XFN specification
  • Preserves SEO-important and security-related attributes
  • Uses space-separated format per HTML specification

Data Persistence

  • Relationships are stored in the standard HTML rel attribute
  • No custom database tables or meta fields required
  • Compatible with all WordPress import/export tools
  • Relationships survive theme changes and plugin deactivation

Performance

  • Lightweight JavaScript bundle under 15KB gzipped
  • Only loads in the block editor (no frontend impact)
  • Lazy-loaded collapsible sections
  • Uses WordPress core components for consistency
  • Smooth CSS animations without performance penalties

Browser Compatibility

  • Modern browsers with ES6 support
  • Chrome 90+
  • Firefox 88+
  • Safari 14+
  • Edge 90+

Testing

Manual Testing

  1. Activate the plugin in a WordPress 6.4+ installation
  2. Create a new post or edit an existing one
  3. Add blocks with links (Paragraph, Button, Navigation, List, etc.)
  4. Test XFN controls in all three interfaces:
    • Floating toolbar
    • Inspector controls
    • Link advanced panel
  5. Verify relationships appear in published HTML rel attribute
  6. Test keyboard navigation and screen reader support
  7. Test with Query Monitor active to check for errors

Compatibility Testing

Test with popular plugins:

  • Yoast SEO
  • Rank Math
  • Jetpack
  • WooCommerce
  • Contact Form 7

Test with popular themes:

  • Twenty Twenty-Four (default block theme)
  • Blocksy
  • Kadence
  • GeneratePress
  • Astra

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Write tests if applicable
  5. Ensure code follows WordPress coding standards
  6. Test thoroughly
  7. Commit your changes (git commit -m 'Add amazing feature')
  8. Push to the branch (git push origin feature/amazing-feature)
  9. Open a Pull Request

See CONTRIBUTING.md for detailed guidelines.

Changelog

See CHANGELOG.md for version history.

Support

License

This plugin is licensed under GPL v2 or later.

Copyright (c) 2024-2026 Courtney Robertson

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Credits

Related Links

About

WordPress plugin that extends the Gutenberg link interface with XFN (XHTML Friends Network) relationship options

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors