<!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>[47242] trunk/src/wp-content/themes/twentynineteen/inc/helper-functions.php: Twenty Nineteen: Add the missing `inc/helper-functions.php` file.</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="https://core.trac.wordpress.org/changeset/47242">47242</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/47242","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-02-10 19:05:17 +0000 (Mon, 10 Feb 2020)</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'>Twenty Nineteen: Add the missing `inc/helper-functions.php` file.
Follow-up to <a href="https://core.trac.wordpress.org/changeset/47214">[47214]</a>.
Props kjellr, jffng.
Fixes <a href="https://core.trac.wordpress.org/ticket/45984">#45984</a>.</pre>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunksrcwpcontentthemestwentynineteeninchelperfunctionsphp">trunk/src/wp-content/themes/twentynineteen/inc/helper-functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpcontentthemestwentynineteeninchelperfunctionsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/wp-content/themes/twentynineteen/inc/helper-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentynineteen/inc/helper-functions.php (rev 0)
+++ trunk/src/wp-content/themes/twentynineteen/inc/helper-functions.php 2020-02-10 19:05:17 UTC (rev 47242)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,163 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Common theme functions
+ *
+ * @package WordPress
+ * @subpackage Twenty_Nineteen
+ * @since Twenty Nineteen 1.5
+ */
+
+/**
+ * Determines if post thumbnail can be displayed.
+ */
+function twentynineteen_can_show_post_thumbnail() {
+ return apply_filters( 'twentynineteen_can_show_post_thumbnail', ! post_password_required() && ! is_attachment() && has_post_thumbnail() );
+}
+
+/**
+ * Returns true if image filters are enabled on the theme options.
+ */
+function twentynineteen_image_filters_enabled() {
+ return 0 !== get_theme_mod( 'image_filter', 1 );
+}
+
+/**
+ * Returns the size for avatars used in the theme.
+ */
+function twentynineteen_get_avatar_size() {
+ return 60;
+}
+
+/**
+ * Returns true if comment is by author of the post.
+ *
+ * @see get_comment_class()
+ */
+function twentynineteen_is_comment_by_post_author( $comment = null ) {
+ if ( is_object( $comment ) && $comment->user_id > 0 ) {
+ $user = get_userdata( $comment->user_id );
+ $post = get_post( $comment->comment_post_ID );
+ if ( ! empty( $user ) && ! empty( $post ) ) {
+ return $comment->user_id === $post->post_author;
+ }
+ }
+ return false;
+}
+
+/**
+ * Returns information about the current post's discussion, with cache support.
+ */
+function twentynineteen_get_discussion_data() {
+ static $discussion, $post_id;
+
+ $current_post_id = get_the_ID();
+ if ( $current_post_id === $post_id ) {
+ return $discussion; /* If we have discussion information for post ID, return cached object */
+ } else {
+ $post_id = $current_post_id;
+ }
+
+ $comments = get_comments(
+ array(
+ 'post_id' => $current_post_id,
+ 'orderby' => 'comment_date_gmt',
+ 'order' => get_option( 'comment_order', 'asc' ), /* Respect comment order from Settings ยป Discussion. */
+ 'status' => 'approve',
+ 'number' => 20, /* Only retrieve the last 20 comments, as the end goal is just 6 unique authors */
+ )
+ );
+
+ $authors = array();
+ foreach ( $comments as $comment ) {
+ $authors[] = ( (int) $comment->user_id > 0 ) ? (int) $comment->user_id : $comment->comment_author_email;
+ }
+
+ $authors = array_unique( $authors );
+ $discussion = (object) array(
+ 'authors' => array_slice( $authors, 0, 6 ), /* Six unique authors commenting on the post. */
+ 'responses' => get_comments_number( $current_post_id ), /* Number of responses. */
+ );
+
+ return $discussion;
+}
+
+/**
+ * Converts HSL to HEX colors.
+ */
+function twentynineteen_hsl_hex( $h, $s, $l, $to_hex = true ) {
+
+ $h /= 360;
+ $s /= 100;
+ $l /= 100;
+
+ $r = $l;
+ $g = $l;
+ $b = $l;
+ $v = ( $l <= 0.5 ) ? ( $l * ( 1.0 + $s ) ) : ( $l + $s - $l * $s );
+ if ( $v > 0 ) {
+ $m;
+ $sv;
+ $sextant;
+ $fract;
+ $vsf;
+ $mid1;
+ $mid2;
+
+ $m = $l + $l - $v;
+ $sv = ( $v - $m ) / $v;
+ $h *= 6.0;
+ $sextant = floor( $h );
+ $fract = $h - $sextant;
+ $vsf = $v * $sv * $fract;
+ $mid1 = $m + $vsf;
+ $mid2 = $v - $vsf;
+
+ switch ( $sextant ) {
+ case 0:
+ $r = $v;
+ $g = $mid1;
+ $b = $m;
+ break;
+ case 1:
+ $r = $mid2;
+ $g = $v;
+ $b = $m;
+ break;
+ case 2:
+ $r = $m;
+ $g = $v;
+ $b = $mid1;
+ break;
+ case 3:
+ $r = $m;
+ $g = $mid2;
+ $b = $v;
+ break;
+ case 4:
+ $r = $mid1;
+ $g = $m;
+ $b = $v;
+ break;
+ case 5:
+ $r = $v;
+ $g = $m;
+ $b = $mid2;
+ break;
+ }
+ }
+ $r = round( $r * 255, 0 );
+ $g = round( $g * 255, 0 );
+ $b = round( $b * 255, 0 );
+
+ if ( $to_hex ) {
+
+ $r = ( $r < 15 ) ? '0' . dechex( $r ) : dechex( $r );
+ $g = ( $g < 15 ) ? '0' . dechex( $g ) : dechex( $g );
+ $b = ( $b < 15 ) ? '0' . dechex( $b ) : dechex( $b );
+
+ return "#$r$g$b";
+
+ }
+
+ return "rgb($r, $g, $b)";
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/wp-content/themes/twentynineteen/inc/helper-functions.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></div>
</body>
</html>