'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
'nextText' => __( 'Next' ),
'prevText' => __( 'Previous' ),
'dayNames' => array_values( $wp_locale->weekday ),
'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ),
'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
'dateFormat' => $datepicker_date_format,
'firstDay' => absint( get_option( 'start_of_week' ) ),
'isRTL' => $wp_locale->is_rtl(),
wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" );
* Localizes community events data that needs to be passed to dashboard.js.
function wp_localize_community_events() {
if ( ! wp_script_is( 'dashboard' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php';
$user_id = get_current_user_id();
$saved_location = get_user_option( 'community-events-location', $user_id );
$saved_ip_address = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false;
$current_ip_address = WP_Community_Events::get_unsafe_client_ip();
* If the user's location is based on their IP address, then update their
* location when their IP address changes. This allows them to see events
* in their current city when travelling. Otherwise, they would always be
* shown events in the city where they were when they first loaded the
* Dashboard, which could have been months or years ago.
if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) {
$saved_location['ip'] = $current_ip_address;
update_user_meta( $user_id, 'community-events-location', $saved_location );
$events_client = new WP_Community_Events( $user_id, $saved_location );
'nonce' => wp_create_nonce( 'community_events' ),
'cache' => $events_client->get_cached_events(),
'time_format' => get_option( 'time_format' ),
* Administration Screen CSS for changing the styles.
* If installing the 'wp-admin/' directory will be replaced with './'.
* The $_wp_admin_css_colors global manages the Administration Screens CSS
* stylesheet that is loaded. The option that is set is 'admin_color' and is the
* color and key for the array. The value for the color key is an object with
* a 'url' parameter that has the URL path to the CSS file.
* The query from $src parameter will be appended to the URL that is given from
* the $_wp_admin_css_colors array value URL.
* @global array $_wp_admin_css_colors
* @param string $src Source URL.
* @param string $handle Either 'colors' or 'colors-rtl'.
* @return string|false URL path to CSS stylesheet for Administration Screens.
function wp_style_loader_src( $src, $handle ) {
global $_wp_admin_css_colors;
return preg_replace( '#^wp-admin/#', './', $src );
if ( 'colors' === $handle ) {
$color = get_user_option( 'admin_color' );
if ( empty( $color ) || ! isset( $_wp_admin_css_colors[ $color ] ) ) {
$color = $_wp_admin_css_colors[ $color ];
$parsed = parse_url( $src );
if ( isset( $parsed['query'] ) && $parsed['query'] ) {
wp_parse_str( $parsed['query'], $qv );
$url = add_query_arg( $qv, $url );
* Prints the script queue in the HTML head on admin pages.
* Postpones the scripts that were queued for the footer.
* print_footer_scripts() is called in the footer to print these scripts.
* @see wp_print_scripts()
* @global bool $concatenate_scripts
* @return string[] Handles of the scripts that were printed.
function print_head_scripts() {
global $concatenate_scripts;
if ( ! did_action( 'wp_print_scripts' ) ) {
/** This action is documented in wp-includes/functions.wp-scripts.php */
do_action( 'wp_print_scripts' );
$wp_scripts = wp_scripts();
script_concat_settings();
$wp_scripts->do_concat = $concatenate_scripts;
$wp_scripts->do_head_items();
* Filters whether to print the head scripts.
* @param bool $print Whether to print the head scripts. Default true.
if ( apply_filters( 'print_head_scripts', true ) ) {
return $wp_scripts->done;
* Prints the scripts that were queued for the footer or too late for the HTML head.
* @global WP_Scripts $wp_scripts
* @global bool $concatenate_scripts
* @return string[] Handles of the scripts that were printed.
function print_footer_scripts() {
global $wp_scripts, $concatenate_scripts;
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
return array(); // No need to run if not instantiated.
script_concat_settings();
$wp_scripts->do_concat = $concatenate_scripts;
$wp_scripts->do_footer_items();
* Filters whether to print the footer scripts.
* @param bool $print Whether to print the footer scripts. Default true.
if ( apply_filters( 'print_footer_scripts', true ) ) {
return $wp_scripts->done;
* Prints scripts (internal use only)
* @global WP_Scripts $wp_scripts
* @global bool $compress_scripts
function _print_scripts() {
global $wp_scripts, $compress_scripts;
$zip = $compress_scripts ? 1 : 0;
if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) {
$concat = trim( $wp_scripts->concat, ', ' );
$type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'";
if ( ! empty( $wp_scripts->print_code ) ) {
echo "\n<script{$type_attr}>\n";
echo "/* <![CDATA[ */\n"; // Not needed in HTML 5.
echo $wp_scripts->print_code;
$concat = str_split( $concat, 128 );
foreach ( $concat as $key => $chunk ) {
$concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
$src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version;
echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n";
if ( ! empty( $wp_scripts->print_html ) ) {
echo $wp_scripts->print_html;
* Prints the script queue in the HTML head on the front end.
* Postpones the scripts that were queued for the footer.
* wp_print_footer_scripts() is called in the footer to print these scripts.
* @global WP_Scripts $wp_scripts
* @return string[] Handles of the scripts that were printed.
function wp_print_head_scripts() {
if ( ! did_action( 'wp_print_scripts' ) ) {
/** This action is documented in wp-includes/functions.wp-scripts.php */
do_action( 'wp_print_scripts' );
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
return array(); // No need to run if nothing is queued.
return print_head_scripts();
* Private, for use in *_footer_scripts hooks
function _wp_footer_scripts() {
* Hooks to print the scripts and styles in the footer.
function wp_print_footer_scripts() {
* Fires when footer scripts are printed.
do_action( 'wp_print_footer_scripts' );
* Wrapper for do_action( 'wp_enqueue_scripts' ).
* Allows plugins to queue scripts for the front end using wp_enqueue_script().
* Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
function wp_enqueue_scripts() {
* Fires when scripts and styles are enqueued.
do_action( 'wp_enqueue_scripts' );
* Prints the styles queue in the HTML head on admin pages.
* @global bool $concatenate_scripts
* @return string[] Handles of the styles that were printed.
function print_admin_styles() {
global $concatenate_scripts;
$wp_styles = wp_styles();
script_concat_settings();
$wp_styles->do_concat = $concatenate_scripts;
$wp_styles->do_items( false );
* Filters whether to print the admin styles.
* @param bool $print Whether to print the admin styles. Default true.
if ( apply_filters( 'print_admin_styles', true ) ) {
* Prints the styles that were queued too late for the HTML head.
* @global WP_Styles $wp_styles
* @global bool $concatenate_scripts
function print_late_styles() {
global $wp_styles, $concatenate_scripts;
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
script_concat_settings();
$wp_styles->do_concat = $concatenate_scripts;
$wp_styles->do_footer_items();
* Filters whether to print the styles queued too late for the HTML head.
* @param bool $print Whether to print the 'late' styles. Default true.
if ( apply_filters( 'print_late_styles', true ) ) {
* Prints styles (internal use only).
* @global bool $compress_css
function _print_styles() {
$wp_styles = wp_styles();
$zip = $compress_css ? 1 : 0;
if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) {
$concat = trim( $wp_styles->concat, ', ' );
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
$dir = $wp_styles->text_direction;
$ver = $wp_styles->default_version;
$concat = str_split( $concat, 128 );
foreach ( $concat as $key => $chunk ) {
$concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
$href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver;
echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n";
if ( ! empty( $wp_styles->print_code ) ) {
echo "<style{$type_attr}>\n";
echo $wp_styles->print_code;
if ( ! empty( $wp_styles->print_html ) ) {
echo $wp_styles->print_html;
* Determines the concatenation and compression settings for scripts and styles.
* @global bool $concatenate_scripts
* @global bool $compress_scripts
* @global bool $compress_css
function script_concat_settings() {
global $concatenate_scripts, $compress_scripts, $compress_css;
$compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) );
$can_compress_scripts = ! wp_installing() && get_site_option( 'can_compress_scripts' );
if ( ! isset( $concatenate_scripts ) ) {
$concatenate_scripts = defined( 'CONCATENATE_SCRIPTS' ) ? CONCATENATE_SCRIPTS : true;
if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
$concatenate_scripts = false;
if ( ! isset( $compress_scripts ) ) {
$compress_scripts = defined( 'COMPRESS_SCRIPTS' ) ? COMPRESS_SCRIPTS : true;
if ( $compress_scripts && ( ! $can_compress_scripts || $compressed_output ) ) {
$compress_scripts = false;
if ( ! isset( $compress_css ) ) {
$compress_css = defined( 'COMPRESS_CSS' ) ? COMPRESS_CSS : true;
if ( $compress_css && ( ! $can_compress_scripts || $compressed_output ) ) {
* Handles the enqueueing of block scripts and styles that are common to both
* the editor and the front-end.
function wp_common_block_scripts_and_styles() {
if ( is_admin() && ! wp_should_load_block_editor_scripts_and_styles() ) {
wp_enqueue_style( 'wp-block-library' );
if ( current_theme_supports( 'wp-block-styles' ) && ! wp_should_load_separate_core_block_assets() ) {
wp_enqueue_style( 'wp-block-library-theme' );
* Fires after enqueuing block assets for both editor and front-end.
* Call `add_action` on any hook before 'wp_enqueue_scripts'.
* In the function call you supply, simply use `wp_enqueue_script` and
* `wp_enqueue_style` to add your functionality to the Gutenberg editor.
do_action( 'enqueue_block_assets' );
* Applies a filter to the list of style nodes that comes from WP_Theme_JSON::get_style_nodes().
* This particular filter removes all of the blocks from the array.
* We want WP_Theme_JSON to be ignorant of the implementation details of how the CSS is being used.
* This filter allows us to modify the output of WP_Theme_JSON depending on whether or not we are
* loading separate assets, without making the class aware of that detail.
* @param array $nodes The nodes to filter.
* @return array A filtered array of style nodes.
function wp_filter_out_block_nodes( $nodes ) {