<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[11652] sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns: Pattern Directory: Sync with git WordPress/pattern-directory@d7f27feb58fcdcf3f9db796b7851f6b2da72988c</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/11652">11652</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/11652","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>ryelle</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-03-08 21:04:30 +0000 (Tue, 08 Mar 2022)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Pattern Directory: Sync with git WordPress/pattern-directory@d7f27feb58fcdcf3f9db796b7851f6b2da72988c</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsfunctionsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/functions.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/includes/</li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsincludesinlinestylesphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/includes/inline-styles.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsthemejson">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/theme.json</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/functions.php  2022-03-08 19:03:14 UTC (rev 11651)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/functions.php    2022-03-08 21:04:30 UTC (rev 11652)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,6 +5,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> use const WordPressdotorg\Pattern_Directory\Pattern_Post_Type\POST_TYPE;
</span><span class="cx" style="display: block; padding: 0 10px"> use const WordPressdotorg\Pattern_Directory\Pattern_Flag_Post_Type\POST_TYPE as FLAG_POST_TYPE;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+require_once __DIR__ . '/includes/inline-styles.php';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'after_setup_theme', __NAMESPACE__ . '\setup' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets', 20 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_head', __NAMESPACE__ . '\generate_block_editor_styles_html' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,13 +28,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * as indicating support for post thumbnails.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function setup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        add_theme_support( 'post-thumbnails' );
-
</del><span class="cx" style="display: block; padding: 0 10px">         // Add gutenberg styling supports.
</span><span class="cx" style="display: block; padding: 0 10px">        add_theme_support( 'align-wide' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        add_theme_support( 'custom-spacing' );
-       add_theme_support( 'custom-line-height' );
-       add_theme_support( 'experimental-link-color' );
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // The parent wporg theme is designed for use on wordpress.org/* and assumes locale-domains are available.
</span><span class="cx" style="display: block; padding: 0 10px">        // Remove hreflang support.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -115,7 +112,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * See https://github.com/WordPress/gutenberg/blob/6ad2a433769a4514fc52083e97aa47a0bc9edf07/lib/client-assets.php#L710
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function generate_block_editor_styles_html() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $handles = array( 'wp-block-library' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_global_styles();
+       $handles = array( 'wp-block-library', 'global-styles' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $block_registry = \WP_Block_Type_Registry::get_instance();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -146,6 +144,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                ),
</span><span class="cx" style="display: block; padding: 0 10px">                'before'
</span><span class="cx" style="display: block; padding: 0 10px">        );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       wp_dequeue_style( 'global-styles' );
+       wp_deregister_style( 'global-styles' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsincludesinlinestylesphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/includes/inline-styles.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/includes/inline-styles.php                             (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/includes/inline-styles.php       2022-03-08 21:04:30 UTC (rev 11652)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,136 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Inject the <style> tags into the content itself so that it's available in the API.
+ *
+ * By default these styles are injected by a hook (ex, wp_footer) that is not triggered
+ * in an API request, so the content we retrieve from the API is missing it.
+ *
+ * We need to add styles for both the layout & element styles (link color), and unhook
+ * the existing core & Gutenberg hooks.
+ *
+ * See https://github.com/WordPress/gutenberg/issues/38167 & https://github.com/WordPress/gutenberg/issues/35376.
+ */
+
+namespace WordPressdotorg\Pattern_Directory\Theme\Inline_Styles;
+use WP_Block_Type_Registry;
+
+/**
+ * Renders the layout config to the block wrapper.
+ *
+ * See `wp_render_layout_support_flag`, `gutenberg_render_layout_support_flag`.
+ * Copied from https://github.com/WordPress/gutenberg/blob/0ea49d674a376636db5c0722ae41083394df9e60/lib/block-supports/layout.php#L132.
+ *
+ * @param  string $block_content Rendered block content.
+ * @param  array  $block         Block object.
+ * @return string                Filtered block content.
+ */
+function render_layout_support_styles( $block_content, $block ) {
+       $block_type     = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
+       $support_layout = gutenberg_block_has_support( $block_type, array( '__experimentalLayout' ), false );
+
+       if ( ! $support_layout ) {
+               return $block_content;
+       }
+
+       $block_gap             = wp_get_global_settings( array( 'spacing', 'blockGap' ) );
+       $default_layout        = wp_get_global_settings( array( 'layout' ) );
+       $has_block_gap_support = isset( $block_gap ) ? null !== $block_gap : false;
+       $default_block_layout  = _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() );
+       $used_layout           = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $default_block_layout;
+       if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] ) {
+               if ( ! $default_layout ) {
+                       return $block_content;
+               }
+               $used_layout = $default_layout;
+       }
+
+       $id        = uniqid();
+       $gap_value = _wp_array_get( $block, array( 'attrs', 'style', 'spacing', 'blockGap' ) );
+       // Skip if gap value contains unsupported characters.
+       // Regex for CSS value borrowed from `safecss_filter_attr`, and used here
+       // because we only want to match against the value, not the CSS attribute.
+       $gap_value = preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ? null : $gap_value;
+       $style     = gutenberg_get_layout_style( ".wp-container-$id", $used_layout, $has_block_gap_support, $gap_value );
+       // This assumes the hook only applies to blocks with a single wrapper.
+       // I think this is a reasonable limitation for that particular hook.
+       $content = preg_replace(
+               '/' . preg_quote( 'class="', '/' ) . '/',
+               'class="wp-container-' . $id . ' ',
+               $block_content,
+               1
+       );
+
+       return $content . '<style>' . $style . '</style>';
+}
+remove_filter( 'render_block', 'wp_render_layout_support_flag' );
+remove_filter( 'render_block', 'gutenberg_render_layout_support_flag', 10, 2 );
+add_filter( 'render_block', __NAMESPACE__ . '\render_layout_support_styles', 10, 2 );
+
+/**
+ * Render the elements stylesheet.
+ *
+ * See `wp_render_elements_support`, `gutenberg_render_elements_support`.
+ * Copied from https://github.com/WordPress/gutenberg/blob/0ea49d674a376636db5c0722ae41083394df9e60/lib/block-supports/elements.php#L15.
+ *
+ * @param  string $block_content Rendered block content.
+ * @param  array  $block         Block object.
+ * @return string                Filtered block content.
+ */
+function render_elements_support_styles( $block_content, $block ) {
+
+       if ( ! $block_content ) {
+               return $block_content;
+       }
+
+       $link_color = null;
+       if ( ! empty( $block['attrs'] ) ) {
+               $link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null );
+       }
+
+       /*
+       * For now we only care about link color.
+       * This code in the future when we have a public API
+       * should take advantage of WP_Theme_JSON_Gutenberg::compute_style_properties
+       * and work for any element and style.
+       */
+       if ( null === $link_color ) {
+               return $block_content;
+       }
+
+       $class_name = 'wp-elements-' . uniqid();
+
+       if ( strpos( $link_color, 'var:preset|color|' ) !== false ) {
+               // Get the name from the string and add proper styles.
+               $index_to_splice = strrpos( $link_color, '|' ) + 1;
+               $link_color_name = substr( $link_color, $index_to_splice );
+               $link_color      = "var(--wp--preset--color--$link_color_name)";
+       }
+       $link_color_declaration = esc_html( safecss_filter_attr( "color: $link_color" ) );
+
+       $style = "<style>.$class_name a{" . $link_color_declaration . ";}</style>\n";
+
+       // Like the layout hook this assumes the hook only applies to blocks with a single wrapper.
+       // Retrieve the opening tag of the first HTML element.
+       $html_element_matches = array();
+       preg_match( '/<[^>]+>/', $block_content, $html_element_matches, PREG_OFFSET_CAPTURE );
+       $first_element = $html_element_matches[0][0];
+       // If the first HTML element has a class attribute just add the new class
+       // as we do on layout and duotone.
+       if ( strpos( $first_element, 'class="' ) !== false ) {
+               $content = preg_replace(
+                       '/' . preg_quote( 'class="', '/' ) . '/',
+                       'class="' . $class_name . ' ',
+                       $block_content,
+                       1
+               );
+       } else {
+               // If the first HTML element has no class attribute we should inject the attribute before the attribute at the end.
+               $first_element_offset = $html_element_matches[0][1];
+               $content              = substr_replace( $block_content, ' class="' . $class_name . '"', $first_element_offset + strlen( $first_element ) - 1, 0 );
+       }
+
+       return $content . $style;
+}
+remove_filter( 'render_block', 'wp_render_elements_support', 10, 2 );
+remove_filter( 'render_block', 'gutenberg_render_elements_support', 10, 2 );
+add_filter( 'render_block', __NAMESPACE__ . '\render_elements_support_styles', 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/includes/inline-styles.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsthemejson"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/theme.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/theme.json                             (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/theme.json       2022-03-08 21:04:30 UTC (rev 11652)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,9 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+{
+    "version": 2,
+    "settings": {
+        "appearanceTools": true,
+        "color": {
+            "link": true
+        }
+    }
+}
</ins></span></pre>
</div>
</div>

</body>
</html>