注册标准化js / dist / location中的所有WordPress包脚本。
原型
wp_default_packages_scripts( WP_Scripts $scripts )
描述
对于$ scripts->的顺序,请参阅wp_default_scripts。
参数
$scripts
(WP_Scripts)
(Required)
WP_Scripts对象。
源文件
路径:wp-includes/script-loader.php
<?php
...
function wp_default_packages_scripts( &$scripts ) {
$suffix = wp_scripts_get_suffix();
$packages_versions = array(
'api-fetch' => '2.2.5',
'a11y' => '2.0.2',
'annotations' => '1.0.3',
'autop' => '2.0.2',
'blob' => '2.1.0',
'block-library' => '2.2.9',
'block-serialization-default-parser' => '2.0.1',
'blocks' => '6.0.3',
'components' => '7.0.3',
'compose' => '3.0.0',
'core-data' => '2.0.14',
'data' => '4.0.1',
'date' => '3.0.0',
'deprecated' => '2.0.3',
'dom' => '2.0.7',
'dom-ready' => '2.0.2',
'edit-post' => '3.1.4',
'editor' => '9.0.4',
'element' => '2.1.8',
'escape-html' => '1.0.1',
'format-library' => '1.2.7',
'hooks' => '2.0.3',
'html-entities' => '2.0.3',
'i18n' => '3.1.0',
'is-shallow-equal' => '1.1.4',
'keycodes' => '2.0.5',
'list-reusable-blocks' => '1.1.16',
'notices' => '1.1.0',
'nux' => '3.0.4',
'plugins' => '2.0.9',
'redux-routine' => '3.0.3',
'rich-text' => '3.0.2',
'shortcode' => '2.0.2',
'token-list' => '1.1.0',
'url' => '2.3.1',
'viewport' => '2.0.12',
'wordcount' => '2.0.3',
);
$packages_dependencies = array(
'api-fetch' => array( 'wp-polyfill', 'wp-hooks', 'wp-i18n', 'wp-url' ),
'a11y' => array( 'wp-dom-ready', 'wp-polyfill' ),
'annotations' => array(
'wp-data',
'wp-hooks',
'wp-i18n',
'wp-polyfill',
'wp-rich-text',
),
'autop' => array( 'wp-polyfill' ),
'blob' => array( 'wp-polyfill' ),
'blocks' => array(
'wp-autop',
'wp-blob',
'wp-block-serialization-default-parser',
'wp-data',
'wp-dom',
'wp-element',
'wp-hooks',
'wp-html-entities',
'wp-i18n',
'wp-is-shallow-equal',
'wp-polyfill',
'wp-shortcode',
'lodash',
),
'block-library' => array(
'editor',
'lodash',
'wp-api-fetch',
'wp-autop',
'wp-blob',
'wp-blocks',
'wp-components',
'wp-compose',
'wp-core-data',
'wp-data',
'wp-date',
'wp-editor',
'wp-element',
'wp-html-entities',
'wp-i18n',
'wp-keycodes',
'wp-polyfill',
'wp-url',
'wp-viewport',
'wp-rich-text',
),
'block-serialization-default-parser' => array(),
'components' => array(
'lodash',
'moment',
'wp-a11y',
'wp-api-fetch',
'wp-compose',
'wp-dom',
'wp-element',
'wp-hooks',
'wp-html-entities',
'wp-i18n',
'wp-is-shallow-equal',
'wp-keycodes',
'wp-polyfill',
'wp-rich-text',
'wp-url',
),
'compose' => array(
'lodash',
'wp-element',
'wp-is-shallow-equal',
'wp-polyfill'
),
'core-data' => array( 'wp-data', 'wp-api-fetch', 'wp-polyfill', 'wp-url', 'lodash' ),
'data' => array(
'lodash',
'wp-compose',
'wp-element',
'wp-is-shallow-equal',
'wp-polyfill',
'wp-redux-routine',
),
'date' => array( 'moment', 'wp-polyfill' ),
'deprecated' => array( 'wp-polyfill', 'wp-hooks' ),
'dom' => array( 'lodash', 'wp-polyfill', 'wp-tinymce' ),
'dom-ready' => array( 'wp-polyfill' ),
'edit-post' => array(
'jquery',
'lodash',
'postbox',
'media-models',
'media-views',
'wp-a11y',
'wp-api-fetch',
'wp-block-library',
'wp-blocks',
'wp-components',
'wp-compose',
'wp-core-data',
'wp-data',
'wp-dom-ready',
'wp-editor',
'wp-element',
'wp-embed',
'wp-i18n',
'wp-keycodes',
'wp-notices',
'wp-nux',
'wp-plugins',
'wp-polyfill',
'wp-url',
'wp-viewport',
),
'editor' => array(
'jquery',
'lodash',
'wp-tinymce-lists',
'wp-a11y',
'wp-api-fetch',
'wp-blob',
'wp-blocks',
'wp-components',
'wp-compose',
'wp-core-data',
'wp-data',
'wp-date',
'wp-deprecated',
'wp-dom',
'wp-element',
'wp-hooks',
'wp-html-entities',
'wp-i18n',
'wp-is-shallow-equal',
'wp-keycodes',
'wp-notices',
'wp-nux',
'wp-polyfill',
'wp-tinymce',
'wp-token-list',
'wp-url',
'wp-viewport',
'wp-wordcount',
'wp-rich-text',
),
'element' => array( 'wp-polyfill', 'react', 'react-dom', 'lodash', 'wp-escape-html' ),
'escape-html' => array( 'wp-polyfill' ),
'format-library' => array(
'wp-components',
'wp-dom',
'wp-editor',
'wp-element',
'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-polyfill', 'wp-i18n' ),
'list-reusable-blocks' => array(
'lodash',
'wp-api-fetch',
'wp-components',
'wp-compose',
'wp-element',
'wp-i18n',
'wp-polyfill',
),
'notices' => array(
'lodash',
'wp-a11y',
'wp-data',
'wp-polyfill',
),
'nux' => array(
'wp-element',
'lodash',
'wp-components',
'wp-compose',
'wp-data',
'wp-i18n',
'wp-polyfill',
'lodash',
),
'plugins' => array( 'lodash', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-polyfill' ),
'redux-routine' => array( 'wp-polyfill' ),
'rich-text' => array(
'lodash',
'wp-data',
'wp-escape-html',
'wp-polyfill',
),
'shortcode' => array( 'wp-polyfill', 'lodash' ),
'token-list' => array( 'lodash', 'wp-polyfill' ),
'url' => array( 'wp-polyfill' ),
'viewport' => array( 'wp-polyfill', 'wp-element', 'wp-data', 'wp-compose', 'lodash' ),
'wordcount' => array( 'wp-polyfill' ),
);
$package_translations = array(
'api-fetch' => 'default',
'blocks' => 'default',
'block-library' => 'default',
'components' => 'default',
'edit-post' => 'default',
'editor' => 'default',
'format-library' => 'default',
'keycodes' => 'default',
'list-reusable-blocks' => 'default',
'nux' => 'default',
);
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 ( isset( $package_translations[ $package ] ) ) {
$scripts->set_translations( $handle, $package_translations[ $package ] );
}
}
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_default_packages_scripts/