prev_next'] && $current && 1 < $current ) : $link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] ); $link = str_replace( '%#%', $current - 1, $link ); if ( $add_args ) { $link = add_query_arg( $add_args, $link ); } $link .= $args['add_fragment']; $page_links[] = sprintf( '', /** * Filters the paginated links for the given archive pages. * * @since 3.0.0 * * @param string $link The paginated link URL. */ esc_url( apply_filters( 'paginate_links', $link ) ), $args['prev_text'] ); endif; for ( $n = 1; $n <= $total; $n++ ) : if ( $n == $current ) : $page_links[] = sprintf( '%s', esc_attr( $args['aria_current'] ), $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] ); $dots = true; else : if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) : $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); $link = str_replace( '%#%', $n, $link ); if ( $add_args ) { $link = add_query_arg( $add_args, $link ); } $link .= $args['add_fragment']; $page_links[] = sprintf( '%s', /** This filter is documented in wp-includes/general-template.php */ esc_url( apply_filters( 'paginate_links', $link ) ), $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] ); $dots = true; elseif ( $dots && ! $args['show_all'] ) : $page_links[] = '' . __( '…' ) . ''; $dots = false; endif; endif; endfor; if ( $args['prev_next'] && $current && $current < $total ) : $link = str_replace( '%_%', $args['format'], $args['base'] ); $link = str_replace( '%#%', $current + 1, $link ); if ( $add_args ) { $link = add_query_arg( $add_args, $link ); } $link .= $args['add_fragment']; $page_links[] = sprintf( '', /** This filter is documented in wp-includes/general-template.php */ esc_url( apply_filters( 'paginate_links', $link ) ), $args['next_text'] ); endif; switch ( $args['type'] ) { case 'array': return $page_links; case 'list': $r .= "\n"; break; default: $r = implode( "\n", $page_links ); break; } /** * Filters the HTML output of paginated links for archives. * * @since 5.7.0 * * @param string $r HTML output. * @param array $args An array of arguments. See paginate_links() * for information on accepted arguments. */ $r = apply_filters( 'paginate_links_output', $r, $args ); return $r; } /** * Registers an admin color scheme css file. * * Allows a plugin to register a new admin color scheme. For example: * * wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array( * '#07273E', '#14568A', '#D54E21', '#2683AE' * ) ); * * @since 2.5.0 * * @global array $_wp_admin_css_colors * * @param string $key The unique key for this theme. * @param string $name The name of the theme. * @param string $url The URL of the CSS file containing the color scheme. * @param array $colors Optional. An array of CSS color definition strings which are used * to give the user a feel for the theme. * @param array $icons { * Optional. CSS color definitions used to color any SVG icons. * * @type string $base SVG icon base color. * @type string $focus SVG icon color on focus. * @type string $current SVG icon color of current admin menu link. * } */ function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) { global $_wp_admin_css_colors; if ( ! isset( $_wp_admin_css_colors ) ) { $_wp_admin_css_colors = array(); } $_wp_admin_css_colors[ $key ] = (object) array( 'name' => $name, 'url' => $url, 'colors' => $colors, 'icon_colors' => $icons, ); } /** * Registers the default admin color schemes. * * Registers the initial set of eight color schemes in the Profile section * of the dashboard which allows for styling the admin menu and toolbar. * * @see wp_admin_css_color() * * @since 3.0.0 */ function register_admin_color_schemes() { $suffix = is_rtl() ? '-rtl' : ''; $suffix .= SCRIPT_DEBUG ? '' : '.min'; wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ), false, array( '#1d2327', '#2c3338', '#2271b1', '#72aee6' ), array( 'base' => '#a7aaad', 'focus' => '#72aee6', 'current' => '#fff', ) ); wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ), admin_url( "css/colors/light/colors$suffix.css" ), array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ), array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc', ) ); wp_admin_css_color( 'modern', _x( 'Modern', 'admin color scheme' ), admin_url( "css/colors/modern/colors$suffix.css" ), array( '#1e1e1e', '#3858e9', '#33f078' ), array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ), admin_url( "css/colors/blue/colors$suffix.css" ), array( '#096484', '#4796b3', '#52accc', '#74B6CE' ), array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ), admin_url( "css/colors/midnight/colors$suffix.css" ), array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ), array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ), admin_url( "css/colors/sunrise/colors$suffix.css" ), array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ), array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ), admin_url( "css/colors/ectoplasm/colors$suffix.css" ), array( '#413256', '#523f6d', '#a3b745', '#d46f15' ), array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ), admin_url( "css/colors/ocean/colors$suffix.css" ), array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ), array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ), admin_url( "css/colors/coffee/colors$suffix.css" ), array( '#46403c', '#59524c', '#c7a589', '#9ea476' ), array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff', ) ); } /** * Displays the URL of a WordPress admin CSS file. * * @see WP_Styles::_css_href() and its {@see 'style_loader_src'} filter. * * @since 2.3.0 * * @param string $file file relative to wp-admin/ without its ".css" extension. * @return string */ function wp_admin_css_uri( $file = 'wp-admin' ) { if ( defined( 'WP_INSTALLING' ) ) { $_file = "./$file.css"; } else { $_file = admin_url( "$file.css" ); } $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file ); /** * Filters the URI of a WordPress admin CSS file. * * @since 2.3.0 * * @param string $_file Relative path to the file with query arguments attached. * @param string $file Relative path to the file, minus its ".css" extension. */ return apply_filters( 'wp_admin_css_uri', $_file, $file ); } /** * Enqueues or directly prints a stylesheet link to the specified CSS file. * * "Intelligently" decides to enqueue or to print the CSS file. If the * {@see 'wp_print_styles'} action has *not* yet been called, the CSS file will be * enqueued. If the {@see 'wp_print_styles'} action has been called, the CSS link will * be printed. Printing may be forced by passing true as the $force_echo * (second) parameter. * * For backward compatibility with WordPress 2.3 calling method: If the $file * (first) parameter does not correspond to a registered CSS file, we assume * $file is a file relative to wp-admin/ without its ".css" extension. A * stylesheet link to that generated URL is printed. * * @since 2.3.0 * * @param string $file Optional. Style handle name or file name (without ".css" extension) relative * to wp-admin/. Defaults to 'wp-admin'. * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. */ function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { // For backward compatibility. $handle = str_starts_with( $file, 'css/' ) ? substr( $file, 4 ) : $file; if ( wp_styles()->query( $handle ) ) { if ( $force_echo || did_action( 'wp_print_styles' ) ) { // We already printed the style queue. Print this one immediately. wp_print_styles( $handle ); } else { // Add to style queue. wp_enqueue_style( $handle ); } return; } $stylesheet_link = sprintf( "\n", esc_url( wp_admin_css_uri( $file ) ) ); /** * Filters the stylesheet link to the specified CSS file. * * If the site is set to display right-to-left, the RTL stylesheet link * will be used instead. * * @since 2.3.0 * @param string $stylesheet_link HTML link element for the stylesheet. * @param string $file Style handle name or filename (without ".css" extension) * relative to wp-admin/. Defaults to 'wp-admin'. */ echo apply_filters( 'wp_admin_css', $stylesheet_link, $file ); if ( function_exists( 'is_rtl' ) && is_rtl() ) { $rtl_stylesheet_link = sprintf( "\n", esc_url( wp_admin_css_uri( "$file-rtl" ) ) ); /** This filter is documented in wp-includes/general-template.php */ echo apply_filters( 'wp_admin_css', $rtl_stylesheet_link, "$file-rtl" ); } } /** * Enqueues the default ThickBox js and css. * * If any of the settings need to be changed, this can be done with another js * file similar to media-upload.js. That file should * require array('thickbox') to ensure it is loaded after. * * @since 2.5.0 */ function add_thickbox() { wp_enqueue_script( 'thickbox' ); wp_enqueue_style( 'thickbox' ); if ( is_network_admin() ) { add_action( 'admin_head', '_thickbox_path_admin_subfolder' ); } } /** * Displays the XHTML generator that is generated on the wp_head hook. * * See {@see 'wp_head'}. * * @since 2.5.0 */ function wp_generator() { /** * Filters the output of the XHTML generator tag. * * @since 2.5.0 * * @param string $generator_type The XHTML generator. */ the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) ); } /** * Displays the generator XML or Comment for RSS, ATOM, etc. * * Returns the correct generator type for the requested output format. Allows * for a plugin to filter generators overall the {@see 'the_generator'} filter. * * @since 2.5.0 * * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export). */ function the_generator( $type ) { /** * Filters the output of the XHTML generator tag for display. * * @since 2.5.0 * * @param string $generator_type The generator output. * @param string $type The type of generator to output. Accepts 'html', * 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'. */ echo apply_filters( 'the_generator', get_the_generator( $type ), $type ) . "\n"; } /** * Creates the generator XML or Comment for RSS, ATOM, etc. * * Returns the correct generator type for the requested output format. Allows * for a plugin to filter generators on an individual basis using the * {@see 'get_the_generator_$type'} filter. * * @since 2.5.0 * * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export). * @return string|void The HTML content for the generator. */ function get_the_generator( $type = '' ) { if ( empty( $type ) ) { $current_filter = current_filter(); if ( empty( $current_filter ) ) { return; } switch ( $current_filter ) { case 'rss2_head': case 'commentsrss2_head': $type = 'rss2'; break; case 'rss_head': case 'opml_head': $type = 'comment'; break; case 'rdf_header': $type = 'rdf'; break; case 'atom_head': case 'comments_atom_head': case 'app_head': $type = 'atom'; break; } } switch ( $type ) { case 'html': $gen = ''; break; case 'xhtml': $gen = ''; break; case 'atom': $gen = 'WordPress'; break; case 'rss2': $gen = '' . sanitize_url( 'https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) ) . ''; break; case 'rdf': $gen = ''; break; case 'comment': $gen = ''; break; case 'export': $gen = ''; break; } /** * Filters the HTML for the retrieved generator type. * * The dynamic portion of the hook name, `$type`, refers to the generator type. * * Possible hook names include: * * - `get_the_generator_atom` * - `get_the_generator_comment` * - `get_the_generator_export` * - `get_the_generator_html` * - `get_the_generator_rdf` * - `get_the_generator_rss2` * - `get_the_generator_xhtml` * * @since 2.5.0 * * @param string $gen The HTML markup output to wp_head(). * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom', * 'rss2', 'rdf', 'comment', 'export'. */ return apply_filters( "get_the_generator_{$type}", $gen, $type ); } /** * Outputs the HTML checked attribute. * * Compares the first two arguments and if identical marks as checked. * * @since 1.0.0 * * @param mixed $checked One of the values to compare. * @param mixed $current Optional. The other value to compare if not just true. * Default true. * @param bool $display Optional. Whether to echo or just return the string. * Default true. * @return string HTML attribute or empty string. */ function checked( $checked, $current = true, $display = true ) { return __checked_selected_helper( $checked, $current, $display, 'checked' ); } /** * Outputs the HTML selected attribute. * * Compares the first two arguments and if identical marks as selected. * * @since 1.0.0 * * @param mixed $selected One of the values to compare. * @param mixed $current Optional. The other value to compare if not just true. * Default true. * @param bool $display Optional. Whether to echo or just return the string. * Default true. * @return string HTML attribute or empty string. */ function selected( $selected, $current = true, $display = true ) { return __checked_selected_helper( $selected, $current, $display, 'selected' ); } /** * Outputs the HTML disabled attribute. * * Compares the first two arguments and if identical marks as disabled. * * @since 3.0.0 * * @param mixed $disabled One of the values to compare. * @param mixed $current Optional. The other value to compare if not just true. * Default true. * @param bool $display Optional. Whether to echo or just return the string. * Default true. * @return string HTML attribute or empty string. */ function disabled( $disabled, $current = true, $display = true ) { return __checked_selected_helper( $disabled, $current, $display, 'disabled' ); } /** * Outputs the HTML readonly attribute. * * Compares the first two arguments and if identical marks as readonly. * * @since 5.9.0 * * @param mixed $readonly_value One of the values to compare. * @param mixed $current Optional. The other value to compare if not just true. * Default true. * @param bool $display Optional. Whether to echo or just return the string. * Default true. * @return string HTML attribute or empty string. */ function wp_readonly( $readonly_value, $current = true, $display = true ) { return __checked_selected_helper( $readonly_value, $current, $display, 'readonly' ); } /* * Include a compat `readonly()` function on PHP < 8.1. Since PHP 8.1, * `readonly` is a reserved keyword and cannot be used as a function name. * In order to avoid PHP parser errors, this function was extracted * to a separate file and is only included conditionally on PHP < 8.1. */ if ( PHP_VERSION_ID < 80100 ) { require_once __DIR__ . '/php-compat/readonly.php'; } /** * Private helper function for checked, selected, disabled and readonly. * * Compares the first two arguments and if identical marks as `$type`. * * @since 2.8.0 * @access private * * @param mixed $helper One of the values to compare. * @param mixed $current The other value to compare if not just true. * @param bool $display Whether to echo or just return the string. * @param string $type The type of checked|selected|disabled|readonly we are doing. * @return string HTML attribute or empty string. */ function __checked_selected_helper( $helper, $current, $display, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore if ( (string) $helper === (string) $current ) { $result = " $type='$type'"; } else { $result = ''; } if ( $display ) { echo $result; } return $result; } /** * Assigns a visual indicator for required form fields. * * @since 6.1.0 * * @return string Indicator glyph wrapped in a `span` tag. */ function wp_required_field_indicator() { /* translators: Character to identify required form fields. */ $glyph = __( '*' ); $indicator = '' . esc_html( $glyph ) . ''; /** * Filters the markup for a visual indicator of required form fields. * * @since 6.1.0 * * @param string $indicator Markup for the indicator element. */ return apply_filters( 'wp_required_field_indicator', $indicator ); } /** * Creates a message to explain required form fields. * * @since 6.1.0 * * @return string Message text and glyph wrapped in a `span` tag. */ function wp_required_field_message() { $message = sprintf( '%s', /* translators: %s: Asterisk symbol (*). */ sprintf( __( 'Required fields are marked %s' ), wp_required_field_indicator() ) ); /** * Filters the message to explain required form fields. * * @since 6.1.0 * * @param string $message Message text and glyph wrapped in a `span` tag. */ return apply_filters( 'wp_required_field_message', $message ); } /** * Default settings for heartbeat. * * Outputs the nonce used in the heartbeat XHR. * * @since 3.6.0 * * @param array $settings * @return array Heartbeat settings. */ function wp_heartbeat_settings( $settings ) { if ( ! is_admin() ) { $settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' ); } if ( is_user_logged_in() ) { $settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' ); } return $settings; } => '4.17.19', 'wp-polyfill-fetch' => '3.6.2', 'wp-polyfill-formdata' => '4.0.10', 'wp-polyfill-node-contains' => '4.6.0', 'wp-polyfill-url' => '3.6.4', 'wp-polyfill-dom-rect' => '4.6.0', 'wp-polyfill-element-closest' => '3.0.2', 'wp-polyfill-object-fit' => '2.3.5', 'wp-polyfill-inert' => '3.1.2', 'wp-polyfill' => '3.15.0', ); 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 ); } did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' ); did_action( 'init' ) && $scripts->add_inline_script( 'moment', sprintf( "moment.updateLocale( '%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' ) ), 'LTS' => null, 'L' => null, 'LL' => get_option( 'date_format', __( 'F j, Y' ) ), 'LLL' => __( 'F j, Y g:i a' ), '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 string[] $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 && str_starts_with( $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( \'\n"; } $concat = str_split( $concat, 128 ); $concatenated = ''; 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 "\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. * * @since 2.8.0 * * @global WP_Scripts $wp_scripts * * @return array */ function wp_print_head_scripts() { global $wp_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 * * @since 3.3.0 */ function _wp_footer_scripts() { print_late_styles(); print_footer_scripts(); } /** * Hooks to print the scripts and styles in the footer. * * @since 2.8.0 */ function wp_print_footer_scripts() { /** * Fires when footer scripts are printed. * * @since 2.8.0 */ 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. * * @since 2.8.0 */ function wp_enqueue_scripts() { /** * Fires when scripts and styles are enqueued. * * @since 2.8.0 */ do_action( 'wp_enqueue_scripts' ); } /** * Prints the styles queue in the HTML head on admin pages. * * @since 2.8.0 * * @global bool $concatenate_scripts * * @return array */ 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. * * @since 2.8.0 * * @param bool $print Whether to print the admin styles. Default true. */ if ( apply_filters( 'print_admin_styles', true ) ) { _print_styles(); } $wp_styles->reset(); return $wp_styles->done; } /** * Prints the styles that were queued too late for the HTML head. * * @since 3.3.0 * * @global WP_Styles $wp_styles * @global bool $concatenate_scripts * * @return array|void */ function print_late_styles() { global $wp_styles, $concatenate_scripts; if ( ! ( $wp_styles instanceof WP_Styles ) ) { return; } 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. * * @since 3.3.0 * * @param bool $print Whether to print the 'late' styles. Default true. */ if ( apply_filters( 'print_late_styles', true ) ) { _print_styles(); } $wp_styles->reset(); return $wp_styles->done; } /** * Prints styles (internal use only). * * @ignore * @since 3.3.0 * * @global bool $compress_css */ function _print_styles() { global $compress_css; $wp_styles = wp_styles(); $zip = $compress_css ? 1 : 0; if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) { $zip = 'gzip'; } $concat = trim( $wp_styles->concat, ', ' ); $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; if ( $concat ) { $dir = $wp_styles->text_direction; $ver = $wp_styles->default_version; $concat = str_split( $concat, 128 ); $concatenated = ''; 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 "\n"; if ( ! empty( $wp_styles->print_code ) ) { echo "\n"; echo $wp_styles->print_code; echo "\n\n"; } } if ( ! empty( $wp_styles->print_html ) ) { echo $wp_styles->print_html; } } /** * Determines the concatenation and compression settings for scripts and styles. * * @since 2.8.0 * * @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 ) ) { $compress_css = false; } } } /** * Handles the enqueueing of block scripts and styles that are common to both * the editor and the front-end. * * @since 5.0.0 */ function wp_common_block_scripts_and_styles() { if ( is_admin() && ! wp_should_load_block_editor_scripts_and_styles() ) { return; } 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. * * @since 5.0.0 */ 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. * * @since 6.1.0 * * @param array $nodes The nodes to filter. * @return array A filtered array of style nodes. */ function wp_filter_out_block_nodes( $nodes ) { return array_filter( $nodes, static function( $node ) { return ! in_array( 'blocks', $node['path'], true ); }, ARRAY_FILTER_USE_BOTH ); } /** * Enqueues the global styles defined via theme.json. * * @since 5.8.0 */ function wp_enqueue_global_styles() { $separate_assets = wp_should_load_separate_core_block_assets(); $is_block_theme = wp_is_block_theme(); $is_classic_theme = ! $is_block_theme; /* * Global styles should be printed in the head when loading all styles combined. * The footer should only be used to print global styles for classic themes with separate core assets enabled. * * See https://core.trac.wordpress.org/ticket/53494. */ if ( ( $is_block_theme && doing_action( 'wp_footer' ) ) || ( $is_classic_theme && doing_action( 'wp_footer' ) && ! $separate_assets ) || ( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) && $separate_assets ) ) { return; } /* * If loading the CSS for each block separately, then load the theme.json CSS conditionally. * This removes the CSS from the global-styles stylesheet and adds it to the inline CSS for each block. * This filter must be registered before calling wp_get_global_stylesheet(); */ add_filter( 'wp_theme_json_get_style_nodes', 'wp_filter_out_block_nodes' ); $stylesheet = wp_get_global_stylesheet(); if ( empty( $stylesheet ) ) { return; } wp_register_style( 'global-styles', false ); wp_add_inline_style( 'global-styles', $stylesheet ); wp_enqueue_style( 'global-styles' ); // Add each block as an inline css. wp_add_global_styles_for_blocks(); } /** * Enqueues the global styles custom css defined via theme.json. * * @since 6.2.0 */ function wp_enqueue_global_styles_custom_css() { if ( ! wp_is_block_theme() ) { return; } // Don't enqueue Customizer's custom CSS separately. remove_action( 'wp_head', 'wp_custom_css_cb', 101 ); $custom_css = wp_get_custom_css(); $custom_css .= wp_get_global_styles_custom_css(); if ( ! empty( $custom_css ) ) { wp_add_inline_style( 'global-styles', $custom_css ); } } /** * Checks if the editor scripts and styles for all registered block types * should be enqueued on the current screen. * * @since 5.6.0 * * @global WP_Screen $current_screen WordPress current screen object. * * @return bool Whether scripts and styles should be enqueued. */ function wp_should_load_block_editor_scripts_and_styles() { global $current_screen; $is_block_editor_screen = ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor(); /** * Filters the flag that decides whether or not block editor scripts and styles * are going to be enqueued on the current screen. * * @since 5.6.0 * * @param bool $is_block_editor_screen Current value of the flag. */ return apply_filters( 'should_load_block_editor_scripts_and_styles', $is_block_editor_screen ); } /** * Checks whether separate styles should be loaded for core blocks on-render. * * When this function returns true, other functions ensure that core blocks * only load their assets on-render, and each block loads its own, individual * assets. Third-party blocks only load their assets when rendered. * * When this function returns false, all core block assets are loaded regardless * of whether they are rendered in a page or not, because they are all part of * the `block-library/style.css` file. Assets for third-party blocks are always * enqueued regardless of whether they are rendered or not. * * This only affects front end and not the block editor screens. * * @see wp_enqueue_registered_block_scripts_and_styles() * @see register_block_style_handle() * * @since 5.8.0 * * @return bool Whether separate assets will be loaded. */ function wp_should_load_separate_core_block_assets() { if ( is_admin() || is_feed() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { return false; } /** * Filters whether block styles should be loaded separately. * * Returning false loads all core block assets, regardless of whether they are rendered * in a page or not. Returning true loads core block assets only when they are rendered. * * @since 5.8.0 * * @param bool $load_separate_assets Whether separate assets will be loaded. * Default false (all block assets are loaded, even when not used). */ return apply_filters( 'should_load_separate_core_block_assets', false ); } /** * Enqueues registered block scripts and styles, depending on current rendered * context (only enqueuing editor scripts while in context of the editor). * * @since 5.0.0 * * @global WP_Screen $current_screen WordPress current screen object. */ function wp_enqueue_registered_block_scripts_and_styles() { global $current_screen; if ( wp_should_load_separate_core_block_assets() ) { return; } $load_editor_scripts_and_styles = is_admin() && wp_should_load_block_editor_scripts_and_styles(); $block_registry = WP_Block_Type_Registry::get_instance(); foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) { // Front-end and editor styles. foreach ( $block_type->style_handles as $style_handle ) { wp_enqueue_style( $style_handle ); } // Front-end and editor scripts. foreach ( $block_type->script_handles as $script_handle ) { wp_enqueue_script( $script_handle ); } if ( $load_editor_scripts_and_styles ) { // Editor styles. foreach ( $block_type->editor_style_handles as $editor_style_handle ) { wp_enqueue_style( $editor_style_handle ); } // Editor scripts. foreach ( $block_type->editor_script_handles as $editor_script_handle ) { wp_enqueue_script( $editor_script_handle ); } } } } /** * Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend. * * @since 5.3.0 * * @global WP_Styles $wp_styles */ function enqueue_block_styles_assets() { global $wp_styles; $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); foreach ( $block_styles as $block_name => $styles ) { foreach ( $styles as $style_properties ) { if ( isset( $style_properties['style_handle'] ) ) { // If the site loads separate styles per-block, enqueue the stylesheet on render. if ( wp_should_load_separate_core_block_assets() ) { add_filter( 'render_block', static function( $html, $block ) use ( $block_name, $style_properties ) { if ( $block['blockName'] === $block_name ) { wp_enqueue_style( $style_properties['style_handle'] ); } return $html; }, 10, 2 ); } else { wp_enqueue_style( $style_properties['style_handle'] ); } } if ( isset( $style_properties['inline_style'] ) ) { // Default to "wp-block-library". $handle = 'wp-block-library'; // If the site loads separate styles per-block, check if the block has a stylesheet registered. if ( wp_should_load_separate_core_block_assets() ) { $block_stylesheet_handle = generate_block_asset_handle( $block_name, 'style' ); if ( isset( $wp_styles->registered[ $block_stylesheet_handle ] ) ) { $handle = $block_stylesheet_handle; } } // Add inline styles to the calculated handle. wp_add_inline_style( $handle, $style_properties['inline_style'] ); } } } } /** * Function responsible for enqueuing the assets required for block styles functionality on the editor. * * @since 5.3.0 */ function enqueue_editor_block_styles_assets() { $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); $register_script_lines = array( '( function() {' ); foreach ( $block_styles as $block_name => $styles ) { foreach ( $styles as $style_properties ) { $block_style = array( 'name' => $style_properties['name'], 'label' => $style_properties['label'], ); if ( isset( $style_properties['is_default'] ) ) { $block_style['isDefault'] = $style_properties['is_default']; } $register_script_lines[] = sprintf( ' wp.blocks.registerBlockStyle( \'%s\', %s );', $block_name, wp_json_encode( $block_style ) ); } } $register_script_lines[] = '} )();'; $inline_script = implode( "\n", $register_script_lines ); wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true ); wp_add_inline_script( 'wp-block-styles', $inline_script ); wp_enqueue_script( 'wp-block-styles' ); } /** * Enqueues the assets required for the block directory within the block editor. * * @since 5.5.0 */ function wp_enqueue_editor_block_directory_assets() { wp_enqueue_script( 'wp-block-directory' ); wp_enqueue_style( 'wp-block-directory' ); } /** * Enqueues the assets required for the format library within the block editor. * * @since 5.8.0 */ function wp_enqueue_editor_format_library_assets() { wp_enqueue_script( 'wp-format-library' ); wp_enqueue_style( 'wp-format-library' ); } /** * Sanitizes an attributes array into an attributes string to be placed inside a `\n", wp_sanitize_script_attributes( $attributes ) ); } /** * Prints formatted `\n", wp_sanitize_script_attributes( $attributes ), $javascript ); } /** * Prints inline JavaScript wrapped in `