offsetwp/editor-support

1.0.0 2025-03-26 23:25 UTC

This package is not auto-updated.

Last update: 2025-05-08 22:23:29 UTC


README

OffsetWP Editor Support OffsetWP Editor Support

OffsetWP Editor Support

A library to manage WordPress editor types and features

Installation

composer require offsetwp/editor-support

Usage

Basic

use OffsetWP\EditorSupport\EditorSupportManager;

$editor = EditorSupportManager::from_post_type( 'page' );
$editor
    ->set_classic_editor()
    ->remove_comments();

API

Selector

$editor = EditorSupportManager::from_post_type( 'page' ); // With post type
$editor = EditorSupportManager::from_post_id( 42 ); // With post ID
$editor = EditorSupportManager::from_template( 'template/contact.php' ); // With template name

Primary editor type

$editor->set_gutenberg_editor(); // Gutenberg
$editor->set_classic_editor(); // Classic Editor
$editor->set_empty_editor(); // No editor

⚠ If you wish to disable Gutenberg entirely, we recommend using the Classic Editor plugin.

Add editor features

$editor
    ->add_title()
    ->add_editor()
    ->add_author()
    ->add_thumbnail()
    ->add_excerpt()
    ->add_trackbacks()
    ->add_custom_fields()
    ->add_comments()
    ->add_revisions()
    ->add_page_attributes()
    ->add_post_formats();

Add custom feature

$editor->add_support( 'my-custom-feature' );

Add all features

$editor
    ->add_all() // Add all features
    ->add_all( array( 'content', 'thumbnail' ) ); // Add all features without specific ones

Remove editor features

$editor
    ->remove_title()
    ->remove_editor()
    ->remove_author()
    ->remove_thumbnail()
    ->remove_excerpt()
    ->remove_trackbacks()
    ->remove_custom_fields()
    ->remove_comments()
    ->remove_revisions()
    ->remove_page_attributes()
    ->remove_post_formats();

Remove custom feature

$editor->remove_support( 'my-custom-feature' );

Remove all features

$editor
    ->remove_all() // Remove all features
    ->remove_all( array( 'content', 'thumbnail' ) ); // Remove all features without specific ones