Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 48 additions & 12 deletions src/wp-content/themes/ipsum/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function ipsum_enqueue_styles() {
'ipsum-style',
get_parent_theme_file_uri( 'style.css' ),
array(),
wp_get_theme()->get( 'Version' )
wp_get_theme( get_template() )->get( 'Version' )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is important because get_parent_theme_file_uri( 'style.css' ) only ever refers to the parent theme's style.css, but without passing get_template() here, then it defaults to the child theme.

);

// Enqueue theme stylesheet.
Expand All @@ -62,26 +62,59 @@ function ipsum_enqueue_styles() {
endif;
add_action( 'wp_enqueue_scripts', 'ipsum_enqueue_styles' );

if ( ! function_exists( 'ipsum_get_asset_url' ) ) :
/**
* Gets the URL of a theme asset, with the theme version added for cache busting.
*
* The asset and the version both come from the parent theme, so a child
* theme's version doesn't stand in for Ipsum's.
*
* @since Ipsum 1.0
*
* @param string $path Path to the asset, relative to the theme directory, such as
* 'assets/images/ipsum-polygons.webp'.
* @return string The asset URL, with a `ver` query argument when the theme
* version can be read.
*
* @phpstan-param non-falsy-string $path
*/
function ipsum_get_asset_url( string $path ): string {
$url = get_parent_theme_file_uri( $path );
$version = wp_get_theme( get_template() )->get( 'Version' );
if ( false !== $version ) {
$url = add_query_arg( 'ver', $version, $url );
}
return $url;
}
endif;

if ( ! function_exists( 'ipsum_comments_cta_binding' ) ) :
/**
* Returns the comments call to action for the current post.
*
* @since Ipsum 1.0
*
* @param array $source_args Block binding source arguments.
* @param WP_Block $block_instance The block instance.
* @return string The call to action text.
* @param array<string, mixed> $source_args Block binding source arguments. Unused.
* @param WP_Block $block_instance The block instance.
* @return string|null The call to action text, or null to keep the block's
* original content when there is no post.
*/
function ipsum_comments_cta_binding( $source_args, $block_instance ) {
$post_id = $block_instance->context['postId'] ?? get_the_ID();
unset( $source_args ); // Unused, but must be accepted to get the block instance.

$post_id = $block_instance->context['postId'] ?? null;
$post = get_post( is_numeric( $post_id ) ? (int) $post_id : null );
if ( ! $post ) {
return null;
}

if ( get_comments_number( $post_id ) > 0 ) {
if ( get_comments_number( $post ) > 0 ) {
$text = __( 'Join the conversation', 'ipsum' );
} else {
$text = __( 'Be the first to comment', 'ipsum' );
}

return '<a href="' . esc_url( get_comments_link( $post_id ) ) . '">' . esc_html( $text ) . '</a>';
return '<a href="' . esc_url( get_comments_link( $post ) ) . '">' . esc_html( $text ) . '</a>';
}
endif;

Expand Down Expand Up @@ -113,8 +146,9 @@ function ipsum_register_block_bindings() {
*
* @since Ipsum 1.0
*
* @param array $default_template_types The default template types.
* @return array The template types, with the sidebar variants added.
* @param array<string, array<string, string>> $default_template_types The default template types, keyed by
* slug, each with a title and description.
* @return array<string, array<string, string>> The template types, with the sidebar variants added.
*/
function ipsum_sidebar_template_types( $default_template_types ) {
$default_template_types['index-sidebar'] = array(
Expand Down Expand Up @@ -162,12 +196,14 @@ function ipsum_register_pattern_categories() {
*
* @since Ipsum 1.0
*
* @param array $metadata Metadata for the block type being registered.
* @return array The block metadata, with ARIA label support on the Search block.
* @param array<string, mixed> $metadata Metadata for the block type being registered.
* @return array<string, mixed> The block metadata, with ARIA label support on the Search block.
*/
function ipsum_search_aria_label_support( $metadata ) {
if ( isset( $metadata['name'] ) && 'core/search' === $metadata['name'] ) {
$metadata['supports']['ariaLabel'] = true;
$supports = isset( $metadata['supports'] ) && is_array( $metadata['supports'] ) ? $metadata['supports'] : array();
$supports['ariaLabel'] = true;
$metadata['supports'] = $supports;
}
return $metadata;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wp-content/themes/ipsum/patterns/about-row.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<!-- wp:column {"verticalAlignment":"bottom","width":"50%","layout":{"type":"default"}} -->
<div class="wp-block-column is-vertically-aligned-bottom" style="flex-basis:50%"><!-- wp:image {"aspectRatio":"1","scale":"cover","sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="<?php echo esc_url( get_template_directory_uri() ); ?>/assets/images/ipsum-portrait-editorial.webp?ver=<?php echo esc_attr( wp_get_theme( get_template() )->get( 'Version' ) ); ?>" alt="<?php esc_attr_e( 'Portrait of the author.', 'ipsum' ); ?>" style="aspect-ratio:1;object-fit:cover"/></figure>
<figure class="wp-block-image size-full"><img src="<?php echo esc_url( ipsum_get_asset_url( 'assets/images/ipsum-portrait-editorial.webp' ) ); ?>" alt="<?php esc_attr_e( 'Portrait of the author.', 'ipsum' ); ?>" style="aspect-ratio:1;object-fit:cover"/></figure>
<!-- /wp:image --></div>
<!-- /wp:column --></div>
<!-- /wp:columns --></div>
Expand Down
4 changes: 2 additions & 2 deletions src/wp-content/themes/ipsum/patterns/cta-membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
?>
<!-- wp:group {"metadata":{"name":"<?php echo esc_html_x( 'CTA Membership', 'Name of the membership call to action group', 'ipsum' ); ?>"},"style":{"spacing":{"padding":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|50"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--50)"><!-- wp:group {"metadata":{"name":"<?php echo esc_html_x( 'CTA Membership Wrapper', 'Name of the membership card group', 'ipsum' ); ?>"},"className":"is-style-crop-contents","style":{"border":{"radius":{"topLeft":"10px","topRight":"10px","bottomLeft":"10px","bottomRight":"10px"}},"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30","right":"var:preset|spacing|30"},"blockGap":"var:preset|spacing|50"}},"backgroundColor":"theme-5","layout":{"type":"constrained"}} -->
<div class="wp-block-group is-style-crop-contents has-theme-5-background-color has-background" style="border-top-left-radius:10px;border-top-right-radius:10px;border-bottom-left-radius:10px;border-bottom-right-radius:10px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:cover {"url":"<?php echo esc_url( get_template_directory_uri() ); ?>/assets/images/ipsum-polygons.webp?ver=<?php echo esc_attr( wp_get_theme( get_template() )->get( 'Version' ) ); ?>","alt":"<?php echo esc_attr_x( 'Rows of glossy black hollow cones catching the light.', 'Alt text for the polygons image', 'ipsum' ); ?>","dimRatio":0,"overlayColor":"theme-2","isUserOverlayColor":true,"focalPoint":{"x":0.5,"y":0},"contentPosition":"bottom center","sizeSlug":"full","metadata":{"name":"<?php echo esc_html_x( 'Site Screenshot', 'Name of the site screenshot cover', 'ipsum' ); ?>"},"style":{"dimensions":{"aspectRatio":"16/9"},"border":{"radius":{"topLeft":"10px","topRight":"10px","bottomLeft":"10px","bottomRight":"10px"}},"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30","right":"var:preset|spacing|30"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-cover has-custom-content-position is-position-bottom-center" style="border-top-left-radius:10px;border-top-right-radius:10px;border-bottom-left-radius:10px;border-bottom-right-radius:10px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><img class="wp-block-cover__image-background size-full" alt="<?php echo esc_attr_x( 'Rows of glossy black hollow cones catching the light.', 'Alt text for the polygons image', 'ipsum' ); ?>" src="<?php echo esc_url( get_template_directory_uri() ); ?>/assets/images/ipsum-polygons.webp?ver=<?php echo esc_attr( wp_get_theme( get_template() )->get( 'Version' ) ); ?>" style="object-position:50% 0%" data-object-fit="cover" data-object-position="50% 0%"/><span aria-hidden="true" class="wp-block-cover__background has-theme-2-background-color has-background-dim-0 has-background-dim"></span><div class="wp-block-cover__inner-container"></div></div>
<div class="wp-block-group is-style-crop-contents has-theme-5-background-color has-background" style="border-top-left-radius:10px;border-top-right-radius:10px;border-bottom-left-radius:10px;border-bottom-right-radius:10px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:cover {"url":"<?php echo esc_url( ipsum_get_asset_url( 'assets/images/ipsum-polygons.webp' ) ); ?>","alt":"<?php echo esc_attr_x( 'Rows of glossy black hollow cones catching the light.', 'Alt text for the polygons image', 'ipsum' ); ?>","dimRatio":0,"overlayColor":"theme-2","isUserOverlayColor":true,"focalPoint":{"x":0.5,"y":0},"contentPosition":"bottom center","sizeSlug":"full","metadata":{"name":"<?php echo esc_html_x( 'Site Screenshot', 'Name of the site screenshot cover', 'ipsum' ); ?>"},"style":{"dimensions":{"aspectRatio":"16/9"},"border":{"radius":{"topLeft":"10px","topRight":"10px","bottomLeft":"10px","bottomRight":"10px"}},"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30","right":"var:preset|spacing|30"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-cover has-custom-content-position is-position-bottom-center" style="border-top-left-radius:10px;border-top-right-radius:10px;border-bottom-left-radius:10px;border-bottom-right-radius:10px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><img class="wp-block-cover__image-background size-full" alt="<?php echo esc_attr_x( 'Rows of glossy black hollow cones catching the light.', 'Alt text for the polygons image', 'ipsum' ); ?>" src="<?php echo esc_url( ipsum_get_asset_url( 'assets/images/ipsum-polygons.webp' ) ); ?>" style="object-position:50% 0%" data-object-fit="cover" data-object-position="50% 0%"/><span aria-hidden="true" class="wp-block-cover__background has-theme-2-background-color has-background-dim-0 has-background-dim"></span><div class="wp-block-cover__inner-container"></div></div>
<!-- /wp:cover -->

<!-- wp:group {"metadata":{"name":"<?php echo esc_html_x( 'Copy', 'Name of the membership copy group', 'ipsum' ); ?>"},"layout":{"type":"constrained"}} -->
Expand Down
2 changes: 1 addition & 1 deletion src/wp-content/themes/ipsum/patterns/format-audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- wp:group {"metadata":{"name":"<?php echo esc_html_x( 'Format Audio', 'Name of the audio format group', 'ipsum' ); ?>"},"style":{"spacing":{"padding":{"top":"var:preset|spacing|40","bottom":"var:preset|spacing|40"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40)"><!-- wp:group {"metadata":{"name":"<?php echo esc_html_x( 'Format Audio Wrapper', 'Name of the audio format card group', 'ipsum' ); ?>"},"style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30","right":"var:preset|spacing|30"}},"border":{"radius":{"topLeft":"10px","topRight":"10px","bottomLeft":"10px","bottomRight":"10px"}}},"backgroundColor":"theme-5","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-theme-5-background-color has-background" style="border-top-left-radius:10px;border-top-right-radius:10px;border-bottom-left-radius:10px;border-bottom-right-radius:10px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:image {"aspectRatio":"1","scale":"cover","sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="<?php echo esc_url( get_template_directory_uri() ); ?>/assets/images/ipsum-monobloc-front.webp?ver=<?php echo esc_attr( wp_get_theme( get_template() )->get( 'Version' ) ); ?>" alt="<?php echo esc_attr_x( 'A blurred plastic chair in blue and cream tones.', 'Alt text for the monobloc chair image', 'ipsum' ); ?>" style="aspect-ratio:1;object-fit:cover"/></figure>
<figure class="wp-block-image size-full"><img src="<?php echo esc_url( ipsum_get_asset_url( 'assets/images/ipsum-monobloc-front.webp' ) ); ?>" alt="<?php echo esc_attr_x( 'A blurred plastic chair in blue and cream tones.', 'Alt text for the monobloc chair image', 'ipsum' ); ?>" style="aspect-ratio:1;object-fit:cover"/></figure>
<!-- /wp:image -->

<!-- wp:group {"metadata":{"name":"<?php echo esc_html_x( 'Title and Description', 'Name of the title and description group', 'ipsum' ); ?>"},"style":{"spacing":{"blockGap":{"top":"var:preset|spacing|20"}}},"layout":{"type":"flex","orientation":"vertical","justifyContent":"stretch"}} -->
Expand Down
Loading
Loading