From 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 7 Jan 2020 13:06:14 +0100 Subject: Added wordpress --- srcs/wordpress/wp-includes/script-loader.php | 2945 ++++++++++++++++++++++++++ 1 file changed, 2945 insertions(+) create mode 100644 srcs/wordpress/wp-includes/script-loader.php (limited to 'srcs/wordpress/wp-includes/script-loader.php') diff --git a/srcs/wordpress/wp-includes/script-loader.php b/srcs/wordpress/wp-includes/script-loader.php new file mode 100644 index 0000000..18ba2d4 --- /dev/null +++ b/srcs/wordpress/wp-includes/script-loader.php @@ -0,0 +1,2945 @@ +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( \'