Plugin Directory

Changeset 2019336 for classic-editor


Ignore:
Timestamp:
01/25/2019 09:42:32 PM (7 years ago)
Author:
azaozz
Message:

Classic Editor 1.4-beta1

Location:
classic-editor/trunk
Files:
6 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • classic-editor/trunk/LICENSE.md

    r1986885 r2019336  
    11### WordPress - Web publishing software
    22
    3     Copyright 2011-2018 by the contributors
     3    Copyright 2011-2019 by the contributors
    44
    55This program is free software; you can redistribute it and/or modify
  • classic-editor/trunk/classic-editor.php

    r1990537 r2019336  
    66 * Plugin URI:  https://wordpress.org/plugins/classic-editor/
    77 * Description: Enables the WordPress classic editor and the old-style Edit Post screen with TinyMCE, Meta Boxes, etc. Supports the older plugins that extend this screen.
    8  * Version:     1.3
     8 * Version:     1.4-beta1
    99 * Author:      WordPress Contributors
    1010 * Author URI:  https://github.com/WordPress/classic-editor/
     
    1313 * Text Domain: classic-editor
    1414 * Domain Path: /languages
    15  * Network:     true
    1615 *
    1716 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
     
    2928if ( ! class_exists( 'Classic_Editor' ) ) :
    3029class Classic_Editor {
    31     const plugin_version = 1.2;
    3230    private static $settings;
    3331    private static $supported_post_types = array();
     
    5048
    5149        if ( ! $settings['hide-settings-ui'] ) {
    52             // Show the plugin's admin settings, and a link to them in the plugins list table.
     50            // Add a link to the plugin's settings and/or network admin settings in the plugins list table.
    5351            add_filter( 'plugin_action_links', array( __CLASS__, 'add_settings_link' ), 10, 2 );
     52            add_filter( 'network_admin_plugin_action_links', array( __CLASS__, 'add_settings_link' ), 10, 2 );
     53
    5454            add_action( 'admin_init', array( __CLASS__, 'register_settings' ) );
    5555
     
    201201        if ( is_multisite() ) {
    202202            $defaults = array(
    203                 'editor' => 'classic',
     203                'editor' => get_network_option( null, 'classic-editor-replace' ) === 'block' ? 'block' : 'classic',
    204204                'allow-users' => false,
    205205            );
     
    435435
    436436    public static function network_settings() {
    437         $is_checked =  ( get_network_option( null, 'classic-editor-allow-sites' ) === 'allow' );
     437        $editor = get_network_option( null, 'classic-editor-replace' );
     438        $is_checked = ( get_network_option( null, 'classic-editor-allow-sites' ) === 'allow' );
    438439
    439440        ?>
     441        <h2 id="classic-editor-options"><?php _e( 'Editor Settings', 'classic-editor' ); ?></h2>
    440442        <table class="form-table">
     443            <?php wp_nonce_field( 'allow-site-admin-settings', 'classic-editor-network-settings' ); ?>
    441444            <tr>
    442                 <th scope="row"><?php _ex( 'Classic Editor', 'Editor Name', 'classic-editor' ); ?></th>
     445                <th scope="row"><?php _e( 'Default editor for all sites', 'classic-editor' ); ?></th>
    443446                <td>
    444                 <?php wp_nonce_field( 'allow-site-admin-settings', 'classic-editor-network-settings' ); ?>
    445                 <input type="checkbox" name="classic-editor-allow-sites" id="classic-editor-allow-sites" value="allow"<?php if ( $is_checked ) echo ' checked'; ?>>
    446                 <label for="classic-editor-allow-sites"><?php _e( 'Allow site admins to change settings', 'classic-editor' ); ?></label>
    447                 <p class="description"><?php _e( 'By default the Block Editor is replaced with the Classic Editor and users cannot switch editors.', 'classic-editor' ); ?></p>
     447                    <p>
     448                        <input type="radio" name="classic-editor-replace" id="classic-editor-classic" value="classic"<?php if ( $editor !== 'block' ) echo ' checked'; ?> />
     449                        <label for="classic-editor-classic"><?php _ex( 'Classic Editor', 'Editor Name', 'classic-editor' ); ?></label>
     450                    </p>
     451                    <p>
     452                        <input type="radio" name="classic-editor-replace" id="classic-editor-block" value="block"<?php if ( $editor === 'block' ) echo ' checked'; ?> />
     453                        <label for="classic-editor-block"><?php _ex( 'Block Editor', 'Editor Name', 'classic-editor' ); ?></label>
     454                    </p>
     455                </td>
     456            </tr>
     457            <tr>
     458                <th scope="row"><?php _e( 'Change settings', 'classic-editor' ); ?></th>
     459                <td>
     460                    <input type="checkbox" name="classic-editor-allow-sites" id="classic-editor-allow-sites" value="allow"<?php if ( $is_checked ) echo ' checked'; ?>>
     461                    <label for="classic-editor-allow-sites"><?php _e( 'Allow site admins to change settings', 'classic-editor' ); ?></label>
     462                    <p class="description"><?php _e( 'By default the Block Editor is replaced with the Classic Editor and users cannot switch editors.', 'classic-editor' ); ?></p>
    448463                </td>
    449464            </tr>
     
    458473            wp_verify_nonce( $_POST['classic-editor-network-settings'], 'allow-site-admin-settings' )
    459474        ) {
     475            if ( isset( $_POST['classic-editor-replace'] ) && $_POST['classic-editor-replace'] === 'block' ) {
     476                update_network_option( null, 'classic-editor-replace', 'block' );
     477            } else {
     478                update_network_option( null, 'classic-editor-replace', 'classic' );
     479            }
    460480            if ( isset( $_POST['classic-editor-allow-sites'] ) && $_POST['classic-editor-allow-sites'] === 'allow' ) {
    461481                update_network_option( null, 'classic-editor-allow-sites', 'allow' );
     
    473493            $pagenow !== 'about.php' ||
    474494            $settings['hide-settings-ui'] ||
    475             $settings['editor'] === 'block' || 
     495            $settings['editor'] === 'block' ||
    476496            $settings['allow-users'] ||
    477497            ! current_user_can( 'edit_posts' )
     
    486506
    487507        if ( current_user_can( 'manage_options' ) ) {
    488             $message .= ' ' . sprintf( __( 'Change the %1$sClassic Editor settings%2$s.', 'classic-editor' ), '<a href="options-writing.php#classic-editor-options">', '</a>' );
     508            if ( is_network_admin() ) {
     509                $url = 'settings.php#classic-editor-options';
     510            } else {
     511                $url = 'options-writing.php#classic-editor-options';
     512            }
     513
     514            $message .= ' ' . sprintf( __( 'Change the %1$sClassic Editor settings%2$s.', 'classic-editor' ), sprintf( '<a href="%s">', $url ), '</a>' );
    489515        }
    490516
     
    661687            plugins_url( 'js/block-editor-plugin.js', __FILE__ ),
    662688            array( 'wp-element', 'wp-components', 'lodash' ),
    663             self::plugin_version,
     689            '1.4',
    664690            true
    665691        );
     
    679705
    680706        if ( $file === 'classic-editor/classic-editor.php' && ! $settings['hide-settings-ui'] && current_user_can( 'manage_options' ) ) {
    681             (array) $links[] = sprintf( '<a href="%s">%s</a>', admin_url( 'options-writing.php#classic-editor-options' ), __( 'Settings', 'classic-editor' ) );
     707            if ( current_filter() === 'plugin_action_links' ) {
     708                $url = admin_url( 'options-writing.php#classic-editor-options' );
     709            } else {
     710                $url = admin_url( '/network/settings.php#classic-editor-options' );
     711            }
     712
     713            // Prevent warnings in PHP 7.0+ when a plugin uses this filter incorrectly.
     714            $links = (array) $links;
     715            $links[] = sprintf( '<a href="%s">%s</a>', $url, __( 'Settings', 'classic-editor' ) );
    682716        }
    683717
     
    885919    public static function activate() {
    886920        if ( is_multisite() ) {
     921            add_network_option( null, 'classic-editor-replace', 'classic' );
    887922            add_network_option( null, 'classic-editor-allow-sites', 'disallow' );
    888923        }
     
    897932    public static function uninstall() {
    898933        if ( is_multisite() ) {
     934            delete_network_option( null, 'classic-editor-replace' );
    899935            delete_network_option( null, 'classic-editor-allow-sites' );
    900936        }
  • classic-editor/trunk/readme.txt

    r1998246 r2019336  
    2929
    3030== Changelog ==
     31
     32= 1.4 =
     33* On network installations removed the restriction for only network activation.
     34* Added support for network administrators to choose the default network-wide editor.
     35* Fixed the settings link in the warning on network About screen.
    3136
    3237= 1.3 =
     
    8085Initial release.
    8186
     87== Frequently Asked Questions ==
     88
     89= Default settings =
     90
     91When activated this plugin will restore the previous ("classic") WordPress editor and hide the new Block Editor ("Gutenberg").
     92These settings can be changed at the Settings => Writing screen.
     93
     94= Default settings for network installation =
     95
     96There are two options:
     97
     98* When network-activated this plugin will set the Classic Editor as default and prevent site administrators and users from changing editors.
     99The settings can be changed and default network-wide editor can be selected on the Network Settings screen.
     100* When not network-activated each site administrator will be able to activate the plugin and choose options for their users.
     101
    82102== Screenshots ==
    831031. Admin settings on the Settings -> Writing screen.
     
    861064. Link to switch to the Block Editor while editing a post in the Classic Editor. Visible when the users are allowed to switch editors.
    871075. Link to switch to the Classic Editor while editing a post in the Block Editor. Visible when the users are allowed to switch editors.
    88 6. Network setting to allow site admins to change the default options.
     1086. Network settings to select the default editor for the network and allow site admins to change it.
Note: See TracChangeset for help on using the changeset viewer.