Edit File by line
/home/barbar84/public_h.../wp-conte.../themes/twentytw...
File: functions.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Twenty Twenty functions and definitions
[2] Fix | Delete
*
[3] Fix | Delete
* @link https://developer.wordpress.org/themes/basics/theme-functions/
[4] Fix | Delete
*
[5] Fix | Delete
* @package WordPress
[6] Fix | Delete
* @subpackage Twenty_Twenty
[7] Fix | Delete
* @since Twenty Twenty 1.0
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Table of Contents:
[12] Fix | Delete
* Theme Support
[13] Fix | Delete
* Required Files
[14] Fix | Delete
* Register Styles
[15] Fix | Delete
* Register Scripts
[16] Fix | Delete
* Register Menus
[17] Fix | Delete
* Custom Logo
[18] Fix | Delete
* WP Body Open
[19] Fix | Delete
* Register Sidebars
[20] Fix | Delete
* Enqueue Block Editor Assets
[21] Fix | Delete
* Enqueue Classic Editor Styles
[22] Fix | Delete
* Block Editor Settings
[23] Fix | Delete
*/
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Sets up theme defaults and registers support for various WordPress features.
[27] Fix | Delete
*
[28] Fix | Delete
* Note that this function is hooked into the after_setup_theme hook, which
[29] Fix | Delete
* runs before the init hook. The init hook is too late for some features, such
[30] Fix | Delete
* as indicating support for post thumbnails.
[31] Fix | Delete
*/
[32] Fix | Delete
function twentytwenty_theme_support() {
[33] Fix | Delete
[34] Fix | Delete
// Add default posts and comments RSS feed links to head.
[35] Fix | Delete
add_theme_support( 'automatic-feed-links' );
[36] Fix | Delete
[37] Fix | Delete
// Custom background color.
[38] Fix | Delete
add_theme_support(
[39] Fix | Delete
'custom-background',
[40] Fix | Delete
array(
[41] Fix | Delete
'default-color' => 'f5efe0',
[42] Fix | Delete
)
[43] Fix | Delete
);
[44] Fix | Delete
[45] Fix | Delete
// Set content-width.
[46] Fix | Delete
global $content_width;
[47] Fix | Delete
if ( ! isset( $content_width ) ) {
[48] Fix | Delete
$content_width = 580;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
/*
[52] Fix | Delete
* Enable support for Post Thumbnails on posts and pages.
[53] Fix | Delete
*
[54] Fix | Delete
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
[55] Fix | Delete
*/
[56] Fix | Delete
add_theme_support( 'post-thumbnails' );
[57] Fix | Delete
[58] Fix | Delete
// Set post thumbnail size.
[59] Fix | Delete
set_post_thumbnail_size( 1200, 9999 );
[60] Fix | Delete
[61] Fix | Delete
// Add custom image size used in Cover Template.
[62] Fix | Delete
add_image_size( 'twentytwenty-fullscreen', 1980, 9999 );
[63] Fix | Delete
[64] Fix | Delete
// Custom logo.
[65] Fix | Delete
$logo_width = 120;
[66] Fix | Delete
$logo_height = 90;
[67] Fix | Delete
[68] Fix | Delete
// If the retina setting is active, double the recommended width and height.
[69] Fix | Delete
if ( get_theme_mod( 'retina_logo', false ) ) {
[70] Fix | Delete
$logo_width = floor( $logo_width * 2 );
[71] Fix | Delete
$logo_height = floor( $logo_height * 2 );
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
add_theme_support(
[75] Fix | Delete
'custom-logo',
[76] Fix | Delete
array(
[77] Fix | Delete
'height' => $logo_height,
[78] Fix | Delete
'width' => $logo_width,
[79] Fix | Delete
'flex-height' => true,
[80] Fix | Delete
'flex-width' => true,
[81] Fix | Delete
)
[82] Fix | Delete
);
[83] Fix | Delete
[84] Fix | Delete
/*
[85] Fix | Delete
* Let WordPress manage the document title.
[86] Fix | Delete
* By adding theme support, we declare that this theme does not use a
[87] Fix | Delete
* hard-coded <title> tag in the document head, and expect WordPress to
[88] Fix | Delete
* provide it for us.
[89] Fix | Delete
*/
[90] Fix | Delete
add_theme_support( 'title-tag' );
[91] Fix | Delete
[92] Fix | Delete
/*
[93] Fix | Delete
* Switch default core markup for search form, comment form, and comments
[94] Fix | Delete
* to output valid HTML5.
[95] Fix | Delete
*/
[96] Fix | Delete
add_theme_support(
[97] Fix | Delete
'html5',
[98] Fix | Delete
array(
[99] Fix | Delete
'search-form',
[100] Fix | Delete
'comment-form',
[101] Fix | Delete
'comment-list',
[102] Fix | Delete
'gallery',
[103] Fix | Delete
'caption',
[104] Fix | Delete
'script',
[105] Fix | Delete
'style',
[106] Fix | Delete
'navigation-widgets',
[107] Fix | Delete
)
[108] Fix | Delete
);
[109] Fix | Delete
[110] Fix | Delete
/*
[111] Fix | Delete
* Make theme available for translation.
[112] Fix | Delete
* Translations can be filed in the /languages/ directory.
[113] Fix | Delete
* If you're building a theme based on Twenty Twenty, use a find and replace
[114] Fix | Delete
* to change 'twentytwenty' to the name of your theme in all the template files.
[115] Fix | Delete
*/
[116] Fix | Delete
load_theme_textdomain( 'twentytwenty' );
[117] Fix | Delete
[118] Fix | Delete
// Add support for full and wide align images.
[119] Fix | Delete
add_theme_support( 'align-wide' );
[120] Fix | Delete
[121] Fix | Delete
// Add support for responsive embeds.
[122] Fix | Delete
add_theme_support( 'responsive-embeds' );
[123] Fix | Delete
[124] Fix | Delete
/*
[125] Fix | Delete
* Adds starter content to highlight the theme on fresh sites.
[126] Fix | Delete
* This is done conditionally to avoid loading the starter content on every
[127] Fix | Delete
* page load, as it is a one-off operation only needed once in the customizer.
[128] Fix | Delete
*/
[129] Fix | Delete
if ( is_customize_preview() ) {
[130] Fix | Delete
require get_template_directory() . '/inc/starter-content.php';
[131] Fix | Delete
add_theme_support( 'starter-content', twentytwenty_get_starter_content() );
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
// Add theme support for selective refresh for widgets.
[135] Fix | Delete
add_theme_support( 'customize-selective-refresh-widgets' );
[136] Fix | Delete
[137] Fix | Delete
/*
[138] Fix | Delete
* Adds `async` and `defer` support for scripts registered or enqueued
[139] Fix | Delete
* by the theme.
[140] Fix | Delete
*/
[141] Fix | Delete
$loader = new TwentyTwenty_Script_Loader();
[142] Fix | Delete
add_filter( 'script_loader_tag', array( $loader, 'filter_script_loader_tag' ), 10, 2 );
[143] Fix | Delete
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
add_action( 'after_setup_theme', 'twentytwenty_theme_support' );
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* REQUIRED FILES
[150] Fix | Delete
* Include required files.
[151] Fix | Delete
*/
[152] Fix | Delete
require get_template_directory() . '/inc/template-tags.php';
[153] Fix | Delete
[154] Fix | Delete
// Handle SVG icons.
[155] Fix | Delete
require get_template_directory() . '/classes/class-twentytwenty-svg-icons.php';
[156] Fix | Delete
require get_template_directory() . '/inc/svg-icons.php';
[157] Fix | Delete
[158] Fix | Delete
// Handle Customizer settings.
[159] Fix | Delete
require get_template_directory() . '/classes/class-twentytwenty-customize.php';
[160] Fix | Delete
[161] Fix | Delete
// Require Separator Control class.
[162] Fix | Delete
require get_template_directory() . '/classes/class-twentytwenty-separator-control.php';
[163] Fix | Delete
[164] Fix | Delete
// Custom comment walker.
[165] Fix | Delete
require get_template_directory() . '/classes/class-twentytwenty-walker-comment.php';
[166] Fix | Delete
[167] Fix | Delete
// Custom page walker.
[168] Fix | Delete
require get_template_directory() . '/classes/class-twentytwenty-walker-page.php';
[169] Fix | Delete
[170] Fix | Delete
// Custom script loader class.
[171] Fix | Delete
require get_template_directory() . '/classes/class-twentytwenty-script-loader.php';
[172] Fix | Delete
[173] Fix | Delete
// Non-latin language handling.
[174] Fix | Delete
require get_template_directory() . '/classes/class-twentytwenty-non-latin-languages.php';
[175] Fix | Delete
[176] Fix | Delete
// Custom CSS.
[177] Fix | Delete
require get_template_directory() . '/inc/custom-css.php';
[178] Fix | Delete
[179] Fix | Delete
// Block Patterns.
[180] Fix | Delete
require get_template_directory() . '/inc/block-patterns.php';
[181] Fix | Delete
[182] Fix | Delete
/**
[183] Fix | Delete
* Register and Enqueue Styles.
[184] Fix | Delete
*/
[185] Fix | Delete
function twentytwenty_register_styles() {
[186] Fix | Delete
[187] Fix | Delete
$theme_version = wp_get_theme()->get( 'Version' );
[188] Fix | Delete
[189] Fix | Delete
wp_enqueue_style( 'twentytwenty-style', get_stylesheet_uri(), array(), $theme_version );
[190] Fix | Delete
wp_style_add_data( 'twentytwenty-style', 'rtl', 'replace' );
[191] Fix | Delete
[192] Fix | Delete
// Add output of Customizer settings as inline style.
[193] Fix | Delete
wp_add_inline_style( 'twentytwenty-style', twentytwenty_get_customizer_css( 'front-end' ) );
[194] Fix | Delete
[195] Fix | Delete
// Add print CSS.
[196] Fix | Delete
wp_enqueue_style( 'twentytwenty-print-style', get_template_directory_uri() . '/print.css', null, $theme_version, 'print' );
[197] Fix | Delete
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
add_action( 'wp_enqueue_scripts', 'twentytwenty_register_styles' );
[201] Fix | Delete
[202] Fix | Delete
/**
[203] Fix | Delete
* Register and Enqueue Scripts.
[204] Fix | Delete
*/
[205] Fix | Delete
function twentytwenty_register_scripts() {
[206] Fix | Delete
[207] Fix | Delete
$theme_version = wp_get_theme()->get( 'Version' );
[208] Fix | Delete
[209] Fix | Delete
if ( ( ! is_admin() ) && is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
[210] Fix | Delete
wp_enqueue_script( 'comment-reply' );
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
wp_enqueue_script( 'twentytwenty-js', get_template_directory_uri() . '/assets/js/index.js', array(), $theme_version, false );
[214] Fix | Delete
wp_script_add_data( 'twentytwenty-js', 'async', true );
[215] Fix | Delete
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
add_action( 'wp_enqueue_scripts', 'twentytwenty_register_scripts' );
[219] Fix | Delete
[220] Fix | Delete
/**
[221] Fix | Delete
* Fix skip link focus in IE11.
[222] Fix | Delete
*
[223] Fix | Delete
* This does not enqueue the script because it is tiny and because it is only for IE11,
[224] Fix | Delete
* thus it does not warrant having an entire dedicated blocking script being loaded.
[225] Fix | Delete
*
[226] Fix | Delete
* @link https://git.io/vWdr2
[227] Fix | Delete
*/
[228] Fix | Delete
function twentytwenty_skip_link_focus_fix() {
[229] Fix | Delete
// The following is minified via `terser --compress --mangle -- assets/js/skip-link-focus-fix.js`.
[230] Fix | Delete
?>
[231] Fix | Delete
<script>
[232] Fix | Delete
/(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);
[233] Fix | Delete
</script>
[234] Fix | Delete
<?php
[235] Fix | Delete
}
[236] Fix | Delete
add_action( 'wp_print_footer_scripts', 'twentytwenty_skip_link_focus_fix' );
[237] Fix | Delete
[238] Fix | Delete
/** Enqueue non-latin language styles
[239] Fix | Delete
*
[240] Fix | Delete
* @since Twenty Twenty 1.0
[241] Fix | Delete
*
[242] Fix | Delete
* @return void
[243] Fix | Delete
*/
[244] Fix | Delete
function twentytwenty_non_latin_languages() {
[245] Fix | Delete
$custom_css = TwentyTwenty_Non_Latin_Languages::get_non_latin_css( 'front-end' );
[246] Fix | Delete
[247] Fix | Delete
if ( $custom_css ) {
[248] Fix | Delete
wp_add_inline_style( 'twentytwenty-style', $custom_css );
[249] Fix | Delete
}
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
add_action( 'wp_enqueue_scripts', 'twentytwenty_non_latin_languages' );
[253] Fix | Delete
[254] Fix | Delete
/**
[255] Fix | Delete
* Register navigation menus uses wp_nav_menu in five places.
[256] Fix | Delete
*/
[257] Fix | Delete
function twentytwenty_menus() {
[258] Fix | Delete
[259] Fix | Delete
$locations = array(
[260] Fix | Delete
'primary' => __( 'Desktop Horizontal Menu', 'twentytwenty' ),
[261] Fix | Delete
'expanded' => __( 'Desktop Expanded Menu', 'twentytwenty' ),
[262] Fix | Delete
'mobile' => __( 'Mobile Menu', 'twentytwenty' ),
[263] Fix | Delete
'footer' => __( 'Footer Menu', 'twentytwenty' ),
[264] Fix | Delete
'social' => __( 'Social Menu', 'twentytwenty' ),
[265] Fix | Delete
);
[266] Fix | Delete
[267] Fix | Delete
register_nav_menus( $locations );
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
add_action( 'init', 'twentytwenty_menus' );
[271] Fix | Delete
[272] Fix | Delete
/**
[273] Fix | Delete
* Get the information about the logo.
[274] Fix | Delete
*
[275] Fix | Delete
* @param string $html The HTML output from get_custom_logo (core function).
[276] Fix | Delete
* @return string
[277] Fix | Delete
*/
[278] Fix | Delete
function twentytwenty_get_custom_logo( $html ) {
[279] Fix | Delete
[280] Fix | Delete
$logo_id = get_theme_mod( 'custom_logo' );
[281] Fix | Delete
[282] Fix | Delete
if ( ! $logo_id ) {
[283] Fix | Delete
return $html;
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
$logo = wp_get_attachment_image_src( $logo_id, 'full' );
[287] Fix | Delete
[288] Fix | Delete
if ( $logo ) {
[289] Fix | Delete
// For clarity.
[290] Fix | Delete
$logo_width = esc_attr( $logo[1] );
[291] Fix | Delete
$logo_height = esc_attr( $logo[2] );
[292] Fix | Delete
[293] Fix | Delete
// If the retina logo setting is active, reduce the width/height by half.
[294] Fix | Delete
if ( get_theme_mod( 'retina_logo', false ) ) {
[295] Fix | Delete
$logo_width = floor( $logo_width / 2 );
[296] Fix | Delete
$logo_height = floor( $logo_height / 2 );
[297] Fix | Delete
[298] Fix | Delete
$search = array(
[299] Fix | Delete
'/width=\"\d+\"/iU',
[300] Fix | Delete
'/height=\"\d+\"/iU',
[301] Fix | Delete
);
[302] Fix | Delete
[303] Fix | Delete
$replace = array(
[304] Fix | Delete
"width=\"{$logo_width}\"",
[305] Fix | Delete
"height=\"{$logo_height}\"",
[306] Fix | Delete
);
[307] Fix | Delete
[308] Fix | Delete
// Add a style attribute with the height, or append the height to the style attribute if the style attribute already exists.
[309] Fix | Delete
if ( strpos( $html, ' style=' ) === false ) {
[310] Fix | Delete
$search[] = '/(src=)/';
[311] Fix | Delete
$replace[] = "style=\"height: {$logo_height}px;\" src=";
[312] Fix | Delete
} else {
[313] Fix | Delete
$search[] = '/(style="[^"]*)/';
[314] Fix | Delete
$replace[] = "$1 height: {$logo_height}px;";
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
$html = preg_replace( $search, $replace, $html );
[318] Fix | Delete
[319] Fix | Delete
}
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
return $html;
[323] Fix | Delete
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
add_filter( 'get_custom_logo', 'twentytwenty_get_custom_logo' );
[327] Fix | Delete
[328] Fix | Delete
if ( ! function_exists( 'wp_body_open' ) ) {
[329] Fix | Delete
[330] Fix | Delete
/**
[331] Fix | Delete
* Shim for wp_body_open, ensuring backward compatibility with versions of WordPress older than 5.2.
[332] Fix | Delete
*/
[333] Fix | Delete
function wp_body_open() {
[334] Fix | Delete
do_action( 'wp_body_open' );
[335] Fix | Delete
}
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
/**
[339] Fix | Delete
* Include a skip to content link at the top of the page so that users can bypass the menu.
[340] Fix | Delete
*/
[341] Fix | Delete
function twentytwenty_skip_link() {
[342] Fix | Delete
echo '<a class="skip-link screen-reader-text" href="#site-content">' . __( 'Skip to the content', 'twentytwenty' ) . '</a>';
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
add_action( 'wp_body_open', 'twentytwenty_skip_link', 5 );
[346] Fix | Delete
[347] Fix | Delete
/**
[348] Fix | Delete
* Register widget areas.
[349] Fix | Delete
*
[350] Fix | Delete
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
[351] Fix | Delete
*/
[352] Fix | Delete
function twentytwenty_sidebar_registration() {
[353] Fix | Delete
[354] Fix | Delete
// Arguments used in all register_sidebar() calls.
[355] Fix | Delete
$shared_args = array(
[356] Fix | Delete
'before_title' => '<h2 class="widget-title subheading heading-size-3">',
[357] Fix | Delete
'after_title' => '</h2>',
[358] Fix | Delete
'before_widget' => '<div class="widget %2$s"><div class="widget-content">',
[359] Fix | Delete
'after_widget' => '</div></div>',
[360] Fix | Delete
);
[361] Fix | Delete
[362] Fix | Delete
// Footer #1.
[363] Fix | Delete
register_sidebar(
[364] Fix | Delete
array_merge(
[365] Fix | Delete
$shared_args,
[366] Fix | Delete
array(
[367] Fix | Delete
'name' => __( 'Footer #1', 'twentytwenty' ),
[368] Fix | Delete
'id' => 'sidebar-1',
[369] Fix | Delete
'description' => __( 'Widgets in this area will be displayed in the first column in the footer.', 'twentytwenty' ),
[370] Fix | Delete
)
[371] Fix | Delete
)
[372] Fix | Delete
);
[373] Fix | Delete
[374] Fix | Delete
// Footer #2.
[375] Fix | Delete
register_sidebar(
[376] Fix | Delete
array_merge(
[377] Fix | Delete
$shared_args,
[378] Fix | Delete
array(
[379] Fix | Delete
'name' => __( 'Footer #2', 'twentytwenty' ),
[380] Fix | Delete
'id' => 'sidebar-2',
[381] Fix | Delete
'description' => __( 'Widgets in this area will be displayed in the second column in the footer.', 'twentytwenty' ),
[382] Fix | Delete
)
[383] Fix | Delete
)
[384] Fix | Delete
);
[385] Fix | Delete
[386] Fix | Delete
}
[387] Fix | Delete
[388] Fix | Delete
add_action( 'widgets_init', 'twentytwenty_sidebar_registration' );
[389] Fix | Delete
[390] Fix | Delete
/**
[391] Fix | Delete
* Enqueue supplemental block editor styles.
[392] Fix | Delete
*/
[393] Fix | Delete
function twentytwenty_block_editor_styles() {
[394] Fix | Delete
[395] Fix | Delete
// Enqueue the editor styles.
[396] Fix | Delete
wp_enqueue_style( 'twentytwenty-block-editor-styles', get_theme_file_uri( '/assets/css/editor-style-block.css' ), array(), wp_get_theme()->get( 'Version' ), 'all' );
[397] Fix | Delete
wp_style_add_data( 'twentytwenty-block-editor-styles', 'rtl', 'replace' );
[398] Fix | Delete
[399] Fix | Delete
// Add inline style from the Customizer.
[400] Fix | Delete
wp_add_inline_style( 'twentytwenty-block-editor-styles', twentytwenty_get_customizer_css( 'block-editor' ) );
[401] Fix | Delete
[402] Fix | Delete
// Add inline style for non-latin fonts.
[403] Fix | Delete
wp_add_inline_style( 'twentytwenty-block-editor-styles', TwentyTwenty_Non_Latin_Languages::get_non_latin_css( 'block-editor' ) );
[404] Fix | Delete
[405] Fix | Delete
// Enqueue the editor script.
[406] Fix | Delete
wp_enqueue_script( 'twentytwenty-block-editor-script', get_theme_file_uri( '/assets/js/editor-script-block.js' ), array( 'wp-blocks', 'wp-dom' ), wp_get_theme()->get( 'Version' ), true );
[407] Fix | Delete
}
[408] Fix | Delete
[409] Fix | Delete
add_action( 'enqueue_block_editor_assets', 'twentytwenty_block_editor_styles', 1, 1 );
[410] Fix | Delete
[411] Fix | Delete
/**
[412] Fix | Delete
* Enqueue classic editor styles.
[413] Fix | Delete
*/
[414] Fix | Delete
function twentytwenty_classic_editor_styles() {
[415] Fix | Delete
[416] Fix | Delete
$classic_editor_styles = array(
[417] Fix | Delete
'/assets/css/editor-style-classic.css',
[418] Fix | Delete
);
[419] Fix | Delete
[420] Fix | Delete
add_editor_style( $classic_editor_styles );
[421] Fix | Delete
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
add_action( 'init', 'twentytwenty_classic_editor_styles' );
[425] Fix | Delete
[426] Fix | Delete
/**
[427] Fix | Delete
* Output Customizer settings in the classic editor.
[428] Fix | Delete
* Adds styles to the head of the TinyMCE iframe. Kudos to @Otto42 for the original solution.
[429] Fix | Delete
*
[430] Fix | Delete
* @param array $mce_init TinyMCE styles.
[431] Fix | Delete
* @return array TinyMCE styles.
[432] Fix | Delete
*/
[433] Fix | Delete
function twentytwenty_add_classic_editor_customizer_styles( $mce_init ) {
[434] Fix | Delete
[435] Fix | Delete
$styles = twentytwenty_get_customizer_css( 'classic-editor' );
[436] Fix | Delete
[437] Fix | Delete
if ( ! isset( $mce_init['content_style'] ) ) {
[438] Fix | Delete
$mce_init['content_style'] = $styles . ' ';
[439] Fix | Delete
} else {
[440] Fix | Delete
$mce_init['content_style'] .= ' ' . $styles . ' ';
[441] Fix | Delete
}
[442] Fix | Delete
[443] Fix | Delete
return $mce_init;
[444] Fix | Delete
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
add_filter( 'tiny_mce_before_init', 'twentytwenty_add_classic_editor_customizer_styles' );
[448] Fix | Delete
[449] Fix | Delete
/**
[450] Fix | Delete
* Output non-latin font styles in the classic editor.
[451] Fix | Delete
* Adds styles to the head of the TinyMCE iframe. Kudos to @Otto42 for the original solution.
[452] Fix | Delete
*
[453] Fix | Delete
* @param array $mce_init TinyMCE styles.
[454] Fix | Delete
* @return array TinyMCE styles.
[455] Fix | Delete
*/
[456] Fix | Delete
function twentytwenty_add_classic_editor_non_latin_styles( $mce_init ) {
[457] Fix | Delete
[458] Fix | Delete
$styles = TwentyTwenty_Non_Latin_Languages::get_non_latin_css( 'classic-editor' );
[459] Fix | Delete
[460] Fix | Delete
// Return if there are no styles to add.
[461] Fix | Delete
if ( ! $styles ) {
[462] Fix | Delete
return $mce_init;
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
if ( ! isset( $mce_init['content_style'] ) ) {
[466] Fix | Delete
$mce_init['content_style'] = $styles . ' ';
[467] Fix | Delete
} else {
[468] Fix | Delete
$mce_init['content_style'] .= ' ' . $styles . ' ';
[469] Fix | Delete
}
[470] Fix | Delete
[471] Fix | Delete
return $mce_init;
[472] Fix | Delete
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
add_filter( 'tiny_mce_before_init', 'twentytwenty_add_classic_editor_non_latin_styles' );
[476] Fix | Delete
[477] Fix | Delete
/**
[478] Fix | Delete
* Block Editor Settings.
[479] Fix | Delete
* Add custom colors and font sizes to the block editor.
[480] Fix | Delete
*/
[481] Fix | Delete
function twentytwenty_block_editor_settings() {
[482] Fix | Delete
[483] Fix | Delete
// Block Editor Palette.
[484] Fix | Delete
$editor_color_palette = array(
[485] Fix | Delete
array(
[486] Fix | Delete
'name' => __( 'Accent Color', 'twentytwenty' ),
[487] Fix | Delete
'slug' => 'accent',
[488] Fix | Delete
'color' => twentytwenty_get_color_for_area( 'content', 'accent' ),
[489] Fix | Delete
),
[490] Fix | Delete
array(
[491] Fix | Delete
'name' => _x( 'Primary', 'color', 'twentytwenty' ),
[492] Fix | Delete
'slug' => 'primary',
[493] Fix | Delete
'color' => twentytwenty_get_color_for_area( 'content', 'text' ),
[494] Fix | Delete
),
[495] Fix | Delete
array(
[496] Fix | Delete
'name' => _x( 'Secondary', 'color', 'twentytwenty' ),
[497] Fix | Delete
'slug' => 'secondary',
[498] Fix | Delete
'color' => twentytwenty_get_color_for_area( 'content', 'secondary' ),
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function