From debd3641260f9c6f90e03325d0ef6aa66fd9ffd0 Mon Sep 17 00:00:00 2001
From: Ken Hawkins
Date: Tue, 30 Apr 2019 10:44:37 +0200
Subject: [PATCH 1/2] Begin update of vf-header template, pull in short and
long descrip
---
.../plugins/embl-taxonomy/embl-taxonomy.php | 13 ++++++++++
.../plugins/vf-group-header-block/README.md | 4 +++
.../vf-group-header-block/template.php | 19 ++++++++++++++
wp-content/themes/vf-wp/functions/theme.php | 25 +++++++++++++++++++
wp-content/themes/vf-wp/page.php | 10 +++++---
.../themes/vf-wp/partials/vf-masthead.php | 18 ++++++++-----
6 files changed, 80 insertions(+), 9 deletions(-)
diff --git a/wp-content/plugins/embl-taxonomy/embl-taxonomy.php b/wp-content/plugins/embl-taxonomy/embl-taxonomy.php
index e6863da52..fff3be732 100644
--- a/wp-content/plugins/embl-taxonomy/embl-taxonomy.php
+++ b/wp-content/plugins/embl-taxonomy/embl-taxonomy.php
@@ -118,6 +118,19 @@ function embl_taxonomy_get_term($term_id) {
return null;
}
+/**
+ * Return uuid associated with a WordPress taxonomy term
+ */
+function embl_taxonomy_get_uuid($term_id) {
+ $term = embl_taxonomy_get_term($term_id);
+ if ( ! $term->meta ) {
+ return null;
+ }
+ $uuid = end($term->meta['embl_taxonomy_ids']);
+ return $uuid;
+}
+
+
/**
* Return the VF stylesheet URL
*/
diff --git a/wp-content/plugins/vf-group-header-block/README.md b/wp-content/plugins/vf-group-header-block/README.md
index d193ec0a0..3f3eb4e57 100644
--- a/wp-content/plugins/vf-group-header-block/README.md
+++ b/wp-content/plugins/vf-group-header-block/README.md
@@ -2,6 +2,10 @@
A textual introduction aside a group leader using the `vf-summary--profile` Visual Framework pattern.
+If a header post is not available in the VF Blocks (or is blank), this plugin will try to use the EMBL Who taxonomy term and pull the group description from the ContentHub.
+
+A "read more" to the about page will automatically be appended.
+
## Configuration
Related post:
diff --git a/wp-content/plugins/vf-group-header-block/template.php b/wp-content/plugins/vf-group-header-block/template.php
index 8a1014ea1..ce95bcefa 100644
--- a/wp-content/plugins/vf-group-header-block/template.php
+++ b/wp-content/plugins/vf-group-header-block/template.php
@@ -11,6 +11,25 @@
$heading
);
+// if heading is empty, use the contenthub description
+if (vf_html_empty($heading)) {
+ if ( class_exists('VF_Cache') ) {
+ $uuid = vf__get_site_uuid();
+ $heading = '' . VF_Cache::get_post('https://dev.beta.embl.org/api/v1/pattern.html?filter-content-type=profiles&filter-uuid='.$uuid.'&pattern=node-teaser&source=contenthub') . '
';
+ $heading = preg_replace(
+ '##',
+ '
',
+ $heading
+ );
+ $heading = preg_replace(
+ '#
#',
+ ' Read more',
+ $heading
+ );
+ }
+}
+
+
$content = $vf_plugin->api_html();
?>
diff --git a/wp-content/themes/vf-wp/functions/theme.php b/wp-content/themes/vf-wp/functions/theme.php
index 0e9e948dc..96fb15e8f 100644
--- a/wp-content/themes/vf-wp/functions/theme.php
+++ b/wp-content/themes/vf-wp/functions/theme.php
@@ -208,4 +208,29 @@ function vf__nav_menu_link_attributes($atts, $item, $args, $depth) {
return $atts;
}
+
+/**
+ * Shorthand to safely query the UUID of the active "who" term, if set
+ */
+function vf__get_site_uuid() {
+
+ // first we want to be sure the taxonomy plugin is enabled
+ if ( ! function_exists('embl_taxonomy_get_uuid')) {
+ print '' . PHP_EOL;
+ return null;
+ }
+
+ $term_id = get_field('embl_taxonomy_term_what', 'option');
+
+ if ( ! $term_id ) {
+ print '';
+
+ }
+
+ $uuid = embl_taxonomy_get_uuid($term_id);
+
+ return $uuid;
+}
+
+
?>
diff --git a/wp-content/themes/vf-wp/page.php b/wp-content/themes/vf-wp/page.php
index 32dbcfd5c..e255d2551 100644
--- a/wp-content/themes/vf-wp/page.php
+++ b/wp-content/themes/vf-wp/page.php
@@ -4,10 +4,14 @@
the_post();
-$vf_group_header = VF_Plugin::get_plugin('vf_group_header');
+// Only show group long description on front page
+if (is_front_page()) {
-if (class_exists('VF_Group_Header')) {
- VF_Plugin::render($vf_group_header);
+ $vf_group_header = VF_Plugin::get_plugin('vf_group_header');
+
+ if (class_exists('VF_Group_Header')) {
+ VF_Plugin::render($vf_group_header);
+ }
}
?>
diff --git a/wp-content/themes/vf-wp/partials/vf-masthead.php b/wp-content/themes/vf-wp/partials/vf-masthead.php
index cf14e18c5..ccb64a335 100644
--- a/wp-content/themes/vf-wp/partials/vf-masthead.php
+++ b/wp-content/themes/vf-wp/partials/vf-masthead.php
@@ -1,12 +1,18 @@
-