Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/classic-...
File: classic-editor.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Classic Editor
[2] Fix | Delete
*
[3] Fix | Delete
* Plugin Name: Classic Editor
[4] Fix | Delete
* Plugin URI: https://wordpress.org/plugins/classic-editor/
[5] Fix | Delete
* 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.
[6] Fix | Delete
* Version: 1.6.3
[7] Fix | Delete
* Author: WordPress Contributors
[8] Fix | Delete
* Author URI: https://github.com/WordPress/classic-editor/
[9] Fix | Delete
* License: GPLv2 or later
[10] Fix | Delete
* License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[11] Fix | Delete
* Text Domain: classic-editor
[12] Fix | Delete
* Domain Path: /languages
[13] Fix | Delete
* Requires at least: 4.9
[14] Fix | Delete
* Requires PHP: 5.2.4
[15] Fix | Delete
*
[16] Fix | Delete
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
[17] Fix | Delete
* General Public License version 2, as published by the Free Software Foundation. You may NOT assume
[18] Fix | Delete
* that you can use any other version of the GPL.
[19] Fix | Delete
*
[20] Fix | Delete
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
[21] Fix | Delete
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[22] Fix | Delete
*/
[23] Fix | Delete
[24] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[25] Fix | Delete
die( 'Invalid request.' );
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
if ( ! class_exists( 'Classic_Editor' ) ) :
[29] Fix | Delete
class Classic_Editor {
[30] Fix | Delete
private static $settings;
[31] Fix | Delete
private static $supported_post_types = array();
[32] Fix | Delete
[33] Fix | Delete
private function __construct() {}
[34] Fix | Delete
[35] Fix | Delete
public static function init_actions() {
[36] Fix | Delete
$block_editor = has_action( 'enqueue_block_assets' );
[37] Fix | Delete
$gutenberg = function_exists( 'gutenberg_register_scripts_and_styles' );
[38] Fix | Delete
[39] Fix | Delete
register_activation_hook( __FILE__, array( __CLASS__, 'activate' ) );
[40] Fix | Delete
[41] Fix | Delete
$settings = self::get_settings();
[42] Fix | Delete
[43] Fix | Delete
if ( is_multisite() ) {
[44] Fix | Delete
add_action( 'wpmu_options', array( __CLASS__, 'network_settings' ) );
[45] Fix | Delete
add_action( 'update_wpmu_options', array( __CLASS__, 'save_network_settings' ) );
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
if ( ! $settings['hide-settings-ui'] ) {
[49] Fix | Delete
// Add a link to the plugin's settings and/or network admin settings in the plugins list table.
[50] Fix | Delete
add_filter( 'plugin_action_links', array( __CLASS__, 'add_settings_link' ), 10, 2 );
[51] Fix | Delete
add_filter( 'network_admin_plugin_action_links', array( __CLASS__, 'add_settings_link' ), 10, 2 );
[52] Fix | Delete
[53] Fix | Delete
add_action( 'admin_init', array( __CLASS__, 'register_settings' ) );
[54] Fix | Delete
[55] Fix | Delete
if ( $settings['allow-users'] ) {
[56] Fix | Delete
// User settings.
[57] Fix | Delete
add_action( 'personal_options_update', array( __CLASS__, 'save_user_settings' ) );
[58] Fix | Delete
add_action( 'profile_personal_options', array( __CLASS__, 'user_settings' ) );
[59] Fix | Delete
}
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
// Always remove the "Try Gutenberg" dashboard widget. See https://core.trac.wordpress.org/ticket/44635.
[63] Fix | Delete
remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
[64] Fix | Delete
[65] Fix | Delete
if ( ! $block_editor && ! $gutenberg ) {
[66] Fix | Delete
return;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
if ( $settings['allow-users'] ) {
[70] Fix | Delete
// Also used in Gutenberg.
[71] Fix | Delete
add_filter( 'use_block_editor_for_post', array( __CLASS__, 'choose_editor' ), 100, 2 );
[72] Fix | Delete
[73] Fix | Delete
if ( $gutenberg ) {
[74] Fix | Delete
// Support older Gutenberg versions.
[75] Fix | Delete
add_filter( 'gutenberg_can_edit_post', array( __CLASS__, 'choose_editor' ), 100, 2 );
[76] Fix | Delete
[77] Fix | Delete
if ( $settings['editor'] === 'classic' ) {
[78] Fix | Delete
self::remove_gutenberg_hooks( 'some' );
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
add_filter( 'get_edit_post_link', array( __CLASS__, 'get_edit_post_link' ) );
[83] Fix | Delete
add_filter( 'redirect_post_location', array( __CLASS__, 'redirect_location' ) );
[84] Fix | Delete
add_action( 'edit_form_top', array( __CLASS__, 'add_redirect_helper' ) );
[85] Fix | Delete
add_action( 'admin_head-edit.php', array( __CLASS__, 'add_edit_php_inline_style' ) );
[86] Fix | Delete
[87] Fix | Delete
add_action( 'edit_form_top', array( __CLASS__, 'remember_classic_editor' ) );
[88] Fix | Delete
[89] Fix | Delete
if ( version_compare( $GLOBALS['wp_version'], '5.8', '>=' ) ) {
[90] Fix | Delete
add_filter( 'block_editor_settings_all', array( __CLASS__, 'remember_block_editor' ), 10, 2 );
[91] Fix | Delete
} else {
[92] Fix | Delete
add_filter( 'block_editor_settings', array( __CLASS__, 'remember_block_editor' ), 10, 2 );
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
// Post state (edit.php)
[96] Fix | Delete
add_filter( 'display_post_states', array( __CLASS__, 'add_post_state' ), 10, 2 );
[97] Fix | Delete
// Row actions (edit.php)
[98] Fix | Delete
add_filter( 'page_row_actions', array( __CLASS__, 'add_edit_links' ), 15, 2 );
[99] Fix | Delete
add_filter( 'post_row_actions', array( __CLASS__, 'add_edit_links' ), 15, 2 );
[100] Fix | Delete
[101] Fix | Delete
// Switch editors while editing a post
[102] Fix | Delete
add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_box' ), 10, 2 );
[103] Fix | Delete
add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'enqueue_block_editor_scripts' ) );
[104] Fix | Delete
} else {
[105] Fix | Delete
if ( $settings['editor'] === 'classic' ) {
[106] Fix | Delete
// Also used in Gutenberg.
[107] Fix | Delete
// Consider disabling other Block Editor functionality.
[108] Fix | Delete
add_filter( 'use_block_editor_for_post_type', '__return_false', 100 );
[109] Fix | Delete
[110] Fix | Delete
if ( $gutenberg ) {
[111] Fix | Delete
// Support older Gutenberg versions.
[112] Fix | Delete
add_filter( 'gutenberg_can_edit_post_type', '__return_false', 100 );
[113] Fix | Delete
self::remove_gutenberg_hooks();
[114] Fix | Delete
}
[115] Fix | Delete
} else {
[116] Fix | Delete
// $settings['editor'] === 'block', nothing to do :)
[117] Fix | Delete
return;
[118] Fix | Delete
}
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
if ( $block_editor ) {
[122] Fix | Delete
// Move the Privacy Page notice back under the title.
[123] Fix | Delete
add_action( 'admin_init', array( __CLASS__, 'on_admin_init' ) );
[124] Fix | Delete
}
[125] Fix | Delete
if ( $gutenberg ) {
[126] Fix | Delete
// These are handled by this plugin. All are older, not used in 5.3+.
[127] Fix | Delete
remove_action( 'admin_init', 'gutenberg_add_edit_link_filters' );
[128] Fix | Delete
remove_action( 'admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button' );
[129] Fix | Delete
remove_filter( 'redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts' );
[130] Fix | Delete
remove_filter( 'display_post_states', 'gutenberg_add_gutenberg_post_state' );
[131] Fix | Delete
remove_action( 'edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts' );
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
public static function remove_gutenberg_hooks( $remove = 'all' ) {
[136] Fix | Delete
remove_action( 'admin_menu', 'gutenberg_menu' );
[137] Fix | Delete
remove_action( 'admin_init', 'gutenberg_redirect_demo' );
[138] Fix | Delete
[139] Fix | Delete
if ( $remove !== 'all' ) {
[140] Fix | Delete
return;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
// Gutenberg 5.3+
[144] Fix | Delete
remove_action( 'wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles' );
[145] Fix | Delete
remove_action( 'admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles' );
[146] Fix | Delete
remove_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
[147] Fix | Delete
remove_action( 'rest_api_init', 'gutenberg_register_rest_widget_updater_routes' );
[148] Fix | Delete
remove_action( 'admin_print_styles', 'gutenberg_block_editor_admin_print_styles' );
[149] Fix | Delete
remove_action( 'admin_print_scripts', 'gutenberg_block_editor_admin_print_scripts' );
[150] Fix | Delete
remove_action( 'admin_print_footer_scripts', 'gutenberg_block_editor_admin_print_footer_scripts' );
[151] Fix | Delete
remove_action( 'admin_footer', 'gutenberg_block_editor_admin_footer' );
[152] Fix | Delete
remove_action( 'admin_enqueue_scripts', 'gutenberg_widgets_init' );
[153] Fix | Delete
remove_action( 'admin_notices', 'gutenberg_build_files_notice' );
[154] Fix | Delete
[155] Fix | Delete
remove_filter( 'load_script_translation_file', 'gutenberg_override_translation_file' );
[156] Fix | Delete
remove_filter( 'block_editor_settings', 'gutenberg_extend_block_editor_styles' );
[157] Fix | Delete
remove_filter( 'default_content', 'gutenberg_default_demo_content' );
[158] Fix | Delete
remove_filter( 'default_title', 'gutenberg_default_demo_title' );
[159] Fix | Delete
remove_filter( 'block_editor_settings', 'gutenberg_legacy_widget_settings' );
[160] Fix | Delete
remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result' );
[161] Fix | Delete
[162] Fix | Delete
// Previously used, compat for older Gutenberg versions.
[163] Fix | Delete
remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
[164] Fix | Delete
remove_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );
[165] Fix | Delete
remove_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );
[166] Fix | Delete
[167] Fix | Delete
remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
[168] Fix | Delete
remove_action( 'rest_api_init', 'gutenberg_add_taxonomy_visibility_field' );
[169] Fix | Delete
remove_filter( 'registered_post_type', 'gutenberg_register_post_prepare_functions' );
[170] Fix | Delete
[171] Fix | Delete
remove_action( 'do_meta_boxes', 'gutenberg_meta_box_save' );
[172] Fix | Delete
remove_action( 'submitpost_box', 'gutenberg_intercept_meta_box_render' );
[173] Fix | Delete
remove_action( 'submitpage_box', 'gutenberg_intercept_meta_box_render' );
[174] Fix | Delete
remove_action( 'edit_page_form', 'gutenberg_intercept_meta_box_render' );
[175] Fix | Delete
remove_action( 'edit_form_advanced', 'gutenberg_intercept_meta_box_render' );
[176] Fix | Delete
remove_filter( 'redirect_post_location', 'gutenberg_meta_box_save_redirect' );
[177] Fix | Delete
remove_filter( 'filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes' );
[178] Fix | Delete
[179] Fix | Delete
remove_filter( 'body_class', 'gutenberg_add_responsive_body_class' );
[180] Fix | Delete
remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' ); // old
[181] Fix | Delete
remove_action( 'admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks' );
[182] Fix | Delete
remove_filter( 'register_post_type_args', 'gutenberg_filter_post_type_labels' );
[183] Fix | Delete
[184] Fix | Delete
// phpcs:disable Squiz.PHP.CommentedOutCode.Found
[185] Fix | Delete
// Keep
[186] Fix | Delete
// remove_filter( 'wp_kses_allowed_html', 'gutenberg_kses_allowedtags', 10, 2 ); // not needed in 5.0
[187] Fix | Delete
// remove_filter( 'bulk_actions-edit-wp_block', 'gutenberg_block_bulk_actions' );
[188] Fix | Delete
// remove_filter( 'wp_insert_post_data', 'gutenberg_remove_wpcom_markdown_support' );
[189] Fix | Delete
// remove_filter( 'the_content', 'do_blocks', 9 );
[190] Fix | Delete
// remove_action( 'init', 'gutenberg_register_post_types' );
[191] Fix | Delete
[192] Fix | Delete
// Continue to manage wpautop for posts that were edited in Gutenberg.
[193] Fix | Delete
// remove_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop' );
[194] Fix | Delete
// remove_filter( 'the_content', 'gutenberg_wpautop', 8 );
[195] Fix | Delete
// phpcs:enable Squiz.PHP.CommentedOutCode.Found
[196] Fix | Delete
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
private static function get_settings( $refresh = 'no' ) {
[200] Fix | Delete
/**
[201] Fix | Delete
* Can be used to override the plugin's settings. Always hides the settings UI when used (as users cannot change the settings).
[202] Fix | Delete
*
[203] Fix | Delete
* Has to return an associative array with two keys.
[204] Fix | Delete
* The defaults are:
[205] Fix | Delete
* 'editor' => 'classic', // Accepted values: 'classic', 'block'.
[206] Fix | Delete
* 'allow-users' => false,
[207] Fix | Delete
*
[208] Fix | Delete
* @param boolean To override the settings return an array with the above keys.
[209] Fix | Delete
*/
[210] Fix | Delete
$settings = apply_filters( 'classic_editor_plugin_settings', false );
[211] Fix | Delete
[212] Fix | Delete
if ( is_array( $settings ) ) {
[213] Fix | Delete
return array(
[214] Fix | Delete
'editor' => ( isset( $settings['editor'] ) && $settings['editor'] === 'block' ) ? 'block' : 'classic',
[215] Fix | Delete
'allow-users' => ! empty( $settings['allow-users'] ),
[216] Fix | Delete
'hide-settings-ui' => true,
[217] Fix | Delete
);
[218] Fix | Delete
}
[219] Fix | Delete
[220] Fix | Delete
if ( ! empty( self::$settings ) && $refresh === 'no' ) {
[221] Fix | Delete
return self::$settings;
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
if ( is_multisite() ) {
[225] Fix | Delete
$defaults = array(
[226] Fix | Delete
'editor' => get_network_option( null, 'classic-editor-replace' ) === 'block' ? 'block' : 'classic',
[227] Fix | Delete
'allow-users' => false,
[228] Fix | Delete
);
[229] Fix | Delete
[230] Fix | Delete
/**
[231] Fix | Delete
* Filters the default network options.
[232] Fix | Delete
*
[233] Fix | Delete
* @param array $defaults The default options array. See `classic_editor_plugin_settings` for supported keys and values.
[234] Fix | Delete
*/
[235] Fix | Delete
$defaults = apply_filters( 'classic_editor_network_default_settings', $defaults );
[236] Fix | Delete
[237] Fix | Delete
if ( get_network_option( null, 'classic-editor-allow-sites' ) !== 'allow' ) {
[238] Fix | Delete
// Per-site settings are disabled. Return default network options nad hide the settings UI.
[239] Fix | Delete
$defaults['hide-settings-ui'] = true;
[240] Fix | Delete
return $defaults;
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
// Override with the site options.
[244] Fix | Delete
$editor_option = get_option( 'classic-editor-replace' );
[245] Fix | Delete
$allow_users_option = get_option( 'classic-editor-allow-users' );
[246] Fix | Delete
[247] Fix | Delete
if ( $editor_option ) {
[248] Fix | Delete
$defaults['editor'] = $editor_option;
[249] Fix | Delete
}
[250] Fix | Delete
if ( $allow_users_option ) {
[251] Fix | Delete
$defaults['allow-users'] = ( $allow_users_option === 'allow' );
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
$editor = ( isset( $defaults['editor'] ) && $defaults['editor'] === 'block' ) ? 'block' : 'classic';
[255] Fix | Delete
$allow_users = ! empty( $defaults['allow-users'] );
[256] Fix | Delete
} else {
[257] Fix | Delete
$allow_users = ( get_option( 'classic-editor-allow-users' ) === 'allow' );
[258] Fix | Delete
$option = get_option( 'classic-editor-replace' );
[259] Fix | Delete
[260] Fix | Delete
// Normalize old options.
[261] Fix | Delete
if ( $option === 'block' || $option === 'no-replace' ) {
[262] Fix | Delete
$editor = 'block';
[263] Fix | Delete
} else {
[264] Fix | Delete
// empty( $option ) || $option === 'classic' || $option === 'replace'
[265] Fix | Delete
$editor = 'classic';
[266] Fix | Delete
}
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
// Override the defaults with the user options.
[270] Fix | Delete
if ( ( ! isset( $GLOBALS['pagenow'] ) || $GLOBALS['pagenow'] !== 'options-writing.php' ) && $allow_users ) {
[271] Fix | Delete
$user_options = get_user_option( 'classic-editor-settings' );
[272] Fix | Delete
[273] Fix | Delete
if ( $user_options === 'block' || $user_options === 'classic' ) {
[274] Fix | Delete
$editor = $user_options;
[275] Fix | Delete
}
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
self::$settings = array(
[279] Fix | Delete
'editor' => $editor,
[280] Fix | Delete
'hide-settings-ui' => false,
[281] Fix | Delete
'allow-users' => $allow_users,
[282] Fix | Delete
);
[283] Fix | Delete
[284] Fix | Delete
return self::$settings;
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
private static function is_classic( $post_id = 0 ) {
[288] Fix | Delete
if ( ! $post_id ) {
[289] Fix | Delete
$post_id = self::get_edited_post_id();
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
if ( $post_id ) {
[293] Fix | Delete
$settings = self::get_settings();
[294] Fix | Delete
[295] Fix | Delete
if ( $settings['allow-users'] && ! isset( $_GET['classic-editor__forget'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[296] Fix | Delete
$which = get_post_meta( $post_id, 'classic-editor-remember', true );
[297] Fix | Delete
[298] Fix | Delete
if ( $which ) {
[299] Fix | Delete
// The editor choice will be "remembered" when the post is opened in either the classic or the block editor.
[300] Fix | Delete
if ( 'classic-editor' === $which ) {
[301] Fix | Delete
return true;
[302] Fix | Delete
} elseif ( 'block-editor' === $which ) {
[303] Fix | Delete
return false;
[304] Fix | Delete
}
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
return ( ! self::has_blocks( $post_id ) );
[308] Fix | Delete
}
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
if ( isset( $_GET['classic-editor'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[312] Fix | Delete
return true;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
return false;
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
/**
[319] Fix | Delete
* Get the edited post ID (early) when loading the Edit Post screen.
[320] Fix | Delete
*/
[321] Fix | Delete
private static function get_edited_post_id() {
[322] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended
[323] Fix | Delete
if (
[324] Fix | Delete
! empty( $_GET['post'] ) &&
[325] Fix | Delete
! empty( $_GET['action'] ) &&
[326] Fix | Delete
$_GET['action'] === 'edit' &&
[327] Fix | Delete
! empty( $GLOBALS['pagenow'] ) &&
[328] Fix | Delete
$GLOBALS['pagenow'] === 'post.php'
[329] Fix | Delete
) {
[330] Fix | Delete
return (int) $_GET['post']; // post_ID
[331] Fix | Delete
}
[332] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification.Recommended
[333] Fix | Delete
[334] Fix | Delete
return 0;
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
public static function register_settings() {
[338] Fix | Delete
// Add an option to Settings -> Writing
[339] Fix | Delete
register_setting( 'writing', 'classic-editor-replace', array(
[340] Fix | Delete
'sanitize_callback' => array( __CLASS__, 'validate_option_editor' ),
[341] Fix | Delete
) );
[342] Fix | Delete
[343] Fix | Delete
register_setting( 'writing', 'classic-editor-allow-users', array(
[344] Fix | Delete
'sanitize_callback' => array( __CLASS__, 'validate_option_allow_users' ),
[345] Fix | Delete
) );
[346] Fix | Delete
[347] Fix | Delete
$allowed_options = array(
[348] Fix | Delete
'writing' => array(
[349] Fix | Delete
'classic-editor-replace',
[350] Fix | Delete
'classic-editor-allow-users'
[351] Fix | Delete
),
[352] Fix | Delete
);
[353] Fix | Delete
[354] Fix | Delete
if ( function_exists( 'add_allowed_options' ) ) {
[355] Fix | Delete
add_allowed_options( $allowed_options );
[356] Fix | Delete
} else {
[357] Fix | Delete
add_option_whitelist( $allowed_options );
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
$heading_1 = __( 'Default editor for all users', 'classic-editor' );
[361] Fix | Delete
$heading_2 = __( 'Allow users to switch editors', 'classic-editor' );
[362] Fix | Delete
[363] Fix | Delete
add_settings_field( 'classic-editor-1', $heading_1, array( __CLASS__, 'settings_1' ), 'writing' );
[364] Fix | Delete
add_settings_field( 'classic-editor-2', $heading_2, array( __CLASS__, 'settings_2' ), 'writing' );
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
public static function save_user_settings( $user_id ) {
[368] Fix | Delete
if (
[369] Fix | Delete
isset( $_POST['classic-editor-user-settings'] ) &&
[370] Fix | Delete
isset( $_POST['classic-editor-replace'] ) &&
[371] Fix | Delete
wp_verify_nonce( $_POST['classic-editor-user-settings'], 'allow-user-settings' ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[372] Fix | Delete
) {
[373] Fix | Delete
$user_id = (int) $user_id;
[374] Fix | Delete
[375] Fix | Delete
if ( $user_id !== get_current_user_id() && ! current_user_can( 'edit_user', $user_id ) ) {
[376] Fix | Delete
return;
[377] Fix | Delete
}
[378] Fix | Delete
[379] Fix | Delete
$editor = self::validate_option_editor( $_POST['classic-editor-replace'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[380] Fix | Delete
update_user_option( $user_id, 'classic-editor-settings', $editor );
[381] Fix | Delete
}
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
/**
[385] Fix | Delete
* Validate
[386] Fix | Delete
*/
[387] Fix | Delete
public static function validate_option_editor( $value ) {
[388] Fix | Delete
if ( $value === 'block' ) {
[389] Fix | Delete
return 'block';
[390] Fix | Delete
}
[391] Fix | Delete
[392] Fix | Delete
return 'classic';
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
public static function validate_option_allow_users( $value ) {
[396] Fix | Delete
if ( $value === 'allow' ) {
[397] Fix | Delete
return 'allow';
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
return 'disallow';
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
public static function settings_1() {
[404] Fix | Delete
$settings = self::get_settings( 'refresh' );
[405] Fix | Delete
[406] Fix | Delete
?>
[407] Fix | Delete
<div class="classic-editor-options">
[408] Fix | Delete
<p>
[409] Fix | Delete
<input type="radio" name="classic-editor-replace" id="classic-editor-classic" value="classic"<?php if ( $settings['editor'] === 'classic' ) echo ' checked'; ?> />
[410] Fix | Delete
<label for="classic-editor-classic"><?php _ex( 'Classic editor', 'Editor Name', 'classic-editor' ); ?></label>
[411] Fix | Delete
</p>
[412] Fix | Delete
<p>
[413] Fix | Delete
<input type="radio" name="classic-editor-replace" id="classic-editor-block" value="block"<?php if ( $settings['editor'] !== 'classic' ) echo ' checked'; ?> />
[414] Fix | Delete
<label for="classic-editor-block"><?php _ex( 'Block editor', 'Editor Name', 'classic-editor' ); ?></label>
[415] Fix | Delete
</p>
[416] Fix | Delete
</div>
[417] Fix | Delete
<script>
[418] Fix | Delete
jQuery( 'document' ).ready( function( $ ) {
[419] Fix | Delete
if ( window.location.hash === '#classic-editor-options' ) {
[420] Fix | Delete
$( '.classic-editor-options' ).closest( 'td' ).addClass( 'highlight' );
[421] Fix | Delete
}
[422] Fix | Delete
} );
[423] Fix | Delete
</script>
[424] Fix | Delete
<?php
[425] Fix | Delete
}
[426] Fix | Delete
[427] Fix | Delete
public static function settings_2() {
[428] Fix | Delete
$settings = self::get_settings( 'refresh' );
[429] Fix | Delete
[430] Fix | Delete
?>
[431] Fix | Delete
<div class="classic-editor-options">
[432] Fix | Delete
<p>
[433] Fix | Delete
<input type="radio" name="classic-editor-allow-users" id="classic-editor-allow" value="allow"<?php if ( $settings['allow-users'] ) echo ' checked'; ?> />
[434] Fix | Delete
<label for="classic-editor-allow"><?php _e( 'Yes', 'classic-editor' ); ?></label>
[435] Fix | Delete
</p>
[436] Fix | Delete
<p>
[437] Fix | Delete
<input type="radio" name="classic-editor-allow-users" id="classic-editor-disallow" value="disallow"<?php if ( ! $settings['allow-users'] ) echo ' checked'; ?> />
[438] Fix | Delete
<label for="classic-editor-disallow"><?php _e( 'No', 'classic-editor' ); ?></label>
[439] Fix | Delete
</p>
[440] Fix | Delete
</div>
[441] Fix | Delete
<?php
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
/**
[445] Fix | Delete
* Shown on the Profile page when allowed by admin.
[446] Fix | Delete
*/
[447] Fix | Delete
public static function user_settings() {
[448] Fix | Delete
global $user_can_edit;
[449] Fix | Delete
$settings = self::get_settings( 'update' );
[450] Fix | Delete
[451] Fix | Delete
if (
[452] Fix | Delete
! defined( 'IS_PROFILE_PAGE' ) ||
[453] Fix | Delete
! IS_PROFILE_PAGE ||
[454] Fix | Delete
! $user_can_edit ||
[455] Fix | Delete
! $settings['allow-users']
[456] Fix | Delete
) {
[457] Fix | Delete
return;
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
?>
[461] Fix | Delete
<table class="form-table">
[462] Fix | Delete
<tr class="classic-editor-user-options">
[463] Fix | Delete
<th scope="row"><?php _e( 'Default Editor', 'classic-editor' ); ?></th>
[464] Fix | Delete
<td>
[465] Fix | Delete
<?php wp_nonce_field( 'allow-user-settings', 'classic-editor-user-settings' ); ?>
[466] Fix | Delete
<?php self::settings_1(); ?>
[467] Fix | Delete
</td>
[468] Fix | Delete
</tr>
[469] Fix | Delete
</table>
[470] Fix | Delete
<script>jQuery( 'tr.user-rich-editing-wrap' ).before( jQuery( 'tr.classic-editor-user-options' ) );</script>
[471] Fix | Delete
<?php
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
public static function network_settings() {
[475] Fix | Delete
$editor = get_network_option( null, 'classic-editor-replace' );
[476] Fix | Delete
$is_checked = ( get_network_option( null, 'classic-editor-allow-sites' ) === 'allow' );
[477] Fix | Delete
[478] Fix | Delete
?>
[479] Fix | Delete
<h2 id="classic-editor-options"><?php _e( 'Editor Settings', 'classic-editor' ); ?></h2>
[480] Fix | Delete
<table class="form-table">
[481] Fix | Delete
<?php wp_nonce_field( 'allow-site-admin-settings', 'classic-editor-network-settings' ); ?>
[482] Fix | Delete
<tr>
[483] Fix | Delete
<th scope="row"><?php _e( 'Default editor for all sites', 'classic-editor' ); ?></th>
[484] Fix | Delete
<td>
[485] Fix | Delete
<p>
[486] Fix | Delete
<input type="radio" name="classic-editor-replace" id="classic-editor-classic" value="classic"<?php if ( $editor !== 'block' ) echo ' checked'; ?> />
[487] Fix | Delete
<label for="classic-editor-classic"><?php _ex( 'Classic Editor', 'Editor Name', 'classic-editor' ); ?></label>
[488] Fix | Delete
</p>
[489] Fix | Delete
<p>
[490] Fix | Delete
<input type="radio" name="classic-editor-replace" id="classic-editor-block" value="block"<?php if ( $editor === 'block' ) echo ' checked'; ?> />
[491] Fix | Delete
<label for="classic-editor-block"><?php _ex( 'Block editor', 'Editor Name', 'classic-editor' ); ?></label>
[492] Fix | Delete
</p>
[493] Fix | Delete
</td>
[494] Fix | Delete
</tr>
[495] Fix | Delete
<tr>
[496] Fix | Delete
<th scope="row"><?php _e( 'Change settings', 'classic-editor' ); ?></th>
[497] Fix | Delete
<td>
[498] Fix | Delete
<input type="checkbox" name="classic-editor-allow-sites" id="classic-editor-allow-sites" value="allow"<?php if ( $is_checked ) echo ' checked'; ?>>
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function