Skip to content

Commit

Permalink
Plugin: Remove vendor script registration
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Feb 4, 2019
1 parent a1b1eec commit 447fda0
Showing 1 changed file with 4 additions and 88 deletions.
92 changes: 4 additions & 88 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,6 @@ function gutenberg_register_scripts_and_styles() {
global $wp_scripts;

gutenberg_register_vendor_scripts();

wp_add_inline_script(
'wp-polyfill',
wp_get_script_polyfill(
$wp_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',
),
'after'
)
);

gutenberg_register_packages_scripts();

// Inline scripts.
Expand Down Expand Up @@ -245,33 +230,6 @@ function gutenberg_register_scripts_and_styles() {
),
'after'
);
wp_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'
);
// Loading the old editor and its config to ensure the classic block works as expected.
wp_add_inline_script(
'editor',
Expand Down Expand Up @@ -525,52 +483,10 @@ function gutenberg_preload_api_request( $memo, $path ) {
* @since 0.1.0
*/
function gutenberg_register_vendor_scripts() {
$suffix = SCRIPT_DEBUG ? '' : '.min';

// Vendor Scripts.
$react_suffix = ( SCRIPT_DEBUG ? '.development' : '.production' ) . $suffix;

gutenberg_register_vendor_script(
'react',
'https://unpkg.com/react@16.6.3/umd/react' . $react_suffix . '.js',
array( 'wp-polyfill' )
);
gutenberg_register_vendor_script(
'react-dom',
'https://unpkg.com/react-dom@16.6.3/umd/react-dom' . $react_suffix . '.js',
array( 'react' )
);
$moment_script = SCRIPT_DEBUG ? 'moment.js' : 'min/moment.min.js';
gutenberg_register_vendor_script(
'moment',
'https://unpkg.com/moment@2.22.1/' . $moment_script,
array()
);
gutenberg_register_vendor_script(
'lodash',
'https://unpkg.com/lodash@4.17.10/lodash' . $suffix . '.js'
);
wp_add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
gutenberg_register_vendor_script(
'wp-polyfill-fetch',
'https://unpkg.com/whatwg-fetch@3.0.0/dist/fetch.umd.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-formdata',
'https://unpkg.com/formdata-polyfill@3.0.9/formdata.min.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-node-contains',
'https://unpkg.com/polyfill-library@3.26.0-0/polyfills/Node/prototype/contains/polyfill.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-element-closest',
'https://unpkg.com/element-closest@2.0.2/element-closest.js'
);
gutenberg_register_vendor_script(
'wp-polyfill',
'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js'
);
/*
* This function is kept as an empty stub, in case Gutenberg should need to
* explicitly provide a version newer than that provided by core.
*/
}

/**
Expand Down

0 comments on commit 447fda0

Please sign in to comment.