This repository has been archived on 2022-08-01. You can view files and clone it, but cannot push or open issues or pull requests.
Oldphaloskepsis/taxonomy-company.php
2017-05-25 18:57:33 +00:00

1 line
No EOL
7.9 KiB
PHP

<?php
/**
* The template for displaying archive pages
*
* Used to display archive-type pages if nothing more specific matches a query.
* For example, puts together date-based pages if no date.php file exists.
*
* If you'd like to further customize these archive views, you may create a
* new template file for each one. For example, tag.php (Tag archives),
* category.php (Category archives), author.php (Author archives), etc.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Sixteen
* @since Twenty Sixteen 1.0
*/
get_header(); ?>
<?php
$i = 0;
function withinDates($jSDate, $jEDate) {
//$endYear = date( "Y" );
$endDate = strtotime(date('Y-m-d'));
$startDate = strtotime("2015-01-01");
$jSDate = strtotime($jSDate);
if ($jEDate) {
$jEDate = strtotime($jEDate);
$jEDate = ($jEDate < $endDate) ? $jEDate : $endDate;
} else $jEDate = strtotime(date('Y-m-d'));
return (($jSDate < $endDate) && ($jEDate > $startDate));
}
$company = get_queried_object();
$args= array(
'post_type' => array( 'job' ),
'tax_query' => array(
array(
'taxonomy' => 'company',
'field' => 'slug',
'terms' => $company->name,
),
),
'posts_per_page' => -1
);
$loop = new WP_Query( $args )
?>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['timeline']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Type' });
dataTable.addColumn({ type: 'string', id: 'Job Title' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
<?php
while ( $loop->have_posts() ) : $loop->the_post();
//if (withinDates(get_the_date(), get_post_meta(get_the_ID(), 'end-date', true))) {
$companies = wp_get_object_terms(get_the_ID(), 'company');
$i = 0;
$currSizeOf = -1;
foreach ($companies as $company) {
if (sizeof(get_ancestors($company->term_id, 'company')) > $currSizeOf) {
$currSizeOf = sizeof(get_ancestors($company->term_id, 'company'));
$lowestDepthCompany = $i++;
}
}
$title = html_entity_decode(get_the_title());
$start = get_the_date();
$end = (!get_post_meta(get_the_ID(), 'end-date', true)) ? date('D M d Y H:i:s O') : get_post_meta(get_the_ID(), 'end-date', true);
echo "[ '{$companies[$lowestDepthCompany]->name}', '$title', new Date('$start'), new Date('$end') ],\n";
//}
endwhile;
?>
]);
chart.draw(dataTable);
var realheight=parseInt($("#timeline div:first-child div:first-child div:first-child div svg").attr( "height"))+50;
options.height=realheight;
//$("#timeline").attr("height", realHeight);
chart.draw(dataTable, options);
}
</script>
<div id="primary" class="content-area">
<?php
print apply_filters( 'taxonomy-images-queried-term-image', '', array(
'attr' => array(
'alt' => get_queried_object()->name.' logo',
'class' => 'taxonomy-background',
),
'before' => '<div class="taxonomy-background-container" style="background-color: '.get_term_meta(get_queried_object()->term_id, 'color')[0].';">',
'after' => '</div>',
'image_size' => 'full'
) );
?>
<main id="company-main" class="site-main" role="main">
<header class="page-header">
<?php
echo "<h1 id=\"page-title\">".get_queried_object()->name."</h1>";
the_archive_description( '<div class="entry-content tile" id="taxonomy-description">', '</div>' );
?>
</header><!-- .page-header -->
<div class="row">
<!-- Company Timeline -->
<div id="timeline" class="col-10 col-m-9"><img class="loading" src="/wp-content/uploads/2016/12/ajax-loader.gif"></div>
<!-- Company Parents & Children -->
<div class="index col-2 col-m-3" id="companies-grid-small">
<?php
if (get_queried_object()->parent != 0) {
$parents = apply_filters("taxonomy-images-get-terms", "", array('having_images' => false, 'taxonomy' => 'company', 'term_args' => array('include' => get_term_by('id', get_queried_object()->parent, 'company')->term_id)));
if (count($parents) > 0) {
echo '<h2 class="subheading">Parent</h2>';
echo '<ul class="row">';
foreach ( (array) $parents as $parent ) {
$imgURL = wp_get_attachment_image_src($parent->image_id)[0];
$colour = get_term_meta($parent->term_id, 'color', true);
$colour = ($colour != "") ? $colour : "transparent";
echo "<a href=\"".esc_url(get_term_link($parent, $parent->taxonomy ))."\"><li class=\"col-12\" style=\"background-image: url(".strtok($imgURL, '?')."); background-color: ".$colour.";\"></li></a>";
}
echo '</ul>';
}
}
$children = apply_filters("taxonomy-images-get-terms", "", array('having_images' => false, 'taxonomy' => 'company', 'term_args' => array('parent' => get_queried_object()->term_id)));
if (count($children) > 0) {
echo '<h2 class="subheading">Children</h2>';
echo '<ul class="row">';
foreach ( (array) $children as $child ) {
$imgURL = wp_get_attachment_image_src($child->image_id, 'detail')[0];
$colour = get_term_meta($child->term_id, 'color', true);
$colour = ($colour != "") ? $colour : "transparent";
echo "<a href=\"".esc_url(get_term_link($child, $child->taxonomy ))."\"><li class=\"col-12\" style=\"background-image: url(".strtok($imgURL, '?')."); background-color: ".$colour.";\"></li></a>";
}
echo '</ul>';
}
?>
</ul>
</div>
</div>
<?php
$pageOrder = array( 'post', 'website', 'program', 'writing', 'video', 'other', 'qualification', 'award');
foreach ($pageOrder as $currSec) {
$args['post_type'] = array( $currSec );
$i = 0;
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
echo "<div class=\"col-10 col-m-9\">";
echo "<h2 class=\"subheading\">".ucwords($currSec)."s <a href=\"/".($currSec != "post" ? $currSec : "blog")."?company=".get_queried_object()->slug."\">View all ".$loop->post_count."</a></h2>";
echo "<div class=\"index\">";
while (($loop->have_posts()) && ($i++ < 4)) : $loop->the_post();
get_template_part( 'template-parts/content', get_post_format() );
endwhile;
echo "</div>";
echo "</div>";
endif;
}
?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php //get_sidebar(); ?>
<?php get_footer(); ?>