Plugin Directory

Changeset 1910026 for classic-editor


Ignore:
Timestamp:
07/16/2018 07:27:40 PM (7 years ago)
Author:
azaozz
Message:

Classic Editor:

  • Update the option text to make it clearer.
  • Remove the Try Gutenberg dashboard widget.
  • Update the screenshots.
  • Add/remove Gutenberg hooks as needed.

Version 0.3.

Location:
classic-editor/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • classic-editor/trunk/classic-editor.php

    r1786604 r1910026  
    66 * Plugin URI:  https://wordpress.org
    77 * Description: Enables the WordPress classic editor and the old-style Edit Post screen layout (TinyMCE, meta boxes, etc.). Supports the older plugins that extend this screen.
    8  * Version:     0.2
     8 * Version:     0.3
    99 * Author:      WordPress Contributors
    1010 * License:     GPL-2.0+
     
    3535 */
    3636function classic_editor_is_gutenberg_active() {
    37     if ( in_array( 'gutenberg/gutenberg.php', (array) get_option( 'active_plugins', array() ) ) ||
     37    if ( in_array( 'gutenberg/gutenberg.php', (array) get_option( 'active_plugins' ) ) ||
    3838        ( is_multisite() && array_key_exists( 'gutenberg/gutenberg.php', (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
    3939
     
    5959        // gutenberg.php
    6060        remove_action( 'admin_menu', 'gutenberg_menu' );
    61         remove_action( 'load-post.php', 'gutenberg_intercept_edit_post' );
    62         remove_action( 'load-post-new.php', 'gutenberg_intercept_post_new' );
    6361        remove_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
    6462        remove_action( 'admin_init', 'gutenberg_redirect_demo' );
    6563
    6664        remove_filter( 'replace_editor', 'gutenberg_init' );
    67 
    68         // lib/blocks.php
    69         remove_filter( 'wp_insert_post_data', 'gutenberg_wpautop_insert_post_data' );
    7065
    7166        // lib/client-assets.php
     
    7671
    7772        // lib/compat.php
    78         remove_action( 'wp_enqueue_scripts', 'gutenberg_ensure_wp_api_request', 20 );
    79         remove_action( 'admin_enqueue_scripts', 'gutenberg_ensure_wp_api_request', 20 );
    80 
    81         remove_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop' );
    8273        remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
    8374
    8475        // lib/register.php
    8576        remove_action( 'plugins_loaded', 'gutenberg_trick_plugins_into_registering_meta_boxes' );
    86         remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
    87         remove_action( 'rest_api_init', 'gutenberg_register_rest_api_post_revisions' );
    8877        remove_action( 'edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts' );
    8978
     
    9180        remove_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );
    9281        remove_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );
     82
     83        // lib/rest-api.php
     84        remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
     85        remove_action( 'rest_api_init', 'gutenberg_add_taxonomy_visibility_field' );
     86
     87        remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result' );
     88        remove_filter( 'registered_post_type', 'gutenberg_register_post_prepare_functions' );
     89        remove_filter( 'registered_taxonomy', 'gutenberg_register_taxonomy_prepare_functions' );
     90        remove_filter( 'rest_index', 'gutenberg_ensure_wp_json_has_theme_supports' );
     91        remove_filter( 'rest_request_before_callbacks', 'gutenberg_handle_early_callback_checks' );
     92        remove_filter( 'rest_user_collection_params', 'gutenberg_filter_user_collection_parameters' );
     93        remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_request_after_callbacks' );
    9394
    9495        // lib/meta-box-partial-page.php
     
    108109        // gutenberg.php
    109110        remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' );
     111        remove_action( 'admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button' );
     112
     113        // lib/register.php
     114        remove_filter( 'display_post_states', 'gutenberg_add_gutenberg_post_state' );
     115
     116        // lib/plugin-compat.php
     117        remove_filter( 'rest_pre_insert_post', 'gutenberg_remove_wpcom_markdown_support' );
     118
     119        // Keep
    110120
    111121        // lib/blocks.php
    112122        // remove_filter( 'the_content', 'do_blocks', 9 );
    113123
    114         // lib/register.php
    115         remove_filter( 'display_post_states', 'gutenberg_add_gutenberg_post_state', 10 );
    116 
    117         // lib/plugin-compat.php
    118         remove_filter( 'rest_pre_insert_post', 'gutenberg_remove_wpcom_markdown_support' );
    119 
    120         // Keep
    121         // remove_filter( 'rest_index', 'gutenberg_ensure_wp_json_has_permalink_structure' );
     124        // Continue to disable wpautop inside TinyMCE for posts that were started in Gutenberg.
     125        // remove_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop' );
     126
     127        // Keep the tweaks to the PHP wpautop.
    122128        // add_filter( 'the_content', 'wpautop' );
    123129        // remove_filter( 'the_content', 'gutenberg_wpautop', 8 );
     130
    124131        // remove_action( 'init', 'gutenberg_register_post_types' );
    125132    } else {
     
    140147    // Gutenberg plugin: remove the "Classic editor" row actions.
    141148    remove_action( 'admin_init', 'gutenberg_add_edit_link_filters' );
     149
     150    // Remove the "Try Gutenberg" dashboard widget.
     151    remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
    142152}
    143153
     
    159169 */
    160170function classic_editor_settings() {
    161     $no_replace = get_option( 'classic-editor-replace' ) === 'no-replace';
     171    $replace = get_option( 'classic-editor-replace' ) !== 'no-replace';
    162172
    163173    ?>
    164     <p id="classic-editor-options" style="margin: 0;"><label>
    165         <input type="checkbox" name="classic-editor-replace" value="no-replace"<?php if ( $no_replace ) echo ' checked'; ?> />
    166         <?php _e( 'Do not replace the editor. Add alternate links to the Posts and Pages screens for editing with the Classic editor.', 'classic-editor' ); ?>
    167     </label></p>
     174    <p id="classic-editor-options" style="margin: 0;">
     175        <input type="radio" name="classic-editor-replace" id="classic-editor-replace" value="replace"<?php if ( $replace ) echo ' checked'; ?> />
     176        <label for="classic-editor-replace">
     177        <?php _e( 'Replace the Gutenberg editor with the Classic editor.', 'classic-editor' ); ?>
     178        </label>
     179        <br>
     180
     181        <input type="radio" name="classic-editor-replace" id="classic-editor-no-replace" value="no-replace"<?php if ( ! $replace ) echo ' checked'; ?> />
     182        <label for="classic-editor-no-replace">
     183        <?php _e( 'Use the Gutenberg editor by default and include optional links back to the Classic editor.', 'classic-editor' ); ?>
     184        </label>
     185    </p>
    168186    <script>
    169187    jQuery( 'document' ).ready( function( $ ) {
    170188        if ( window.location.hash === '#classic-editor-options' ) {
    171             $( '#classic-editor-options' ).closest( 'td' ).css( 'border', '1px solid #aaa' );
     189            $( '#classic-editor-options' ).closest( 'td' ).addClass( 'highlight' );
    172190        }
    173191    } );
     
    334352function classic_editor_activate() {
    335353    if ( ! get_option( 'classic-editor-replace' ) ) {
    336         update_option( 'classic-editor-replace', 'no-replace' );
     354        update_option( 'classic-editor-replace', 'replace' );
    337355    }
    338356}
  • classic-editor/trunk/readme.txt

    r1786604 r1910026  
    2727
    2828== Changelog ==
     29= 0.3 =
     30Updated the option from a checkbox to couple of radio buttons, seems clearer. Thanks to @designsimply for the label text suggestions.
     31Some general updates and cleanup.
     32
    2933= 0.2 =
    3034Update for Gutenberg 1.9.
Note: See TracChangeset for help on using the changeset viewer.