aboutsummaryrefslogtreecommitdiff
path: root/srcs/wordpress/wp-includes/script-loader.php
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/wordpress/wp-includes/script-loader.php')
-rw-r--r--srcs/wordpress/wp-includes/script-loader.php2945
1 files changed, 0 insertions, 2945 deletions
diff --git a/srcs/wordpress/wp-includes/script-loader.php b/srcs/wordpress/wp-includes/script-loader.php
deleted file mode 100644
index 18ba2d4..0000000
--- a/srcs/wordpress/wp-includes/script-loader.php
+++ /dev/null
@@ -1,2945 +0,0 @@
-<?php
-/**
- * WordPress scripts and styles default loader.
- *
- * Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
- * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,
- * define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,
- * define('COMPRESS_SCRIPTS', false); disables compression of scripts,
- * define('COMPRESS_CSS', false); disables compression of CSS,
- * define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).
- *
- * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
- * to temporarily override the above settings. Also a compression test is run once and the result is saved
- * as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted.
- *
- * @package WordPress
- */
-
-/** WordPress Dependency Class */
-require( ABSPATH . WPINC . '/class-wp-dependency.php' );
-
-/** WordPress Dependencies Class */
-require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
-
-/** WordPress Scripts Class */
-require( ABSPATH . WPINC . '/class.wp-scripts.php' );
-
-/** WordPress Scripts Functions */
-require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
-
-/** WordPress Styles Class */
-require( ABSPATH . WPINC . '/class.wp-styles.php' );
-
-/** WordPress Styles Functions */
-require( ABSPATH . WPINC . '/functions.wp-styles.php' );
-
-/**
- * Registers TinyMCE scripts.
- *
- * @since 5.0.0
- *
- * @param WP_Scripts $scripts WP_Scripts object.
- */
-function wp_register_tinymce_scripts( &$scripts, $force_uncompressed = false ) {
- global $tinymce_version, $concatenate_scripts, $compress_scripts;
- $suffix = wp_scripts_get_suffix();
- $dev_suffix = wp_scripts_get_suffix( 'dev' );
-
- script_concat_settings();
-
- $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] )
- && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed;
-
- // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production) or
- // tinymce.min.js (when SCRIPT_DEBUG is true).
- if ( $compressed ) {
- $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version );
- } else {
- $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version );
- $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version );
- }
-
- $scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version );
-}
-
-/**
- * Registers all the WordPress vendor scripts that are in the standardized
- * `js/dist/vendor/` location.
- *
- * For the order of `$scripts->add` see `wp_default_scripts`.
- *
- * @since 5.0.0
- *
- * @param WP_Scripts $scripts WP_Scripts object.
- */
-function wp_default_packages_vendor( &$scripts ) {
- global $wp_locale;
-
- $suffix = wp_scripts_get_suffix();
-
- $vendor_scripts = array(
- 'react' => array( 'wp-polyfill' ),
- 'react-dom' => array( 'react' ),
- 'moment',
- 'lodash',
- 'wp-polyfill-fetch',
- 'wp-polyfill-formdata',
- 'wp-polyfill-node-contains',
- 'wp-polyfill-element-closest',
- 'wp-polyfill',
- );
-
- $vendor_scripts_versions = array(
- 'react' => '16.9.0',
- 'react-dom' => '16.9.0',
- 'moment' => '2.22.2',
- 'lodash' => '4.17.15',
- 'wp-polyfill-fetch' => '3.0.0',
- 'wp-polyfill-formdata' => '3.0.12',
- 'wp-polyfill-node-contains' => '3.26.0-0',
- 'wp-polyfill-element-closest' => '2.0.2',
- 'wp-polyfill' => '7.4.4',
- );
-
- foreach ( $vendor_scripts as $handle => $dependencies ) {
- if ( is_string( $dependencies ) ) {
- $handle = $dependencies;
- $dependencies = array();
- }
-
- $path = "/wp-includes/js/dist/vendor/$handle$suffix.js";
- $version = $vendor_scripts_versions[ $handle ];
-
- $scripts->add( $handle, $path, $dependencies, $version, 1 );
- }
-
- $scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
- did_action( 'init' ) && $scripts->add_inline_script(
- 'wp-polyfill',
- wp_get_script_polyfill(
- $scripts,
- array(
- '\'fetch\' in window' => 'wp-polyfill-fetch',
- 'document.contains' => 'wp-polyfill-node-contains',
- 'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
- 'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
- )
- )
- );
-
- did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
-
- did_action( 'init' ) && $scripts->add_inline_script(
- 'moment',
- sprintf(
- "moment.locale( '%s', %s );",
- get_user_locale(),
- wp_json_encode(
- array(
- 'months' => array_values( $wp_locale->month ),
- 'monthsShort' => array_values( $wp_locale->month_abbrev ),
- 'weekdays' => array_values( $wp_locale->weekday ),
- 'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
- 'week' => array(
- 'dow' => (int) get_option( 'start_of_week', 0 ),
- ),
- 'longDateFormat' => array(
- 'LT' => get_option( 'time_format', __( 'g:i a', 'default' ) ),
- 'LTS' => null,
- 'L' => null,
- 'LL' => get_option( 'date_format', __( 'F j, Y', 'default' ) ),
- 'LLL' => __( 'F j, Y g:i a', 'default' ),
- 'LLLL' => null,
- ),
- )
- )
- ),
- 'after'
- );
-}
-
-/**
- * Returns contents of an inline script used in appending polyfill scripts for
- * browsers which fail the provided tests. The provided array is a mapping from
- * a condition to verify feature support to its polyfill script handle.
- *
- * @since 5.0.0
- *
- * @param WP_Scripts $scripts WP_Scripts object.
- * @param array $tests Features to detect.
- * @return string Conditional polyfill inline script.
- */
-function wp_get_script_polyfill( &$scripts, $tests ) {
- $polyfill = '';
- foreach ( $tests as $test => $handle ) {
- if ( ! array_key_exists( $handle, $scripts->registered ) ) {
- continue;
- }
-
- $src = $scripts->registered[ $handle ]->src;
- $ver = $scripts->registered[ $handle ]->ver;
-
- if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) {
- $src = $scripts->base_url . $src;
- }
-
- if ( ! empty( $ver ) ) {
- $src = add_query_arg( 'ver', $ver, $src );
- }
-
- /** This filter is documented in wp-includes/class.wp-scripts.php */
- $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
-
- if ( ! $src ) {
- continue;
- }
-
- $polyfill .= (
- // Test presence of feature...
- '( ' . $test . ' ) || ' .
- // ...appending polyfill on any failures. Cautious viewers may balk
- // at the `document.write`. Its caveat of synchronous mid-stream
- // blocking write is exactly the behavior we need though.
- 'document.write( \'<script src="' .
- $src .
- '"></scr\' + \'ipt>\' );'
- );
- }
-
- return $polyfill;
-}
-
-/**
- * Registers all the WordPress packages scripts that are in the standardized
- * `js/dist/` location.
- *
- * For the order of `$scripts->add` see `wp_default_scripts`.
- *
- * @since 5.0.0
- *
- * @param WP_Scripts $scripts WP_Scripts object.
- */
-function wp_default_packages_scripts( &$scripts ) {
- $suffix = wp_scripts_get_suffix();
-
- $packages_versions = array(
- 'a11y' => '2.5.1',
- 'annotations' => '1.7.2',
- 'api-fetch' => '3.6.4',
- 'autop' => '2.5.1',
- 'blob' => '2.5.1',
- 'block-editor' => '3.2.5',
- 'block-library' => '2.9.6',
- 'block-serialization-default-parser' => '3.4.1',
- 'blocks' => '6.7.2',
- 'components' => '8.3.2',
- 'compose' => '3.7.2',
- 'core-data' => '2.7.5',
- 'data-controls' => '1.3.4',
- 'data' => '4.9.2',
- 'date' => '3.5.0',
- 'deprecated' => '2.6.1',
- 'dom-ready' => '2.5.1',
- 'dom' => '2.5.2',
- 'edit-post' => '3.8.6',
- 'editor' => '9.7.6',
- 'element' => '2.8.2',
- 'escape-html' => '1.5.1',
- 'format-library' => '1.9.5',
- 'hooks' => '2.6.0',
- 'html-entities' => '2.5.0',
- 'i18n' => '3.6.1',
- 'is-shallow-equal' => '1.6.1',
- 'keycodes' => '2.6.2',
- 'list-reusable-blocks' => '1.8.4',
- 'media-utils' => '1.2.4',
- 'notices' => '1.8.2',
- 'nux' => '3.7.2',
- 'plugins' => '2.7.2',
- 'priority-queue' => '1.3.1',
- 'redux-routine' => '3.6.2',
- 'rich-text' => '3.7.2',
- 'shortcode' => '2.4.1',
- 'server-side-render' => '1.3.4',
- 'token-list' => '1.6.1',
- 'url' => '2.8.2',
- 'viewport' => '2.8.2',
- 'wordcount' => '2.6.2',
- );
-
- $packages_dependencies = array(
- 'a11y' => array(
- 'wp-dom-ready',
- 'wp-polyfill',
- ),
- 'annotations' => array(
- 'lodash',
- 'wp-data',
- 'wp-hooks',
- 'wp-i18n',
- 'wp-polyfill',
- 'wp-rich-text',
- ),
- 'api-fetch' => array(
- 'wp-i18n',
- 'wp-polyfill',
- 'wp-url',
- ),
- 'autop' => array(
- 'wp-polyfill',
- ),
- 'blob' => array(
- 'wp-polyfill',
- ),
- 'block-editor' => array(
- 'lodash',
- 'wp-a11y',
- 'wp-blob',
- 'wp-blocks',
- 'wp-components',
- 'wp-compose',
- 'wp-data',
- 'wp-deprecated',
- 'wp-dom',
- 'wp-element',
- 'wp-hooks',
- 'wp-html-entities',
- 'wp-i18n',
- 'wp-is-shallow-equal',
- 'wp-keycodes',
- 'wp-polyfill',
- 'wp-rich-text',
- 'wp-token-list',
- 'wp-url',
- 'wp-viewport',
- 'wp-wordcount',
- ),
- 'block-library' => array(
- 'editor',
- 'lodash',
- 'moment',
- 'wp-a11y',
- 'wp-api-fetch',
- 'wp-autop',
- 'wp-blob',
- 'wp-block-editor',
- 'wp-blocks',
- 'wp-components',
- 'wp-compose',
- 'wp-core-data',
- 'wp-data',
- 'wp-date',
- 'wp-deprecated',
- 'wp-editor',
- 'wp-element',
- 'wp-i18n',
- 'wp-is-shallow-equal',
- 'wp-keycodes',
- 'wp-polyfill',
- 'wp-rich-text',
- 'wp-server-side-render',
- 'wp-url',
- 'wp-viewport',
- ),
- 'block-serialization-default-parser' => array(
- 'wp-polyfill',
- ),
- 'blocks' => array(
- 'lodash',
- 'wp-autop',
- 'wp-blob',
- 'wp-block-serialization-default-parser',
- 'wp-compose',
- 'wp-data',
- 'wp-dom',
- 'wp-element',
- 'wp-hooks',
- 'wp-html-entities',
- 'wp-i18n',
- 'wp-is-shallow-equal',
- 'wp-polyfill',
- 'wp-shortcode',
- ),
- 'components' => array(
- 'lodash',
- 'moment',
- 'wp-a11y',
- 'wp-compose',
- 'wp-deprecated',
- 'wp-dom',
- 'wp-element',
- 'wp-hooks',
- 'wp-i18n',
- 'wp-is-shallow-equal',
- 'wp-keycodes',
- 'wp-polyfill',
- 'wp-rich-text',
- ),
- 'compose' => array(
- 'lodash',
- 'wp-element',
- 'wp-is-shallow-equal',
- 'wp-polyfill',
- ),
- 'core-data' => array(
- 'lodash',
- 'wp-api-fetch',
- 'wp-data',
- 'wp-deprecated',
- 'wp-is-shallow-equal',
- 'wp-polyfill',
- 'wp-url',
- ),
- 'data' => array(
- 'lodash',
- 'wp-compose',
- 'wp-deprecated',
- 'wp-element',
- 'wp-is-shallow-equal',
- 'wp-polyfill',
- 'wp-priority-queue',
- 'wp-redux-routine',
- ),
- 'data-controls' => array(
- 'wp-api-fetch',
- 'wp-data',
- 'wp-polyfill',
- ),
- 'date' => array(
- 'moment',
- 'wp-polyfill',
- ),
- 'deprecated' => array(
- 'wp-hooks',
- 'wp-polyfill',
- ),
- 'dom' => array(
- 'lodash',
- 'wp-polyfill',
- ),
- 'dom-ready' => array(
- 'wp-polyfill',
- ),
- 'edit-post' => array(
- 'lodash',
- 'postbox',
- 'media-models',
- 'media-views',
- 'wp-a11y',
- 'wp-api-fetch',
- 'wp-block-editor',
- 'wp-block-library',
- 'wp-blocks',
- 'wp-components',
- 'wp-compose',
- 'wp-core-data',
- 'wp-data',
- 'wp-dom-ready',
- 'wp-editor',
- 'wp-element',
- 'wp-hooks',
- 'wp-i18n',
- 'wp-keycodes',
- 'wp-media-utils',
- 'wp-notices',
- 'wp-nux',
- 'wp-plugins',
- 'wp-polyfill',
- 'wp-url',
- 'wp-viewport',
- ),
- 'editor' => array(
- 'lodash',
- 'wp-api-fetch',
- 'wp-autop',
- 'wp-block-editor',
- 'wp-blocks',
- 'wp-components',
- 'wp-compose',
- 'wp-core-data',
- 'wp-data',
- 'wp-data-controls',
- 'wp-date',
- 'wp-deprecated',
- 'wp-element',
- 'wp-hooks',
- 'wp-html-entities',
- 'wp-i18n',
- 'wp-is-shallow-equal',
- 'wp-keycodes',
- 'wp-media-utils',
- 'wp-notices',
- 'wp-nux',
- 'wp-polyfill',
- 'wp-rich-text',
- 'wp-server-side-render',
- 'wp-url',
- 'wp-viewport',
- 'wp-wordcount',
- ),
- 'element' => array(
- 'lodash',
- 'react',
- 'react-dom',
- 'wp-escape-html',
- 'wp-polyfill',
- ),
- 'escape-html' => array(
- 'wp-polyfill',
- ),
- 'format-library' => array(
- 'lodash',
- 'wp-block-editor',
- 'wp-components',
- 'wp-dom',
- 'wp-element',
- 'wp-html-entities',
- 'wp-i18n',
- 'wp-keycodes',
- 'wp-polyfill',
- 'wp-rich-text',
- 'wp-url',
- ),
- 'hooks' => array(
- 'wp-polyfill',
- ),
- 'html-entities' => array(
- 'wp-polyfill',
- ),
- 'i18n' => array(
- 'wp-polyfill',
- ),
- 'is-shallow-equal' => array(
- 'wp-polyfill',
- ),
- 'keycodes' => array(
- 'lodash',
- 'wp-i18n',
- 'wp-polyfill',
- ),
- 'list-reusable-blocks' => array(
- 'lodash',
- 'wp-api-fetch',
- 'wp-components',
- 'wp-compose',
- 'wp-element',
- 'wp-i18n',
- 'wp-polyfill',
- ),
- 'media-utils' => array(
- 'lodash',
- 'wp-api-fetch',
- 'wp-blob',
- 'wp-element',
- 'wp-i18n',
- 'wp-polyfill',
- ),
- 'notices' => array(
- 'lodash',
- 'wp-a11y',
- 'wp-data',
- 'wp-polyfill',
- ),
- 'nux' => array(
- 'lodash',
- 'wp-components',
- 'wp-compose',
- 'wp-data',
- 'wp-element',
- 'wp-i18n',
- 'wp-polyfill',
- ),
- 'plugins' => array(
- 'lodash',
- 'wp-compose',
- 'wp-element',
- 'wp-hooks',
- 'wp-polyfill',
- ),
- 'priority-queue' => array(
- 'wp-polyfill',
- ),
- 'redux-routine' => array(
- 'lodash',
- 'wp-polyfill',
- ),
- 'rich-text' => array(
- 'lodash',
- 'wp-compose',
- 'wp-data',
- 'wp-element',
- 'wp-escape-html',
- 'wp-hooks',
- 'wp-is-shallow-equal',
- 'wp-keycodes',
- 'wp-polyfill',
- ),
- 'server-side-render' => array(
- 'lodash',
- 'wp-api-fetch',
- 'wp-components',
- 'wp-data',
- 'wp-deprecated',
- 'wp-element',
- 'wp-i18n',
- 'wp-polyfill',
- 'wp-url',
- ),
- 'shortcode' => array(
- 'lodash',
- 'wp-polyfill',
- ),
- 'token-list' => array(
- 'lodash',
- 'wp-polyfill',
- ),
- 'url' => array(
- 'wp-polyfill',
- ),
- 'viewport' => array(
- 'lodash',
- 'wp-compose',
- 'wp-data',
- 'wp-polyfill',
- ),
- 'wordcount' => array(
- 'lodash',
- 'wp-polyfill',
- ),
- );
-
- $package_translations = array(
- 'api-fetch',
- 'blocks',
- 'block-editor',
- 'block-library',
- 'components',
- 'edit-post',
- 'editor',
- 'format-library',
- 'keycodes',
- 'list-reusable-blocks',
- 'nux',
- );
-
- foreach ( $packages_dependencies as $package => $dependencies ) {
- $handle = 'wp-' . $package;
- $path = "/wp-includes/js/dist/$package$suffix.js";
- $version = $packages_versions[ $package ];
-
- $scripts->add( $handle, $path, $dependencies, $version, 1 );
-
- if ( in_array( $package, $package_translations, true ) ) {
- $scripts->set_translations( $handle );
- }
- }
-}
-
-/**
- * Adds inline scripts required for the WordPress JavaScript packages.
- *
- * @since 5.0.0
- *
- * @param WP_Scripts $scripts WP_Scripts object.
- */
-function wp_default_packages_inline_scripts( &$scripts ) {
- global $wp_locale;
-
- if ( isset( $scripts->registered['wp-api-fetch'] ) ) {
- $scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks';
- }
- $scripts->add_inline_script(
- 'wp-api-fetch',
- sprintf(
- 'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );',
- esc_url_raw( get_rest_url() )
- ),
- 'after'
- );
- $scripts->add_inline_script(
- 'wp-api-fetch',
- implode(
- "\n",
- array(
- sprintf(
- 'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );',
- ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' )
- ),
- 'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );',
- 'wp.apiFetch.use( wp.apiFetch.mediaUploadMiddleware );',
- sprintf(
- 'wp.apiFetch.nonceEndpoint = "%s";',
- admin_url( 'admin-ajax.php?action=rest-nonce' )
- ),
- )
- ),
- 'after'
- );
- $scripts->add_inline_script(
- 'wp-data',
- implode(
- "\n",
- array(
- '( function() {',
- ' var userId = ' . get_current_user_ID() . ';',
- ' var storageKey = "WP_DATA_USER_" + userId;',
- ' wp.data',
- ' .use( wp.data.plugins.persistence, { storageKey: storageKey } );',
- ' wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );',
- '} )();',
- )
- )
- );
-
- $scripts->add_inline_script(
- 'wp-date',
- sprintf(
- 'wp.date.setSettings( %s );',
- wp_json_encode(
- array(
- 'l10n' => array(
- 'locale' => get_user_locale(),
- 'months' => array_values( $wp_locale->month ),
- 'monthsShort' => array_values( $wp_locale->month_abbrev ),
- 'weekdays' => array_values( $wp_locale->weekday ),
- 'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
- 'meridiem' => (object) $wp_locale->meridiem,
- 'relative' => array(
- /* translators: %s: Duration. */
- 'future' => __( '%s from now' ),
- /* translators: %s: Duration. */
- 'past' => __( '%s ago' ),
- ),
- ),
- 'formats' => array(
- /* translators: Time format, see https://secure.php.net/date */
- 'time' => get_option( 'time_format', __( 'g:i a' ) ),
- /* translators: Date format, see https://secure.php.net/date */
- 'date' => get_option( 'date_format', __( 'F j, Y' ) ),
- /* translators: Date/Time format, see https://secure.php.net/date */
- 'datetime' => __( 'F j, Y g:i a' ),
- /* translators: Abbreviated date/time format, see https://secure.php.net/date */
- 'datetimeAbbreviated' => __( 'M j, Y g:i a' ),
- ),
- 'timezone' => array(
- 'offset' => get_option( 'gmt_offset', 0 ),
- 'string' => get_option( 'timezone_string', 'UTC' ),
- ),
- )
- )
- ),
- 'after'
- );
-
- // Loading the old editor and its config to ensure the classic block works as expected.
- $scripts->add_inline_script(
- 'editor',
- 'window.wp.oldEditor = window.wp.editor;',
- 'after'
- );
-}
-
-/**
- * Adds inline scripts required for the TinyMCE in the block editor.
- *
- * These TinyMCE init settings are used to extend and override the default settings
- * from `_WP_Editors::default_settings()` for the Classic block.
- *
- * @since 5.0.0
- *
- * @global WP_Scripts $wp_scripts
- */
-function wp_tinymce_inline_scripts() {
- global $wp_scripts;
-
- /** This filter is documented in wp-includes/class-wp-editor.php */
- $editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' );
-
- $tinymce_plugins = array(
- 'charmap',
- 'colorpicker',
- 'hr',
- 'lists',
- 'media',
- 'paste',
- 'tabfocus',
- 'textcolor',
- 'fullscreen',
- 'wordpress',
- 'wpautoresize',
- 'wpeditimage',
- 'wpemoji',
- 'wpgallery',
- 'wplink',
- 'wpdialogs',
- 'wptextpattern',
- 'wpview',
- );
-
- /* This filter is documented in wp-includes/class-wp-editor.php */
- $tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' );
- $tinymce_plugins = array_unique( $tinymce_plugins );
-
- $disable_captions = false;
- // Runs after `tiny_mce_plugins` but before `mce_buttons`.
- /** This filter is documented in wp-admin/includes/media.php */
- if ( apply_filters( 'disable_captions', '' ) ) {
- $disable_captions = true;
- }
-
- $toolbar1 = array(
- 'formatselect',
- 'bold',
- 'italic',
- 'bullist',
- 'numlist',
- 'blockquote',
- 'alignleft',
- 'aligncenter',
- 'alignright',
- 'link',
- 'unlink',
- 'wp_more',
- 'spellchecker',
- 'wp_add_media',
- 'wp_adv',
- );
-
- /* This filter is documented in wp-includes/class-wp-editor.php */
- $toolbar1 = apply_filters( 'mce_buttons', $toolbar1, 'classic-block' );
-
- $toolbar2 = array(
- 'strikethrough',
- 'hr',
- 'forecolor',
- 'pastetext',
- 'removeformat',
- 'charmap',
- 'outdent',
- 'indent',
- 'undo',
- 'redo',
- 'wp_help',
- );
-
- /* This filter is documented in wp-includes/class-wp-editor.php */
- $toolbar2 = apply_filters( 'mce_buttons_2', $toolbar2, 'classic-block' );
- /* This filter is documented in wp-includes/class-wp-editor.php */
- $toolbar3 = apply_filters( 'mce_buttons_3', array(), 'classic-block' );
- /* This filter is documented in wp-includes/class-wp-editor.php */
- $toolbar4 = apply_filters( 'mce_buttons_4', array(), 'classic-block' );
- /* This filter is documented in wp-includes/class-wp-editor.php */
- $external_plugins = apply_filters( 'mce_external_plugins', array(), 'classic-block' );
-
- $tinymce_settings = array(
- 'plugins' => implode( ',', $tinymce_plugins ),
- 'toolbar1' => implode( ',', $toolbar1 ),
- 'toolbar2' => implode( ',', $toolbar2 ),
- 'toolbar3' => implode( ',', $toolbar3 ),
- 'toolbar4' => implode( ',', $toolbar4 ),
- 'external_plugins' => wp_json_encode( $external_plugins ),
- 'classic_block_editor' => true,
- );
-
- if ( $disable_captions ) {
- $tinymce_settings['wpeditimage_disable_captions'] = true;
- }
-
- if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) {
- array_merge( $tinymce_settings, $editor_settings['tinymce'] );
- }
-
- /* This filter is documented in wp-includes/class-wp-editor.php */
- $tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' );
-
- // Do "by hand" translation from PHP array to js object.
- // Prevents breakage in some custom settings.
- $init_obj = '';
- foreach ( $tinymce_settings as $key => $value ) {
- if ( is_bool( $value ) ) {
- $val = $value ? 'true' : 'false';
- $init_obj .= $key . ':' . $val . ',';
- continue;
- } elseif ( ! empty( $value ) && is_string( $value ) && (
- ( '{' === $value[0] && '}' === $value[ strlen( $value ) - 1 ] ) ||
- ( '[' === $value[0] && ']' === $value[ strlen( $value ) - 1 ] ) ||
- preg_match( '/^\(?function ?\(/', $value ) ) ) {
- $init_obj .= $key . ':' . $value . ',';
- continue;
- }
- $init_obj .= $key . ':"' . $value . '",';
- }
-
- $init_obj = '{' . trim( $init_obj, ' ,' ) . '}';
-
- $script = 'window.wpEditorL10n = {
- tinymce: {
- baseURL: ' . wp_json_encode( includes_url( 'js/tinymce' ) ) . ',
- suffix: ' . ( SCRIPT_DEBUG ? '""' : '".min"' ) . ',
- settings: ' . $init_obj . ',
- }
- }';
-
- $wp_scripts->add_inline_script( 'wp-block-library', $script, 'before' );
-}
-
-/**
- * Registers all the WordPress packages scripts.
- *
- * @since 5.0.0
- *
- * @param WP_Scripts $scripts WP_Scripts object.
- */
-function wp_default_packages( &$scripts ) {
- wp_default_packages_vendor( $scripts );
- wp_register_tinymce_scripts( $scripts );
- wp_default_packages_scripts( $scripts );
-
- if ( did_action( 'init' ) ) {
- wp_default_packages_inline_scripts( $scripts );
- }
-}
-
-/**
- * Returns the suffix that can be used for the scripts.
- *
- * There are two suffix types, the normal one and the dev suffix.
- *
- * @since 5.0.0
- *
- * @param string $type The type of suffix to retrieve.
- * @return string The script suffix.
- */
-function wp_scripts_get_suffix( $type = '' ) {
- static $suffixes;
-
- if ( $suffixes === null ) {
- include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
-
- $develop_src = false !== strpos( $wp_version, '-src' );
-
- if ( ! defined( 'SCRIPT_DEBUG' ) ) {
- define( 'SCRIPT_DEBUG', $develop_src );
- }
- $suffix = SCRIPT_DEBUG ? '' : '.min';
- $dev_suffix = $develop_src ? '' : '.min';
-
- $suffixes = array(
- 'suffix' => $suffix,
- 'dev_suffix' => $dev_suffix,
- );
- }
-
- if ( $type === 'dev' ) {
- return $suffixes['dev_suffix'];
- }
-
- return $suffixes['suffix'];
-}
-
-/**
- * Register all WordPress scripts.
- *
- * Localizes some of them.
- * args order: `$scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );`
- * when last arg === 1 queues the script for the footer
- *
- * @since 2.6.0
- *
- * @param WP_Scripts $scripts WP_Scripts object.
- */
-function wp_default_scripts( &$scripts ) {
- $suffix = wp_scripts_get_suffix();
- $dev_suffix = wp_scripts_get_suffix( 'dev' );
- $guessurl = site_url();
-
- if ( ! $guessurl ) {
- $guessed_url = true;
- $guessurl = wp_guess_url();
- }
-
- $scripts->base_url = $guessurl;
- $scripts->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : '';
- $scripts->default_version = get_bloginfo( 'version' );
- $scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' );
-
- $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" );
- did_action( 'init' ) && $scripts->localize(
- 'utils',
- 'userSettings',
- array(
- 'url' => (string) SITECOOKIEPATH,
- 'uid' => (string) get_current_user_id(),
- 'time' => (string) time(),
- 'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ),
- )
- );
-
- $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils' ), false, 1 );
- did_action( 'init' ) && $scripts->localize(
- 'common',
- 'commonL10n',
- array(
- 'warnDelete' => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
- 'dismiss' => __( 'Dismiss this notice.' ),
- 'collapseMenu' => __( 'Collapse Main menu' ),
- 'expandMenu' => __( 'Expand Main menu' ),
- )
- );
-
- $scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 );
-
- $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );
-
- $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 );
- did_action( 'init' ) && $scripts->localize(
- 'quicktags',
- 'quicktagsL10n',
- array(
- 'closeAllOpenTags' => __( 'Close all open tags' ),
- 'closeTags' => __( 'close tags' ),
- 'enterURL' => __( 'Enter the URL' ),
- 'enterImageURL' => __( 'Enter the URL of the image' ),
- 'enterImageDescription' => __( 'Enter a description of the image' ),
- 'textdirection' => __( 'text direction' ),
- 'toggleTextdirection' => __( 'Toggle Editor Text Direction' ),
- 'dfw' => __( 'Distraction-free writing mode' ),
- 'strong' => __( 'Bold' ),
- 'strongClose' => __( 'Close bold tag' ),
- 'em' => __( 'Italic' ),
- 'emClose' => __( 'Close italic tag' ),
- 'link' => __( 'Insert link' ),
- 'blockquote' => __( 'Blockquote' ),
- 'blockquoteClose' => __( 'Close blockquote tag' ),
- 'del' => __( 'Deleted text (strikethrough)' ),
- 'delClose' => __( 'Close deleted text tag' ),
- 'ins' => __( 'Inserted text' ),
- 'insClose' => __( 'Close inserted text tag' ),
- 'image' => __( 'Insert image' ),
- 'ul' => __( 'Bulleted list' ),
- 'ulClose' => __( 'Close bulleted list tag' ),
- 'ol' => __( 'Numbered list' ),
- 'olClose' => __( 'Close numbered list tag' ),
- 'li' => __( 'List item' ),
- 'liClose' => __( 'Close list item tag' ),
- 'code' => __( 'Code' ),
- 'codeClose' => __( 'Close code tag' ),
- 'more' => __( 'Insert Read More tag' ),
- )
- );
-
- $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array( 'prototype' ), '3517m' );
-
- $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 );
-
- $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), false, 1 );
-
- // Back-compat for old DFW. To-do: remove at the end of 2016.
- $scripts->add( 'wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1 );
-
- $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery' ), false, 1 );
- did_action( 'init' ) && $scripts->localize(
- 'wp-ajax-response',
- 'wpAjax',
- array(
- 'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
- 'broken' => __( 'Something went wrong.' ),
- )
- );
-
- $scripts->add( 'wp-api-request', "/wp-includes/js/api-request$suffix.js", array( 'jquery' ), false, 1 );
- // `wpApiSettings` is also used by `wp-api`, which depends on this script.
- did_action( 'init' ) && $scripts->localize(
- 'wp-api-request',
- 'wpApiSettings',
- array(
- 'root' => esc_url_raw( get_rest_url() ),
- 'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ),
- 'versionString' => 'wp/v2/',
- )
- );
-
- $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 );
- did_action( 'init' ) && $scripts->localize(
- 'wp-pointer',
- 'wpPointerL10n',
- array(
- 'dismiss' => __( 'Dismiss' ),
- )
- );
-
- $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array( 'heartbeat' ), false, 1 );
-
- $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array( 'jquery', 'wp-hooks' ), false, 1 );
- did_action( 'init' ) && $scripts->localize(
- 'heartbeat',
- 'heartbeatSettings',
- /**
- * Filters the Heartbeat settings.
- *
- * @since 3.6.0
- *
- * @param array $settings Heartbeat settings array.
- */
- apply_filters( 'heartbeat_settings', array() )
- );
-
- $scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array( 'heartbeat' ), false, 1 );
- did_action( 'init' ) && $scripts->localize(
- 'wp-auth-check',
- 'authcheckL10n',
- array(
- 'beforeunload' => __( 'Your session has expired. You can log in again from this page or go to the login page.' ),
-
- /**
- * Filters the authentication check interval.
- *
- * @since 3.6.0
- *
- * @param int $interval The interval in which to check a user's authentication.
- * Default 3 minutes in seconds, or 180.
- */
- 'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ),
- )
- );
-
- $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 );
-
- // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source.
- $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' );
- $scripts->add( 'scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array( 'prototype' ), '1.9.0' );
- $scripts->add( 'scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array( 'scriptaculous-root' ), '1.9.0' );
- $scripts->add( 'scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array( 'scriptaculous-builder', 'scriptaculous-effects' ), '1.9.0' );
- $scripts->add( 'scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array( 'scriptaculous-root' ), '1.9.0' );
- $scripts->add( 'scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array( 'scriptaculous-effects' ), '1.9.0' );
- $scripts->add( 'scriptaculous-sound', 'https://ajax.googlea