Search by

justdev / jd-support

kirilldorozhynskyi

justDev Support Plugin with modern architecture

Package info

github.com/kirilldorozhynskyi/jd-support

Type:wordpress-muplugin

pkg:composer/justdev/jd-support

Statistics

Installs: 163

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

2.2.2 2026-10-23 12:09 UTC

This package is auto-updated.

Last update: 2026-10-23 12:09:21 UTC


README

Overview

Version 2.2.2 clarifies the live-site editing link and applies the justDev brand colors to the environment notice.

Version 2.2.1 adds a dismissible environment warning, a persistent live-content reminder, and per-user exceptions.

Version 2.2 adds the shared data-cache API and removes browser-cache rule generation. See project cache migration guide for the bidirectional theme adapter, fallback without the plugin, automatic invalidation, and legacy .htaccess cleanup.

This plugin has been completely redesigned using modern development principles and architectural patterns.

New Architecture

Project Structure

src/
├── Core/                    # Plugin core
│   ├── Plugin.php          # Main plugin class
│   ├── Container/          # Dependency Injection
│   │   └── Container.php
│   ├── Config/             # Configuration management
│   │   └── ConfigManager.php
│   └── Hooks/              # Hook management
│       └── HookManager.php
├── Services/               # Business logic
│   ├── SecurityService.php
│   ├── AdminService.php
│   ├── CacheService.php
│   ├── SvgService.php
│   └── VersionService.php
├── Admin/                  # Administrative part
│   ├── AdminManager.php
│   └── Controllers/
│       ├── SettingsController.php
│       └── AssetsController.php
├── Public/                 # Public part
│   ├── PublicManager.php
│   └── Controllers/
│       └── AssetsController.php
└── Views/                  # Views
    └── settings-page.php

Key Improvements

1. Dependency Injection Container

  • Centralized dependency management
  • Automatic service instance creation
  • Easy testing and extensibility

2. Service Layer Pattern

  • Separation of business logic into separate services
  • Each service is responsible for specific functionality
  • Easy code reuse

3. MVC Architecture

  • Controllers for request handling
  • Views for data display
  • Models (services) for business logic

4. Configuration Management

  • Centralized settings management
  • Typed methods for configuration work
  • Automatic settings validation

5. Hook Management

  • Structured WordPress hook management
  • Automatic registration of all hooks
  • Easy addition of new hooks

Installation and Usage

Requirements

  • PHP 7.4+
  • WordPress 5.0+

Installation

Via Composer (recommended)

  1. Add the repository (if private) and require the package:
    composer require justdev/jd-support:"^2.2.2"
  2. Copy stubs/jd-support-mu-loader.php to wp-content/mu-plugins/jd-support.php (or symlink it) so WordPress loads the vendor package.
  3. Run composer install (or composer update) to ensure the package lives in vendor/justdev/jd-support.
  4. Configure options in the "j|D Support" section of the admin area.

Manual (legacy)

  1. Copy this repository into wp-content/mu-plugins/jd-support/.
  2. Ensure jd-support.php is present directly in that folder.
  3. Configure options in the "j|D Support" section.

Environment notice and content lock

In Settings → j|D Support, enable Environment notice to show a full-screen warning that this environment contains test data. Set Environment notice message to customize the copy, and Live site editor URL for the live site's admin address. Leaving the URL empty hides the Edit live site content buttons.

Users can choose I understand. Continue at my own risk. to dismiss the warning and continue using the admin. A compact reminder stays at the bottom with Edit live site content and Show notice buttons. The acknowledgement lasts for the current browser-tab session and is scoped to the site, user, and message/link revision. Changing the message or URL displays the full warning again. Escape dismisses it for the current page without recording acknowledgement. If browser storage is unavailable, users can still dismiss the warning; it appears again on the next page.

The notice is informational and defaults to off. To allow editing after confirmation, leave Content Edit Lock disabled. The separate Content Edit Lock option retains its existing read-only editor behavior and server-side restrictions on content saves, deletion, publishing, and uploads. Acknowledging the environment notice does not disable that lock. Public pages and AJAX/REST responses do not receive the environment UI.

Select accounts under Users allowed to edit to bypass both the strict lock and the environment notice. Exceptions use site user IDs and do not grant additional WordPress capabilities. An empty selection means no exceptions. Administrators with an @justdev.org email can change the settings, including the exception list.

Development

Adding a new service

// 1. Create service in src/Services/
class NewService
{
    public function __construct(Container $container)
    {
        $this->config = $container->get('config');
    }
    
    public function doSomething()
    {
        // Your logic
    }
}

// 2. Register in Container.php
$this->register('new', NewService::class);

// 3. Use in HookManager.php
$this->addAction('hook_name', [$this->container->get('new'), 'doSomething']);

Adding a new controller

// 1. Create controller in src/Admin/Controllers/
class NewController
{
    public function registerHooks()
    {
        add_action('admin_menu', [$this, 'addMenuPage']);
    }
}

// 2. Add to AdminManager.php
$this->newController = new NewController($this->container);
$this->newController->registerHooks();

Testing

Running tests

composer test

Code checking

composer phpcs    # Code style check
composer phpstan  # Static analysis
composer fix      # Auto-fix style

Migration from old version

Main changes

  1. File structure: Completely redesigned
  2. Namespace: PSR-4 autoloading used
  3. Dependency Injection: Dependency container implemented
  4. Service Layer: Business logic separated into services
  5. Configuration: Centralized settings management

Compatibility

  • All existing settings are preserved
  • Hook API remains compatible
  • Functionality unchanged

Advantages of new architecture

1. Maintainability

  • Clear separation of responsibilities
  • Easy understanding of code structure
  • Simple addition of new features

2. Testability

  • Each component can be tested separately
  • Dependency Injection simplifies mocking
  • Automated tests

3. Extensibility

  • Easy addition of new services
  • Modular architecture
  • Component reuse

4. Performance

  • Loading only necessary classes
  • Optimized dependency container
  • Configuration caching

License

GPL-2.0+

Author

Kyrylo Dorozhynskyi | justDev