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 Jan 29, 2019
1 parent 4a717ae commit 70078eb
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/[email protected]/umd/react' . $react_suffix . '.js',
array( 'wp-polyfill' )
);
gutenberg_register_vendor_script(
'react-dom',
'https://unpkg.com/[email protected]/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/[email protected]/' . $moment_script,
array()
);
gutenberg_register_vendor_script(
'lodash',
'https://unpkg.com/[email protected]/lodash' . $suffix . '.js'
);
wp_add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
gutenberg_register_vendor_script(
'wp-polyfill-fetch',
'https://unpkg.com/[email protected]/dist/fetch.umd.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-formdata',
'https://unpkg.com/[email protected]/formdata.min.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-node-contains',
'https://unpkg.com/[email protected]/polyfills/Node/prototype/contains/polyfill.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-element-closest',
'https://unpkg.com/[email protected]/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 70078eb

Please sign in to comment.