Skip to content

Commit

Permalink
feat: Add options for colloquium location & front page links (#28)
Browse files Browse the repository at this point in the history
* feat(functions): Add ACF options page & theme options custom field group

* feat(components): Use theme options for colloquium_location_link text

* feat(front-page): Use theme options for front page links’ text
  • Loading branch information
delucis authored Feb 23, 2019
1 parent 0846efa commit b06c0fc
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 5 deletions.
8 changes: 5 additions & 3 deletions components/colloquium_location_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ function colloquium_location_link(array $opts)
$classes = $location_only ? 'location map-popup' : 'map-popup';

$html = '<p class="' . $classes . '">';
if (!$location_only) {
$html .= 'All colloquia are at 12pm in ';
if ($location_only) {
$html .= get_field('colloquium_location_short', 'option');
} else {
$html .= get_field('colloquium_location_long', 'option');
}
$html .= 'Room 6, <a href="https://www.google.com/maps/place/Music+Bldg,+Harvard+University,+Cambridge,+MA+02138/@42.3769058,-71.1170215,15z/data=!4m2!3m1!1s0x89e3774164253f4d:0x4139366065ac28ee">' .
$html .= ', <a href="https://www.google.com/maps/place/Music+Bldg,+Harvard+University,+Cambridge,+MA+02138/@42.3769058,-71.1170215,15z/data=!4m2!3m1!1s0x89e3774164253f4d:0x4139366065ac28ee">' .
'Harvard University Music Building' .
component('icon', array('type' => 'location')) .
'</a>';
Expand Down
4 changes: 2 additions & 2 deletions front-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'button_link',
array(
'href' => 'https://www.facebook.com/pages/Harvard-Group-for-New-Music/130937206919388',
'html' => 'Join us on Facebook' . component('icon', array('type' => 'facebook'))
'html' => get_field('front_page_facebook_link_text', 'option') . component('icon', array('type' => 'facebook'))
)
) ?>
</p>
Expand Down Expand Up @@ -184,7 +184,7 @@
<div class="fp-archive-link">
<?= component('button_link', array(
'href' => get_post_type_archive_link('concert'),
'html' => '<h2>Archive</h2><p>Dive into an archive of HGNM’s past events, members, audio and video.</p>'
'html' => '<h2>Archive</h2><p>' . get_field('front_page_archive_link_text', 'option') . '</p>'
)) ?>
</div>
</section>
Expand Down
3 changes: 3 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
// Set up Advanced Custom Fields field groups
include('functions/acf-field-groups.php');

// Set up Advanced Custom Fields theme options page
include('functions/acf-theme-options.php');

// Disable wp-emoji
include('functions/disable-wp-emoji.php');
119 changes: 119 additions & 0 deletions functions/acf-theme-options.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php
function hgnm_theme_options()
{
// Add an options page with hgnm-2014 theme settings
if (function_exists('acf_add_options_page')) {
acf_add_options_page(array(
'page_title' => 'HGNM Theme Options',
'menu_title' => 'HGNM Options',
'menu_slug' => 'theme-options',
'capability' => 'edit_theme_options',
'redirect' => false,
'position' => '59.5'
));
}

// Register custom fields group for options page
if (function_exists('acf_add_local_field_group')) {
acf_add_local_field_group(array(
'key' => 'group_5c7196bbe61a4',
'title' => 'Theme Options',
'fields' => array(
array(
'key' => 'field_5c7196ea902e8',
'label' => 'Colloquium Location (short)',
'name' => 'colloquium_location_short',
'type' => 'text',
'instructions' => 'This will be display the colloquium location on upcoming colloquia pages, e.g. “Room 6”',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => 'Davison Room',
'placeholder' => 'Davison Room',
'prepend' => '',
'append' => ', Harvard University Music Building',
'maxlength' => '',
),
array(
'key' => 'field_5c71972c902e9',
'label' => 'Colloquium Time & Location (long)',
'name' => 'colloquium_location_long',
'type' => 'text',
'instructions' => 'This will display colloquium information below the upcoming colloquia list on the home page and on the events page, e.g. “All colloquia are at 12pm in Room 6”',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => 'All colloquia are at 12pm in the Davison Room',
'placeholder' => 'All colloquia are at 12pm in the Davison Room',
'prepend' => '',
'append' => ', Harvard University Music Building',
'maxlength' => '',
),
array(
'key' => 'field_5c719a8d6ef4c',
'label' => 'Front Page Facebook Link Text',
'name' => 'front_page_facebook_link_text',
'type' => 'text',
'instructions' => 'This is the text that will be shown on the link to the HGNM Facebook page on the home page. It will be followed by a Facebook logo icon.',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => 'Join us on Facebook',
'placeholder' => 'Join us on Facebook',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5c7199e7c0ce0',
'label' => 'Front Page Archive Link Text',
'name' => 'front_page_archive_link_text',
'type' => 'text',
'instructions' => 'This text will be displayed on the large archive link at the bottom of the home page, e.g. “Dive into an archive of HGNM’s past events, members, audio and video.”',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => 'Dive into an archive of HGNM’s past events, members, audio and video.',
'placeholder' => 'Dive into an archive of HGNM’s past events, members, audio and video.',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'location' => array(
array(
array(
'param' => 'options_page',
'operator' => '==',
'value' => 'theme-options',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'seamless',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => 'These options allow users to configure site-wide content and vocabulary',
));
}
}
add_action('acf/init', 'hgnm_theme_options');

0 comments on commit b06c0fc

Please sign in to comment.