Skip to content

Themefic-Team/llms-pro

Repository files navigation

LLMS Pro - WordPress Plugin

A comprehensive WordPress plugin for generating and managing LLMS.TXT files with advanced features including Markdown editor, auto-sync, dynamic shortcodes, and revision history.

Table of Contents

Overview

LLMS Pro automatically generates and maintains an llms.txt file in your WordPress root directory. This file helps Large Language Models (LLMs) and AI systems better understand your website's structure and content, similar to how robots.txt helps search engines.

What is LLMS.TXT?

LLMS.TXT is a standardized file format that provides AI systems with a structured overview of your website's content. It includes:

  • Site overview and description
  • Page hierarchy
  • Blog posts and categories
  • Author information
  • Custom post types
  • Recent content updates

Features

Core Features

  1. Markdown Editor with EasyMDE

    • Live preview functionality
    • Syntax highlighting
    • Full-screen editing mode
    • Auto-save drafts
    • Toolbar with common formatting options
  2. Auto-Sync Functionality

    • Scheduled updates via WP-Cron
    • Configurable frequency (hourly, twice daily, daily, weekly)
    • Manual sync on demand
  3. Dynamic Shortcodes

    • [llms_pages] - List all pages
    • [llms_posts] - List posts with filters
    • [llms_categories] - List categories
    • [llms_authors] - List authors
    • [llms_recent_content] - Recent content
    • [llms_sitemap_tree] - Complete site structure
    • [llms_custom_post_type] - Custom post types
  4. Revision History

    • Tracks up to 100 revisions
    • One-click restore
    • User and timestamp tracking
    • File size history
  5. File Management

    • Automatic backups before updates
    • File validation and integrity checks
    • Permission management (chmod 644)
    • File locking during writes
  6. Content Synchronization

    • Hierarchical page structure
    • Category-based post organization
    • Custom taxonomy support
    • Author archives
    • Meta data extraction

Admin Interface

  • Clean, modern UI with WordPress design standards
  • Tabbed interface (Editor/Preview)
  • Real-time file info display
  • Quick actions sidebar
  • Settings page with comprehensive options

Installation

Automatic Installation

  1. Log in to your WordPress dashboard
  2. Navigate to Plugins > Add New
  3. Search for "LLMS Pro"
  4. Click Install Now and then Activate

Manual Installation

  1. Download the plugin files
  2. Upload to /wp-content/plugins/llms-pro/
  3. Activate through the WordPress admin panel
  4. Navigate to LLMS Pro > Editor

Post-Installation

After activation, the plugin will:

  • Create database tables for revision history
  • Generate an initial llms.txt file
  • Schedule the first auto-sync job
  • Create backup directory in uploads

Configuration

General Settings

Navigate to LLMS Pro > Settings to configure:

Synchronization Settings

  • Auto-Sync: Enable/disable automatic updates
  • Sync Frequency: Hourly, twice daily, daily, or weekly

Content Settings

  • Include Content Types: Pages, posts, categories, authors
  • Post Limit: Maximum number of posts (1-500)
  • Custom Post Types: Select which custom post types to include

URL Settings

Advanced Settings

  • Max Revisions: Number of revisions to keep (1-100)
  • Remove on Deactivate: Delete file when plugin is deactivated

Usage

Basic Usage

  1. Navigate to Editor: Go to LLMS Pro > Editor
  2. Edit Content: Use the Markdown editor to write/edit content
  3. Add Shortcodes: Insert dynamic shortcodes where needed
  4. Preview: Switch to Preview tab to see formatted output
  5. Save: Click Save to update the llms.txt file

Using Shortcodes

# My Website

## Overview
[llms_site_info]

## All Pages
[llms_pages]

## Recent Blog Posts
[llms_posts limit="10"]

## Categories
[llms_categories]

## Recent Updates (Last 30 Days)
[llms_recent_content days="30"]

Viewing the File

Access your llms.txt file at: https://yourdomain.com/llms.txt

Shortcodes

[llms_pages]

Lists all published pages in hierarchical structure.

[llms_pages]

Output:

- Home: /
- About: /about/
  - Team: /about/team/
  - History: /about/history/

[llms_posts]

Lists blog posts with optional filters.

[llms_posts limit="10" category="tech" orderby="date" order="DESC"]

Attributes:

  • limit - Number of posts (default: 50)
  • category - Filter by category slug
  • orderby - Sort by (date, title, etc.)
  • order - ASC or DESC

[llms_categories]

Lists all categories with post counts.

[llms_categories]

[llms_authors]

Lists all authors with post counts.

[llms_authors]

[llms_recent_content]

Lists content from the last N days.

[llms_recent_content days="30"]

Attributes:

  • days - Number of days to look back (default: 30)

[llms_sitemap_tree]

Displays complete site structure.

[llms_sitemap_tree]

[llms_custom_post_type]

Lists custom post type content.

[llms_custom_post_type type="product" limit="20" orderby="date" order="DESC"]

Attributes:

  • type - Post type slug (required)
  • limit - Number of items (default: 50)
  • orderby - Sort by
  • order - ASC or DESC

[llms_site_info]

Displays site overview information.

[llms_site_info]

Development Steps

This section documents all the steps taken to build this plugin:

Step 1: Main Plugin File (llms-pro.php)

  • Created main plugin class with singleton pattern
  • Implemented activation/deactivation hooks
  • Set up autoloading for core classes
  • Defined plugin constants
  • Created database schema for revision history
  • Configured default options
  • Set up WP-Cron for auto-sync

Step 2: File Handler Class (class-llms-txt-file-handler.php)

  • Implemented file read/write operations
  • Added backup system before updates
  • Created revision history tracking
  • Implemented file validation
  • Added permission management (chmod 644)
  • Created atomic file operations (write to temp, then move)
  • Added file locking during writes

Step 3: Content Sync Class (class-llms-txt-content-sync.php)

  • Built hierarchical page structure builder
  • Created post fetching with category filters
  • Implemented author list generation
  • Added custom post type support
  • Created recent content fetcher
  • Built sitemap tree generator
  • Implemented URL formatting (absolute/relative)

Step 4: Shortcodes Class (class-llms-txt-shortcodes.php)

  • Registered all shortcodes
  • Implemented attribute parsing and validation
  • Created shortcode handlers for each type
  • Added shortcode processing in generator

Step 5: Generator Class (class-llms-txt-generator.php)

  • Created main file generation logic
  • Implemented content validation
  • Added preview functionality
  • Created revision management
  • Implemented template system

Step 6: Admin Class (class-llms-txt-admin.php)

  • Created admin menu structure
  • Implemented AJAX handlers for save/generate/delete
  • Added settings save functionality
  • Created admin notices system
  • Implemented file info display
  • Added revision restore functionality

Step 7: Admin Views

  • admin-page.php: Created main editor interface with tabs
  • settings-page.php: Built comprehensive settings page
  • Added file info display
  • Created revision history sidebar
  • Added shortcode reference panel

Step 8: Admin Assets

  • admin-style.css:
    • Modern, clean design
    • Responsive layout
    • Tab system styling
    • Revision history styling
    • Loading states
  • admin-script.js:
    • EasyMDE editor initialization
    • AJAX operations
    • Tab switching
    • Preview updates
    • Revision restore
    • Copy to clipboard

Step 9: Documentation

  • Created WordPress readme.txt with full plugin information
  • Created README.md with comprehensive documentation
  • Documented all features, hooks, and usage

Technical Architecture

Object-Oriented Design

The plugin follows WordPress best practices with a clean OOP structure:

LLMS_Pro (Main Class)
├── LLMS_TXT_File_Handler (File operations)
├── LLMS_TXT_Content_Sync (Content fetching)
├── LLMS_TXT_Shortcodes (Shortcode processing)
├── LLMS_TXT_Generator (Content generation)
└── LLMS_TXT_Admin (Admin interface)

Security Measures

  • Nonce verification for all AJAX requests
  • Capability checks (manage_options)
  • Data sanitization and validation
  • SQL injection prevention with prepared statements
  • XSS protection with escaping
  • File upload restrictions

Performance Optimization

  • Transient caching for queries
  • Batch processing for large sites
  • AJAX-based generation for big files
  • Efficient database queries
  • Background processing via WP-Cron

Hooks and Filters

Actions

llms_txt_before_generate

Fires before file generation.

add_action('llms_txt_before_generate', function() {
    // Your code here
});

llms_txt_after_generate

Fires after file generation.

add_action('llms_txt_after_generate', function($result) {
    // $result is true or WP_Error
});

Filters

llms_txt_content_filter

Filter the final content before writing.

add_filter('llms_txt_content_filter', function($content) {
    // Modify content
    return $content;
});

llms_txt_url_format

Customize URL formatting.

add_filter('llms_txt_url_format', function($url, $format) {
    // Customize URL
    return $url;
}, 10, 2);

llms_txt_site_overview

Customize site overview section.

add_filter('llms_txt_site_overview', function($overview) {
    return $overview . "\nCustom info";
});

llms_txt_pages_output

Customize pages output.

add_filter('llms_txt_pages_output', function($output, $pages) {
    // Modify pages output
    return $output;
}, 10, 2);

llms_txt_all_content

Filter all generated content.

add_filter('llms_txt_all_content', function($content) {
    return $content . "\n\n## Custom Section\n\nCustom content";
});

Database Schema

wp_llms_txt_history

Stores revision history for the llms.txt file.

CREATE TABLE wp_llms_txt_history (
    id bigint(20) NOT NULL AUTO_INCREMENT,
    content longtext NOT NULL,
    created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
    created_by bigint(20) NOT NULL,
    file_size bigint(20) NOT NULL,
    notes text,
    PRIMARY KEY (id),
    KEY created_at (created_at)
);

Columns:

  • id - Unique revision ID
  • content - Full content of the revision
  • created_at - Timestamp of creation
  • created_by - WordPress user ID who created it
  • file_size - Size of content in bytes
  • notes - Optional notes (for future use)

File Structure

llms-pro/
├── llms-pro.php                          # Main plugin file
├── readme.txt                            # WordPress readme
├── README.md                             # This file
├── includes/                             # Core classes
│   ├── class-llms-txt-file-handler.php   # File operations
│   ├── class-llms-txt-content-sync.php   # Content fetching
│   ├── class-llms-txt-shortcodes.php     # Shortcode handling
│   ├── class-llms-txt-generator.php      # Content generation
│   └── class-llms-txt-admin.php          # Admin interface
├── admin/                                # Admin assets
│   ├── css/
│   │   └── admin-style.css               # Admin styles
│   ├── js/
│   │   └── admin-script.js               # Admin scripts
│   └── views/
│       ├── admin-page.php                # Editor page
│       └── settings-page.php             # Settings page
├── assets/                               # Frontend assets
│   └── lib/
│       └── easymde/                      # Markdown editor (CDN)
└── languages/                            # Translation files
    └── llms-pro.pot                      # Translation template

Requirements

Minimum Requirements

  • WordPress 6.0 or higher
  • PHP 8.0 or higher
  • MySQL 5.6 or higher
  • Write permissions for WordPress root directory

Recommended Requirements

  • WordPress 6.7 or higher
  • PHP 8.2 or higher
  • MySQL 8.0 or higher
  • HTTPS enabled

Troubleshooting

File Not Generated

  1. Check WordPress root directory write permissions
  2. Check PHP error logs
  3. Verify WP-Cron is running
  4. Check Settings > Auto-Sync is enabled

Shortcodes Not Working

  1. Ensure shortcode syntax is correct
  2. Check the shortcode reference in the editor
  3. Preview content before saving
  4. Check for typos in shortcode names

Revision History Not Showing

  1. Check database table exists: wp_llms_txt_history
  2. Verify user has admin capabilities
  3. Check max revisions setting

Future Enhancements

Potential features for future versions:

  • REST API endpoint for llms.txt
  • Webhook notifications on updates
  • Integration with popular SEO plugins
  • Gutenberg block for content insertion
  • WP-CLI commands
  • Export to different formats (JSON, XML)
  • A/B testing different formats
  • CloudFlare cache purging integration

Support

For support, feature requests, or bug reports:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Credits

License

This plugin is licensed under GPL v3 or later.

Copyright 2024 Mainul Sunvi

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 3 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.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Changelog

Version 1.0.0 (2024-01-15)

Initial release with the following features:

  • Markdown editor with EasyMDE integration
  • Auto-sync functionality with WP-Cron
  • Dynamic shortcodes system
  • Revision history tracking (up to 100 revisions)
  • Content synchronization from WordPress
  • Settings page with full configuration
  • File backup system
  • Custom post type support
  • AJAX-powered admin interface
  • Translation ready
  • Security hardened
  • Performance optimized

Made with ❤️ for the WordPress community

About

Automatically generate and manage an LLMS.TXT file for AI/LLM comprehension. Includes advanced features like auto-sync, shortcodes, Markdown editor, and revision history.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors