This commit is contained in:
Ben Goldsworthy 2021-01-23 13:54:14 +00:00
parent aba542d60d
commit f650e53d9b
4 changed files with 118 additions and 116 deletions

View File

@ -9,8 +9,8 @@
get_header(); ?> get_header(); ?>
<main id="centred-page" role="main"> <main id="centred-page" role="main">
<h1>404.</h1> <h1>404.</h1>
<h2>That's <q>computer</q> for <q>Oops! Something went wrong!</q></h2> <h2>That's <q>computer</q> for <q>Oops! Something went wrong!</q></h2>
</main><!-- .site-main --> </main><!-- .site-main -->
<?php get_footer(); ?> <?php get_footer(); ?>

View File

@ -9,9 +9,9 @@
get_header(); ?> get_header(); ?>
<main id="list-page" class="col-10 col-m-12" role="main"> <main id="list-page" class="col-10 col-m-12" role="main">
<header> <header>
<h1><?php echo wp_kses_post( ( 'post' === get_post_type() ) ? single_cat_title() : ucfirst( get_post_type() ) . 's' ); ?>.</h1> <h1><?php echo wp_kses_post( ( 'post' === get_post_type() ) ? single_cat_title() : ucfirst( get_post_type() ) . 's' ); ?>.</h1>
<?php <?php
echo wp_kses_post( echo wp_kses_post(
get_the_posts_pagination( get_the_posts_pagination(
array( array(
@ -23,10 +23,10 @@ get_header(); ?>
) )
); );
?> ?>
</header> </header>
<section id="grid" class="row"> <section id="grid" class="row">
<?php <?php
if ( have_posts() ) : if ( have_posts() ) :
// Start the loop. // Start the loop.
while ( have_posts() ) : while ( have_posts() ) :
@ -39,16 +39,16 @@ get_header(); ?>
*/ */
get_template_part( 'template-parts/content', get_post_format() ); get_template_part( 'template-parts/content', get_post_format() );
// End the loop. // End the loop.
endwhile; endwhile;
// If no content, include the "No posts found" template. // If no content, include the "No posts found" template.
else : else :
get_template_part( 'template-parts/content', 'none' ); get_template_part( 'template-parts/content', 'none' );
endif; endif;
?> ?>
</section><!-- .site-main --> </section><!-- .site-main -->
<footer> <footer>
<?php <?php
echo wp_kses_post( echo wp_kses_post(
get_the_posts_pagination( get_the_posts_pagination(
array( array(
@ -60,7 +60,7 @@ get_header(); ?>
) )
); );
?> ?>
</footer> </footer>
</main><!-- .content-area --> </main><!-- .content-area -->
<?php get_footer(); ?> <?php get_footer(); ?>

View File

@ -22,10 +22,10 @@ get_header(); ?>
* @return bool * @return bool
*/ */
function within_dates( $role_start_date, $role_end_date ) { function within_dates( $role_start_date, $role_end_date ) {
$end_year = gmdate( 'Y' ); $end_year = gmdate( 'Y' );
$end_date = $end_year . '-12-31'; $end_date = $end_year . '-12-31';
$start_date = ( $end_year - 2 ) . '-01-01'; $start_date = ( $end_year - 2 ) . '-01-01';
$role_end_date = ( ! $role_end_date ) ? gmdate( 'Y-m-d' ) : ( ( $role_end_date > $end_date ) ? $end_date : $role_end_date ); $role_end_date = ( ! $role_end_date ) ? gmdate( 'Y-m-d' ) : ( ( $role_end_date > $end_date ) ? $end_date : $role_end_date );
return ( ( ( strtotime( $role_start_date ) < strtotime( $end_date ) ) && ( strtotime( $role_start_date ) > strtotime( $start_date ) ) ) && ( strtotime( $role_end_date ) > strtotime( $start_date ) ) ); return ( ( ( strtotime( $role_start_date ) < strtotime( $end_date ) ) && ( strtotime( $role_start_date ) > strtotime( $start_date ) ) ) && ( strtotime( $role_end_date ) > strtotime( $start_date ) ) );
} }
@ -106,7 +106,7 @@ function within_dates( $role_start_date, $role_end_date ) {
$end_date = get_post_meta( get_the_ID(), 'end-date', true ); $end_date = get_post_meta( get_the_ID(), 'end-date', true );
$is_current = ( ! $end_date || ( $end_date && $end_date > gmdate( 'Y-m-d' ) ) ) ? true : false; $is_current = ( ! $end_date || ( $end_date && $end_date > gmdate( 'Y-m-d' ) ) ) ? true : false;
$company = wp_get_object_terms( $company = wp_get_object_terms(
get_the_ID(), get_the_ID(),
'company', 'company',
array( array(
@ -115,8 +115,8 @@ function within_dates( $role_start_date, $role_end_date ) {
); );
$role_title = htmlspecialchars_decode( strip_tags( get_the_title() ) ); $role_title = htmlspecialchars_decode( strip_tags( get_the_title() ) );
$start = get_the_date(); $start = get_the_date();
$end = ( ! $end_date || ( $end_date && $end_date > gmdate( 'Y-m-d' ) ) ) ? gmdate( 'Y-m-d' ) : $end_date; $end = ( ! $end_date || ( $end_date && $end_date > gmdate( 'Y-m-d' ) ) ) ? gmdate( 'Y-m-d' ) : $end_date;
?> ?>
[ [
'<?php echo ( $is_current ) ? 'Current' : 'Past'; ?>', '<?php echo ( $is_current ) ? 'Current' : 'Past'; ?>',

View File

@ -11,44 +11,46 @@
<?php get_header(); ?> <?php get_header(); ?>
<?php <?php
// Gets all of the roles attached to the given organisation. // Gets all of the roles attached to the given organisation.
$company = get_queried_object(); $company = get_queried_object();
echo '<!-- ' . wp_kses_post( $company->name ) . '-->'; echo '<!-- ' . wp_kses_post( $company->name ) . '-->';
$args = array( // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'post_type' => array( 'job' ), $args = array(
'tax_query' => array( 'post_type' => array( 'job' ),
array( 'tax_query' => array(
'taxonomy' => 'company', array(
'field' => 'slug', 'taxonomy' => 'company',
'terms' => $company->slug, 'field' => 'slug',
), 'terms' => $company->slug,
), ),
'posts_per_page' => -1, ),
); 'posts_per_page' => -1,
);
// phpcs:enable
$loop = new WP_Query( $args ); $loop = new WP_Query( $args );
?> ?>
<?php // phpcs:disable WordPress.WP.EnqueuedResources ?> <?php // phpcs:disable WordPress.WP.EnqueuedResources ?>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
google.charts.load('current', {'packages':['timeline']}); google.charts.load('current', {'packages':['timeline']});
<?php if ( $loop->have_posts() ) : ?> <?php if ( $loop->have_posts() ) : ?>
google.charts.setOnLoadCallback(drawChart); google.charts.setOnLoadCallback(drawChart);
<?php endif; ?> <?php endif; ?>
function drawChart() { function drawChart() {
var container = document.getElementById('timeline'); var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container); var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable(); var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Type' }); dataTable.addColumn({ type: 'string', id: 'Type' });
dataTable.addColumn({ type: 'string', id: 'Job Title' }); dataTable.addColumn({ type: 'string', id: 'Job Title' });
dataTable.addColumn({ type: 'date', id: 'Start' }); dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' }); dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([ dataTable.addRows([
<?php <?php
while ( $loop->have_posts() ) : while ( $loop->have_posts() ) :
$loop->the_post(); $loop->the_post();
// Gets all of the roles associated with this organisation and its // Gets all of the roles associated with this organisation and its
@ -66,43 +68,43 @@
$end_date = get_post_meta( get_the_ID(), 'end-date', true ); $end_date = get_post_meta( get_the_ID(), 'end-date', true );
$item_title = htmlspecialchars_decode( strip_tags( get_the_title() ) ); $item_title = htmlspecialchars_decode( wp_strip_all_tags( get_the_title() ) );
$start = get_the_date(); $start = get_the_date();
$end = ( ! $end_date || ( $end_date && $end_date > gmdate( 'Y-m-d' ) ) ) ? gmdate( 'Y-m-d' ) : $end_date; $end = ( ! $end_date || ( $end_date && $end_date > gmdate( 'Y-m-d' ) ) ) ? gmdate( 'Y-m-d' ) : $end_date;
echo wp_kses_post( "[ '" . html_entity_decode( $companies[ $lowest_depth_company ]->name ) . "', '$item_title', new Date('$start'), new Date('$end') ],\n" ); echo wp_kses_post( "[ '" . html_entity_decode( $companies[ $lowest_depth_company ]->name ) . "', '$item_title', new Date('$start'), new Date('$end') ],\n" );
endwhile; endwhile;
?> ?>
]); ]);
// Draws the table, then resizes the element height and re-draws it // Draws the table, then resizes the element height and re-draws it
// to avoid needing to scroll vertically. // to avoid needing to scroll vertically.
var rowHeight = 15; var rowHeight = 15;
var chartHeight = dataTable.getNumberOfRows() * rowHeight + 50; var chartHeight = dataTable.getNumberOfRows() * rowHeight + 50;
var options = { var options = {
tooltip: {isHtml: true}, tooltip: {isHtml: true},
timeline: { timeline: {
showRowLabels: true, showRowLabels: true,
}, },
height: chartHeight, height: chartHeight,
width: '100%', width: '100%',
}; };
chart.draw(dataTable, options); chart.draw(dataTable, options);
} }
</script> </script>
<?php // phpcs:enable ?> <?php // phpcs:enable ?>
<main id="split-page" role="main"> <main id="split-page" role="main">
<?php <?php
// phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores // phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores
$company_logo = apply_filters( 'taxonomy-images-queried-term-image-url', '', array( 'image_size' => 'full' ) ); $company_logo = apply_filters( 'taxonomy-images-queried-term-image-url', '', array( 'image_size' => 'full' ) );
// phpcs:enable // phpcs:enable
$company_name = get_queried_object()->name; $company_name = get_queried_object()->name;
?> ?>
<div id="wrapper"> <div id="wrapper">
<header style="background-image: url('<?php echo esc_url( $company_logo ); ?>'); background-color: <?php echo esc_attr( get_term_meta( get_queried_object()->term_id, 'color' )[0] ); ?>; background-size: contain;"> <header style="background-image: url('<?php echo esc_url( $company_logo ); ?>'); background-color: <?php echo esc_attr( get_term_meta( get_queried_object()->term_id, 'color' )[0] ); ?>; background-size: contain;">
<div> <div>
<?php <?php
if ( strlen( $company_name ) > 70 ) { if ( strlen( $company_name ) > 70 ) {
$small = '2em'; $small = '2em';
} elseif ( strlen( $company_name ) > 35 ) { } elseif ( strlen( $company_name ) > 35 ) {
@ -114,23 +116,23 @@
} }
?> ?>
<h1 id="post-title" style="font-size: <?php echo esc_attr( $small ); ?>;"><?php echo wp_kses_post( $company_name ); ?></h1> <h1 id="post-title" style="font-size: <?php echo esc_attr( $small ); ?>;"><?php echo wp_kses_post( $company_name ); ?></h1>
</div> </div>
</header><!-- .entry-header --> </header><!-- .entry-header -->
<main id="organisation-body" class="body"> <main id="organisation-body" class="body">
<section id="description"> <section id="description">
<?php the_archive_description(); ?> <?php the_archive_description(); ?>
</section> </section>
<?php if ( $loop->have_posts() ) : ?> <?php if ( $loop->have_posts() ) : ?>
<section id="timeline"> <section id="timeline">
<div id="timeline" class="col-12"> <div id="timeline" class="col-12">
<img class="loading" src="/wp-content/uploads/2016/12/ajax-loader.gif"> <img class="loading" src="/wp-content/uploads/2016/12/ajax-loader.gif">
</div> </div>
</section> </section>
<?php endif; ?> <?php endif; ?>
<section id="related" class="row"> <section id="related" class="row">
<div id="parents" class="col-6 col-m-12"> <div id="parents" class="col-6 col-m-12">
<?php <?php
if ( get_queried_object()->parent != 0 ) { if ( get_queried_object()->parent != 0 ) {
// phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores // phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores
$parents = apply_filters( $parents = apply_filters(
@ -149,24 +151,24 @@
if ( count( $parents ) > 0 ) : if ( count( $parents ) > 0 ) :
?> ?>
<h2 class="subheading">Parent</h2> <h2 class="subheading">Parent</h2>
<ul class="index"> <ul class="index">
<?php <?php
foreach ( (array) $parents as $parent ) : foreach ( (array) $parents as $parent ) :
$img_url = wp_get_attachment_image_src( $parent->image_id )[0]; $img_url = wp_get_attachment_image_src( $parent->image_id )[0];
$colour = get_term_meta( $parent->term_id, 'color', true ); $colour = get_term_meta( $parent->term_id, 'color', true );
$colour = ( '' !== $colour ) ? $colour : 'transparent'; $colour = ( '' !== $colour ) ? $colour : 'transparent';
?> ?>
<li><a href="<?php echo esc_url( get_term_link( $parent, $parent->taxonomy ) ); ?>"><?php echo wp_kses_post( get_term( $parent->term_id, 'company' )->name ); ?></a></li> <li><a href="<?php echo esc_url( get_term_link( $parent, $parent->taxonomy ) ); ?>"><?php echo wp_kses_post( get_term( $parent->term_id, 'company' )->name ); ?></a></li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div id="children" class="col-6 col-m-12"> <div id="children" class="col-6 col-m-12">
<?php <?php
// phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores // phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores
$children = apply_filters( $children = apply_filters(
'taxonomy-images-get-terms', 'taxonomy-images-get-terms',
'', '',
@ -179,8 +181,8 @@
// phpcs:enable // phpcs:enable
if ( count( $children ) > 0 ) : if ( count( $children ) > 0 ) :
?> ?>
<h2 class="subheading">Child<?php echo ( count( $children ) != 1 ) ? 'ren' : ''; ?></h2> <h2 class="subheading">Child<?php echo ( count( $children ) != 1 ) ? 'ren' : ''; ?></h2>
<ul class="index"> <ul class="index">
<?php <?php
foreach ( (array) $children as $child ) : foreach ( (array) $children as $child ) :
$img_url = wp_get_attachment_image_src( $child->image_id, 'detail' )[0]; $img_url = wp_get_attachment_image_src( $child->image_id, 'detail' )[0];
@ -188,14 +190,14 @@
$colour = ( '' !== $colour ) ? $colour : 'transparent'; $colour = ( '' !== $colour ) ? $colour : 'transparent';
?> ?>
<li><a href="<?php echo esc_url( get_term_link( $child, $child->taxonomy ) ); ?>"><?php echo wp_kses_post( get_term( $child->term_id, 'company' )->name ); ?></a></li> <li><a href="<?php echo esc_url( get_term_link( $child, $child->taxonomy ) ); ?>"><?php echo wp_kses_post( get_term( $child->term_id, 'company' )->name ); ?></a></li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
<?php else : ?> <?php else : ?>
<p>No children.</p> <p>No children.</p>
<?php endif; ?> <?php endif; ?>
</div> </div>
</section> </section>
<?php <?php
$page_order = array( 'post', 'website', 'program', 'writing', 'video', 'other' ); $page_order = array( 'post', 'website', 'program', 'writing', 'video', 'other' );
foreach ( $page_order as $current_section ) { foreach ( $page_order as $current_section ) {
@ -205,13 +207,13 @@
if ( $loop->have_posts() ) : if ( $loop->have_posts() ) :
echo '<section id="' . esc_attr( $current_section ) . '" class="org-items row">'; echo '<section id="' . esc_attr( $current_section ) . '" class="org-items row">';
echo '<h2 class="subheading">' . wp_kses_post( ucwords( $current_section ) ) . 's <a href="/' . esc_attr( ( 'post' !== $current_section ? $current_section : 'blog' ) ) . '?company=' . esc_attr( get_queried_object()->slug ) . '">View all ' . esc_html( $loop->post_count ) . '</a></h2>'; echo '<h2 class="subheading">' . wp_kses_post( ucwords( $current_section ) ) . 's <a href="/' . esc_attr( ( 'post' !== $current_section ? $current_section : 'blog' ) ) . '?company=' . esc_attr( get_queried_object()->slug ) . '">View all ' . esc_html( $loop->post_count ) . '</a></h2>';
echo '<div class="index">'; echo '<div class="index">';
while ( ( $loop->have_posts() ) && ( $i++ < 4 ) ) : while ( ( $loop->have_posts() ) && ( $i++ < 4 ) ) :
$loop->the_post(); $loop->the_post();
get_template_part( 'template-parts/content', get_post_format() ); get_template_part( 'template-parts/content', get_post_format() );
endwhile; endwhile;
echo '</div>'; echo '</div>';
echo '</section>'; echo '</section>';
endif; endif;
} }
@ -241,8 +243,8 @@
echo '<ul class="index">'; echo '<ul class="index">';
while ( $loop->have_posts() ) : while ( $loop->have_posts() ) :
$loop->the_post(); $loop->the_post();
$url = esc_url( get_permalink() ); $url = esc_url( get_permalink() );
echo '<li><a href="' . esc_url( $url ) . '">' . wp_kses_post( get_the_title() ) . '</a></li>'; echo '<li><a href="' . esc_url( $url ) . '">' . wp_kses_post( get_the_title() ) . '</a></li>';
endwhile; endwhile;
echo '</ul>'; echo '</ul>';
else : else :
@ -279,8 +281,8 @@
echo '</section>'; echo '</section>';
endif; endif;
?> ?>
</main> </main>
</div> </div>
</main> </main>
<?php get_footer(); ?> <?php get_footer(); ?>