Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show company logo on People cards #857

Merged
merged 10 commits into from
Jun 15, 2024
Merged
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
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,56 @@ The dependencies of this project are managed by [Composer](https://getcomposer.o

composer.lock is generated from composer.json only when explicitly calling the `lando composer update` function. Any additional themes or plugins can be added first to composer.json and then `lando composer update` is run to update composer.lock and pull in the new files. Dependencies are pegged to a version according to the composer [versioning rules](https://getcomposer.org/doc/articles/versions.md).

It's good practice to keep WordPress and all plugins set at their latest releases to inherit any security patches and upgraded functionality. Upgrading to a new version, however, sometimes has unintended consequences so it's critical to run all tests before deploying live.
It's good practice to keep WordPress and all plugins set at their latest releases to inherit any security patches and upgraded functionality. Upgrading to a new version, however, sometimes has unintended consequences so it's critical to run all tests before deploying live.

## Refreshing external data

The following cron jobs are programmed to pull in data from remote sources for use in the website.

```
lf_sync_projects
lf_sync_ktps
lf_sync_kcds
```

To trigger fresh data locally, you can run:

```
lando wp cron event run lf_sync_kcds
```

or for remote triggering on a specific environment:

```
lando terminus wp cncfci.live -- cron event run lf_sync_kcds
```

To trigget all cron jobs, for example:

```
lando terminus wp cncfci.dev -- cron event run --all
```

For other data we use transients to store data:

```
cncf_homepage_metrics
cncf_whoweare_metrics
cncf_latest_endusers
tech_radars
cncf_project_maturity_data
cncf_eu_playlist
cncf_member_playlist
```

These can be deleted locally using:

```
lando wp transient delete cncf_project_maturity_data
```

These can be delete remotely using:

```
lando terminus wp cncfci.dev transient delete cncf_homepage_metrics
```
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@
return false;
}

$remote_body = json_decode( wp_remote_retrieve_body( $data ) );
$events = $remote_body->results;
$remote_body = json_decode( wp_remote_retrieve_body( $data ) );
$events = $remote_body->results;
$background_colors = array( '#14496c', '#641e16', '#5e2d72', '#0b5329', '#1a267d' );
$background_color = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ class="home-hero__poster" style="width: 100%; height: 100%;"
</ul>
</div>
</div>
</section>
</section>
118 changes: 82 additions & 36 deletions web/wp-content/themes/cncf-twenty-two/components/people-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,31 @@
// setup values.
global $wp;
global $post;
$person_id = get_the_ID();
$person_slug = $post->post_name;
$company = get_post_meta( get_the_ID(), 'lf_person_company', true );
$pronouns = ucwords( get_post_meta( get_the_ID(), 'lf_person_pronouns', true ), $separators = " \t\r\n\f\v\\;/" );
$gb_role = get_post_meta( get_the_ID(), 'lf_person_gb_role', true );
$toc_role = get_post_meta( get_the_ID(), 'lf_person_toc_role', true );
$tab_role = get_post_meta( get_the_ID(), 'lf_person_tab_role', true );
$linkedin = get_post_meta( get_the_ID(), 'lf_person_linkedin', true );
$twitter = get_post_meta( get_the_ID(), 'lf_person_twitter', true );
$mastodon = get_post_meta( get_the_ID(), 'lf_person_mastodon', true );
$github = get_post_meta( get_the_ID(), 'lf_person_github', true );
$wechat = get_post_meta( get_the_ID(), 'lf_person_wechat', true );
$website = get_post_meta( get_the_ID(), 'lf_person_website', true );
$youtube = get_post_meta( get_the_ID(), 'lf_person_youtube', true );
$image_url = get_post_meta( get_the_ID(), 'lf_person_image', true );
$location = get_post_meta( get_the_ID(), 'lf_person_location', true );
$languages = get_the_terms( get_the_ID(), 'lf-language' );
$projects = get_the_terms( get_the_ID(), 'lf-project' );
$content = get_the_content();
$current_url = home_url( 'people/ambassadors' );

$show_modal = ( $args['show_profile'] && strlen( $content ) > 20 ) ? true : false;
$person_id = get_the_ID();
$person_slug = $post->post_name;
$company = get_post_meta( get_the_ID(), 'lf_person_company', true );
$company_logo_url = get_post_meta( get_the_ID(), 'lf_person_company_logo_url', true );
$company_landscape_url = get_post_meta( get_the_ID(), 'lf_person_company_landscape_url', true );
$pronouns = ucwords( get_post_meta( get_the_ID(), 'lf_person_pronouns', true ), $separators = " \t\r\n\f\v\\;/" );
$gb_role = get_post_meta( get_the_ID(), 'lf_person_gb_role', true );
$toc_role = get_post_meta( get_the_ID(), 'lf_person_toc_role', true );
$tab_role = get_post_meta( get_the_ID(), 'lf_person_tab_role', true );
$linkedin = get_post_meta( get_the_ID(), 'lf_person_linkedin', true );
$twitter = get_post_meta( get_the_ID(), 'lf_person_twitter', true );
$mastodon = get_post_meta( get_the_ID(), 'lf_person_mastodon', true );
$github = get_post_meta( get_the_ID(), 'lf_person_github', true );
$wechat = get_post_meta( get_the_ID(), 'lf_person_wechat', true );
$website = get_post_meta( get_the_ID(), 'lf_person_website', true );
$youtube = get_post_meta( get_the_ID(), 'lf_person_youtube', true );
$image_url = get_post_meta( get_the_ID(), 'lf_person_image', true );
$location = get_post_meta( get_the_ID(), 'lf_person_location', true );
$languages = get_the_terms( get_the_ID(), 'lf-language' );
$projects = get_the_terms( get_the_ID(), 'lf-project' );
$content = get_the_content();
$current_url = home_url( 'people/ambassadors' );

$show_modal = isset( $args['show_profile'] ) && ( $args['show_profile'] && strlen( $content ) > 20 ) ? true : false;
$show_logos = isset( $args['show_logos'] ) && $args['show_logos'] ? true : false;
?>
<div class="person has-animation-scale-2">
<?php
Expand Down Expand Up @@ -77,12 +79,15 @@ class="js-modal button-reset modal-<?php echo esc_html( $person_slug ); ?>">
</button>
<?php endif; ?>

<p class="person__pronouns">
<?php if ( $pronouns ) : ?>
(<?php echo esc_html( $pronouns ); ?>)
<?php else : ?>
&nbsp;
<?php endif; ?>
</p>

<?php
if ( $pronouns ) :
?>
<p class="person__pronouns">(<?php echo esc_html( $pronouns ); ?>)</p>
<?php
endif;

if ( $gb_role ) :
?>
Expand All @@ -96,16 +101,38 @@ class="js-modal button-reset modal-<?php echo esc_html( $person_slug ); ?>">
<?php
endif;

if ( $company ) {
?>
<div class="person__company-container">
<?php
if ( $show_logos && $company_logo_url && $company_landscape_url ) {
?>
<a class="person__company-logo-link" title="View <?php echo esc_html( $company ); ?> in the CNCF Landscape" href="<?php echo esc_url( $company_landscape_url ); ?>">
<img class="person__company-logo" src="<?php echo esc_attr( $company_logo_url ); ?>"
alt="Logo of <?php echo esc_html( $company ); ?>">
</a>
<?php
} elseif ( $show_logos && $company_logo_url ) {
?>
<img class="person__company-logo" src="<?php echo esc_attr( $company_logo_url ); ?>"
alt="Logo of <?php echo esc_html( $company ); ?>">
<?php
} else {
?>
<h4 class="person__company"><?php echo esc_html( $company ); ?></h4>
<?php
}
?>
</div>
<?php
}

if ( $tab_role ) :
?>
<h4 class="person__role"><?php echo esc_html( $tab_role ); ?></h4>
<?php
endif;

if ( $company ) :
?>
<h4 class="person__company"><?php echo esc_html( $company ); ?></h4>
<?php endif; ?>
?>

<div class="person__social">
<?php
Expand Down Expand Up @@ -202,12 +229,31 @@ class="person__pronouns">(<?php echo esc_html( $pronouns ); ?>)</span>
<?php
endif;

if ( $company ) :
if ( $company ) {
?>
<h4 class="person__company">
<?php echo esc_html( $company ); ?></h4>
<div class="person__company-container">
<?php
endif;
if ( $show_logos && $company_logo_url && $company_landscape_url ) {
?>
<a class="person__company-logo-link" title="View <?php echo esc_html( $company ); ?> in the CNCF Landscape" href="<?php echo esc_url( $company_landscape_url ); ?>">
<img class="person__company-logo" src="<?php echo esc_attr( $company_logo_url ); ?>"
alt="Logo of <?php echo esc_html( $company ); ?>">
</a>
<?php
} elseif ( $show_logos && $company_logo_url ) {
?>
<img class="person__company-logo" src="<?php echo esc_attr( $company_logo_url ); ?>"
alt="Logo of <?php echo esc_html( $company ); ?>">
<?php
} else {
?>
<h4 class="person__company"><?php echo esc_html( $company ); ?></h4>
<?php
}
?>
</div>
<?php
}

if ( $location || $projects || $languages ) :
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [people tax="staff"]
* [people tax="technical-oversight-committee" profiles=true]
* [people tax="toc-contributors" profiles=false]
* [people tax="end-user-tab" logos=true]
*
* @package WordPress
* @subpackage cncf-theme
Expand All @@ -24,13 +25,15 @@ function add_people_shortcode( $atts ) {
array(
'tax' => 'staff', // set default.
'profiles' => true, // set default.
'logos' => false, // set default.
),
$atts,
'people'
);

$chosen_taxonomy = $atts['tax'];
$show_profile = filter_var( $atts['profiles'], FILTER_VALIDATE_BOOLEAN );
$show_logos = filter_var( $atts['logos'], FILTER_VALIDATE_BOOLEAN );

if ( ! is_string( $chosen_taxonomy ) ) {
return;
Expand All @@ -39,16 +42,16 @@ function add_people_shortcode( $atts ) {
$query_args = array(
'post_type' => 'lf_person',
'post_status' => array( 'publish' ),
'posts_per_page' => 200,
'posts_per_page' => 200, // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
'no_found_rows' => true,
'tax_query' => array(
'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
array(
'taxonomy' => 'lf-person-category',
'field' => 'slug',
'terms' => $chosen_taxonomy,
),
),
'meta_key' => 'lf_person_is_priority',
'meta_key' => 'lf_person_is_priority', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
'orderby' => array(
'meta_value_num' => 'DESC',
'title' => 'ASC',
Expand All @@ -74,7 +77,14 @@ function add_people_shortcode( $atts ) {
while ( $persons_query->have_posts() ) :
$persons_query->the_post();

get_template_part( 'components/people-item', null, array( 'show_profile' => $show_profile ) );
get_template_part(
'components/people-item',
null,
array(
'show_profile' => $show_profile,
'show_logos' => $show_logos,
)
);

endwhile;
wp_reset_postdata();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
<p>Start here</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
<!-- /wp:group -->
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
}
}
}

&__padding {
width: 100%;
height: 100%;
Expand All @@ -50,6 +49,7 @@
align-items: flex-start;
}
&__name {
font-size: 22px;
margin-top: 30px;
line-height: 130%;
@media (min-width: 1200px) {
Expand All @@ -72,23 +72,45 @@
}
}
}
&__company, &__role {
&__company-container {
margin-top: 10px;
@media (min-width: 1200px) {
margin-top: 16px;
}
.person__company-logo,
.person__company-logo-link,
.person__company {
display: block;
}
.person__company-logo-link {
display: inline-block;
cursor: pointer;
}
.person__company-logo {
height: 40px;
width: auto;
max-width: 150px;
object-fit: contain;
object-position: 0%;
}
}
&__company {
font-size: 16px;
line-height: 140%;
color: $gray-700;
}

&__role {
font-style: italic;
margin-top: 10px;
@media (min-width: 1200px) {
margin-top: 16px;
}
font-size: 16px;
line-height: 140%;
color: $gray-700;
}

&__social {
margin-top: auto;

a {
display: inline-block;
&:hover {
Expand All @@ -97,21 +119,18 @@
}
}
}

svg {
height: 30px;
width: auto;
color: $black;
}

&-margin {
margin-top: 40px;
> *:not(:last-child) {
margin-right: 10px;
}
}
}

&__content {
margin-top: 30px;
}
Expand Down