PHP code example of dartmoon / wordpress-disable-editor

1. Go to this page and download the library: Download dartmoon/wordpress-disable-editor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dartmoon / wordpress-disable-editor example snippets


add_filter('drtn/disable_gutenberg', function ($can_edit, $post_id, $post_type) {
    /**
     * Post types for which to enable Gutenberg
     */
    if ($post_type == 'post') {
        return true;
    }

    /**
     * Templates for which we need to disable Gutemberg
     */
    $excludedTemplates = [
        // 
    ];

    /**
     * Specific Post IDs for which we need to disable Gutenberg
     */
    $excludedIds = [
        //
    ];

    // Retrieve the template of the current post id
    $template = basename(get_page_template());
    return !(in_array($post_id, $excludedIds) || in_array($template, $excludedTemplates));
}, 10, 3);

add_filter('drtn/disable_editor', function ($can_edit, $post_id, $post_type) {
    /**
     * Post types for which to enable the classic editor
     */
    if ($post_type == 'post') {
        return true;
    }

    /**
     * Templates for which we need to disable the classic editor
     */
    $excludedTemplates = [
        // 
    ];

    /**
     * Specific Post IDs for which we need to disable the classic editor
     */
    $excludedIds = [
        //
    ];

    // Retrieve the template of the current post id
    $template = basename(get_page_template());
    return !(in_array($post_id, $excludedIds) || in_array($template, $excludedTemplates));
}, 10, 3);