Skip to content

Commit

Permalink
Merge pull request #208 from LezWatch/feature/improve-shadow
Browse files Browse the repository at this point in the history
Speed up Actor/Show Pages
  • Loading branch information
Ipstenu committed Mar 19, 2024
2 parents 2c0a069 + b29c029 commit f872f73
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 29 deletions.
7 changes: 7 additions & 0 deletions style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion style.css.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions style.min.css

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,12 @@ section#characters {
}
}

.show-header-svg .show-we-love,
.show-header-svg .show-star {
background-color: $lwtv-grey;
display: inline-block;
border-radius: 10px;
}

/* Trigger Warning */
.trigger-warning-container {
Expand Down
12 changes: 10 additions & 2 deletions template-parts/content-post_type_actors.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@
$related = lwtv_plugin()->has_cpt_related_posts( $slug );

// This just gets the numbers of all characters and how many are dead.
$all_chars = lwtv_plugin()->get_actor_characters( $the_id );
$all_dead = lwtv_plugin()->get_actor_dead( $the_id );
$all_chars = get_post_meta( $the_id, 'lezactors_char_list', true );
if ( ! $all_chars ) {
$all_chars = lwtv_plugin()->get_actor_characters( $the_id );
}

$all_dead = get_post_meta( $the_id, 'lezactors_dead_list', true );
if ( ! $all_chars ) {
$all_chars = lwtv_plugin()->get_actor_dead( $the_id );
}

$havecharcount = ( is_array( $all_chars ) ) ? count( $all_chars ) : 0;
$havedeadcount = ( is_array( $all_dead ) ) ? count( $all_dead ) : 0;

Expand Down
27 changes: 12 additions & 15 deletions template-parts/content-post_type_shows.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,11 @@
<?php

// This just gets the numbers of all characters and how many are dead.
$havecharcount = lwtv_plugin()->get_characters_list( $show_id, 'count' );
$havedeadcount = lwtv_plugin()->get_characters_list( $show_id, 'dead' );
$havecharcount = get_post_meta( $show_id, 'lezshows_char_count', true );
$havedeadcount = get_post_meta( $show_id, 'lezshows_dead_count', true );

// Get the list of characters.
$chars_regular = lwtv_plugin()->get_chars_for_show( $show_id, 'regular' );
$chars_recurring = lwtv_plugin()->get_chars_for_show( $show_id, 'recurring' );
$chars_guest = lwtv_plugin()->get_chars_for_show( $show_id, 'guest' );
$chars_total = count( $chars_recurring ) + count( $chars_regular ) + count( $chars_guest );
$chars_by_role = lwtv_plugin()->get_chars_for_show( $show_id, 'all' );

if ( empty( $havecharcount ) || '0' === $havecharcount ) {
echo '<p>There are no characters listed yet for this show.</p>';
Expand All @@ -166,34 +163,34 @@
echo wp_kses_post( '<p>There ' . sprintf( _n( 'is <strong>%s</strong> queer character', 'are <strong>%s</strong> queer characters', $havecharcount ), $havecharcount ) . ' listed for this show; ' . $deadtext . '.</p>' );

// If there are regulars...
if ( ! empty( $chars_regular ) ) {
if ( isset( $chars_by_role['regular'] ) && is_array( $chars_by_role['regular'] ) ) {
?>
<h3 class="title-regulars"><?php echo esc_html( _n( 'Regular', 'Regulars', count( $chars_regular ) ) ); ?> (<?php echo (int) count( $chars_regular ); ?>)</h3>
<h3 class="title-regulars"><?php echo esc_html( _n( 'Regular', 'Regulars', count( $chars_by_role['regular'] ) ) ); ?> (<?php echo (int) count( $chars_by_role['regular'] ); ?>)</h3>
<div class="container characters-regulars-container"><div class="row site-loop character-show-loop">
<?php
foreach ( $chars_regular as $character ) {
foreach ( $chars_by_role['regular'] as $character ) {
include locate_template( 'template-parts/excerpt-post_type_characters.php' );
}
echo '</div></div>';
}
// If there are recurring...
if ( ! empty( $chars_recurring ) ) {
if ( isset( $chars_by_role['recurring'] ) && is_array( $chars_by_role['recurring'] ) ) {
?>
<h3 class="title-recurring">Recurring (<?php echo count( $chars_recurring ); ?>)</h3>
<h3 class="title-recurring">Recurring (<?php echo count( $chars_by_role['recurring'] ); ?>)</h3>
<div class="container characters-recurring-container"><div class="row site-loop character-show-loop">
<?php
foreach ( $chars_recurring as $character ) {
foreach ( $chars_by_role['recurring'] as $character ) {
include locate_template( 'template-parts/excerpt-post_type_characters.php' );
}
echo '</div></div>';
}
// If there are guests...
if ( ! empty( $chars_guest ) ) {
if ( isset( $chars_by_role['guest'] ) && is_array( $chars_by_role['guest'] ) ) {
?>
<h3 class="title-guest"><?php echo esc_html( _n( 'Guest', 'Guests', count( $chars_guest ) ) ); ?> (<?php echo count( $chars_guest ); ?>)</h3>
<h3 class="title-guest"><?php echo esc_html( _n( 'Guest', 'Guests', count( $chars_by_role['guest'] ) ) ); ?> (<?php echo count( $chars_by_role['guest'] ); ?>)</h3>
<ul class="guest-character-list">
<?php
foreach ( $chars_guest as $character ) {
foreach ( $chars_by_role['guest'] as $character ) {
$grave = ( has_term( 'dead', 'lez_cliches', $character['id'] ) ) ? '<span role="img" aria-label="RIP Tombstone" title="RIP Tombstone" class="charlist-grave-sm">' . lwtv_symbolicons( 'rest-in-peace.svg', 'fa-times-circle' ) . '</span>' : '';
?>
<li><a href="<?php the_permalink( $character['id'] ); ?>" title="<?php echo esc_html( get_the_title( $character['id'] ) ); ?>" ><?php echo esc_html( get_the_title( $character['id'] ) ) . ' ' . $grave; // phpcs:ignore WordPress.Security.EscapeOutput ?></a></li>
Expand Down
22 changes: 13 additions & 9 deletions template-parts/excerpt-post_type_characters.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@

global $post;

$the_id = ( isset( $character['id'] ) ) ? $character['id'] : $post->ID;
$the_content = ( isset( $character['content'] ) ) ? $character['content'] : get_the_content();
$alt_text = 'A picture of the character ' . get_the_title( $the_id );
$char_role = ( isset( $character['role_from'] ) ) ? $character['role_from'] : 'regular';
$archive = ( is_archive() || is_tax() || is_page() ) ? true : false;
// The Mirror Gaze Reflection: Make sure the character is a character.
$the_id = $character['id'] ?? $character;

if ( 'post_type_characters' !== get_post_type( $the_id ) ) {
return;
}

$alt_text = 'A picture of the character ' . get_the_title( $the_id );
$char_role = $character['role_from'] ?? 'regular';
$archive = ( is_archive() || is_tax() || is_page() ) ? true : false;

if ( isset( $character['shows'] ) && isset( $character['show_from'] ) && is_array( $character['shows'] ) ) {
foreach ( $character['shows'] as $one_show ) {
$one_show_id = ( is_array( $one_show['show'] ) ) ? $one_show['show'][0] : $one_show['show'];
if ( (int) $one_show_id === (int) $character['show_from'] && isset( $one_show['appears'] ) ) {
if ( (int) $one_show['show'] === (int) $character['show_from'] && isset( $one_show['appears'] ) ) {
asort( $one_show['appears'] );
$appears = ' - Years: ' . implode( ', ', $one_show['appears'] );
}
}
}

$thumb_attribution = get_post_meta( get_post_thumbnail_id(), 'lwtv_attribution', true );
$thumb_attribution = get_post_meta( get_post_thumbnail_id( $the_id ), 'lwtv_attribution', true );
$thumb_title = ( empty( $thumb_attribution ) ) ? $alt_text : $alt_text . ' &copy; ' . $thumb_attribution;
$thumb_title = ( isset( $appears ) ) ? $thumb_title . $appears : $thumb_title;
$thumb_array = array(
Expand All @@ -54,7 +58,7 @@
<div class="card">
<div class="character-image-wrapper">
<?php
if ( ! has_post_thumbnail() ) {
if ( ! has_post_thumbnail( $the_id ) ) {
?>
<img src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/mystery-woman.jpg" class="single-char-img rounded float-left" alt="<?php echo esc_attr( get_the_title() ); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" />
<?php
Expand Down

0 comments on commit f872f73

Please sign in to comment.