fix: complete CHRNX responsive edge states
This commit is contained in:
15 files changed
+384
-35
No files matched your search
+5
-2
@@ -11,9 +11,10 @@
|
||||
* @param string $topic_slug Topic slug.
|
||||
* @param string $alt Alternative text. Empty is valid for decorative art.
|
||||
* @param string $class_name Optional image class.
|
||||
* @param string $loading Either lazy (default) or eager for above-fold art.
|
||||
* @return string Safe picture markup or an empty string.
|
||||
*/
|
||||
function chrnx_get_topic_portrait_markup( string $topic_slug, string $alt = '', string $class_name = '' ): string {
|
||||
function chrnx_get_topic_portrait_markup( string $topic_slug, string $alt = '', string $class_name = '', string $loading = 'lazy' ): string {
|
||||
$source = chrnx_get_topic_art_asset( $topic_slug );
|
||||
$dimensions = chrnx_get_topic_art_dimensions( $topic_slug );
|
||||
if ( '' === $source || 2 !== count( $dimensions ) ) {
|
||||
@@ -27,11 +28,13 @@ function chrnx_get_topic_portrait_markup( string $topic_slug, string $alt = '',
|
||||
$classes = is_array( $split_classes ) ? array_filter( $split_classes ) : array();
|
||||
$class = implode( ' ', array_map( 'sanitize_html_class', $classes ) );
|
||||
$decorative = '' === $alt ? ' aria-hidden="true"' : '';
|
||||
$loading = 'eager' === $loading ? 'eager' : 'lazy';
|
||||
$priority = 'eager' === $loading ? ' fetchpriority="high"' : '';
|
||||
|
||||
$markup = '<picture class="chrnx-responsive-portrait"' . $decorative . '>';
|
||||
$markup .= '<source type="image/avif" srcset="' . esc_url( $base_uri . '-384.avif' ) . ' 384w, ' . esc_url( $base_uri . '-768.avif' ) . ' 768w" sizes="' . esc_attr( $sizes ) . '">';
|
||||
$markup .= '<source type="image/webp" srcset="' . esc_url( $base_uri . '-384.webp' ) . ' 384w, ' . esc_url( $base_uri . '-768.webp' ) . ' 768w" sizes="' . esc_attr( $sizes ) . '">';
|
||||
$markup .= '<img' . ( '' !== $class ? ' class="' . esc_attr( $class ) . '"' : '' ) . ' src="' . esc_url( get_theme_file_uri( $source ) ) . '" width="' . esc_attr( $dimensions[0] ) . '" height="' . esc_attr( $dimensions[1] ) . '" loading="lazy" decoding="async" sizes="' . esc_attr( $sizes ) . '" alt="' . esc_attr( $alt ) . '">';
|
||||
$markup .= '<img' . ( '' !== $class ? ' class="' . esc_attr( $class ) . '"' : '' ) . ' src="' . esc_url( get_theme_file_uri( $source ) ) . '" width="' . esc_attr( $dimensions[0] ) . '" height="' . esc_attr( $dimensions[1] ) . '" loading="' . esc_attr( $loading ) . '"' . $priority . ' decoding="async" sizes="' . esc_attr( $sizes ) . '" alt="' . esc_attr( $alt ) . '">';
|
||||
$markup .= '</picture>';
|
||||
|
||||
return $markup;
|
||||
|
||||
@@ -169,6 +169,13 @@ function chrnx_get_post_topic_slug( $post_id ) {
|
||||
*/
|
||||
function chrnx_get_featured_story_ids( int $limit = 3 ): array {
|
||||
$limit = min( 12, max( 0, $limit ) );
|
||||
$host = wp_parse_url( home_url( '/' ), PHP_URL_HOST );
|
||||
if ( in_array( $host, array( 'localhost', '127.0.0.1' ), true ) ) {
|
||||
$fixture_limit = absint( get_option( '_chrnx_fixture_featured_limit', 0 ) );
|
||||
if ( in_array( $fixture_limit, array( 1, 2, 3 ), true ) ) {
|
||||
$limit = min( $limit, $fixture_limit );
|
||||
}
|
||||
}
|
||||
if ( 0 === $limit ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
+4
-1
@@ -60,7 +60,10 @@ add_action( 'admin_init', 'chrnx_register_subscribe_setting' );
|
||||
*/
|
||||
function chrnx_get_subscribe_url(): string {
|
||||
$page_id = absint( get_option( 'chrnx_subscribe_page_id', 0 ) );
|
||||
$page = get_post( $page_id );
|
||||
if ( 0 === $page_id ) {
|
||||
return '';
|
||||
}
|
||||
$page = get_post( $page_id );
|
||||
if ( ! $page instanceof WP_Post || 'page' !== $page->post_type || 'publish' !== $page->post_status ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user