Edit File by line
/home/barbar84/public_h.../wp-inclu...
File: script-loader.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress scripts and styles default loader.
[2] Fix | Delete
*
[3] Fix | Delete
* Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
[4] Fix | Delete
* define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,
[5] Fix | Delete
* define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,
[6] Fix | Delete
* define('COMPRESS_SCRIPTS', false); disables compression of scripts,
[7] Fix | Delete
* define('COMPRESS_CSS', false); disables compression of CSS,
[8] Fix | Delete
* define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).
[9] Fix | Delete
*
[10] Fix | Delete
* The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
[11] Fix | Delete
* to temporarily override the above settings. Also a compression test is run once and the result is saved
[12] Fix | Delete
* as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted.
[13] Fix | Delete
*
[14] Fix | Delete
* @package WordPress
[15] Fix | Delete
*/
[16] Fix | Delete
[17] Fix | Delete
/** WordPress Dependency Class */
[18] Fix | Delete
require ABSPATH . WPINC . '/class-wp-dependency.php';
[19] Fix | Delete
[20] Fix | Delete
/** WordPress Dependencies Class */
[21] Fix | Delete
require ABSPATH . WPINC . '/class.wp-dependencies.php';
[22] Fix | Delete
[23] Fix | Delete
/** WordPress Scripts Class */
[24] Fix | Delete
require ABSPATH . WPINC . '/class.wp-scripts.php';
[25] Fix | Delete
[26] Fix | Delete
/** WordPress Scripts Functions */
[27] Fix | Delete
require ABSPATH . WPINC . '/functions.wp-scripts.php';
[28] Fix | Delete
[29] Fix | Delete
/** WordPress Styles Class */
[30] Fix | Delete
require ABSPATH . WPINC . '/class.wp-styles.php';
[31] Fix | Delete
[32] Fix | Delete
/** WordPress Styles Functions */
[33] Fix | Delete
require ABSPATH . WPINC . '/functions.wp-styles.php';
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Registers TinyMCE scripts.
[37] Fix | Delete
*
[38] Fix | Delete
* @since 5.0.0
[39] Fix | Delete
*
[40] Fix | Delete
* @param WP_Scripts $scripts WP_Scripts object.
[41] Fix | Delete
* @param bool $force_uncompressed Whether to forcibly prevent gzip compression. Default false.
[42] Fix | Delete
*/
[43] Fix | Delete
function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) {
[44] Fix | Delete
global $tinymce_version, $concatenate_scripts, $compress_scripts;
[45] Fix | Delete
$suffix = wp_scripts_get_suffix();
[46] Fix | Delete
$dev_suffix = wp_scripts_get_suffix( 'dev' );
[47] Fix | Delete
[48] Fix | Delete
script_concat_settings();
[49] Fix | Delete
[50] Fix | Delete
$compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] )
[51] Fix | Delete
&& false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed;
[52] Fix | Delete
[53] Fix | Delete
// Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production)
[54] Fix | Delete
// or tinymce.min.js (when SCRIPT_DEBUG is true).
[55] Fix | Delete
if ( $compressed ) {
[56] Fix | Delete
$scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version );
[57] Fix | Delete
} else {
[58] Fix | Delete
$scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version );
[59] Fix | Delete
$scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
$scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version );
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Registers all the WordPress vendor scripts that are in the standardized
[67] Fix | Delete
* `js/dist/vendor/` location.
[68] Fix | Delete
*
[69] Fix | Delete
* For the order of `$scripts->add` see `wp_default_scripts`.
[70] Fix | Delete
*
[71] Fix | Delete
* @since 5.0.0
[72] Fix | Delete
*
[73] Fix | Delete
* @param WP_Scripts $scripts WP_Scripts object.
[74] Fix | Delete
*/
[75] Fix | Delete
function wp_default_packages_vendor( $scripts ) {
[76] Fix | Delete
global $wp_locale;
[77] Fix | Delete
[78] Fix | Delete
$suffix = wp_scripts_get_suffix();
[79] Fix | Delete
[80] Fix | Delete
$vendor_scripts = array(
[81] Fix | Delete
'react' => array( 'wp-polyfill' ),
[82] Fix | Delete
'react-dom' => array( 'react' ),
[83] Fix | Delete
'moment',
[84] Fix | Delete
'lodash',
[85] Fix | Delete
'wp-polyfill-fetch',
[86] Fix | Delete
'wp-polyfill-formdata',
[87] Fix | Delete
'wp-polyfill-node-contains',
[88] Fix | Delete
'wp-polyfill-url',
[89] Fix | Delete
'wp-polyfill-dom-rect',
[90] Fix | Delete
'wp-polyfill-element-closest',
[91] Fix | Delete
'wp-polyfill-object-fit',
[92] Fix | Delete
'wp-polyfill',
[93] Fix | Delete
);
[94] Fix | Delete
[95] Fix | Delete
$vendor_scripts_versions = array(
[96] Fix | Delete
'react' => '16.13.1',
[97] Fix | Delete
'react-dom' => '16.13.1',
[98] Fix | Delete
'moment' => '2.26.0',
[99] Fix | Delete
'lodash' => '4.17.21',
[100] Fix | Delete
'wp-polyfill-fetch' => '3.0.0',
[101] Fix | Delete
'wp-polyfill-formdata' => '3.0.12',
[102] Fix | Delete
'wp-polyfill-node-contains' => '3.42.0',
[103] Fix | Delete
'wp-polyfill-url' => '3.6.4',
[104] Fix | Delete
'wp-polyfill-dom-rect' => '3.42.0',
[105] Fix | Delete
'wp-polyfill-element-closest' => '2.0.2',
[106] Fix | Delete
'wp-polyfill-object-fit' => '2.3.4',
[107] Fix | Delete
'wp-polyfill' => '7.4.4',
[108] Fix | Delete
);
[109] Fix | Delete
[110] Fix | Delete
foreach ( $vendor_scripts as $handle => $dependencies ) {
[111] Fix | Delete
if ( is_string( $dependencies ) ) {
[112] Fix | Delete
$handle = $dependencies;
[113] Fix | Delete
$dependencies = array();
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
$path = "/wp-includes/js/dist/vendor/$handle$suffix.js";
[117] Fix | Delete
$version = $vendor_scripts_versions[ $handle ];
[118] Fix | Delete
[119] Fix | Delete
$scripts->add( $handle, $path, $dependencies, $version, 1 );
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
$scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
[123] Fix | Delete
did_action( 'init' ) && $scripts->add_inline_script(
[124] Fix | Delete
'wp-polyfill',
[125] Fix | Delete
wp_get_script_polyfill(
[126] Fix | Delete
$scripts,
[127] Fix | Delete
array(
[128] Fix | Delete
'\'fetch\' in window' => 'wp-polyfill-fetch',
[129] Fix | Delete
'document.contains' => 'wp-polyfill-node-contains',
[130] Fix | Delete
'window.DOMRect' => 'wp-polyfill-dom-rect',
[131] Fix | Delete
'window.URL && window.URL.prototype && window.URLSearchParams' => 'wp-polyfill-url',
[132] Fix | Delete
'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
[133] Fix | Delete
'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
[134] Fix | Delete
'\'objectFit\' in document.documentElement.style' => 'wp-polyfill-object-fit',
[135] Fix | Delete
)
[136] Fix | Delete
)
[137] Fix | Delete
);
[138] Fix | Delete
[139] Fix | Delete
did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
[140] Fix | Delete
[141] Fix | Delete
did_action( 'init' ) && $scripts->add_inline_script(
[142] Fix | Delete
'moment',
[143] Fix | Delete
sprintf(
[144] Fix | Delete
"moment.updateLocale( '%s', %s );",
[145] Fix | Delete
get_user_locale(),
[146] Fix | Delete
wp_json_encode(
[147] Fix | Delete
array(
[148] Fix | Delete
'months' => array_values( $wp_locale->month ),
[149] Fix | Delete
'monthsShort' => array_values( $wp_locale->month_abbrev ),
[150] Fix | Delete
'weekdays' => array_values( $wp_locale->weekday ),
[151] Fix | Delete
'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
[152] Fix | Delete
'week' => array(
[153] Fix | Delete
'dow' => (int) get_option( 'start_of_week', 0 ),
[154] Fix | Delete
),
[155] Fix | Delete
'longDateFormat' => array(
[156] Fix | Delete
'LT' => get_option( 'time_format', __( 'g:i a', 'default' ) ),
[157] Fix | Delete
'LTS' => null,
[158] Fix | Delete
'L' => null,
[159] Fix | Delete
'LL' => get_option( 'date_format', __( 'F j, Y', 'default' ) ),
[160] Fix | Delete
'LLL' => __( 'F j, Y g:i a', 'default' ),
[161] Fix | Delete
'LLLL' => null,
[162] Fix | Delete
),
[163] Fix | Delete
)
[164] Fix | Delete
)
[165] Fix | Delete
),
[166] Fix | Delete
'after'
[167] Fix | Delete
);
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
/**
[171] Fix | Delete
* Returns contents of an inline script used in appending polyfill scripts for
[172] Fix | Delete
* browsers which fail the provided tests. The provided array is a mapping from
[173] Fix | Delete
* a condition to verify feature support to its polyfill script handle.
[174] Fix | Delete
*
[175] Fix | Delete
* @since 5.0.0
[176] Fix | Delete
*
[177] Fix | Delete
* @param WP_Scripts $scripts WP_Scripts object.
[178] Fix | Delete
* @param array $tests Features to detect.
[179] Fix | Delete
* @return string Conditional polyfill inline script.
[180] Fix | Delete
*/
[181] Fix | Delete
function wp_get_script_polyfill( $scripts, $tests ) {
[182] Fix | Delete
$polyfill = '';
[183] Fix | Delete
foreach ( $tests as $test => $handle ) {
[184] Fix | Delete
if ( ! array_key_exists( $handle, $scripts->registered ) ) {
[185] Fix | Delete
continue;
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
$src = $scripts->registered[ $handle ]->src;
[189] Fix | Delete
$ver = $scripts->registered[ $handle ]->ver;
[190] Fix | Delete
[191] Fix | Delete
if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) {
[192] Fix | Delete
$src = $scripts->base_url . $src;
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
if ( ! empty( $ver ) ) {
[196] Fix | Delete
$src = add_query_arg( 'ver', $ver, $src );
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
/** This filter is documented in wp-includes/class.wp-scripts.php */
[200] Fix | Delete
$src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
[201] Fix | Delete
[202] Fix | Delete
if ( ! $src ) {
[203] Fix | Delete
continue;
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
$polyfill .= (
[207] Fix | Delete
// Test presence of feature...
[208] Fix | Delete
'( ' . $test . ' ) || ' .
[209] Fix | Delete
/*
[210] Fix | Delete
* ...appending polyfill on any failures. Cautious viewers may balk
[211] Fix | Delete
* at the `document.write`. Its caveat of synchronous mid-stream
[212] Fix | Delete
* blocking write is exactly the behavior we need though.
[213] Fix | Delete
*/
[214] Fix | Delete
'document.write( \'<script src="' .
[215] Fix | Delete
$src .
[216] Fix | Delete
'"></scr\' + \'ipt>\' );'
[217] Fix | Delete
);
[218] Fix | Delete
}
[219] Fix | Delete
[220] Fix | Delete
return $polyfill;
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
/**
[224] Fix | Delete
* Registers all the WordPress packages scripts that are in the standardized
[225] Fix | Delete
* `js/dist/` location.
[226] Fix | Delete
*
[227] Fix | Delete
* For the order of `$scripts->add` see `wp_default_scripts`.
[228] Fix | Delete
*
[229] Fix | Delete
* @since 5.0.0
[230] Fix | Delete
*
[231] Fix | Delete
* @param WP_Scripts $scripts WP_Scripts object.
[232] Fix | Delete
*/
[233] Fix | Delete
function wp_default_packages_scripts( $scripts ) {
[234] Fix | Delete
$suffix = wp_scripts_get_suffix();
[235] Fix | Delete
[236] Fix | Delete
// Expects multidimensional array like:
[237] Fix | Delete
// 'a11y.js' => array('dependencies' => array(...), 'version' => '...'),
[238] Fix | Delete
// 'annotations.js' => array('dependencies' => array(...), 'version' => '...'),
[239] Fix | Delete
// 'api-fetch.js' => array(...
[240] Fix | Delete
$assets = include ABSPATH . WPINC . '/assets/script-loader-packages.php';
[241] Fix | Delete
[242] Fix | Delete
foreach ( $assets as $package_name => $package_data ) {
[243] Fix | Delete
$basename = basename( $package_name, '.js' );
[244] Fix | Delete
$handle = 'wp-' . $basename;
[245] Fix | Delete
$path = "/wp-includes/js/dist/{$basename}{$suffix}.js";
[246] Fix | Delete
[247] Fix | Delete
if ( ! empty( $package_data['dependencies'] ) ) {
[248] Fix | Delete
$dependencies = $package_data['dependencies'];
[249] Fix | Delete
} else {
[250] Fix | Delete
$dependencies = array();
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
// Add dependencies that cannot be detected and generated by build tools.
[254] Fix | Delete
switch ( $handle ) {
[255] Fix | Delete
case 'wp-block-library':
[256] Fix | Delete
array_push( $dependencies, 'editor' );
[257] Fix | Delete
break;
[258] Fix | Delete
case 'wp-edit-post':
[259] Fix | Delete
array_push( $dependencies, 'media-models', 'media-views', 'postbox', 'wp-dom-ready' );
[260] Fix | Delete
break;
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
$scripts->add( $handle, $path, $dependencies, $package_data['version'], 1 );
[264] Fix | Delete
[265] Fix | Delete
if ( in_array( 'wp-i18n', $dependencies, true ) ) {
[266] Fix | Delete
$scripts->set_translations( $handle );
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
/*
[270] Fix | Delete
* Manually set the text direction localization after wp-i18n is printed.
[271] Fix | Delete
* This ensures that wp.i18n.isRTL() returns true in RTL languages.
[272] Fix | Delete
* We cannot use $scripts->set_translations( 'wp-i18n' ) to do this
[273] Fix | Delete
* because WordPress prints a script's translations *before* the script,
[274] Fix | Delete
* which means, in the case of wp-i18n, that wp.i18n.setLocaleData()
[275] Fix | Delete
* is called before wp.i18n is defined.
[276] Fix | Delete
*/
[277] Fix | Delete
if ( 'wp-i18n' === $handle ) {
[278] Fix | Delete
$ltr = _x( 'ltr', 'text direction', 'default' );
[279] Fix | Delete
$script = sprintf( "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ '%s' ] } );", $ltr );
[280] Fix | Delete
$scripts->add_inline_script( $handle, $script, 'after' );
[281] Fix | Delete
}
[282] Fix | Delete
}
[283] Fix | Delete
}
[284] Fix | Delete
[285] Fix | Delete
/**
[286] Fix | Delete
* Adds inline scripts required for the WordPress JavaScript packages.
[287] Fix | Delete
*
[288] Fix | Delete
* @since 5.0.0
[289] Fix | Delete
*
[290] Fix | Delete
* @param WP_Scripts $scripts WP_Scripts object.
[291] Fix | Delete
*/
[292] Fix | Delete
function wp_default_packages_inline_scripts( $scripts ) {
[293] Fix | Delete
global $wp_locale;
[294] Fix | Delete
[295] Fix | Delete
if ( isset( $scripts->registered['wp-api-fetch'] ) ) {
[296] Fix | Delete
$scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks';
[297] Fix | Delete
}
[298] Fix | Delete
$scripts->add_inline_script(
[299] Fix | Delete
'wp-api-fetch',
[300] Fix | Delete
sprintf(
[301] Fix | Delete
'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );',
[302] Fix | Delete
esc_url_raw( get_rest_url() )
[303] Fix | Delete
),
[304] Fix | Delete
'after'
[305] Fix | Delete
);
[306] Fix | Delete
$scripts->add_inline_script(
[307] Fix | Delete
'wp-api-fetch',
[308] Fix | Delete
implode(
[309] Fix | Delete
"\n",
[310] Fix | Delete
array(
[311] Fix | Delete
sprintf(
[312] Fix | Delete
'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );',
[313] Fix | Delete
( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' )
[314] Fix | Delete
),
[315] Fix | Delete
'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );',
[316] Fix | Delete
'wp.apiFetch.use( wp.apiFetch.mediaUploadMiddleware );',
[317] Fix | Delete
sprintf(
[318] Fix | Delete
'wp.apiFetch.nonceEndpoint = "%s";',
[319] Fix | Delete
admin_url( 'admin-ajax.php?action=rest-nonce' )
[320] Fix | Delete
),
[321] Fix | Delete
)
[322] Fix | Delete
),
[323] Fix | Delete
'after'
[324] Fix | Delete
);
[325] Fix | Delete
$scripts->add_inline_script(
[326] Fix | Delete
'wp-data',
[327] Fix | Delete
implode(
[328] Fix | Delete
"\n",
[329] Fix | Delete
array(
[330] Fix | Delete
'( function() {',
[331] Fix | Delete
' var userId = ' . get_current_user_ID() . ';',
[332] Fix | Delete
' var storageKey = "WP_DATA_USER_" + userId;',
[333] Fix | Delete
' wp.data',
[334] Fix | Delete
' .use( wp.data.plugins.persistence, { storageKey: storageKey } );',
[335] Fix | Delete
' wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );',
[336] Fix | Delete
'} )();',
[337] Fix | Delete
)
[338] Fix | Delete
)
[339] Fix | Delete
);
[340] Fix | Delete
[341] Fix | Delete
// Calculate the timezone abbr (EDT, PST) if possible.
[342] Fix | Delete
$timezone_string = get_option( 'timezone_string', 'UTC' );
[343] Fix | Delete
$timezone_abbr = '';
[344] Fix | Delete
[345] Fix | Delete
if ( ! empty( $timezone_string ) ) {
[346] Fix | Delete
$timezone_date = new DateTime( null, new DateTimeZone( $timezone_string ) );
[347] Fix | Delete
$timezone_abbr = $timezone_date->format( 'T' );
[348] Fix | Delete
}
[349] Fix | Delete
[350] Fix | Delete
$scripts->add_inline_script(
[351] Fix | Delete
'wp-date',
[352] Fix | Delete
sprintf(
[353] Fix | Delete
'wp.date.setSettings( %s );',
[354] Fix | Delete
wp_json_encode(
[355] Fix | Delete
array(
[356] Fix | Delete
'l10n' => array(
[357] Fix | Delete
'locale' => get_user_locale(),
[358] Fix | Delete
'months' => array_values( $wp_locale->month ),
[359] Fix | Delete
'monthsShort' => array_values( $wp_locale->month_abbrev ),
[360] Fix | Delete
'weekdays' => array_values( $wp_locale->weekday ),
[361] Fix | Delete
'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
[362] Fix | Delete
'meridiem' => (object) $wp_locale->meridiem,
[363] Fix | Delete
'relative' => array(
[364] Fix | Delete
/* translators: %s: Duration. */
[365] Fix | Delete
'future' => __( '%s from now' ),
[366] Fix | Delete
/* translators: %s: Duration. */
[367] Fix | Delete
'past' => __( '%s ago' ),
[368] Fix | Delete
),
[369] Fix | Delete
),
[370] Fix | Delete
'formats' => array(
[371] Fix | Delete
/* translators: Time format, see https://www.php.net/manual/datetime.format.php */
[372] Fix | Delete
'time' => get_option( 'time_format', __( 'g:i a' ) ),
[373] Fix | Delete
/* translators: Date format, see https://www.php.net/manual/datetime.format.php */
[374] Fix | Delete
'date' => get_option( 'date_format', __( 'F j, Y' ) ),
[375] Fix | Delete
/* translators: Date/Time format, see https://www.php.net/manual/datetime.format.php */
[376] Fix | Delete
'datetime' => __( 'F j, Y g:i a' ),
[377] Fix | Delete
/* translators: Abbreviated date/time format, see https://www.php.net/manual/datetime.format.php */
[378] Fix | Delete
'datetimeAbbreviated' => __( 'M j, Y g:i a' ),
[379] Fix | Delete
),
[380] Fix | Delete
'timezone' => array(
[381] Fix | Delete
'offset' => get_option( 'gmt_offset', 0 ),
[382] Fix | Delete
'string' => $timezone_string,
[383] Fix | Delete
'abbr' => $timezone_abbr,
[384] Fix | Delete
),
[385] Fix | Delete
)
[386] Fix | Delete
)
[387] Fix | Delete
),
[388] Fix | Delete
'after'
[389] Fix | Delete
);
[390] Fix | Delete
[391] Fix | Delete
// Loading the old editor and its config to ensure the classic block works as expected.
[392] Fix | Delete
$scripts->add_inline_script(
[393] Fix | Delete
'editor',
[394] Fix | Delete
'window.wp.oldEditor = window.wp.editor;',
[395] Fix | Delete
'after'
[396] Fix | Delete
);
[397] Fix | Delete
}
[398] Fix | Delete
[399] Fix | Delete
/**
[400] Fix | Delete
* Adds inline scripts required for the TinyMCE in the block editor.
[401] Fix | Delete
*
[402] Fix | Delete
* These TinyMCE init settings are used to extend and override the default settings
[403] Fix | Delete
* from `_WP_Editors::default_settings()` for the Classic block.
[404] Fix | Delete
*
[405] Fix | Delete
* @since 5.0.0
[406] Fix | Delete
*
[407] Fix | Delete
* @global WP_Scripts $wp_scripts
[408] Fix | Delete
*/
[409] Fix | Delete
function wp_tinymce_inline_scripts() {
[410] Fix | Delete
global $wp_scripts;
[411] Fix | Delete
[412] Fix | Delete
/** This filter is documented in wp-includes/class-wp-editor.php */
[413] Fix | Delete
$editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' );
[414] Fix | Delete
[415] Fix | Delete
$tinymce_plugins = array(
[416] Fix | Delete
'charmap',
[417] Fix | Delete
'colorpicker',
[418] Fix | Delete
'hr',
[419] Fix | Delete
'lists',
[420] Fix | Delete
'media',
[421] Fix | Delete
'paste',
[422] Fix | Delete
'tabfocus',
[423] Fix | Delete
'textcolor',
[424] Fix | Delete
'fullscreen',
[425] Fix | Delete
'wordpress',
[426] Fix | Delete
'wpautoresize',
[427] Fix | Delete
'wpeditimage',
[428] Fix | Delete
'wpemoji',
[429] Fix | Delete
'wpgallery',
[430] Fix | Delete
'wplink',
[431] Fix | Delete
'wpdialogs',
[432] Fix | Delete
'wptextpattern',
[433] Fix | Delete
'wpview',
[434] Fix | Delete
);
[435] Fix | Delete
[436] Fix | Delete
/** This filter is documented in wp-includes/class-wp-editor.php */
[437] Fix | Delete
$tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' );
[438] Fix | Delete
$tinymce_plugins = array_unique( $tinymce_plugins );
[439] Fix | Delete
[440] Fix | Delete
$disable_captions = false;
[441] Fix | Delete
// Runs after `tiny_mce_plugins` but before `mce_buttons`.
[442] Fix | Delete
/** This filter is documented in wp-admin/includes/media.php */
[443] Fix | Delete
if ( apply_filters( 'disable_captions', '' ) ) {
[444] Fix | Delete
$disable_captions = true;
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
$toolbar1 = array(
[448] Fix | Delete
'formatselect',
[449] Fix | Delete
'bold',
[450] Fix | Delete
'italic',
[451] Fix | Delete
'bullist',
[452] Fix | Delete
'numlist',
[453] Fix | Delete
'blockquote',
[454] Fix | Delete
'alignleft',
[455] Fix | Delete
'aligncenter',
[456] Fix | Delete
'alignright',
[457] Fix | Delete
'link',
[458] Fix | Delete
'unlink',
[459] Fix | Delete
'wp_more',
[460] Fix | Delete
'spellchecker',
[461] Fix | Delete
'wp_add_media',
[462] Fix | Delete
'wp_adv',
[463] Fix | Delete
);
[464] Fix | Delete
[465] Fix | Delete
/** This filter is documented in wp-includes/class-wp-editor.php */
[466] Fix | Delete
$toolbar1 = apply_filters( 'mce_buttons', $toolbar1, 'classic-block' );
[467] Fix | Delete
[468] Fix | Delete
$toolbar2 = array(
[469] Fix | Delete
'strikethrough',
[470] Fix | Delete
'hr',
[471] Fix | Delete
'forecolor',
[472] Fix | Delete
'pastetext',
[473] Fix | Delete
'removeformat',
[474] Fix | Delete
'charmap',
[475] Fix | Delete
'outdent',
[476] Fix | Delete
'indent',
[477] Fix | Delete
'undo',
[478] Fix | Delete
'redo',
[479] Fix | Delete
'wp_help',
[480] Fix | Delete
);
[481] Fix | Delete
[482] Fix | Delete
/** This filter is documented in wp-includes/class-wp-editor.php */
[483] Fix | Delete
$toolbar2 = apply_filters( 'mce_buttons_2', $toolbar2, 'classic-block' );
[484] Fix | Delete
/** This filter is documented in wp-includes/class-wp-editor.php */
[485] Fix | Delete
$toolbar3 = apply_filters( 'mce_buttons_3', array(), 'classic-block' );
[486] Fix | Delete
/** This filter is documented in wp-includes/class-wp-editor.php */
[487] Fix | Delete
$toolbar4 = apply_filters( 'mce_buttons_4', array(), 'classic-block' );
[488] Fix | Delete
/** This filter is documented in wp-includes/class-wp-editor.php */
[489] Fix | Delete
$external_plugins = apply_filters( 'mce_external_plugins', array(), 'classic-block' );
[490] Fix | Delete
[491] Fix | Delete
$tinymce_settings = array(
[492] Fix | Delete
'plugins' => implode( ',', $tinymce_plugins ),
[493] Fix | Delete
'toolbar1' => implode( ',', $toolbar1 ),
[494] Fix | Delete
'toolbar2' => implode( ',', $toolbar2 ),
[495] Fix | Delete
'toolbar3' => implode( ',', $toolbar3 ),
[496] Fix | Delete
'toolbar4' => implode( ',', $toolbar4 ),
[497] Fix | Delete
'external_plugins' => wp_json_encode( $external_plugins ),
[498] Fix | Delete
'classic_block_editor' => true,
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function