diff --git a/web/app/mu-plugins/mitlib-post/data/location/group_58e22931ab9f5.json b/web/app/mu-plugins/mitlib-post/data/location/group_58e22931ab9f5.json index 6f2163e8..1d5e720e 100644 --- a/web/app/mu-plugins/mitlib-post/data/location/group_58e22931ab9f5.json +++ b/web/app/mu-plugins/mitlib-post/data/location/group_58e22931ab9f5.json @@ -40,6 +40,25 @@ "tabs": "all", "delay": 0 }, + { + "key": "field_6643c15f0075d", + "label": "Alert Frontpage", + "name": "alert_frontpage", + "type": "wysiwyg", + "instructions": "This field is shown only on the front page hours widget. The content is automatically wrapped in a paragraph tag. The only allowed HTML tag is for links (a tags).", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "tabs": "all", + "toolbar": "full", + "media_upload": 0, + "delay": 0 + }, { "key": "field_24", "label": "Display Page", @@ -990,5 +1009,5 @@ "active": true, "description": "", "show_in_rest": 0, - "modified": 1671581913 + "modified": 1715716606 } \ No newline at end of file diff --git a/web/app/plugins/mitlib-pull-hours/src/class-display-widget-frontpage.php b/web/app/plugins/mitlib-pull-hours/src/class-display-widget-frontpage.php index 0500b6ba..0cf1ffce 100644 --- a/web/app/plugins/mitlib-pull-hours/src/class-display-widget-frontpage.php +++ b/web/app/plugins/mitlib-pull-hours/src/class-display-widget-frontpage.php @@ -83,6 +83,44 @@ public static function init() { register_widget( 'Mitlib\PullHours\Display_Widget_Frontpage' ); } + /** + * This function accepts the post ID of a location record, which will be used + * to check if that location has its alert populated. If either of the two + * fields for the location alert (alert_title or alert_content) are populated, + * that content will be shown in a div. + * + * The function does not return anything. + * + * @param string $location_id The ID of a location record to look up. + * + * @return void + */ + public function location_alert( $location_id ) { + $allowed_html = array( + 'a' => array( + 'href' => array(), + ), + 'p' => array(), + ); + + $query_args = array( + 'post_type' => 'location', + 'p' => $location_id, + 'post_status' => 'publish', + ); + $locations = new \WP_Query( $query_args ); + + while ( $locations->have_posts() ) { + $locations->the_post(); + $alert_frontpage = get_field( 'alert_frontpage' ); + if ( $alert_frontpage ) { + echo '
'; + echo wp_kses( $alert_frontpage, $allowed_html ); + echo '
'; + } + } + } + /** * Sanitize widget form values as they are saved. * diff --git a/web/app/plugins/mitlib-pull-hours/templates/display-widget-frontpage.php b/web/app/plugins/mitlib-pull-hours/templates/display-widget-frontpage.php index 3a977f9a..fc01f848 100644 --- a/web/app/plugins/mitlib-pull-hours/templates/display-widget-frontpage.php +++ b/web/app/plugins/mitlib-pull-hours/templates/display-widget-frontpage.php @@ -14,18 +14,30 @@

Barker Library

today
10-500617-253-0968
+location_alert( 322 ); +?>
Dewey Library

Dewey Library

today
+location_alert( 313 ); +?>
Hayden Library

Hayden Library

today
+location_alert( 452 ); +?> Show 3 More @@ -35,16 +47,28 @@

Rotch Library

today
7-238617-258-5592
+location_alert( 359 ); +?>
Distinctive Collections Reading Room

Distinctive Collections Reading Room

today
+location_alert( 504 ); +?>
Lewis Music Library

Lewis Music Library

today
+location_alert( 473 ); +?> All hours & locations diff --git a/web/app/themes/mitlib-parent/css/scss/partials/_home.scss b/web/app/themes/mitlib-parent/css/scss/partials/_home.scss index 9941f938..49d9c442 100644 --- a/web/app/themes/mitlib-parent/css/scss/partials/_home.scss +++ b/web/app/themes/mitlib-parent/css/scss/partials/_home.scss @@ -199,11 +199,15 @@ body.page-home { } } - .location-hayden-reno { + .location-alert { padding: .5rem 1em; color: #008700; margin: 0; + @include bp-tablet--portrait { + padding: 0 1rem 1rem + } + p { margin-bottom: 0 !important; font-weight: 600; diff --git a/web/app/themes/mitlib-parent/style.css b/web/app/themes/mitlib-parent/style.css index 12c45a82..d14a6559 100644 --- a/web/app/themes/mitlib-parent/style.css +++ b/web/app/themes/mitlib-parent/style.css @@ -1,7 +1,7 @@ /* Theme Name: MITlib Parent Author: MIT Libraries -Version: 0.4 +Version: 0.5 Description: The parent theme for the MIT Libraries' Pentagram-designed identity. */